comparison mercurial/destutil.py @ 26722:6cd643a1d32c

destupdate: move obsolete handling first This block was overwriting any result from the previous block anyway. So we move it first to prove it is possible and we'll extract it in its own function in the next patch.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Thu, 15 Oct 2015 02:12:55 +0100
parents 3d094fbedf74
children 52d08a93de1f
comparison
equal deleted inserted replaced
26721:3d094fbedf74 26722:6cd643a1d32c
51 - activemark: a bookmark to activate at the end of the update. 51 - activemark: a bookmark to activate at the end of the update.
52 """ 52 """
53 node = None 53 node = None
54 wc = repo[None] 54 wc = repo[None]
55 p1 = wc.p1() 55 p1 = wc.p1()
56 movemark, activemark = None 56 movemark = activemark = None
57 57
58 if node is None:
59 # we also move the active bookmark, if any
60 node, movemark = bookmarks.calculateupdate(repo.ui, repo, None)
61 if node is not None:
62 activemark = node
63
64 if node is None:
65 try:
66 node = repo.branchtip(wc.branch())
67 except error.RepoLookupError:
68 if wc.branch() == 'default': # no default branch!
69 node = repo.lookup('tip') # update to tip
70 else:
71 raise error.Abort(_("branch %s not found") % wc.branch())
72 if p1.obsolete() and not p1.children(): 58 if p1.obsolete() and not p1.children():
73 # allow updating to successors 59 # allow updating to successors
74 successors = obsolete.successorssets(repo, p1.node()) 60 successors = obsolete.successorssets(repo, p1.node())
75 61
76 # behavior of certain cases is as follows, 62 # behavior of certain cases is as follows,
92 successors = [n for sub in successors for n in sub] 78 successors = [n for sub in successors for n in sub]
93 79
94 # get the max revision for the given successors set, 80 # get the max revision for the given successors set,
95 # i.e. the 'tip' of a set 81 # i.e. the 'tip' of a set
96 node = repo.revs('max(%ln)', successors).first() 82 node = repo.revs('max(%ln)', successors).first()
83 if bookmarks.isactivewdirparent(repo):
84 movemark = repo['.'].node()
85
86 if node is None:
87 # we also move the active bookmark, if any
88 node, movemark = bookmarks.calculateupdate(repo.ui, repo, None)
89 if node is not None:
90 activemark = node
91
92 if node is None:
93 try:
94 node = repo.branchtip(wc.branch())
95 except error.RepoLookupError:
96 if wc.branch() == 'default': # no default branch!
97 node = repo.lookup('tip') # update to tip
98 else:
99 raise error.Abort(_("branch %s not found") % wc.branch())
97 rev = repo[node].rev() 100 rev = repo[node].rev()
98 101
99 _destupdatevalidate(repo, rev, clean, check) 102 _destupdatevalidate(repo, rev, clean, check)
100 103
101 return rev, movemark, activemark 104 return rev, movemark, activemark