diff --git a/hgext3rd/heptapod/git.py b/hgext3rd/heptapod/git.py index 4aabd4184152def55d4e18a4ed78e41a41827473_aGdleHQzcmQvaGVwdGFwb2QvZ2l0LnB5..dd6fc894d36110f7310de91f04bd9d159c5ba7b4_aGdleHQzcmQvaGVwdGFwb2QvZ2l0LnB5 100644 --- a/hgext3rd/heptapod/git.py +++ b/hgext3rd/heptapod/git.py @@ -18,10 +18,9 @@ from mercurial import ( error, hg, - obsutil, phases, pycompat, ) import re import traceback @@ -22,9 +21,11 @@ phases, pycompat, ) import re import traceback +from . import obsutil + class MultipleDescendants(LookupError): pass @@ -295,7 +296,7 @@ return self.published_topic_latest_hg_sha(topic, before_ctx) try: - succctx = self.latest_unique_successor(before_ctx) + succctx = obsutil.latest_unique_successor(before_ctx) except error.Abort as exc: if initial_import: # we don't want to break an initial import because @@ -596,25 +597,3 @@ "Can't find public descendants of %r in topic %r" % ( ctx.hex(), topic)) return self.repo[rev] - - def latest_unique_successor(self, ctx): - """Return the latest of unique set of successors of a changeset. - - The changeset is given by its context, and a context is also returned, - or `None` if there is no successor. - - `Abort` gets raised if there are several sets of successors. - """ - successorssets = obsutil.successorssets(self.repo, - ctx.node()) - if not successorssets: - return None - if len(successorssets) > 1: - # There is more than one set of successors, so we have - # a divergence, and we cannot handle it automatically - raise error.Abort(("Changeset %r evolved into a " - "divergent state") % ctx.hex()) - - # Single successor set: it can be one or many (split) - # In all cases, we can take the last one. - return self.repo[successorssets[0][-1]] diff --git a/hgext3rd/heptapod/obsutil.py b/hgext3rd/heptapod/obsutil.py new file mode 100644 index 0000000000000000000000000000000000000000..dd6fc894d36110f7310de91f04bd9d159c5ba7b4_aGdleHQzcmQvaGVwdGFwb2Qvb2JzdXRpbC5weQ== --- /dev/null +++ b/hgext3rd/heptapod/obsutil.py @@ -0,0 +1,27 @@ +from mercurial import ( + error, + obsutil as hgobsutil, +) + + +def latest_unique_successor(ctx): + """Return the latest of unique set of successors of a changeset. + + The changeset is given by its context, and a context is also returned, + or `None` if there is no successor. + + `Abort` gets raised if there are several sets of successors. + """ + repo = ctx.repo() + successorssets = hgobsutil.successorssets(repo, ctx.node()) + if not successorssets: + return None + if len(successorssets) > 1: + # There is more than one set of successors, so we have + # a divergence, and we cannot handle it automatically + raise error.Abort(("Changeset %r evolved into a " + "divergent state") % ctx.hex()) + + # Single successor set: it can be one or many (split) + # In all cases, we can take the last one. + return repo[successorssets[0][-1]]