# HG changeset patch # User Martin von Zweigbergk # Date 2018-03-21 17:46:00 # Node ID 74f91bec69916427b9296a54b85347b78da78e02 # Parent 9cc9b3e155f8432c4f0577c3019f1fff12cb712c rebase: register status file generator only once when using single transaction rebase.storestatus() behaved differently depending on whether a transaction is passed to it. If a transaction is passed, it registers a "file generator" that runs when the transaction commits. If no transaction was passed, it writes the rebase state immediately. This imprecise timing of the writing makes it hard to reason about, so let's make it more explicit which behavior we're getting by checking if we have a transaction before calling it. For the single-transaction case, move the call to storestatus(tr) early and do it only once since it's only going to write the file (at most) once anyway. Differential Revision: https://phab.mercurial-scm.org/D2912 diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -420,6 +420,10 @@ class rebaseruntime(object): # Store the state before we begin so users can run 'hg rebase --abort' # if we fail before the transaction closes. self.storestatus() + if tr: + # When using single transaction, store state when transaction + # commits. + self.storestatus(tr) cands = [k for k, v in self.state.iteritems() if v == revtodo] total = len(cands) @@ -480,7 +484,8 @@ class rebaseruntime(object): p1, p2, base = defineparents(repo, rev, self.destmap, self.state, self.skipped, self.obsoletenotrebased) - self.storestatus(tr=tr) + if not tr: + self.storestatus() if len(repo[None].parents()) == 2: repo.ui.debug('resuming interrupted rebase\n') else: