Skip to content

Commit

Permalink
cmdutil: get rid of "clearable" in-progress commands
Browse files Browse the repository at this point in the history
Summary:
Make the interrupted "graft" state no longer trivially clearable by running "goto". "graft" now supports "--abort", so it doesn't need this escape hatch.

I also removed clearable for "updatestate" and "updatemergestate" in favor of direct cleanup in the "update" command since the "update" command was the only place we cleared clearable states. This way we no longer have any command that can forcefully exit another command's in-progress state.

Reviewed By: quark-zju

Differential Revision: D51771498

fbshipit-source-id: 27a0793ab570c07e092d702a3002ed1531fc71a2
  • Loading branch information
muirdm authored and facebook-github-bot committed Dec 4, 2023
1 parent a6e5afa commit 5fe8e59
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 25 deletions.
20 changes: 2 additions & 18 deletions eden/scm/sapling/cmdutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -4726,27 +4726,23 @@ def _doregister(self, func, name, *args, **kwargs):
summaryremotehooks = util.hooks()

# A list of state files kept by multistep operations like graft.
# Since graft cannot be aborted, it is considered 'clearable' by update.
# note: bisect is intentionally excluded
# (state file, clearable, allowcommit, error, hint)
# (state file, allowcommit, error, hint)
unfinishedstates = [
(
"graftstate",
True,
False,
_("graft in progress"),
_("use '@prog@ graft --continue' or '@prog@ graft --abort' to abort"),
),
(
"updatemergestate",
True,
True,
_("update --merge in progress"),
_("use '@prog@ goto --continue' to continue"),
),
(
"updatestate",
True,
False,
_("last update was interrupted"),
_(
Expand All @@ -4763,25 +4759,13 @@ def checkunfinished(repo, commit=False):
if found. It's probably good to check this right before
bailifchanged().
"""
for f, clearable, allowcommit, msg, hint in unfinishedstates:
for f, allowcommit, msg, hint in unfinishedstates:
if commit and allowcommit:
continue
if repo.localvfs.exists(f):
raise error.Abort(msg, hint=hint)


def clearunfinished(repo):
"""Check for unfinished operations (as above), and clear the ones
that are clearable.
"""
for f, clearable, allowcommit, msg, hint in unfinishedstates:
if not clearable and repo.localvfs.exists(f):
raise error.Abort(msg, hint=hint)
for f, clearable, allowcommit, msg, hint in unfinishedstates:
if clearable and repo.localvfs.exists(f):
util.unlink(repo.localvfs.join(f))


afterresolvedstates = [
("graftstate", _("@prog@ graft --continue")),
("updatemergestate", _("@prog@ goto --continue")),
Expand Down
15 changes: 12 additions & 3 deletions eden/scm/sapling/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6408,6 +6408,9 @@ def abort_on_unresolved_conflicts():
repo.ui.warn(_("continuing checkout to '%s'\n") % rev)
else:
raise error.Abort(_("not in an interrupted update state"))
else:
# proactively clean this up if we aren't continuing
repo.localvfs.tryunlink("updatestate")

if rev is not None and rev != "" and node is not None:
raise error.Abort(_("please specify just one revision"))
Expand Down Expand Up @@ -6458,11 +6461,17 @@ def abort_on_unresolved_conflicts():
updatecheck = "none"

with repo.wlock():
if not clean:
# Don't delete the "updatemergestate" marker if we have conflicts.
# Don't delete the "updatemergestate" marker if we have conflicts.
if clean:
repo.localvfs.tryunlink("updatemergestate")
else:
abort_on_unresolved_conflicts()

cmdutil.clearunfinished(repo)
# Either we consumed this with "--continue" or we ignoring it with a
# different destination.
repo.localvfs.tryunlink("updatestate")

cmdutil.checkunfinished(repo)

if date:
rev = hex(cmdutil.finddate(ui, repo, date))
Expand Down
1 change: 0 additions & 1 deletion eden/scm/sapling/ext/histedit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1723,7 +1723,6 @@ def extsetup(ui):
cmdutil.unfinishedstates.append(
[
"histedit-state",
False,
True,
_("histedit in progress"),
_("use '@prog@ histedit --continue' or '@prog@ histedit --abort'"),
Expand Down
1 change: 0 additions & 1 deletion eden/scm/sapling/ext/rebase.py
Original file line number Diff line number Diff line change
Expand Up @@ -2457,7 +2457,6 @@ def uisetup(ui) -> None:
[
"rebasestate",
False,
False,
_("rebase in progress"),
_("use '@prog@ rebase --continue' or '@prog@ rebase --abort'"),
]
Expand Down
1 change: 0 additions & 1 deletion eden/scm/sapling/ext/shelve.py
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,6 @@ def extsetup(ui) -> None:
[
shelvedstate._filename,
False,
False,
_("unshelve already in progress"),
_("use '@prog@ unshelve --continue' or '@prog@ unshelve --abort'"),
]
Expand Down
2 changes: 1 addition & 1 deletion eden/scm/sapling/ext/undo.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def log(repo, command, tr):

def unfinished(repo):
"""like cmdutil.checkunfinished without raising an Abort"""
for f, clearable, allowcommit, msg, hint in cmdutil.unfinishedstates:
for f, allowcommit, msg, hint in cmdutil.unfinishedstates:
if repo.localvfs.exists(f):
return True
return False
Expand Down

0 comments on commit 5fe8e59

Please sign in to comment.