[PATCH] resolve issue 3375: Operation not permitted: journal.phaseroots

Michael Bacarella mbacarella at janestreet.com
Tue Apr 17 14:08:52 UTC 2012


# HG changeset patch
# User Michael Bacarella <mbacarella at janestreet.com>
# Date 1334671188 14400
# Node ID a7b53829e08f290f5e9c02bfff19c6713fb33efb
# Parent  3387c7dc83b1c94b7ac16ed7fa152d9b19e74efe
localrepo: fix unpushable repos when transaction aborted (issue3375)

This fix is similar to the fix for issue3317.

This patch makes journal file copying more consistent.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -743,28 +743,25 @@
         return [undoname(x) for x in self._journalfiles()]

     def _writejournal(self, desc):
+        def __copyfile(opener, fn):
+            # not using util.copyfile because it won't succeed if another
+            # user has a failed transaction in this repo (can't chmod files
+            # you don't own)
+            try:
+                b = opener.read(fn)
+            except IOError:
+                b = ""
+            opener.write('journal.'+fn, b)
+
         # save dirstate for rollback
-        try:
-            ds = self.opener.read("dirstate")
-        except IOError:
-            ds = ""
-        self.opener.write("journal.dirstate", ds)
+        __copyfile(self.opener, 'dirstate')
         self.opener.write("journal.branch",
                           encoding.fromlocal(self.dirstate.branch()))
         self.opener.write("journal.desc",
                           "%d\n%s\n" % (len(self), desc))

-        try:
-            bk = self.opener.read("bookmarks")
-        except IOError:
-            bk = ""
-        self.opener.write("journal.bookmarks", bk)
-
-        phasesname = self.sjoin('phaseroots')
-        if os.path.exists(phasesname):
-            util.copyfile(phasesname, self.sjoin('journal.phaseroots'))
-        else:
-            self.sopener.write('journal.phaseroots', '')
+        __copyfile(self.opener, 'bookmarks')
+        __copyfile(self.sopener, 'phaseroots')

     def recover(self):
         lock = self.lock()



More information about the Mercurial-devel mailing list