diff mercurial/localrepo.py @ 17126:8fa8717b47b6

obsolete: write obsolete marker inside a transaction Marker are now written as soon as possible but within a transaction. Using a transaction ensure a proper behavior on error and rollback compatibility. Flush logic are not necessary anymore and are dropped from lock release. With this changeset, the obsstore is open, written and closed for every single added marker. This is expected to be highly inefficient and batched write should be implemented "quickly". Another issue is that every flush of the file will invalidate the obsstore filecache and trigger a full re instantiation of the repo.obsstore attribute (including, reading and parsing entry). This is also expected to be highly inefficient and proper filecache operation should be implemented "quickly" too. A side benefit of the filecache issue is that repo.obsstore object is properly invalidated on transaction abortion.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Wed, 04 Jul 2012 02:21:04 +0200
parents 95d785ccb4e5
children ad1b5e070f16
line wrap: on
line diff
--- a/mercurial/localrepo.py	Wed Jul 04 02:02:48 2012 +0200
+++ b/mercurial/localrepo.py	Wed Jul 04 02:21:04 2012 +0200
@@ -987,8 +987,6 @@
             self.store.write()
             if '_phasecache' in vars(self):
                 self._phasecache.write()
-            if 'obsstore' in vars(self):
-                self.obsstore.flushmarkers()
             for k, ce in self._filecache.items():
                 if k == 'dirstate':
                     continue
@@ -1607,6 +1605,10 @@
         return r
 
     def pull(self, remote, heads=None, force=False):
+        # don't open transaction for nothing or you break future useful
+        # rollback call
+        tr = None
+        trname = 'pull\n' + util.hidepassword(remote.url())
         lock = self.lock()
         try:
             tmp = discovery.findcommonincoming(self, remote, heads=heads,
@@ -1617,6 +1619,7 @@
                 added = []
                 result = 0
             else:
+                tr = self.transaction(trname)
                 if heads is None and list(common) == [nullid]:
                     self.ui.status(_("requesting all changes\n"))
                 elif heads is None and remote.capable('changegroupsubset'):
@@ -1665,9 +1668,15 @@
 
             remoteobs = remote.listkeys('obsolete')
             if 'dump' in remoteobs:
+                if tr is None:
+                    tr = self.transaction(trname)
                 data = base85.b85decode(remoteobs['dump'])
-                self.obsstore.mergemarkers(data)
+                self.obsstore.mergemarkers(tr, data)
+            if tr is not None:
+                tr.close()
         finally:
+            if tr is not None:
+                tr.release()
             lock.release()
 
         return result