Patchwork [1,of,3] destutil: ensure we offer 'hg update' hint when not at head in all cases

mail settings
Submitter Pierre-Yves David
Date Feb. 15, 2016, 10:49 a.m.
Message ID <>
Download mbox | patch
Permalink /patch/13194/
State Accepted
Delegated to: Yuya Nishihara
Headers show


Pierre-Yves David - Feb. 15, 2016, 10:49 a.m.
# HG changeset patch
# User Pierre-Yves David <>
# Date 1455060921 0
#      Tue Feb 09 23:35:21 2016 +0000
# Node ID dfac70f47ed5ac6802eba6a331f36fb843c81bc7
# Parent  ade8a14a32f640eafc0e1ab3921280f508b0353b
# EXP-Topic destination
# Available At
#              hg pull -r dfac70f47ed5
destutil: ensure we offer 'hg update' hint when not at head in all cases

In the merge case, we abort if the working copy is not at head, offering to
run 'hg update' in the hint instead. In the rebase case, we do not abort in that
case. Yet if no rebase destination are found, it still make sense to hint the
user about running 'hg update'. So we re-introduce a conditional using this
branch in the 'onheadcheck == False' case.

This will get used on rebase use this function.


diff --git a/mercurial/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -233,11 +233,12 @@  def _destmergebranch(repo, action='merge
                 msg, hint = msgdestmerge['multiplebranchessourceset'][action]
                 raise error.ManyMergeDestAbort(msg, hint=hint)
             branch = ctx.branch()
     bheads = repo.branchheads(branch)
-    if onheadcheck and not repo.revs('%ld and %ln', sourceset, bheads):
+    onhead = repo.revs('%ld and %ln', sourceset, bheads)
+    if onheadcheck and not onhead:
         # Case A: working copy if not on a head. (merge only)
         # This is probably a user mistake We bailout pointing at 'hg update'
         if len(repo.heads()) <= 1:
             msg, hint = msgdestmerge['nootherheadsbehind'][action]
@@ -265,10 +266,14 @@  def _destmergebranch(repo, action='merge
         if bheads:
             msg, hint = msgdestmerge['bookmarkedheads'][action]
         elif len(repo.heads()) > 1:
             msg, hint = msgdestmerge['nootherbranchheads'][action]
             msg %= branch
+        elif not onhead:
+            # if 'onheadcheck == False' (rebase case),
+            # this was not caught in Case A.
+            msg, hint = msgdestmerge['nootherheadsbehind'][action]
             msg, hint = msgdestmerge['nootherheads'][action]
         raise error.NoMergeDestAbort(msg, hint=hint)
         node = nbhs[0]