[PATCH 1 of 1] subrepo: backout f02d7a562a21

Erik Zielke ez at aragost.com
Fri Dec 17 06:40:08 CST 2010


# HG changeset patch
# User Erik Zielke <ez at aragost.com>
# Date 1292589495 -3600
# Node ID a5c192e0ee74af37f8d3a728f644146d2b90774e
# Parent  115a9760c38222ee01fabea6904c6bf1956d6f12
subrepo: backout f02d7a562a21

backing out f02d7a562a21 because it introduced a bug in
.hgsubstate handling.

diff -r 115a9760c382 -r a5c192e0ee74 mercurial/localrepo.py
--- a/mercurial/localrepo.py	Mon Dec 13 11:46:31 2010 -0500
+++ b/mercurial/localrepo.py	Fri Dec 17 13:38:15 2010 +0100
@@ -949,7 +949,6 @@
 
             # commit subs
             if subs or removedsubs:
-                pstate = subrepo.substate(self['.'])
                 state = wctx.substate.copy()
                 for s in sorted(subs):
                     sub = wctx.sub(s)
@@ -957,19 +956,7 @@
                         subrepo.subrelpath(sub))
                     sr = sub.commit(cctx._text, user, date)
                     state[s] = (state[s][0], sr)
-
-                changed = False
-                if len(pstate) != len(state):
-                    changed = True
-                if not changed:
-                    for newstate in state:
-                        if state[newstate][1] != pstate[newstate]:
-                            changed = True
-                if changed:
-                    subrepo.writestate(self, state)
-                elif (changes[0] == ['.hgsubstate'] and changes[1] == [] and
-                     changes[2] == []):
-                    return None
+                subrepo.writestate(self, state)
 
             # Save commit message in case this transaction gets rolled back
             # (e.g. by a pretxncommit hook).  Leave the content alone on
diff -r 115a9760c382 -r a5c192e0ee74 mercurial/subrepo.py
--- a/mercurial/subrepo.py	Mon Dec 13 11:46:31 2010 -0500
+++ b/mercurial/subrepo.py	Fri Dec 17 13:38:15 2010 +0100
@@ -13,19 +13,6 @@
 
 nullstate = ('', '', 'empty')
 
-
-def substate(ctx):
-    rev = {}
-    if '.hgsubstate' in ctx:
-        try:
-            for l in ctx['.hgsubstate'].data().splitlines():
-                revision, path = l.split(" ", 1)
-                rev[path] = revision
-        except IOError, err:
-            if err.errno != errno.ENOENT:
-                raise
-    return rev
-
 def state(ctx, ui):
     """return a state dict, mapping subrepo paths configured in .hgsub
     to tuple: (source from .hgsub, revision from .hgsubstate, kind
@@ -52,7 +39,15 @@
     for path, src in ui.configitems('subpaths'):
         p.set('subpaths', path, src, ui.configsource('subpaths', path))
 
-    rev = substate(ctx)
+    rev = {}
+    if '.hgsubstate' in ctx:
+        try:
+            for l in ctx['.hgsubstate'].data().splitlines():
+                revision, path = l.split(" ", 1)
+                rev[path] = revision
+        except IOError as err:
+            if err.errno != errno.ENOENT:
+                raise
 
     state = {}
     for path, src in p[''].items():
diff -r 115a9760c382 -r a5c192e0ee74 tests/test-subrepo-empty-commit.t
--- a/tests/test-subrepo-empty-commit.t	Mon Dec 13 11:46:31 2010 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-  $ hg init
-  $ hg init sub
-  $ echo 'sub = sub' > .hgsub
-  $ hg add .hgsub
-  $ echo c1 > f1
-  $ echo c2 > sub/f2
-  $ hg add -S
-  adding f1
-  adding sub/f2
-  $ hg commit -m0
-  committing subrepository sub
-
-Make .hgsubstate dirty:
-
-  $ echo '0000000000000000000000000000000000000000 sub' > .hgsubstate
-  $ hg diff --nodates
-  diff -r 853ea21970bb .hgsubstate
-  --- a/.hgsubstate
-  +++ b/.hgsubstate
-  @@ -1,1 +1,1 @@
-  -5bbc614a5b06ad7f3bf7c2463d74b005324f34c1 sub
-  +0000000000000000000000000000000000000000 sub
-
-trying to do an empty commit:
-
-  $ hg commit -m1
-  committing subrepository sub
-  nothing changed
-  [1]
-
-an okay update of .hgsubstate
-  $ cd sub
-  $ echo c3 > f2
-  $ hg commit -m "Sub commit"
-  $ cd ..
-  $ hg commit -m "Updated sub"
-  committing subrepository sub
-
-deleting again:
-  $ echo '' > .hgsub
-  $ hg commit -m2
-  $ cat .hgsub
-  
-  $ cat .hgsubstate
-
-an okay commit, but with a dirty .hgsubstate
-  $ echo 'sub = sub' > .hgsub
-  $ hg commit -m3
-  committing subrepository sub
-  $ echo '0000000000000000000000000000000000000000 sub' > .hgsubstate
-  $ hg diff --nodates
-  diff -r 41e1dee3d5d9 .hgsubstate
-  --- a/.hgsubstate
-  +++ b/.hgsubstate
-  @@ -1,1 +1,1 @@
-  -fe0229ee9a0a38b43163c756bb51b94228b118e7 sub
-  +0000000000000000000000000000000000000000 sub
-  $ echo c4 > f3
-  $ hg add f3
-  $ hg status 
-  M .hgsubstate
-  A f3
-  $ hg commit -m4
-  committing subrepository sub


More information about the Mercurial-devel mailing list