[PATCH 3 of 5] merge: remove unused handling of default destination in merge.update()

Martin von Zweigbergk martinvonz at google.com
Fri Feb 10 01:00:30 EST 2017


# HG changeset patch
# User Martin von Zweigbergk <martinvonz at google.com>
# Date 1486623813 28800
#      Wed Feb 08 23:03:33 2017 -0800
# Node ID 85fdf08596df69b9e9d8dd206e90d9017416b572
# Parent  efccada71f928962cd578ab7e763506df5d7fb86
merge: remove unused handling of default destination in merge.update()

As far as I can tell, all the callers of merge.update() have been
migrated over to use destutil to find the default destination when the
revision was not specified. So it's time to delete the code for
handling a node value of None. Let's add an assertion that node is not
None, so any extensions relying on it will not silently misbehave.

diff -r efccada71f92 -r 85fdf08596df mercurial/merge.py
--- a/mercurial/merge.py	Wed Feb 08 14:49:37 2017 -0800
+++ b/mercurial/merge.py	Wed Feb 08 23:03:33 2017 -0800
@@ -1448,7 +1448,7 @@
     """
     Perform a merge between the working directory and the given node
 
-    node = the node to update to, or None if unspecified
+    node = the node to update to
     branchmerge = whether to merge between branches
     force = whether to force branch merging or file overwriting
     matcher = a matcher to filter file lists (dirstate not updated)
@@ -1491,7 +1491,9 @@
     Return the same tuple as applyupdates().
     """
 
-    onode = node
+    # This functon used to find the default destination if node was None, but
+    # that's now in destutil.py.
+    assert node is not None
     # If we're doing a partial update, we need to skip updating
     # the dirstate, so make a note of any partial-ness to the
     # update here.
@@ -1550,25 +1552,16 @@
 
             if pas not in ([p1], [p2]):  # nonlinear
                 dirty = wc.dirty(missing=True)
-                if dirty or onode is None:
+                if dirty:
                     # Branching is a bit strange to ensure we do the minimal
                     # amount of call to obsolete.background.
                     foreground = obsolete.foreground(repo, [p1.node()])
                     # note: the <node> variable contains a random identifier
                     if repo[node].node() in foreground:
                         pass # allow updating to successors
-                    elif dirty:
+                    else:
                         msg = _("uncommitted changes")
-                        if onode is None:
-                            hint = _("commit and merge, or update --clean to"
-                                     " discard changes")
-                        else:
-                            hint = _("commit or update --clean to discard"
-                                     " changes")
-                        raise error.Abort(msg, hint=hint)
-                    else:  # node is none
-                        msg = _("not a linear update")
-                        hint = _("merge or update --check to force update")
+                        hint = _("commit or update --clean to discard changes")
                         raise error.Abort(msg, hint=hint)
                 else:
                     # Allow jumping branches if clean and specific rev given


More information about the Mercurial-devel mailing list