##// END OF EJS Templates
subrepo: strip gitcommand output
Eric Eisner -
r13085:b4814f1f default
parent child Browse files
Show More
@@ -638,7 +638,7 b' class gitsubrepo(object):'
638 if stream:
638 if stream:
639 return p.stdout, None
639 return p.stdout, None
640
640
641 retdata = p.stdout.read()
641 retdata = p.stdout.read().strip()
642 # wait for the child to exit to avoid race condition.
642 # wait for the child to exit to avoid race condition.
643 p.wait()
643 p.wait()
644
644
@@ -659,14 +659,14 b' class gitsubrepo(object):'
659 return retdata, p.returncode
659 return retdata, p.returncode
660
660
661 def _gitstate(self):
661 def _gitstate(self):
662 return self._gitcommand(['rev-parse', 'HEAD']).strip()
662 return self._gitcommand(['rev-parse', 'HEAD'])
663
663
664 def _githavelocally(self, revision):
664 def _githavelocally(self, revision):
665 out, code = self._gitdir(['cat-file', '-e', revision])
665 out, code = self._gitdir(['cat-file', '-e', revision])
666 return code == 0
666 return code == 0
667
667
668 def _gitisancestor(self, r1, r2):
668 def _gitisancestor(self, r1, r2):
669 base = self._gitcommand(['merge-base', r1, r2]).strip()
669 base = self._gitcommand(['merge-base', r1, r2])
670 return base == r1
670 return base == r1
671
671
672 def _gitbranchmap(self):
672 def _gitbranchmap(self):
@@ -677,8 +677,6 b' class gitsubrepo(object):'
677 out = self._gitcommand(['branch', '-a', '--no-color',
677 out = self._gitcommand(['branch', '-a', '--no-color',
678 '--verbose', '--abbrev=40'])
678 '--verbose', '--abbrev=40'])
679 for line in out.split('\n'):
679 for line in out.split('\n'):
680 if not line:
681 continue
682 if line[2:].startswith('(no branch)'):
680 if line[2:].startswith('(no branch)'):
683 continue
681 continue
684 branch, revision = line[2:].split()[:2]
682 branch, revision = line[2:].split()[:2]
@@ -708,14 +706,13 b' class gitsubrepo(object):'
708 # docs say --porcelain flag is future-proof format
706 # docs say --porcelain flag is future-proof format
709 changed = self._gitcommand(['status', '--porcelain',
707 changed = self._gitcommand(['status', '--porcelain',
710 '--untracked-files=no'])
708 '--untracked-files=no'])
711 return bool(changed.strip())
709 return bool(changed)
712
710
713 def get(self, state):
711 def get(self, state):
714 source, revision, kind = state
712 source, revision, kind = state
715 self._fetch(source, revision)
713 self._fetch(source, revision)
716 # if the repo was set to be bare, unbare it
714 # if the repo was set to be bare, unbare it
717 if self._gitcommand(['config', '--get', 'core.bare']
715 if self._gitcommand(['config', '--bool', 'core.bare']) == 'true':
718 ).strip() == 'true':
719 self._gitcommand(['config', 'core.bare', 'false'])
716 self._gitcommand(['config', 'core.bare', 'false'])
720 if self._gitstate() == revision:
717 if self._gitstate() == revision:
721 self._gitcommand(['reset', '--hard', 'HEAD'])
718 self._gitcommand(['reset', '--hard', 'HEAD'])
@@ -763,8 +760,7 b' class gitsubrepo(object):'
763 def merge(self, state):
760 def merge(self, state):
764 source, revision, kind = state
761 source, revision, kind = state
765 self._fetch(source, revision)
762 self._fetch(source, revision)
766 base = self._gitcommand(['merge-base', revision,
763 base = self._gitcommand(['merge-base', revision, self._state[1]])
767 self._state[1]]).strip()
768 if base == revision:
764 if base == revision:
769 self.get(state) # fast forward merge
765 self.get(state) # fast forward merge
770 elif base != self._state[1]:
766 elif base != self._state[1]:
General Comments 0
You need to be logged in to leave comments. Login now