transaction: reorder unlinking .hg/journal and .hg/journal.backupfiles
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Fri, 16 Oct 2015 03:29:51 +0900
changeset 26753 96dd93de548c
parent 26752 949e8c626d19
child 26754 e7e1528cf200
transaction: reorder unlinking .hg/journal and .hg/journal.backupfiles After this reordering, absence of '.hg/journal' just before starting new transaction means also absence of '.hg/journal.backupfiles'. In this case, all temporary files for preceding transaction should be completely unlinked, and HG_PENDING doesn't cause unintentional reading stalled temporary files in. Otherwise, 'repo.transaction()' raises exception with "run 'hg recover' to clean up transaction" hint.
mercurial/transaction.py
--- a/mercurial/transaction.py	Sat Oct 17 01:15:34 2015 +0900
+++ b/mercurial/transaction.py	Fri Oct 16 03:29:51 2015 +0900
@@ -75,10 +75,10 @@
             if not c:
                 raise
 
-    opener.unlink(journal)
     backuppath = "%s.backupfiles" % journal
     if opener.exists(backuppath):
         opener.unlink(backuppath)
+    opener.unlink(journal)
     try:
         for f in backupfiles:
             if opener.exists(f):
@@ -427,10 +427,11 @@
         self._writeundo()
         if self.after:
             self.after()
+        if self.opener.isfile(self._backupjournal):
+            self.opener.unlink(self._backupjournal)
         if self.opener.isfile(self.journal):
             self.opener.unlink(self.journal)
-        if self.opener.isfile(self._backupjournal):
-            self.opener.unlink(self._backupjournal)
+        if True:
             for l, _f, b, c in self._backupentries:
                 if l not in self._vfsmap and c:
                     self.report("couldn't remote %s: unknown cache location"
@@ -497,10 +498,10 @@
 
         try:
             if not self.entries and not self._backupentries:
+                if self._backupjournal:
+                    self.opener.unlink(self._backupjournal)
                 if self.journal:
                     self.opener.unlink(self.journal)
-                if self._backupjournal:
-                    self.opener.unlink(self._backupjournal)
                 return
 
             self.report(_("transaction abort!\n"))