def _rebaserestoredcommit(ui, repo, opts, tr, oldtiprev, basename, pctx, tmpwctx, shelvectx, branchtorestore, activebookmark): """Rebase restored commit from its original location to a destination""" # If the shelve is not immediately on top of the commit # we'll be merging with, rebase it to be on top. if tmpwctx.node() == shelvectx.parents()[0].node(): return shelvectx overrides = { ('ui', 'forcemerge'): opts.get('tool', ''), ('phases', 'new-commit'): phases.secret, } with repo.ui.configoverride(overrides, 'unshelve'): ui.status(_('rebasing shelved changes\n')) stats = merge.graft(repo, shelvectx, shelvectx.p1(), labels=['shelve', 'working-copy'], keepconflictparent=True) if stats.unresolvedcount: tr.close() nodestoremove = [ repo.changelog.node(rev) for rev in pycompat.xrange(oldtiprev, len(repo)) ] shelvedstate.save(repo, basename, pctx, tmpwctx, nodestoremove, branchtorestore, opts.get('keep'), activebookmark) raise error.InterventionRequired( _("unresolved conflicts (see 'hg resolve', then " "'hg unshelve --continue')")) with repo.dirstate.parentchange(): repo.setparents(tmpwctx.node(), nodemod.nullid) newnode = repo.commit(text=shelvectx.description(), extra=shelvectx.extra(), user=shelvectx.user(), date=shelvectx.date()) if newnode is None: # If it ended up being a no-op commit, then the normal # merge state clean-up path doesn't happen, so do it # here. Fix issue5494 merge.mergestate.clean(repo) shelvectx = tmpwctx msg = _('note: unshelved changes already existed ' 'in the working copy\n') ui.status(msg) else: shelvectx = repo[newnode] hg.updaterepo(repo, tmpwctx.node(), False) return shelvectx
def applychanges(ui, repo, ctx, opts): """Merge changeset from ctx (only) in the current working directory""" wcpar = repo.dirstate.parents()[0] if ctx.p1().node() == wcpar: # edition ar "in place" we do not need to make any merge, # just applies changes on parent for edition cmdutil.revert(ui, repo, ctx, (wcpar, node.nullid), all=True) stats = None else: try: # ui.forcemerge is an internal variable, do not document repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'histedit') stats = mergemod.graft(repo, ctx, ctx.p1(), ['local', 'histedit']) finally: repo.ui.setconfig('ui', 'forcemerge', '', 'histedit') return stats