##// END OF EJS Templates
destmerge: extract logic based on branch heads in its own function...
Pierre-Yves David -
r26728:e8f1b728 default
parent child Browse files
Show More
@@ -152,42 +152,49 b' def _destmergebook(repo):'
152 assert node is not None
152 assert node is not None
153 return node
153 return node
154
154
155 def _destmergebranch(repo):
156 """find merge destination based on branch heads"""
157 node = None
158 branch = repo[None].branch()
159 bheads = repo.branchheads(branch)
160 nbhs = [bh for bh in bheads if not repo[bh].bookmarks()]
161
162 if len(nbhs) > 2:
163 raise error.Abort(_("branch '%s' has %d heads - "
164 "please merge with an explicit rev")
165 % (branch, len(bheads)),
166 hint=_("run 'hg heads .' to see heads"))
167
168 parent = repo.dirstate.p1()
169 if len(nbhs) <= 1:
170 if len(bheads) > 1:
171 raise error.Abort(_("heads are bookmarked - "
172 "please merge with an explicit rev"),
173 hint=_("run 'hg heads' to see all heads"))
174 if len(repo.heads()) > 1:
175 raise error.Abort(_("branch '%s' has one head - "
176 "please merge with an explicit rev")
177 % branch,
178 hint=_("run 'hg heads' to see all heads"))
179 msg, hint = _('nothing to merge'), None
180 if parent != repo.lookup(branch):
181 hint = _("use 'hg update' instead")
182 raise error.Abort(msg, hint=hint)
183
184 if parent not in bheads:
185 raise error.Abort(_('working directory not at a head revision'),
186 hint=_("use 'hg update' or merge with an "
187 "explicit revision"))
188 if parent == nbhs[0]:
189 node = nbhs[-1]
190 else:
191 node = nbhs[0]
192 assert node is not None
193 return node
194
155 def destmerge(repo):
195 def destmerge(repo):
156 if repo._activebookmark:
196 if repo._activebookmark:
157 node = _destmergebook(repo)
197 node = _destmergebook(repo)
158 else:
198 else:
159 branch = repo[None].branch()
199 node = _destmergebranch(repo)
160 bheads = repo.branchheads(branch)
161 nbhs = [bh for bh in bheads if not repo[bh].bookmarks()]
162
163 if len(nbhs) > 2:
164 raise error.Abort(_("branch '%s' has %d heads - "
165 "please merge with an explicit rev")
166 % (branch, len(bheads)),
167 hint=_("run 'hg heads .' to see heads"))
168
169 parent = repo.dirstate.p1()
170 if len(nbhs) <= 1:
171 if len(bheads) > 1:
172 raise error.Abort(_("heads are bookmarked - "
173 "please merge with an explicit rev"),
174 hint=_("run 'hg heads' to see all heads"))
175 if len(repo.heads()) > 1:
176 raise error.Abort(_("branch '%s' has one head - "
177 "please merge with an explicit rev")
178 % branch,
179 hint=_("run 'hg heads' to see all heads"))
180 msg, hint = _('nothing to merge'), None
181 if parent != repo.lookup(branch):
182 hint = _("use 'hg update' instead")
183 raise error.Abort(msg, hint=hint)
184
185 if parent not in bheads:
186 raise error.Abort(_('working directory not at a head revision'),
187 hint=_("use 'hg update' or merge with an "
188 "explicit revision"))
189 if parent == nbhs[0]:
190 node = nbhs[-1]
191 else:
192 node = nbhs[0]
193 return repo[node].rev()
200 return repo[node].rev()
General Comments 0
You need to be logged in to leave comments. Login now