localrepo: add desc parameter to transaction
authorSteve Borho <steve@borho.org>
Fri, 09 Apr 2010 17:23:35 -0500
changeset 10881 a685011ed38e
parent 10880 4775fc1e04a8
child 10882 f0bfe42c7b1f
localrepo: add desc parameter to transaction All callers to localrepo.transaction() must supply a transaction description. The description and the existing repository tip are then stored (transactionally) into .hg/undo.desc; where rollback can later find it.
hgext/mq.py
mercurial/localrepo.py
mercurial/repair.py
tests/test-fncache.out
tests/test-hup.out
tests/test-inherit-mode.out
--- a/hgext/mq.py	Fri Apr 09 15:16:52 2010 +0200
+++ b/hgext/mq.py	Fri Apr 09 17:23:35 2010 -0500
@@ -610,7 +610,7 @@
         try:
             wlock = repo.wlock()
             lock = repo.lock()
-            tr = repo.transaction()
+            tr = repo.transaction("qpush")
             try:
                 ret = self._apply(repo, series, list, update_status,
                                   strict, patchdir, merge, all_files=all_files)
--- a/mercurial/localrepo.py	Fri Apr 09 15:16:52 2010 +0200
+++ b/mercurial/localrepo.py	Fri Apr 09 17:23:35 2010 -0500
@@ -554,7 +554,7 @@
     def wwritedata(self, filename, data):
         return self._filter("decode", filename, data)
 
-    def transaction(self):
+    def transaction(self, desc):
         tr = self._transref and self._transref() or None
         if tr and tr.running():
             return tr.nest()
@@ -571,10 +571,12 @@
             ds = ""
         self.opener("journal.dirstate", "w").write(ds)
         self.opener("journal.branch", "w").write(self.dirstate.branch())
+        self.opener("journal.desc", "w").write("%d,%s" % (len(self), desc))
 
         renames = [(self.sjoin("journal"), self.sjoin("undo")),
                    (self.join("journal.dirstate"), self.join("undo.dirstate")),
-                   (self.join("journal.branch"), self.join("undo.branch"))]
+                   (self.join("journal.branch"), self.join("undo.branch")),
+                   (self.join("journal.desc"), self.join("undo.desc"))]
         tr = transaction.transaction(self.ui.warn, self.sopener,
                                      self.sjoin("journal"),
                                      aftertrans(renames),
@@ -890,7 +892,7 @@
 
         lock = self.lock()
         try:
-            tr = self.transaction()
+            tr = self.transaction("commit")
             trp = weakref.proxy(tr)
 
             # check in files
@@ -2003,7 +2005,7 @@
         cl.delayupdate()
         oldheads = len(cl.heads())
 
-        tr = self.transaction()
+        tr = self.transaction(",".join([srctype, url]))
         try:
             trp = weakref.proxy(tr)
             # pull off the changeset group
--- a/mercurial/repair.py	Fri Apr 09 15:16:52 2010 +0200
+++ b/mercurial/repair.py	Fri Apr 09 17:23:35 2010 -0500
@@ -114,7 +114,7 @@
 
     mfst = repo.manifest
 
-    tr = repo.transaction()
+    tr = repo.transaction("strip")
     offset = len(tr.entries)
 
     tr.startgroup()
--- a/tests/test-fncache.out	Fri Apr 09 15:16:52 2010 +0200
+++ b/tests/test-fncache.out	Fri Apr 09 17:23:35 2010 -0500
@@ -54,6 +54,7 @@
 .hg/requires
 .hg/undo
 .hg/undo.branch
+.hg/undo.desc
 .hg/undo.dirstate
 % non fncache repo
 adding tst.d/Foo
@@ -70,4 +71,5 @@
 .hg/store/data/tst.d.hg/_foo.i
 .hg/store/undo
 .hg/undo.branch
+.hg/undo.desc
 .hg/undo.dirstate
--- a/tests/test-hup.out	Fri Apr 09 15:16:52 2010 +0200
+++ b/tests/test-hup.out	Fri Apr 09 17:23:35 2010 -0500
@@ -4,4 +4,4 @@
 transaction abort!
 rollback completed
 killed!
-.hg/00changelog.i .hg/journal.branch .hg/journal.dirstate .hg/requires .hg/store .hg/store/00changelog.i .hg/store/00changelog.i.a
+.hg/00changelog.i .hg/journal.branch .hg/journal.desc .hg/journal.dirstate .hg/requires .hg/store .hg/store/00changelog.i .hg/store/00changelog.i.a
--- a/tests/test-inherit-mode.out	Fri Apr 09 15:16:52 2010 +0200
+++ b/tests/test-inherit-mode.out	Fri Apr 09 17:23:35 2010 -0500
@@ -26,6 +26,7 @@
 00660 ./.hg/store/fncache
 00660 ./.hg/store/undo
 00660 ./.hg/undo.branch
+00660 ./.hg/undo.desc
 00660 ./.hg/undo.dirstate
 00700 ./dir/
 00600 ./dir/bar
@@ -54,4 +55,5 @@
 00660 ../push/.hg/store/fncache
 00660 ../push/.hg/store/undo
 00660 ../push/.hg/undo.branch
+00660 ../push/.hg/undo.desc
 00660 ../push/.hg/undo.dirstate