##// END OF EJS Templates
destupdate: extract validation logic...
Pierre-Yves David -
r26720:6c22a17f default
parent child Browse files
Show More
@@ -12,6 +12,34 b' from . import ('
12 obsolete,
12 obsolete,
13 )
13 )
14
14
15 def _destupdatevalidate(repo, rev, clean, check):
16 """validate that the destination comply to various rules
17
18 This exists as its own function to help wrapping from extensions."""
19 wc = repo[None]
20 p1 = wc.p1()
21 if not clean:
22 # Check that the update is linear.
23 #
24 # Mercurial do not allow update-merge for non linear pattern
25 # (that would be technically possible but was considered too confusing
26 # for user a long time ago)
27 #
28 # See mercurial.merge.update for details
29 if p1.rev() not in repo.changelog.ancestors([rev], inclusive=True):
30 dirty = wc.dirty(missing=True)
31 foreground = obsolete.foreground(repo, [p1.node()])
32 if not repo[rev].node() in foreground:
33 if dirty:
34 msg = _("uncommitted changes")
35 hint = _("commit and merge, or update --clean to"
36 " discard changes")
37 raise error.UpdateAbort(msg, hint=hint)
38 elif not check: # destination is not a descendant.
39 msg = _("not a linear update")
40 hint = _("merge or update --check to force update")
41 raise error.UpdateAbort(msg, hint=hint)
42
15 def destupdate(repo, clean=False, check=False):
43 def destupdate(repo, clean=False, check=False):
16 """destination for bare update operation
44 """destination for bare update operation
17
45
@@ -68,27 +96,7 b' def destupdate(repo, clean=False, check='
68 node = repo.revs('max(%ln)', successors).first()
96 node = repo.revs('max(%ln)', successors).first()
69 rev = repo[node].rev()
97 rev = repo[node].rev()
70
98
71 if not clean:
99 _destupdatevalidate(repo, rev, clean, check)
72 # Check that the update is linear.
73 #
74 # Mercurial do not allow update-merge for non linear pattern
75 # (that would be technically possible but was considered too confusing
76 # for user a long time ago)
77 #
78 # See mercurial.merge.update for details
79 if p1.rev() not in repo.changelog.ancestors([rev], inclusive=True):
80 dirty = wc.dirty(missing=True)
81 foreground = obsolete.foreground(repo, [p1.node()])
82 if not repo[rev].node() in foreground:
83 if dirty:
84 msg = _("uncommitted changes")
85 hint = _("commit and merge, or update --clean to"
86 " discard changes")
87 raise error.UpdateAbort(msg, hint=hint)
88 elif not check: # destination is not a descendant.
89 msg = _("not a linear update")
90 hint = _("merge or update --check to force update")
91 raise error.UpdateAbort(msg, hint=hint)
92
100
93 return rev, movemark, activemark
101 return rev, movemark, activemark
94
102
General Comments 0
You need to be logged in to leave comments. Login now