diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -6955,6 +6955,8 @@ def update(ui, repo, node=None, rev=None if rev is None or rev == '': rev = node + warndest = False + with repo.wlock(): cmdutil.clearunfinished(repo) @@ -6976,6 +6978,7 @@ def update(ui, repo, node=None, rev=None if rev is None: updata = destutil.destupdate(repo, clean=clean, check=check) rev, movemarkfrom, brev = updata + warndest = True repo.ui.setconfig('ui', 'forcemerge', tool, 'update') @@ -7002,7 +7005,8 @@ def update(ui, repo, node=None, rev=None ui.status(_("(leaving bookmark %s)\n") % repo._activebookmark) bookmarks.deactivate(repo) - + if warndest: + destutil.statusotherdests(ui, repo) return ret @command('verify', []) diff --git a/mercurial/destutil.py b/mercurial/destutil.py --- a/mercurial/destutil.py +++ b/mercurial/destutil.py @@ -218,3 +218,34 @@ def desthistedit(ui, repo): return revs.first() return None + +def _statusotherbook(ui, repo): + bmheads = repo.bookmarkheads(repo._activebookmark) + curhead = repo[repo._activebookmark].node() + if repo.revs('%n and parents()', curhead): + # we are on the active bookmark + bmheads = [b for b in bmheads if curhead != b] + if bmheads: + msg = _('%i other divergent bookmarks for "%s"\n') + ui.status(msg % (len(bmheads), repo._activebookmark)) + +def _statusotherbranchheads(ui, repo): + currentbranch = repo.dirstate.branch() + heads = repo.branchheads(currentbranch) + l = len(heads) + if repo.revs('%ln and parents()', heads): + # we are on a head + heads = repo.revs('%ln - parents()', heads) + if heads and l != len(heads): + ui.status(_('%i other heads for branch "%s"\n') % + (len(heads), currentbranch)) + +def statusotherdests(ui, repo): + """Print message about other head""" + # XXX we should probably include a hint: + # - about what to do + # - how to see such heads + if repo._activebookmark: + _statusotherbook(ui, repo) + else: + _statusotherbranchheads(ui, repo) diff --git a/tests/test-bisect2.t b/tests/test-bisect2.t --- a/tests/test-bisect2.t +++ b/tests/test-bisect2.t @@ -244,6 +244,7 @@ hg up -C $ hg up -C 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + 3 other heads for branch "default" complex bisect test 1 # first bad rev is 9 diff --git a/tests/test-blackbox.t b/tests/test-blackbox.t --- a/tests/test-blackbox.t +++ b/tests/test-blackbox.t @@ -123,6 +123,7 @@ extension and python hooks - use the eol $ hg update hooked 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + 1 other heads for branch "default" $ hg blackbox -l 6 1970/01/01 00:00:00 bob (*)> update (glob) 1970/01/01 00:00:00 bob (*)> writing .hg/cache/tags2-visible with 0 tags (glob) diff --git a/tests/test-bookmarks.t b/tests/test-bookmarks.t --- a/tests/test-bookmarks.t +++ b/tests/test-bookmarks.t @@ -573,6 +573,7 @@ pull --update works the same as pull && $ hg bookmark -r3 Y moving bookmark 'Y' forward from db815d6d32e6 $ cp -r ../cloned-bookmarks-update ../cloned-bookmarks-manual-update + $ cp -r ../cloned-bookmarks-update ../cloned-bookmarks-manual-update-with-divergence (manual version) @@ -617,6 +618,34 @@ pull --update works the same as pull && updating to active bookmark Y 1 files updated, 0 files merged, 0 files removed, 0 files unresolved +We warn about divergent during bare update to the active bookmark + + $ hg -R ../cloned-bookmarks-manual-update-with-divergence update Y + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + (activating bookmark Y) + $ hg -R ../cloned-bookmarks-manual-update-with-divergence bookmarks -r X2 Y@1 + $ hg -R ../cloned-bookmarks-manual-update-with-divergence bookmarks + X2 1:925d80f479bb + * Y 2:db815d6d32e6 + Y@1 1:925d80f479bb + Z 2:db815d6d32e6 + x y 2:db815d6d32e6 + $ hg -R ../cloned-bookmarks-manual-update-with-divergence pull + pulling from $TESTTMP + searching for changes + adding changesets + adding manifests + adding file changes + added 2 changesets with 2 changes to 2 files (+1 heads) + updating bookmark Y + updating bookmark Z + (run 'hg heads' to see heads, 'hg merge' to merge) + $ hg -R ../cloned-bookmarks-manual-update-with-divergence update + updating to active bookmark Y + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + (activating bookmark Y) + 1 other divergent bookmarks for "Y" + test wrongly formated bookmark $ echo '' >> .hg/bookmarks @@ -715,6 +744,7 @@ test non-linear update not clearing acti $ hg up -C 1 files updated, 0 files merged, 1 files removed, 0 files unresolved (leaving bookmark drop) + 1 other heads for branch "default" $ hg sum parent: 2:db815d6d32e6 2 diff --git a/tests/test-conflict.t b/tests/test-conflict.t --- a/tests/test-conflict.t +++ b/tests/test-conflict.t @@ -232,6 +232,7 @@ are merging, unlike :local and :other $ hg up -C 2 files updated, 0 files merged, 0 files removed, 0 files unresolved + 1 other heads for branch "default" $ printf "\n\nEnd of file\n" >> a $ hg ci -m "Add some stuff at the end" $ hg up -r 1 @@ -269,6 +270,7 @@ Now test :merge-other and :merge-local $ hg up -C 1 files updated, 0 files merged, 1 files removed, 0 files unresolved + 1 other heads for branch "default" $ hg merge --tool :merge-local merging a 2 files updated, 0 files merged, 0 files removed, 0 files unresolved diff --git a/tests/test-largefiles-cache.t b/tests/test-largefiles-cache.t --- a/tests/test-largefiles-cache.t +++ b/tests/test-largefiles-cache.t @@ -202,6 +202,7 @@ Inject corruption into the largefiles st large: data corruption in $TESTTMP/src/.hg/largefiles/e2fb5f2139d086ded2cb600d5a91a196e76bf020 with hash 6a7bb2556144babe3899b25e5428123735bb1e27 (glob) 0 largefiles updated, 0 removed 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + 2 other heads for branch "default" $ hg st ! large ? z diff --git a/tests/test-largefiles-update.t b/tests/test-largefiles-update.t --- a/tests/test-largefiles-update.t +++ b/tests/test-largefiles-update.t @@ -68,6 +68,7 @@ we don't have to hash them again next ti $ hg up 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + 1 other heads for branch "default" $ hg debugdirstate --large --nodate n 644 7 set large1 n 644 13 set large2 @@ -82,6 +83,7 @@ prevents unnecessary hashing of content n 644 13 set large2 $ hg up 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + 1 other heads for branch "default" $ hg debugdirstate --large --nodate n 644 7 set large1 n 644 13 set large2 diff --git a/tests/test-merge-changedelete.t b/tests/test-merge-changedelete.t --- a/tests/test-merge-changedelete.t +++ b/tests/test-merge-changedelete.t @@ -111,6 +111,7 @@ Interactive merge: $ hg co -C 1 files updated, 0 files merged, 1 files removed, 0 files unresolved + 1 other heads for branch "default" $ hg merge --config ui.interactive=true < c @@ -171,6 +172,7 @@ Interactive merge with bad input: $ hg co -C 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + 1 other heads for branch "default" $ hg merge --config ui.interactive=true < foo @@ -243,6 +245,7 @@ Interactive merge with not enough input: $ hg co -C 2 files updated, 0 files merged, 1 files removed, 0 files unresolved + 1 other heads for branch "default" $ hg merge --config ui.interactive=true < d @@ -301,6 +304,7 @@ Choose local versions of files $ hg co -C 2 files updated, 0 files merged, 1 files removed, 0 files unresolved + 1 other heads for branch "default" $ hg merge --tool :local 0 files updated, 3 files merged, 0 files removed, 0 files unresolved @@ -345,6 +349,7 @@ Choose other versions of files $ hg co -C 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + 1 other heads for branch "default" $ hg merge --tool :other 0 files updated, 2 files merged, 1 files removed, 0 files unresolved @@ -389,6 +394,7 @@ Fail $ hg co -C 2 files updated, 0 files merged, 1 files removed, 0 files unresolved + 1 other heads for branch "default" $ hg merge --tool :fail 0 files updated, 0 files merged, 0 files removed, 3 files unresolved @@ -436,6 +442,7 @@ Force prompts with no input (should be s $ hg co -C 1 files updated, 0 files merged, 1 files removed, 0 files unresolved + 1 other heads for branch "default" $ hg merge --config ui.interactive=True --tool :prompt local changed file1 which remote deleted @@ -491,6 +498,7 @@ Force prompts $ hg co -C 1 files updated, 0 files merged, 1 files removed, 0 files unresolved + 1 other heads for branch "default" $ hg merge --tool :prompt local changed file1 which remote deleted @@ -544,6 +552,7 @@ Choose to merge all files $ hg co -C 1 files updated, 0 files merged, 1 files removed, 0 files unresolved + 1 other heads for branch "default" $ hg merge --tool :merge3 local changed file1 which remote deleted diff --git a/tests/test-merge-default.t b/tests/test-merge-default.t --- a/tests/test-merge-default.t +++ b/tests/test-merge-default.t @@ -33,6 +33,7 @@ Should fail because not at a head: $ hg up 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + 2 other heads for branch "default" Should fail because > 2 heads: diff --git a/tests/test-merge-types.t b/tests/test-merge-types.t --- a/tests/test-merge-types.t +++ b/tests/test-merge-types.t @@ -155,6 +155,7 @@ Update to link without local change shou 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg up 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + 1 other heads for branch "default" $ hg st ? a.orig @@ -175,6 +176,7 @@ Update to link with local change should keep (l)ocal, take (o)ther, or leave (u)nresolved? u 0 files updated, 0 files merged, 0 files removed, 1 files unresolved use 'hg resolve' to retry unresolved file merges + 1 other heads for branch "default" [1] $ hg diff --git diff --git a/a b/a diff --git a/tests/test-merge5.t b/tests/test-merge5.t --- a/tests/test-merge5.t +++ b/tests/test-merge5.t @@ -24,6 +24,7 @@ $ hg revert b $ hg update -c 0 files updated, 0 files merged, 1 files removed, 0 files unresolved + 1 other heads for branch "default" $ mv a c Should abort: diff --git a/tests/test-strip.t b/tests/test-strip.t --- a/tests/test-strip.t +++ b/tests/test-strip.t @@ -287,6 +287,7 @@ after strip of merge parent $ hg up 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + 1 other heads for branch "default" $ hg log -G @ changeset: 4:264128213d29 | tag: tip diff --git a/tests/test-subrepo.t b/tests/test-subrepo.t --- a/tests/test-subrepo.t +++ b/tests/test-subrepo.t @@ -664,6 +664,7 @@ update $ cd ../t $ hg up -C # discard our earlier merge 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + 2 other heads for branch "default" $ echo blah > t/t $ hg ci -m13 committing subrepository t @@ -677,6 +678,7 @@ KeyError $ hg up -C # discard changes 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + 2 other heads for branch "default" pull @@ -718,6 +720,7 @@ should pull t adding file changes added 1 changesets with 1 changes to 1 files 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + 2 other heads for branch "default" $ cat t/t blah @@ -1185,6 +1188,7 @@ Check hg update --clean ? s/c $ hg update -C 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + 2 other heads for branch "default" $ hg status -S ? s/b ? s/c diff --git a/tests/test-transplant.t b/tests/test-transplant.t --- a/tests/test-transplant.t +++ b/tests/test-transplant.t @@ -409,6 +409,7 @@ transplant -c shouldn't use an old chang $ hg up -C 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + 1 other heads for branch "default" $ rm added $ hg transplant --continue abort: no transplant to continue diff --git a/tests/test-update-branches.t b/tests/test-update-branches.t --- a/tests/test-update-branches.t +++ b/tests/test-update-branches.t @@ -167,6 +167,7 @@ Cases are run as shown in that table, ro $ norevtest '-c clean same' clean 2 -c 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + 1 other heads for branch "default" parent=3 $ revtest '-cC dirty linear' dirty 1 2 -cC