[PATCH 1 of 2] localrepo: add desc parameter to transaction

Steve Borho steve at borho.org
Sat Apr 10 22:39:30 CDT 2010


# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1270851815 18000
# Node ID d97789125f1f9fce45d74ff1e75bfbd197a91e1c
# Parent  4775fc1e04a8c083a83d54336f8485b357cb4894
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.

diff -r 4775fc1e04a8 -r d97789125f1f hgext/mq.py
--- 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)
diff -r 4775fc1e04a8 -r d97789125f1f mercurial/localrepo.py
--- 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
diff -r 4775fc1e04a8 -r d97789125f1f mercurial/repair.py
--- 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()


More information about the Mercurial-devel mailing list