【问题标题】:how to pass parameters to tortoiseproc.exe via file?如何通过文件将参数传递给tortoiseproc.exe?
【发布时间】:2011-08-07 08:32:45
【问题描述】:

我正在使用来自 java 的 Runtime.getRuntime.exec() 以编程方式生成要提交给 cmd.exe 的命令。

命令是tortoiseproc忽略命令的形式

tortoiseproc /command:ignore /path:file1*file2*file3*...................filen

如您所见,path 参数需要多个文件,当此字符串超过一定长度时会出现问题。 8197 个字符,如 microsoft KB for cmd.exe 中所述。

那里的解决方法是修改程序,使其接受来自文件而不是命令行字符串的参数。有人知道如何通过文件将参数传递给 tortoiseproc.exe 吗?

【问题讨论】:

    标签: file command-line parameters tortoisesvn


    【解决方案1】:

    我遇到了同样的问题,这是我的解决方案:

    using (var s = File.Create("D:\\p3.tmp"))
    {
        using (var sw = new StreamWriter(s, new UnicodeEncoding(false, false)))
        {
            sw.Write(@"D:\SourceCode\Utils\ProductProvider.cs" + '\n');
            sw.Write(@"D:\SourceCode\Utils\BillingProvider.cs"+ '\n');
        }
    }
    

    创建文件后我使用

    TortoiseProc.exe /command:commit /pathfile:"D:\p3.tmp" /logmsg:"test log message" /deletepathfile
    

    【讨论】:

      【解决方案2】:

      您可以传递一个 utf16 格式的文件,每个文件在单独的行中列出。

      使用/pathfile:"path/to/file.txt"传递该文件的路径

      【讨论】:

      • 如何创建 UTF16 编码文件?我尝试使用 PrintWriter pw = new PrintWriter(new OutputStreamWriter(new FileOutputStream(tempFile), Charset.forName("UTF-16")));但是 tortoiseproc 返回了一个错误。进一步的想法?
      【解决方案3】:

      不,这是不可能的。但是,在这种特定情况下,这并不重要:您可以将文件列表拆分为多个较小的文件,并多次运行 tortoiseproc。示例:

      tortoiseproc /command:ignore /path:file1*file2*file3*file4
      tortoiseproc /command:ignore /path:file5*file6*file7*file8
      

      以此类推,直到文件 n

      【讨论】:

      • 我曾想过这个选项,但它会效率低下,所以我选择使用 svn 命令行工具来设置从文件中接受忽略模式的忽略属性。 svn propset 忽略 -F tmpfile 。其中 tmpfile 表示具有由换行符分隔的忽略模式的文件。谢谢你的回答。
      猜你喜欢
      • 2012-12-08
      • 1970-01-01
      • 2023-03-11
      • 1970-01-01
      • 2013-10-27
      • 2018-03-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多