subrepo: strip gitcommand output
authorEric Eisner <ede@mit.edu>
Sun, 28 Nov 2010 15:03:48 -0500
changeset 13085 b4814f1f415c
parent 13084 c97ded7b6e79
child 13086 8db85e39d59c
subrepo: strip gitcommand output
mercurial/subrepo.py
--- a/mercurial/subrepo.py	Wed Dec 01 21:46:08 2010 +0100
+++ b/mercurial/subrepo.py	Sun Nov 28 15:03:48 2010 -0500
@@ -638,7 +638,7 @@
         if stream:
             return p.stdout, None
 
-        retdata = p.stdout.read()
+        retdata = p.stdout.read().strip()
         # wait for the child to exit to avoid race condition.
         p.wait()
 
@@ -659,14 +659,14 @@
         return retdata, p.returncode
 
     def _gitstate(self):
-        return self._gitcommand(['rev-parse', 'HEAD']).strip()
+        return self._gitcommand(['rev-parse', 'HEAD'])
 
     def _githavelocally(self, revision):
         out, code = self._gitdir(['cat-file', '-e', revision])
         return code == 0
 
     def _gitisancestor(self, r1, r2):
-        base = self._gitcommand(['merge-base', r1, r2]).strip()
+        base = self._gitcommand(['merge-base', r1, r2])
         return base == r1
 
     def _gitbranchmap(self):
@@ -677,8 +677,6 @@
         out = self._gitcommand(['branch', '-a', '--no-color',
                                 '--verbose', '--abbrev=40'])
         for line in out.split('\n'):
-            if not line:
-                continue
             if line[2:].startswith('(no branch)'):
                 continue
             branch, revision = line[2:].split()[:2]
@@ -708,14 +706,13 @@
         # docs say --porcelain flag is future-proof format
         changed = self._gitcommand(['status', '--porcelain',
                                     '--untracked-files=no'])
-        return bool(changed.strip())
+        return bool(changed)
 
     def get(self, state):
         source, revision, kind = state
         self._fetch(source, revision)
         # if the repo was set to be bare, unbare it
-        if self._gitcommand(['config', '--get', 'core.bare']
-                            ).strip() == 'true':
+        if self._gitcommand(['config', '--bool', 'core.bare']) == 'true':
             self._gitcommand(['config', 'core.bare', 'false'])
             if self._gitstate() == revision:
                 self._gitcommand(['reset', '--hard', 'HEAD'])
@@ -763,8 +760,7 @@
     def merge(self, state):
         source, revision, kind = state
         self._fetch(source, revision)
-        base = self._gitcommand(['merge-base', revision,
-                                 self._state[1]]).strip()
+        base = self._gitcommand(['merge-base', revision, self._state[1]])
         if base == revision:
             self.get(state) # fast forward merge
         elif base != self._state[1]: