comparison mercurial/subrepo.py @ 13153:dca5488f0e4f

subrepo: use low-level git-diff-index for dirty() Despite its name, git-diff-index compares a revision to the files in the working directory. This seems way less sketchy and more future proof than parsing human-readable git-status.
author Eric Eisner <ede@mit.edu>
date Tue, 14 Dec 2010 21:58:13 -0500
parents 70d80907e4b8
children f02d7a562a21
comparison
equal deleted inserted replaced
13152:70d80907e4b8 13153:dca5488f0e4f
716 716
717 def dirty(self): 717 def dirty(self):
718 if self._state[1] != self._gitstate(): # version checked out changed? 718 if self._state[1] != self._gitstate(): # version checked out changed?
719 return True 719 return True
720 # check for staged changes or modified files; ignore untracked files 720 # check for staged changes or modified files; ignore untracked files
721 status = self._gitcommand(['status']) 721 out, code = self._gitdir(['diff-index', '--quiet', 'HEAD'])
722 return ('\n# Changed but not updated:' in status or 722 return code == 1
723 '\n# Changes to be committed:' in status)
724 723
725 def get(self, state): 724 def get(self, state):
726 source, revision, kind = state 725 source, revision, kind = state
727 self._fetch(source, revision) 726 self._fetch(source, revision)
728 # if the repo was set to be bare, unbare it 727 # if the repo was set to be bare, unbare it