Patchwork [4,of,5] revlog: always open revlogs for reading and appending

login
register
mail settings
Submitter Gregory Szorc
Date Sept. 28, 2015, 3:32 a.m.
Message ID <d96325c529d1b114ded9.1443411133@vm-ubuntu-main.gateway.sonic.net>
Download mbox | patch
Permalink /patch/10663/
State Accepted
Headers show

Comments

Gregory Szorc - Sept. 28, 2015, 3:32 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1443394759 25200
#      Sun Sep 27 15:59:19 2015 -0700
# Node ID d96325c529d1b114ded988b22114d28f219d6fdd
# Parent  bfcc837cb4817e3e94d95f936e3631acded55c6c
revlog: always open revlogs for reading and appending

An upcoming patch will teach revlogs to use the existing file
handle to read revision data instead of opening a new file handle
just for quick reads. For this to work, files must be opened for
reading as well.

This patch is merely cosmetic: there are no behavior changes.

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1217,9 +1217,9 @@  class revlog(object):
             return node
 
         dfh = None
         if not self._inline:
-            dfh = self.opener(self.datafile, "a")
+            dfh = self.opener(self.datafile, "a+")
         ifh = self.opener(self.indexfile, "a+")
         try:
             return self._addrevision(node, text, transaction, link, p1, p2,
                                      REVIDX_DEFAULT_FLAGS, cachedelta, ifh, dfh)
@@ -1465,9 +1465,9 @@  class revlog(object):
             dfh = None
         else:
             transaction.add(self.indexfile, isize, r)
             transaction.add(self.datafile, end)
-            dfh = self.opener(self.datafile, "a")
+            dfh = self.opener(self.datafile, "a+")
         def flush():
             if dfh:
                 dfh.flush()
             ifh.flush()
@@ -1533,10 +1533,10 @@  class revlog(object):
                 if not dfh and not self._inline:
                     # addrevision switched from inline to conventional
                     # reopen the index
                     ifh.close()
-                    dfh = self.opener(self.datafile, "a")
-                    ifh = self.opener(self.indexfile, "a")
+                    dfh = self.opener(self.datafile, "a+")
+                    ifh = self.opener(self.indexfile, "a+")
         finally:
             if dfh:
                 dfh.close()
             ifh.close()