diff --git a/hgext/strip.py b/hgext/strip.py --- a/hgext/strip.py +++ b/hgext/strip.py @@ -47,18 +47,17 @@ return inclsubs def checklocalchanges(repo, force=False, excsuffix=''): - statemod.checkunfinished(repo) s = repo.status() if not force: - if len(repo[None].parents()) > 1: - _("outstanding uncommitted merge") #i18 tool detection - raise error.Abort(_("outstanding uncommitted merge"+ excsuffix)) + statemod.checkunfinished(repo) if s.modified or s.added or s.removed or s.deleted: _("local changes found") # i18n tool detection raise error.Abort(_("local changes found" + excsuffix)) if checksubstate(repo): _("local changed subrepos found") # i18n tool detection raise error.Abort(_("local changed subrepos found" + excsuffix)) + else: + statemod.checkunfinished(repo ,mergeskip=True) return s def _findupdatetarget(repo, nodes): diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -620,18 +620,17 @@ return _commentlines(msg) def morestatus(repo, fm): - statetuple = statemod._getrepostate(repo) + statetuple = statemod.getrepostate(repo) label = 'status.morestatus' if statetuple: - state, statedetectionpredicate, helpfulmsg = statetuple + state, helpfulmsg = statetuple statemsg = _('The repository is in an unfinished *%s* state.') % state fm.plain('%s\n' % _commentlines(statemsg), label=label) conmsg = _conflictsmsg(repo) if conmsg: fm.plain('%s\n' % conmsg, label=label) if helpfulmsg: - helpmsg = helpfulmsg() - fm.plain('%s\n' % helpmsg, label=label) + fm.plain('%s\n' % _commentlines(helpfulmsg), label=label) def findpossible(cmd, table, strict=False): """ diff --git a/mercurial/state.py b/mercurial/state.py --- a/mercurial/state.py +++ b/mercurial/state.py @@ -134,8 +134,13 @@ return self._cmdmsg def isunfinished(self, repo): - """determines whether a multi-step operation is in progress or not""" - return repo.vfs.exists(self._fname) + """determines whether a multi-step operation is in progress + or not + """ + if self._opname == 'merge': + return len(repo[None].parents()) > 1 + else: + return repo.vfs.exists(self._fname) # A list of statecheck objects for multistep operations like graft. _unfinishedstates = [] @@ -144,7 +149,10 @@ """this registers a new command or operation to unfinishedstates """ statecheckobj = _statecheck(opname, **kwargs) - _unfinishedstates.append(statecheckobj) + if opname=='merge' or opname=='bisect': + _unfinishedstates.append(statecheckobj) + else: + _unfinishedstates.insert(0, statecheckobj) addunfinished( 'graft', @@ -161,8 +169,25 @@ cmdmsg = _('last update was interrupted'), cmdhint = _("use 'hg update' to get a consistent checkout") ) - -def checkunfinished(repo, commit=False): +addunfinished( + 'bisect', + fname = 'bisect.state', + clearable = False, + allowcommit = True, + cmdhint = _('To mark the changeset good: hg bisect --good\n' + 'To mark the changeset bad: hg bisect --bad\n' + 'To abort: hg bisect --reset\n') +) +addunfinished( + 'merge', + fname = None, + clearable = True, + allowcommit = True, + cmdhint = _('To continue: hg commit\n' + 'To abort: hg merge --abort') +) + +def checkunfinished(repo, commit=False, mergeskip=False): '''Look for an unfinished multistep operation, like graft, and abort if found. It's probably good to check this right before bailifchanged(). @@ -170,13 +195,15 @@ # 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): + if (state._clearable or (commit and state._allowcommit) or + state._opname == 'bisect'): 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): + if (not s._clearable or (commit and s._allowcommit) or + (s._opname == 'merge' and mergeskip)): continue if s.isunfinished(repo): raise error.Abort(s.msg(), hint=s.hint()) @@ -186,70 +213,22 @@ that are clearable. ''' for state in _unfinishedstates: + if state._opname == 'bisect': + continue if not state._clearable and state.isunfinished(repo): raise error.Abort(state.msg(), hint=state.hint()) for s in _unfinishedstates: + if s._opname == 'merge': + continue if s._clearable and s.isunfinished(repo): util.unlink(repo.vfs.join(s._fname)) -def _commentlines(raw): - '''Surround lineswith a comment char and a new line''' - lines = raw.splitlines() - commentedlines = ['# %s' % line for line in lines] - return '\n'.join(commentedlines) + '\n' - -def _helpmessage(continuecmd, abortcmd): - msg = _('To continue: %s\n' - 'To abort: %s') % (continuecmd, abortcmd) - return _commentlines(msg) - -def _rebasemsg(): - return _helpmessage('hg rebase --continue', 'hg rebase --abort') - -def _histeditmsg(): - return _helpmessage('hg histedit --continue', 'hg histedit --abort') - -def _unshelvemsg(): - return _helpmessage('hg unshelve --continue', 'hg unshelve --abort') - -def _graftmsg(): - return _helpmessage('hg graft --continue', 'hg graft --abort') - -def _mergemsg(): - return _helpmessage('hg commit', 'hg merge --abort') - -def _bisectmsg(): - msg = _('To mark the changeset good: hg bisect --good\n' - 'To mark the changeset bad: hg bisect --bad\n' - 'To abort: hg bisect --reset\n') - return _commentlines(msg) - -def fileexistspredicate(filename): - return lambda repo: repo.vfs.exists(filename) - -def _mergepredicate(repo): - return len(repo[None].parents()) > 1 - -STATES = ( - # (state, predicate to detect states, helpful message function) - ('histedit', fileexistspredicate('histedit-state'), _histeditmsg), - ('bisect', fileexistspredicate('bisect.state'), _bisectmsg), - ('graft', fileexistspredicate('graftstate'), _graftmsg), - ('unshelve', fileexistspredicate('shelvedstate'), _unshelvemsg), - ('rebase', fileexistspredicate('rebasestate'), _rebasemsg), - # The merge state is part of a list that will be iterated over. - # They need to be last because some of the other unfinished states may also - # be in a merge or update state (eg. rebase, histedit, graft, etc). - # We want those to have priority. - ('merge', _mergepredicate, _mergemsg), -) - -def _getrepostate(repo): +def getrepostate(repo): # experimental config: commands.status.skipstates skip = set(repo.ui.configlist('commands', 'status.skipstates')) - for state, statedetectionpredicate, msgfn in STATES: - if state in skip: - continue - if statedetectionpredicate(repo): - return (state, statedetectionpredicate, msgfn) + for state in _unfinishedstates: + if state._opname in skip: + continue + if state.isunfinished(repo): + return (state._opname, state.hint()) diff --git a/tests/test-graft.t b/tests/test-graft.t --- a/tests/test-graft.t +++ b/tests/test-graft.t @@ -279,8 +279,7 @@ # # To mark files as resolved: hg resolve --mark FILE - # To continue: hg graft --continue - # To abort: hg graft --abort + # use 'hg graft --continue' or 'hg graft --stop' to stop Commit while interrupted should fail: diff --git a/tests/test-histedit-fold.t b/tests/test-histedit-fold.t --- a/tests/test-histedit-fold.t +++ b/tests/test-histedit-fold.t @@ -306,8 +306,7 @@ # # To mark files as resolved: hg resolve --mark FILE - # To continue: hg histedit --continue - # To abort: hg histedit --abort + # use 'hg histedit --continue' or 'hg histedit --abort' $ hg resolve -l U file diff --git a/tests/test-rebase-conflicts.t b/tests/test-rebase-conflicts.t --- a/tests/test-rebase-conflicts.t +++ b/tests/test-rebase-conflicts.t @@ -80,8 +80,7 @@ # # To mark files as resolved: hg resolve --mark FILE - # To continue: hg rebase --continue - # To abort: hg rebase --abort + # use 'hg rebase --continue' or 'hg rebase --abort' Try to continue without solving the conflict: diff --git a/tests/test-rebase-pull.t b/tests/test-rebase-pull.t --- a/tests/test-rebase-pull.t +++ b/tests/test-rebase-pull.t @@ -115,8 +115,9 @@ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) $ hg pull --rebase - abort: outstanding uncommitted merge - (cannot pull with rebase: please commit or shelve your changes first) + abort: merge in progress + (To continue: hg commit + To abort: hg merge --abort) [255] $ hg update --clean --quiet diff --git a/tests/test-shelve.t b/tests/test-shelve.t --- a/tests/test-shelve.t +++ b/tests/test-shelve.t @@ -375,8 +375,7 @@ # # To mark files as resolved: hg resolve --mark FILE - # To continue: hg unshelve --continue - # To abort: hg unshelve --abort + # use 'hg unshelve --continue' or 'hg unshelve --abort' ensure that we have a merge with unresolved conflicts @@ -1153,7 +1152,9 @@ -- trying to pull in the shelve bits -- unshelve should abort otherwise, it'll eat my second parent. $ hg unshelve - abort: cannot unshelve while merging + abort: merge in progress + (To continue: hg commit + To abort: hg merge --abort) [255] $ cd .. diff --git a/tests/test-strip.t b/tests/test-strip.t --- a/tests/test-strip.t +++ b/tests/test-strip.t @@ -274,7 +274,9 @@ ##strip not allowed with merge in progress $ hg strip 4 - abort: outstanding uncommitted merge + abort: merge in progress + (To continue: hg commit + To abort: hg merge --abort) [255] ##strip allowed --force with merge in progress $ hg strip 4 --force diff --git a/tests/test-transplant.t b/tests/test-transplant.t --- a/tests/test-transplant.t +++ b/tests/test-transplant.t @@ -39,7 +39,9 @@ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) $ hg transplant 1 - abort: outstanding uncommitted merge + abort: merge in progress + (To continue: hg commit + To abort: hg merge --abort) [255] $ hg up -qC tip $ echo b0 > b1 @@ -461,7 +463,7 @@ baz foo -test multiple revisions and --continue +test multiple revisions, --continue and hg status --verbose $ hg up -qC 0 $ echo bazbaz > baz @@ -481,6 +483,14 @@ abort: transplant in progress (use 'hg transplant --continue' or 'hg update' to abort) [255] + $ hg status -v + A bar + ? baz.rej + ? foo.rej + # The repository is in an unfinished *transplant* state. + + # use 'hg transplant --continue' or 'hg update' to abort + $ echo fixed > baz $ hg transplant --continue 9d6d6b5a8275 transplanted as d80c49962290