From patchwork Mon Sep 28 03:32:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [4,of,5] revlog: always open revlogs for reading and appending From: Gregory Szorc X-Patchwork-Id: 10663 Message-Id: To: mercurial-devel@selenic.com Date: Sun, 27 Sep 2015 20:32:13 -0700 # HG changeset patch # User Gregory Szorc # 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. 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()