yuja added a comment.
> +def _abortgraft(ui, repo, graftstate): > + """abort the interrupted graft and rollbacks to the state before interrupted > + graft""" > + if not graftstate.exists(): > + raise error.Abort(_("no interrupted graft to abort")) > + statedata = _readgraftstate(repo, graftstate) > + startnode = statedata.get('startnode') > + if not startnode: > + # and old graft state which does not have all the data required to abort > + # the graft > + raise error.Abort(_("cannot abort using an old graftstate")) > + newnodes = statedata.get('newnodes') > + hg.updaterepo(repo, startnode, True) > + if newnodes: It's probably better to not updating to the startnode if we can't strip grafted revisions. > + newnodes = [repo[r].rev() for r in newnodes] > + > + # checking that none of the newnodes turned public or is public > + immutable = [c for c in newnodes if not repo[c].mutable()] > + if immutable: > + repo.ui.warn(_("cannot clean up public changesets %s\n") > + % ','.join(bytes(repo[r]) for r in immutable), > + hint=_("see 'hg help phases' for details")) > + > + # checking that no new nodes are created on top of grafted revs > + desc = set(repo.changelog.descendants(newnodes)) > + if desc - set(newnodes): > + repo.ui.warn(_("new changesets detected on destination " > + "branch, can't strip\n")) > + > + with repo.wlock(), repo.lock(): > + # stripping the new nodes created > + strippoints = [c.node() for c in repo.set("roots(%ld)", newnodes)] > + repair.strip(repo.ui, repo, strippoints, False) > + > + ui.write(_("graft aborted\nworking directory is now at %s\n") > + % repo[startnode].hex()[:12]) > + graftstate.delete() > + return 0 This looks quite similar to rebase.abort(). Can we factor out a common part? Maybe it's time to add a new module for rebase/graft thingy. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3754 To: pulkit, #hg-reviewers Cc: yuja, mercurial-devel _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel