diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -167,7 +167,7 @@ def manifestmerge(repo, p1, p2, pa, over 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(): diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py --- a/mercurial/subrepo.py +++ b/mercurial/subrepo.py @@ -67,11 +67,13 @@ def submerge(repo, wctx, mctx, actx): 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 diff --git a/tests/test-subrepo b/tests/test-subrepo --- a/tests/test-subrepo +++ b/tests/test-subrepo @@ -19,6 +19,13 @@ hg -R s ci -Ams0 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 diff --git a/tests/test-subrepo.out b/tests/test-subrepo.out --- a/tests/test-subrepo.out +++ b/tests/test-subrepo.out @@ -8,6 +8,17 @@ branch: default 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