[PATCH 5 of 6] subrepo: show git command with --debug

Eric Eisner ede at MIT.EDU
Thu Dec 9 15:53:28 CST 2010


# HG changeset patch
# User Eric Eisner <ede at mit.edu>
# Date 1291931534 18000
# Node ID cad35f06c031f0e653ade1003fd9fb6939e3ee66
# Parent  53341289eaf8f2c03e6df6baf633f4de28723811
subrepo: show git command with --debug

Also removing the clutter of --no-pager, since none of these commands use
the pager.

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -614,7 +614,6 @@ class gitsubrepo(abstractsubrepo):
         return self._gitdir(commands, env=env, stream=stream)[0]
 
     def _gitdir(self, commands, env=None, stream=False):
-        commands = ['--no-pager'] + commands
         return self._gitnodir(commands, env=env, stream=stream, cwd=self._path)
 
     def _gitnodir(self, commands, env=None, stream=False, cwd=None):
@@ -623,6 +622,7 @@ class gitsubrepo(abstractsubrepo):
         The methods tries to call the git command. versions previor to 1.6.0
         are not supported and very probably fail.
         """
+        self._ui.debug('%s: git %s\n' % (self._relpath, ' '.join(commands)))
         # print git's stderr, which is mostly progress and useful info
         p = subprocess.Popen(['git'] + commands, bufsize=-1, cwd=cwd, env=env,
                              close_fds=util.closefds,
@@ -636,15 +636,12 @@ class gitsubrepo(abstractsubrepo):
 
         if p.returncode != 0 and p.returncode != 1:
             # there are certain error codes that are ok
-            command = None
-            for arg in commands:
-                if not arg.startswith('-'):
-                    command = arg
-                    break
+            command = commands[0]
             if command == 'cat-file':
                 return retdata, p.returncode
             # for all others, abort
-            raise util.Abort('git %s error %d' % (command, p.returncode))
+            raise util.Abort('git %s error %d in %s' %
+                             (command, p.returncode, self._relpath))
 
         return retdata, p.returncode
 


More information about the Mercurial-devel mailing list