Mercurial > hg
comparison mercurial/destutil.py @ 26727:5b7fd48f9868
destmerge: extract logic based on bookmark into 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 03:13:14 +0100 |
parents | 8e6649616699 |
children | e8f1b7285917 |
comparison
equal
deleted
inserted
replaced
26726:8e6649616699 | 26727:5b7fd48f9868 |
---|---|
129 | 129 |
130 _destupdatevalidate(repo, rev, clean, check) | 130 _destupdatevalidate(repo, rev, clean, check) |
131 | 131 |
132 return rev, movemark, activemark | 132 return rev, movemark, activemark |
133 | 133 |
134 def _destmergebook(repo): | |
135 """find merge destination in the active bookmark case""" | |
136 node = None | |
137 bmheads = repo.bookmarkheads(repo._activebookmark) | |
138 curhead = repo[repo._activebookmark].node() | |
139 if len(bmheads) == 2: | |
140 if curhead == bmheads[0]: | |
141 node = bmheads[1] | |
142 else: | |
143 node = bmheads[0] | |
144 elif len(bmheads) > 2: | |
145 raise error.Abort(_("multiple matching bookmarks to merge - " | |
146 "please merge with an explicit rev or bookmark"), | |
147 hint=_("run 'hg heads' to see all heads")) | |
148 elif len(bmheads) <= 1: | |
149 raise error.Abort(_("no matching bookmark to merge - " | |
150 "please merge with an explicit rev or bookmark"), | |
151 hint=_("run 'hg heads' to see all heads")) | |
152 assert node is not None | |
153 return node | |
154 | |
134 def destmerge(repo): | 155 def destmerge(repo): |
135 if repo._activebookmark: | 156 if repo._activebookmark: |
136 bmheads = repo.bookmarkheads(repo._activebookmark) | 157 node = _destmergebook(repo) |
137 curhead = repo[repo._activebookmark].node() | |
138 if len(bmheads) == 2: | |
139 if curhead == bmheads[0]: | |
140 node = bmheads[1] | |
141 else: | |
142 node = bmheads[0] | |
143 elif len(bmheads) > 2: | |
144 raise error.Abort(_("multiple matching bookmarks to merge - " | |
145 "please merge with an explicit rev or bookmark"), | |
146 hint=_("run 'hg heads' to see all heads")) | |
147 elif len(bmheads) <= 1: | |
148 raise error.Abort(_("no matching bookmark to merge - " | |
149 "please merge with an explicit rev or bookmark"), | |
150 hint=_("run 'hg heads' to see all heads")) | |
151 else: | 158 else: |
152 branch = repo[None].branch() | 159 branch = repo[None].branch() |
153 bheads = repo.branchheads(branch) | 160 bheads = repo.branchheads(branch) |
154 nbhs = [bh for bh in bheads if not repo[bh].bookmarks()] | 161 nbhs = [bh for bh in bheads if not repo[bh].bookmarks()] |
155 | 162 |