Example #1
0
 def run_command(self, host, command, username=None, port=None):
     if isinstance(command, (str, bytes)):
         # 0.12.x dulwich sends the raw string
         command = [command]
     elif len(command) > 1:
         # 0.11.x dulwich sends an array of [command arg1 arg2 ...], so
         # we detect that here and reformat it back to what hg-git
         # expects (e.g. "command 'arg1 arg2'")
         command = ["%s '%s'" % (command[0], " ".join(command[1:]))]
     sshcmd = ui.config("ui", "ssh")
     args = util.sshargs(sshcmd, host, username, port)
     cmd = "%s %s %s" % (sshcmd, args, util.shellquote(
         " ".join(command)))
     ui.debug("calling ssh: %s\n" % cmd)
     proc = subprocess.Popen(
         util.quotecommand(cmd),
         shell=True,
         stdin=subprocess.PIPE,
         stdout=subprocess.PIPE,
     )
     return SubprocessWrapper(proc)
Example #2
0
 def _getlog(
     self,
     paths,
     start,
     end,
     limit=0,
     discover_changed_paths=True,
     strict_node_history=False,
 ):
     # Normalize path names, svn >= 1.5 only wants paths relative to
     # supplied URL
     relpaths = []
     for p in paths:
         if not p.startswith("/"):
             p = self.module + "/" + p
         relpaths.append(p.strip("/"))
     args = [
         self.baseurl,
         relpaths,
         start,
         end,
         limit,
         discover_changed_paths,
         strict_node_history,
     ]
     # developer config: convert.svn.debugsvnlog
     if not self.ui.configbool("convert", "svn.debugsvnlog"):
         return directlogstream(*args)
     arg = encodeargs(args)
     hgexe = util.hgexecutable()
     cmd = "%s debugsvnlog" % util.shellquote(hgexe)
     stdin, stdout = util.popen2(util.quotecommand(cmd))
     stdin.write(arg)
     try:
         stdin.close()
     except IOError:
         raise error.Abort(
             _("Mercurial failed to run itself, check" " hg executable is in PATH")
         )
     return logstream(stdout)