[PATCH 2 of 4] commands: add postincoming explicit brev argument (API)

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Wed Feb 17 14:49:26 EST 2016


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1455738393 -32400
#      Thu Feb 18 04:46:33 2016 +0900
# Node ID 677cfb752ac33aff00ad51564acb44dcfd6724d8
# Parent  4da9702b2eef28a1c6097f5dbce322bec8925fcd
commands: add postincoming explicit brev argument (API)

Before this patch, postincoming() initializes 'brev' with 'checkout',
but this isn't useful to activate/deactivate bookmark after updating,
because 'checkout' is not a string actually specified at command line,
but an already node-nized byte sequence.

This patch adds postincoming() explicit 'brev' argument, and makes
'pull()' pass appropriate value.

This patch adds 'brev' argument instead of 'brev=None', because
'brev=None' isn't reasonable value if checkout is not None.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5543,13 +5543,12 @@ def phase(ui, repo, *revs, **opts):
             ui.warn(_('no phases changed\n'))
     return ret
 
-def postincoming(ui, repo, modheads, optupdate, checkout):
+def postincoming(ui, repo, modheads, optupdate, checkout, brev):
     if modheads == 0:
         return
     if optupdate:
         warndest = False
         try:
-            brev = checkout
             movemarkfrom = None
             if not checkout:
                 warndest = True
@@ -5655,6 +5654,12 @@ def pull(ui, repo, source="default", **o
                                  force=opts.get('force'),
                                  bookmarks=opts.get('bookmark', ()),
                                  opargs=pullopargs).cgresult
+
+        # brev is a name, which might be a bookmark to be activated at
+        # the end of the update. In other words, it is an explicit
+        # destination of the update
+        brev = None
+
         if checkout:
             fragment = branches[0]
             # treat "hg pull -u URL#fragment" as same as "hg pull" +
@@ -5666,9 +5671,20 @@ def pull(ui, repo, source="default", **o
                 checkout = None
             else:
                 checkout = str(repo.changelog.rev(checkout))
+
+                # order below depends on implementation of
+                # hg.addbranchrevs(). opts['bookmark'] is ignored,
+                # because 'checkout' is determined without it.
+                if opts.get('rev'):
+                    brev = opts['rev'][0]
+                elif opts.get('branch'):
+                    brev = opts['branch'][0]
+                else:
+                    brev = fragment
         repo._subtoppath = source
         try:
-            ret = postincoming(ui, repo, modheads, opts.get('update'), checkout)
+            ret = postincoming(ui, repo, modheads, opts.get('update'),
+                               checkout, brev)
 
         finally:
             del repo._subtoppath
@@ -6905,7 +6921,7 @@ def unbundle(ui, repo, fname1, *fnames, 
             else:
                 modheads = gen.apply(repo, 'unbundle', 'bundle:' + fname)
 
-    return postincoming(ui, repo, modheads, opts.get('update'), None)
+    return postincoming(ui, repo, modheads, opts.get('update'), None, None)
 
 @command('^update|up|checkout|co',
     [('C', 'clean', None, _('discard uncommitted changes (no backup)')),


More information about the Mercurial-devel mailing list