# HG changeset patch # User mpm@selenic.com # Date 1122516980 28800 # Node ID 46a8dd3145cc417af6643c291d794db75c5b8779 # Parent 853bfbf1a3123ee517dcc517b50e41a5e8310bea Fix undo after aborted commit bug Commit would overwrite undo.dirstate unconditionally, so an undo after an aborted commit would restore the dirstate from the aborted commit and not the prior transaction. This copies dirstate to journal.dirstate and moves it after a successful transaction. diff -r 853bfbf1a312 -r 46a8dd3145cc mercurial/hg.py --- a/mercurial/hg.py Wed Jul 27 10:21:19 2005 -0800 +++ b/mercurial/hg.py Wed Jul 27 18:16:20 2005 -0800 @@ -675,11 +675,15 @@ ds = self.opener("dirstate").read() except IOError: ds = "" - self.opener("undo.dirstate", "w").write(ds) + self.opener("journal.dirstate", "w").write(ds) - return transaction.transaction(self.ui.warn, - self.opener, self.join("journal"), - self.join("undo")) + def after(): + util.rename(self.join("journal"), self.join("undo")) + util.rename(self.join("journal.dirstate"), + self.join("undo.dirstate")) + + return transaction.transaction(self.ui.warn, self.opener, + self.join("journal"), after) def recover(self): lock = self.lock() diff -r 853bfbf1a312 -r 46a8dd3145cc mercurial/transaction.py --- a/mercurial/transaction.py Wed Jul 27 10:21:19 2005 -0800 +++ b/mercurial/transaction.py Wed Jul 27 18:16:20 2005 -0800 @@ -50,7 +50,7 @@ self.file.close() self.entries = [] if self.after: - util.rename(self.journal, self.after) + self.after() else: os.unlink(self.journal) self.journal = None diff -r 853bfbf1a312 -r 46a8dd3145cc tests/test-hup.out --- a/tests/test-hup.out Wed Jul 27 10:21:19 2005 -0800 +++ b/tests/test-hup.out Wed Jul 27 18:16:20 2005 -0800 @@ -7,4 +7,4 @@ 00changelog.d 00changelog.i data -undo.dirstate +journal.dirstate