subrepo: correctly handle update -C with modified subrepos (
issue2022)
(based on a patch by Saint Germain)
--- a/mercurial/merge.py Wed Jun 30 18:15:23 2010 -0500
+++ b/mercurial/merge.py Wed Jun 30 23:56:35 2010 -0500
@@ -167,7 +167,7 @@
m1, m2, ma = p1.manifest(), p2.manifest(), pa.manifest()
copied = set(copy.values())
- if not overwrite and '.hgsubstate' in m1:
+ if '.hgsubstate' in m1:
# check whether sub state is modified
for s in p1.substate:
if p1.sub(s).dirty():
--- a/mercurial/subrepo.py Wed Jun 30 18:15:23 2010 -0500
+++ b/mercurial/subrepo.py Wed Jun 30 23:56:35 2010 -0500
@@ -67,11 +67,13 @@
repo.ui.debug(" subrepo %s: %s %s\n" % (s, msg, r))
for s, l in s1.items():
+ a = sa.get(s, nullstate)
ld = l # local state with possible dirty flag for compares
- if wctx != actx and wctx.sub(s).dirty():
+ if wctx.sub(s).dirty():
ld = (l[0], l[1] + "+")
+ if wctx == actx: # overwrite
+ a = ld
- a = sa.get(s, nullstate)
if s in s2:
r = s2[s]
if ld == r or r == a: # no change or local is newer
--- a/tests/test-subrepo Wed Jun 30 18:15:23 2010 -0500
+++ b/tests/test-subrepo Wed Jun 30 23:56:35 2010 -0500
@@ -19,6 +19,13 @@
hg sum
hg ci -m1
+# issue 2022 - update -C
+
+echo b > s/a
+hg sum
+hg co -C 1
+hg sum
+
echo % add sub sub
echo ss = ss > s/.hgsub
hg init s/ss
--- a/tests/test-subrepo.out Wed Jun 30 18:15:23 2010 -0500
+++ b/tests/test-subrepo.out Wed Jun 30 23:56:35 2010 -0500
@@ -8,6 +8,17 @@
commit: 1 added, 1 subrepos
update: (current)
committing subrepository s
+parent: 1:7cf8cfea66e4 tip
+ 1
+branch: default
+commit: 1 subrepos
+update: (current)
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+parent: 1:7cf8cfea66e4 tip
+ 1
+branch: default
+commit: (clean)
+update: (current)
% add sub sub
parent: 1:7cf8cfea66e4 tip
1