diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -1148,6 +1148,10 @@ def restorecollapsemsg(repo, isabort): def clearstatus(repo): 'Remove the status files' _clearrebasesetvisibiliy(repo) + # Make sure the active transaction won't write the state file + tr = repo.currenttransaction() + if tr: + tr.removefilegenerator('rebasestate') repo.vfs.unlinkpath("rebasestate", ignoremissing=True) def needupdate(repo, state): diff --git a/mercurial/transaction.py b/mercurial/transaction.py --- a/mercurial/transaction.py +++ b/mercurial/transaction.py @@ -292,6 +292,12 @@ class transaction(object): # but for bookmarks that are handled outside this mechanism. self._filegenerators[genid] = (order, filenames, genfunc, location) + @active + def removefilegenerator(self, genid): + """reverse of addfilegenerator, remove a file generator function""" + if genid in self._filegenerators: + del self._filegenerators[genid] + def _generatefiles(self, suffix='', group=gengroupall): # write files registered for generation any = False diff --git a/tests/test-rebase-scenario-global.t b/tests/test-rebase-scenario-global.t --- a/tests/test-rebase-scenario-global.t +++ b/tests/test-rebase-scenario-global.t @@ -954,4 +954,4 @@ Testing rebase being called inside anoth rebasing 2:dc0947a82db8 "C" (C tip) $ [ -f .hg/rebasestate ] && echo 'WRONG: rebasestate should not exist' - WRONG: rebasestate should not exist + [1]