D6488: statecheck: added support for unfinishedstates and utilities
taapas1128 (Taapas Agrawal)
phabricator at mercurial-scm.org
Fri Jun 7 12:06:17 EDT 2019
taapas1128 updated this revision to Diff 15369.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D6488?vs=15368&id=15369
REVISION DETAIL
https://phab.mercurial-scm.org/D6488
AFFECTED FILES
mercurial/state.py
CHANGE DETAILS
diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -123,6 +123,9 @@
'To abort: hg bisect --reset\n')
elif self.cmdname == 'update':
msg = _("use 'hg update' to get a consistent checkout")
+ elif self.cmdname == 'transplant':
+ msg = _('To continue: hg %s --continue\n'
+ 'To abort: hg update') % (self.cmdname)
else:
msg = (_('To continue: hg %s --continue\n'
'To abort: hg %s --abort') % (self.cmdname,
@@ -139,7 +142,7 @@
else:
return _('%s in progress') % (self.cmdname)
- def inunfinished(self, repo, mergecheck=False):
+ def isunfinished(self, repo, mergecheck=False):
"""determines whether a multi-step operation is in progress
or not
mergecheck flag helps in determining state specifically for merge
@@ -149,4 +152,39 @@
else:
return repo.vfs.exists(self.fname)
+unfinishedstates=[]
+unfinishedstates.append(statecheck('graft','graftstate', clearable=True,
+ allowcommit=False, stopflag=True))
+unfinishedstates.append(statecheck('update', 'updatestate', clearable=True,
+ allowcommit=False, stopflag=False))
+def checkunfinished(repo, commit=False):
+ '''Look for an unfinished multistep operation, like graft, and abort
+ if found. It's probably good to check this right before
+ bailifchanged().
+ '''
+ # Check for non-clearable states first, so things like rebase will take
+ # precedence over update.
+ for state in unfinishedstates:
+ if state.clearable or (commit and state.allowcommit):
+ continue
+ if state.isunfinished(repo):
+ raise error.Abort(state.msg(), hint=state.hint())
+
+ for s in unfinishedstates:
+ if not s.clearable or (commit and s.allowcommit):
+ continue
+ if s.isunfinished(repo):
+ raise error.Abort(s.msg(), hint=s.hint())
+
+def clearunfinished(repo):
+ '''Check for unfinished operations (as above), and clear the ones
+ that are clearable.
+ '''
+ for state in unfinishedstates:
+ if not state.clearable and state.isunfinished(repo):
+ raise error.Abort(state.msg(), hint=state.hint())
+
+ for s in unfinishedstates:
+ if s.clearable and s.isunfinished(repo):
+ util.unlink(repo.vfs.join(s.fname))
To: taapas1128, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list