# HG changeset patch # User eugene.petrenko@jetbrains.com # Date 1401467927 -7200 # Node ID ef19cc8d5bc1e83027550e4969465754b16c078c # Parent 568bb3e7a8eb32bb60a0cd127c7ba2d507ccbbe0 support parameters throug file for every mercurial command diff -r 568bb3e7a8eb -r ef19cc8d5bc1 mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandUtil.java --- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandUtil.java Fri May 30 17:35:01 2014 +0200 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandUtil.java Fri May 30 18:38:47 2014 +0200 @@ -19,7 +19,6 @@ import jetbrains.buildServer.LineAwareByteArrayOutputStream; import jetbrains.buildServer.SimpleCommandLineProcessRunner; import jetbrains.buildServer.buildTriggers.vcs.mercurial.HgFileUtil; -import jetbrains.buildServer.buildTriggers.vcs.mercurial.OS; import jetbrains.buildServer.log.Loggers; import jetbrains.buildServer.util.FileUtil; import jetbrains.buildServer.util.StringUtil; @@ -58,6 +57,7 @@ @NotNull public static CommandResult runWrappedCommand(@NotNull final MercurialCommandLine originalCommandLine, @NotNull final CommandSettings settings) throws VcsException { + final String realCommand = logRunCommand(originalCommandLine, settings); final File tempDir = createTempDir(); try { @@ -67,15 +67,9 @@ setupExtensionsFromResource(fork, tempDir, "load-commands-command.py"); fork.addParameters("CMD", commands.getAbsolutePath()); - for (String arg : originalCommandLine.getArguments()) { - if (fork.getCommandLineLength() + arg.length() >= OS.getMaxCommandLineSize() - 5) { - fork.addParameter("..."); - break; - } - fork.addParameter(arg); - } + String forkCommand = logRunCommand(fork, settings); - return runCommand(fork, settings); + return runCommandWithName(fork, settings, forkCommand + " \n|| for command: " + realCommand); } finally { FileUtil.delete(tempDir); } @@ -106,8 +100,10 @@ @NotNull public static CommandResult runCommand(@NotNull final MercurialCommandLine cli, @NotNull final CommandSettings settings) throws VcsException { - final String command = removePrivateData(cli.getCommandLineString(), settings.getPrivateData()); - logRunCommand(cli, command, settings); + return runCommandWithName(cli, settings, logRunCommand(cli, settings)); + } + + private static CommandResult runCommandWithName(MercurialCommandLine cli, CommandSettings settings, String command) throws VcsException { CommandResult res = run(cli, settings.getTimeout(), command, settings.getPrivateData(), settings); if (settings.isCheckForFailure() || settings.isFailWithNonEmptyStderr()) res.checkFailure(settings.isFailWithNonEmptyStderr()); @@ -166,6 +162,14 @@ } } + @NotNull + private static String logRunCommand(@NotNull final MercurialCommandLine cli, + @NotNull final CommandSettings settings) { + final String command = removePrivateData(cli.getCommandLineString(), settings.getPrivateData()); + logRunCommand(cli, command, settings); + return command; + } + private static void logCommandOutput(@NotNull String command, @NotNull CommandResult result, @NotNull CommandSettings settings) { int limit = settings.getLogOutputLimit(); if (limit == -1) { diff -r 568bb3e7a8eb -r ef19cc8d5bc1 mercurial-common/src/python/load-commands-command.py --- a/mercurial-common/src/python/load-commands-command.py Fri May 30 17:35:01 2014 +0200 +++ b/mercurial-common/src/python/load-commands-command.py Fri May 30 18:38:47 2014 +0200 @@ -26,33 +26,31 @@ import codecs from mercurial import dispatch +from mercurial import commands def loadArguments(ui, params_file): file_commands = [] - ui.write("Parameters from the file (one by line):\n") with codecs.open(params_file, "r", "utf-8") as f: for _line in f: line = _line.strip() if len(line) <= 0: continue - ui.write(" " + line + "\n") - file_commands.append(line) + file_commands.append(str(line)) return file_commands -def load_commands_command(ui, repo, params_file, *pats, **opts): - ui.write("Staring command with arguments from " + params_file + "\n") +def load_commands_command(ui, params_file, *params): command_arguments = loadArguments(ui, params_file) - - ui.write("\nRunning the command...\n\n") return dispatch.dispatch(dispatch.request(command_arguments)) #so here goes command registration and options cmdtable = { - "CMD": (load_commands_command, [ ], "params_file [foo]...") + "CMD": (load_commands_command, [], " OUTPUT_FILE") } +commands.norepo += " CMD" + testedwith = '2.2.2' buglink = "@jonnyzzz"