Patchwork [1,of,6] destutil: remove duplicate check and leave it to merge.update()

login
register
mail settings
Submitter via Mercurial-devel
Date Feb. 14, 2017, 1:07 a.m.
Message ID <f261eed3d3080b00a25f.1487034438@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/18460/
State Superseded
Headers show

Comments

via Mercurial-devel - Feb. 14, 2017, 1:07 a.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1486662752 28800
#      Thu Feb 09 09:52:32 2017 -0800
# Node ID f261eed3d3080b00a25fd4f422966b40c44fceb6
# Parent  455677a7667f6658be5c6e3f3d7b81a29cf5f9a2
destutil: remove duplicate check and leave it to merge.update()

The check is done in merge.update() already and the next few patches
will add more checks there. Some of the additional checks will need
information about the merge that will not be available in destutil.

Since commands.postincoming() catches UpdateAbort(), we need to change
merge.update() to raise that more specific exception.

This goes directly again 45b86dbabbda (destupdate: move the check
related to the "clean" logic in the function, 2015-10-05), but it will
simplify the next few patches, and we can always move it out again
(preferably move, not copy) after if we still think it's better that
way.

Patch

diff -r 455677a7667f -r f261eed3d308 mercurial/destutil.py
--- a/mercurial/destutil.py	Mon Feb 13 09:44:16 2017 -0800
+++ b/mercurial/destutil.py	Thu Feb 09 09:52:32 2017 -0800
@@ -14,30 +14,6 @@ 
     obsolete,
 )
 
-def _destupdatevalidate(repo, rev, clean, check):
-    """validate that the destination comply to various rules
-
-    This exists as its own function to help wrapping from extensions."""
-    wc = repo[None]
-    p1 = wc.p1()
-    if not clean:
-        # Check that the update is linear.
-        #
-        # Mercurial do not allow update-merge for non linear pattern
-        # (that would be technically possible but was considered too confusing
-        # for user a long time ago)
-        #
-        # See mercurial.merge.update for details
-        if p1.rev() not in repo.changelog.ancestors([rev], inclusive=True):
-            dirty = wc.dirty(missing=True)
-            foreground = obsolete.foreground(repo, [p1.node()])
-            if not repo[rev].node() in foreground:
-                if dirty:
-                    msg = _("uncommitted changes")
-                    hint = _("commit and merge, or update --clean to"
-                             " discard changes")
-                    raise error.UpdateAbort(msg, hint=hint)
-
 def _destupdateobs(repo, clean, check):
     """decide of an update destination from obsolescence markers"""
     node = None
@@ -157,8 +133,6 @@ 
             break
     rev = repo[node].rev()
 
-    _destupdatevalidate(repo, rev, clean, check)
-
     return rev, movemark, activemark
 
 msgdestmerge = {
diff -r 455677a7667f -r f261eed3d308 mercurial/merge.py
--- a/mercurial/merge.py	Mon Feb 13 09:44:16 2017 -0800
+++ b/mercurial/merge.py	Thu Feb 09 09:52:32 2017 -0800
@@ -1562,7 +1562,7 @@ 
                     else:
                         msg = _("uncommitted changes")
                         hint = _("commit or update --clean to discard changes")
-                        raise error.Abort(msg, hint=hint)
+                        raise error.UpdateAbort(msg, hint=hint)
                 else:
                     # Allow jumping branches if clean and specific rev given
                     pass