comparison mercurial/destutil.py @ 30961:330fbd515512

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.
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 09 Feb 2017 09:52:32 -0800
parents 76a1e735449c
children 11c253997b0e
comparison
equal deleted inserted replaced
30960:e4492d55fb66 30961:330fbd515512
11 from . import ( 11 from . import (
12 bookmarks, 12 bookmarks,
13 error, 13 error,
14 obsolete, 14 obsolete,
15 ) 15 )
16
17 def _destupdatevalidate(repo, rev, clean, check):
18 """validate that the destination comply to various rules
19
20 This exists as its own function to help wrapping from extensions."""
21 wc = repo[None]
22 p1 = wc.p1()
23 if not clean:
24 # Check that the update is linear.
25 #
26 # Mercurial do not allow update-merge for non linear pattern
27 # (that would be technically possible but was considered too confusing
28 # for user a long time ago)
29 #
30 # See mercurial.merge.update for details
31 if p1.rev() not in repo.changelog.ancestors([rev], inclusive=True):
32 dirty = wc.dirty(missing=True)
33 foreground = obsolete.foreground(repo, [p1.node()])
34 if not repo[rev].node() in foreground:
35 if dirty:
36 msg = _("uncommitted changes")
37 hint = _("commit and merge, or update --clean to"
38 " discard changes")
39 raise error.UpdateAbort(msg, hint=hint)
40 16
41 def _destupdateobs(repo, clean, check): 17 def _destupdateobs(repo, clean, check):
42 """decide of an update destination from obsolescence markers""" 18 """decide of an update destination from obsolescence markers"""
43 node = None 19 node = None
44 wc = repo[None] 20 wc = repo[None]
154 for step in destupdatesteps: 130 for step in destupdatesteps:
155 node, movemark, activemark = destupdatestepmap[step](repo, clean, check) 131 node, movemark, activemark = destupdatestepmap[step](repo, clean, check)
156 if node is not None: 132 if node is not None:
157 break 133 break
158 rev = repo[node].rev() 134 rev = repo[node].rev()
159
160 _destupdatevalidate(repo, rev, clean, check)
161 135
162 return rev, movemark, activemark 136 return rev, movemark, activemark
163 137
164 msgdestmerge = { 138 msgdestmerge = {
165 # too many matching divergent bookmark 139 # too many matching divergent bookmark