comparison mercurial/subrepo.py @ 14440:96f1c1b14154

subrepo: bare git repos considered dirty Currently, if there is a bare git subrepo, but it is at the "right" revision, calling dirty() will error because diff-index does not work on bare repos. This patch makes it so bare subrepos are always considered dirty.
author Paul Molodowitch <pm@stanfordalumni.org>
date Wed, 25 May 2011 08:38:58 -0700
parents 25137d99a5ed
children 6fe6defdc924
comparison
equal deleted inserted replaced
14439:80c599eee3f3 14440:96f1c1b14154
759 759
760 def _gitisancestor(self, r1, r2): 760 def _gitisancestor(self, r1, r2):
761 base = self._gitcommand(['merge-base', r1, r2]) 761 base = self._gitcommand(['merge-base', r1, r2])
762 return base == r1 762 return base == r1
763 763
764 def _gitisbare(self):
765 return self._gitcommand(['config', '--bool', 'core.bare']) == 'true'
766
764 def _gitbranchmap(self): 767 def _gitbranchmap(self):
765 '''returns 2 things: 768 '''returns 2 things:
766 a map from git branch to revision 769 a map from git branch to revision
767 a map from revision to branches''' 770 a map from revision to branches'''
768 branch2rev = {} 771 branch2rev = {}
821 (revision, self._relpath)) 824 (revision, self._relpath))
822 825
823 def dirty(self, ignoreupdate=False): 826 def dirty(self, ignoreupdate=False):
824 if self._gitmissing(): 827 if self._gitmissing():
825 return True 828 return True
829 if self._gitisbare():
830 return True
826 if not ignoreupdate and self._state[1] != self._gitstate(): 831 if not ignoreupdate and self._state[1] != self._gitstate():
827 # different version checked out 832 # different version checked out
828 return True 833 return True
829 # check for staged changes or modified files; ignore untracked files 834 # check for staged changes or modified files; ignore untracked files
830 out, code = self._gitdir(['diff-index', '--quiet', 'HEAD']) 835 out, code = self._gitdir(['diff-index', '--quiet', 'HEAD'])
832 837
833 def get(self, state, overwrite=False): 838 def get(self, state, overwrite=False):
834 source, revision, kind = state 839 source, revision, kind = state
835 self._fetch(source, revision) 840 self._fetch(source, revision)
836 # if the repo was set to be bare, unbare it 841 # if the repo was set to be bare, unbare it
837 if self._gitcommand(['config', '--bool', 'core.bare']) == 'true': 842 if self._gitisbare():
838 self._gitcommand(['config', 'core.bare', 'false']) 843 self._gitcommand(['config', 'core.bare', 'false'])
839 if self._gitstate() == revision: 844 if self._gitstate() == revision:
840 self._gitcommand(['reset', '--hard', 'HEAD']) 845 self._gitcommand(['reset', '--hard', 'HEAD'])
841 return 846 return
842 elif self._gitstate() == revision: 847 elif self._gitstate() == revision: