changeset 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 80c599eee3f3
children 39e81b9377e6
files mercurial/subrepo.py
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/subrepo.py	Thu May 26 00:53:23 2011 +0300
+++ b/mercurial/subrepo.py	Wed May 25 08:38:58 2011 -0700
@@ -761,6 +761,9 @@
         base = self._gitcommand(['merge-base', r1, r2])
         return base == r1
 
+    def _gitisbare(self):
+        return self._gitcommand(['config', '--bool', 'core.bare']) == 'true'
+
     def _gitbranchmap(self):
         '''returns 2 things:
         a map from git branch to revision
@@ -823,6 +826,8 @@
     def dirty(self, ignoreupdate=False):
         if self._gitmissing():
             return True
+        if self._gitisbare():
+            return True
         if not ignoreupdate and self._state[1] != self._gitstate():
             # different version checked out
             return True
@@ -834,7 +839,7 @@
         source, revision, kind = state
         self._fetch(source, revision)
         # if the repo was set to be bare, unbare it
-        if self._gitcommand(['config', '--bool', 'core.bare']) == 'true':
+        if self._gitisbare():
             self._gitcommand(['config', 'core.bare', 'false'])
             if self._gitstate() == revision:
                 self._gitcommand(['reset', '--hard', 'HEAD'])