# HG changeset patch # User FUJIWARA Katsunori # Date 1456322433 -32400 # Node ID de8b09482fb7e83704ba2d3074e417ad39dbe669 # Parent 332926212ef81f990e769207180ee8d7ed873b11 destutil: show message about other branch heads, even if on a closed head Before this patch, bare "hg update" displays message below, if there is at least one non-closed branch head other than current parent: 1. 'XX other heads for branch "BRANCH"' message, if current parent is on a non-closed branch head This suggests user to invoke "hg heads" or so for merging them. 2. no message, if current parent is on a closed branch head At this patch, bare "hg update" might choose closed branch head as update destination, and it causes this situation easily. 3. no message, otherwise (= current parent isn't on any branch head) 'XX other heads for branch "BRANCH"' should be displayed also in #2 case above, because user might overlook other non-closed branch heads. This patch gets a list of all branch heads regardless of closed-ness of it, and uses it (= 'allheads') to distinguish #1/#2 from #3 above. diff -r 332926212ef8 -r de8b09482fb7 mercurial/destutil.py --- a/mercurial/destutil.py Wed Feb 24 06:10:46 2016 +0900 +++ b/mercurial/destutil.py Wed Feb 24 23:00:33 2016 +0900 @@ -358,9 +358,10 @@ def _statusotherbranchheads(ui, repo): currentbranch = repo.dirstate.branch() + allheads = repo.branchheads(currentbranch, closed=True) heads = repo.branchheads(currentbranch) - if repo.revs('%ln and parents()', heads): - # we are on a head + if repo.revs('%ln and parents()', allheads): + # we are on a head, even though it might be closed otherheads = repo.revs('%ln - parents()', heads) if otherheads: ui.status(_('%i other heads for branch "%s"\n') % diff -r 332926212ef8 -r de8b09482fb7 tests/test-update-branches.t --- a/tests/test-update-branches.t Wed Feb 24 06:10:46 2016 +0900 +++ b/tests/test-update-branches.t Wed Feb 24 23:00:33 2016 +0900 @@ -175,6 +175,41 @@ parent=1 M foo + $ cd .. + +Test updating with closed head +--------------------------------------------------------------------- + + $ hg clone -U -q b1 closed-heads + $ cd closed-heads + +Test updating if at least one non-closed branch head exists + +if on the closed branch head: +- updating is no-op +- "N other heads for ...." message is displayed + + $ hg update -q -C 3 + $ hg commit --close-branch -m 6 + $ norevtest "on closed branch head" clean 6 + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + 1 other heads for branch "default" + parent=6 + +Test updating if all branch heads are closed + +if on the closed branch head: +- updating is no-op +- "N other heads for ...." message isn't displayed + + $ hg update -q -C 2 + $ hg commit --close-branch -m 7 + $ norevtest "all heads of branch default are closed" clean 6 + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + parent=6 + + $ cd ../b1 + Test obsolescence behavior ---------------------------------------------------------------------