comparison mercurial/destutil.py @ 26723:52d08a93de1f

destupdate: extract logic based on obsolescence marker in its own function One of the main goal of having consolidated destination function is to allow extension to play with this logic. We extract sub logic to make is wrapping more practical.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Thu, 15 Oct 2015 02:15:43 +0100
parents 6cd643a1d32c
children 7fc759c0c430
comparison
equal deleted inserted replaced
26722:6cd643a1d32c 26723:52d08a93de1f
38 elif not check: # destination is not a descendant. 38 elif not check: # destination is not a descendant.
39 msg = _("not a linear update") 39 msg = _("not a linear update")
40 hint = _("merge or update --check to force update") 40 hint = _("merge or update --check to force update")
41 raise error.UpdateAbort(msg, hint=hint) 41 raise error.UpdateAbort(msg, hint=hint)
42 42
43 def destupdate(repo, clean=False, check=False): 43 def _destupdateobs(repo, clean, check):
44 """destination for bare update operation 44 """decide of an update destination from obsolescence markers"""
45
46 return (rev, movemark, activemark)
47
48 - rev: the revision to update to,
49 - movemark: node to move the active bookmark from
50 (cf bookmark.calculate update),
51 - activemark: a bookmark to activate at the end of the update.
52 """
53 node = None 45 node = None
54 wc = repo[None] 46 wc = repo[None]
55 p1 = wc.p1() 47 p1 = wc.p1()
56 movemark = activemark = None 48 movemark = None
57 49
58 if p1.obsolete() and not p1.children(): 50 if p1.obsolete() and not p1.children():
59 # allow updating to successors 51 # allow updating to successors
60 successors = obsolete.successorssets(repo, p1.node()) 52 successors = obsolete.successorssets(repo, p1.node())
61 53
80 # get the max revision for the given successors set, 72 # get the max revision for the given successors set,
81 # i.e. the 'tip' of a set 73 # i.e. the 'tip' of a set
82 node = repo.revs('max(%ln)', successors).first() 74 node = repo.revs('max(%ln)', successors).first()
83 if bookmarks.isactivewdirparent(repo): 75 if bookmarks.isactivewdirparent(repo):
84 movemark = repo['.'].node() 76 movemark = repo['.'].node()
77 return node, movemark, None
78
79 def destupdate(repo, clean=False, check=False):
80 """destination for bare update operation
81
82 return (rev, movemark, activemark)
83
84 - rev: the revision to update to,
85 - movemark: node to move the active bookmark from
86 (cf bookmark.calculate update),
87 - activemark: a bookmark to activate at the end of the update.
88 """
89 node = None
90 wc = repo[None]
91 movemark = activemark = None
92
93 node, movemark, activemark = _destupdateobs(repo, clean, check)
85 94
86 if node is None: 95 if node is None:
87 # we also move the active bookmark, if any 96 # we also move the active bookmark, if any
88 node, movemark = bookmarks.calculateupdate(repo.ui, repo, None) 97 node, movemark = bookmarks.calculateupdate(repo.ui, repo, None)
89 if node is not None: 98 if node is not None: