You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows环境下如何将文本文件中的文件列表传入Mercurial的hg add命令?

解决Windows 10下Mercurial hg add 命令行长度限制的方案
  • 通过文件传递文件列表的两种方式
    先把需要添加的文件路径按每行一个的格式保存到文本文件(比如命名为file_list.txt),然后用以下任意一种方式执行hg add:

    1. 使用--files参数:
      hg add --files file_list.txt
      
    2. 使用@前缀快捷写法:
      hg add @file_list.txt
      

    这两种方式都会让Mercurial直接读取文本文件中的文件列表,完全避开Windows命令行的字符长度限制。

  • 分组提交的实操建议
    既然需要按每10000个文件一组提交,可以用PowerShell把总文件列表分割成多个小批量文件:
    假设总文件列表是all_files.txt,执行以下PowerShell命令生成每组10000个文件的分批列表:

    $totalFiles = Get-Content all_files.txt
    $batchSize = 10000
    for ($idx = 0; $idx -lt $totalFiles.Count; $idx += $batchSize) {
        $batchNumber = [math]::Floor($idx / $batchSize) + 1
        $totalFiles[$idx..($idx + $batchSize - 1)] | Out-File "batch_$batchNumber.txt" -Encoding UTF8
    }
    

    之后依次处理每一批:

    # 处理第一批
    hg add --files batch_1.txt
    hg commit -m "Add batch 1 of files"
    
    # 处理第二批
    hg add --files batch_2.txt
    hg commit -m "Add batch 2 of files"
    
    # 以此类推处理剩余批次
    

内容的提问来源于stack exchange,提问作者Geordie

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.03 20:45:57