Patchwork [3,of,4] transaction: pass the name of the "undo" journal to the transaction

login
register
mail settings
Submitter Pierre-Yves David
Date Jan. 17, 2015, 3:51 a.m.
Message ID <cb7106ff9861b85f1e2c.1421466675@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/7512/
State Accepted
Commit 426607be9c6960588b66e24548dd3cdc8c69d18c
Headers show

Comments

Pierre-Yves David - Jan. 17, 2015, 3:51 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1421465704 28800
#      Fri Jan 16 19:35:04 2015 -0800
# Node ID cb7106ff9861b85f1e2cfbf55f7694c66a596941
# Parent  0487eefa5bd23b4236d0361a78accc1ac9af99f6
transaction: pass the name of the "undo" journal to the transaction

It is time for the transaction to be responsible for the setting up the undo
data. It is necessary to move this logic in the transaction because much more
file are handled now, and the transaction is the object tracking them all.

The value can be set to None if no undo should be set.

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -910,10 +910,11 @@  class localrepository(object):
         renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()]
         rp = report and report or self.ui.warn
         vfsmap = {'plain': self.vfs} # root of .hg/
         tr = transaction.transaction(rp, self.svfs, vfsmap,
                                      "journal",
+                                     "undo",
                                      aftertrans(renames),
                                      self.store.createmode)
         # note: writing the fncache only during finalize mean that the file is
         # outdated when running hooks. As fncache is used for streaming clone,
         # this is not expected to break anything that happen during the hooks.
diff --git a/mercurial/transaction.py b/mercurial/transaction.py
--- a/mercurial/transaction.py
+++ b/mercurial/transaction.py
@@ -80,12 +80,12 @@  def _playback(journal, report, opener, v
     except (IOError, OSError, util.Abort), inst:
         # only pure backup file remains, it is sage to ignore any error
         pass
 
 class transaction(object):
-    def __init__(self, report, opener, vfsmap, journalname, after=None,
-                 createmode=None):
+    def __init__(self, report, opener, vfsmap, journalname, undoname=None,
+                 after=None, createmode=None):
         """Begin a new transaction
 
         Begins a new transaction that allows rolling back writes in the event of
         an exception.
 
@@ -103,10 +103,11 @@  class transaction(object):
         self._vfsmap = vfsmap
         self.after = after
         self.entries = []
         self.map = {}
         self.journal = journalname
+        self.undoname = undoname
         self._queue = []
         # a dict of arguments to be passed to hooks
         self.hookargs = {}
         self.file = opener.open(self.journal, "w")