--- a/hgext/convert/common.py Mon Mar 21 17:03:16 2011 +0100
+++ b/hgext/convert/common.py Thu Mar 24 16:54:09 2011 -0400
@@ -254,7 +254,7 @@
def postrun(self):
pass
- def _cmdline(self, cmd, *args, **kwargs):
+ def _cmdline(self, cmd, closestdin, *args, **kwargs):
cmdline = [self.command, cmd] + list(args)
for k, v in kwargs.iteritems():
if len(k) == 1:
@@ -271,16 +271,23 @@
cmdline = [util.shellquote(arg) for arg in cmdline]
if not self.ui.debugflag:
cmdline += ['2>', util.nulldev]
- cmdline += ['<', util.nulldev]
+ if closestdin:
+ cmdline += ['<', util.nulldev]
cmdline = ' '.join(cmdline)
return cmdline
def _run(self, cmd, *args, **kwargs):
- cmdline = self._cmdline(cmd, *args, **kwargs)
+ return self._dorun(util.popen, cmd, True, *args, **kwargs)
+
+ def _run2(self, cmd, *args, **kwargs):
+ return self._dorun(util.popen2, cmd, False, *args, **kwargs)
+
+ def _dorun(self, openfunc, cmd, closestdin, *args, **kwargs):
+ cmdline = self._cmdline(cmd, closestdin, *args, **kwargs)
self.ui.debug('running: %s\n' % (cmdline,))
self.prerun()
try:
- return util.popen(cmdline)
+ return openfunc(cmdline)
finally:
self.postrun()
@@ -336,8 +343,9 @@
self._argmax = self._argmax / 2 - 1
return self._argmax
- def limit_arglist(self, arglist, cmd, *args, **kwargs):
- limit = self.getargmax() - len(self._cmdline(cmd, *args, **kwargs))
+ def limit_arglist(self, arglist, cmd, closestdin, *args, **kwargs):
+ cmdlen = len(self._cmdline(cmd, closestdin, *args, **kwargs))
+ limit = self.getargmax() - cmdlen
bytes = 0
fl = []
for fn in arglist:
@@ -353,7 +361,7 @@
yield fl
def xargs(self, arglist, cmd, *args, **kwargs):
- for l in self.limit_arglist(arglist, cmd, *args, **kwargs):
+ for l in self.limit_arglist(arglist, cmd, True, *args, **kwargs):
self.run0(cmd, *(list(args) + l), **kwargs)
class mapfile(dict):