def run(self): parentctx, replacements = super(stop, self).run() self.state.read() self.state.replacements.extend(replacements) self.state.write() raise error.InterventionRequired( _("Changes committed as %s. You may amend the changeset now.\n" "When you are done, run hg histedit --continue to resume") % parentctx)
def run(self): state = self.state repo, ctxnode = state.repo, state.parentctxnode with repo.wlock(), repo.lock(), repo.transaction("histedit"): hg.update(repo, ctxnode) # release locks so the program can call hg and then relock. lock.release(state.lock, state.wlock) try: ctx = repo[ctxnode] shell = encoding.environ.get("SHELL", None) cmd = self.command if shell and self.repo.ui.config("fbhistedit", "exec_in_user_shell"): cmd = "%s -c -i %s" % (shell, quote(cmd)) rc = repo.ui.system( cmd, environ={"HGNODE": ctx.hex()}, cwd=self.cwd, blockedtag="histedit_exec", ) except OSError as ose: raise error.InterventionRequired( _("Cannot execute command '%s': %s") % (self.command, ose)) finally: # relock the repository state.wlock = repo.wlock() state.lock = repo.lock() repo.invalidateall() if rc != 0: raise error.InterventionRequired( _("Command '%s' failed with exit status %d") % (self.command, rc)) m, a, r, d = self.repo.status()[:4] if m or a or r or d: self.continuedirty() return self.continueclean()
def _rebaserestoredcommit( ui, repo, opts, tr, oldtiprev, basename, pctx, tmpwctx, shelvectx, branchtorestore, activebookmark, obsshelve, ): """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.p1().node(): # shelvectx is immediately on top of the tmpwctx return shelvectx # we need a new commit extra every time we perform a rebase to ensure # that "nothing to rebase" does not happen with obs-based shelve # "nothing to rebase" means that tip does not point to a "successor" # commit after a rebase and we have no way to learn which commit # should be a "shelvectx". this is a dirty hack until we implement # some way to learn the results of rebase operation, other than # text output and return code def extrafn(ctx, extra): extra["unshelve_time"] = str(time.time()) ui.status(_("rebasing shelved changes\n")) try: # we only want keep to be true if shelve is traditional, since # for obs-based shelve, rebase will also be obs-based and # markers created help us track the relationship between shelvectx # and its new version rebase.rebase( ui, repo, **{ "rev": [shelvectx.hex()], "dest": str(tmpwctx.hex()), "keep": not obsshelve, "tool": opts.get("tool", ""), "extrafn": extrafn if obsshelve else None, }) except error.InterventionRequired: tr.close() nodestoremove = [ repo.changelog.node(rev) for rev in range(oldtiprev, len(repo)) ] shelvedstate.save( repo, basename, pctx, tmpwctx, nodestoremove, branchtorestore, opts.get("keep"), activebookmark, obsshelve, ) repo.localvfs.rename("rebasestate", "unshelverebasestate") raise error.InterventionRequired( _("unresolved conflicts (see 'hg resolve', then " "'hg unshelve --continue')")) # refresh ctx after rebase completes shelvectx = repo["tip"] if not shelvectx in tmpwctx.children(): # rebase was a no-op, so it produced no child commit shelvectx = tmpwctx return shelvectx