diff mercurial/localrepo.py @ 31074:59e69ed81776

localrepo: check HG_PENDING strictly Before this patch, checking HG_PENDING for changelog in localrepo.py might cause unintentional reading unrelated '00changelog.i.a' in, because HG_PENDING is checked by str.startswith(). An external hook spawned by inner repository in nested ones satisfies this condition. This patch uses txnutil.mayhavepending() to check HG_PENDING strictly. BTW, this patch may cause failure of bisect in the repository of Mercurial itself, if examination at bisecting assumes that an external hook can see all pending changes while nested transactions across repositories. This invisibility issue will be fixed by subsequent patch, which allows HG_PENDING to refer multiple repositories.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Tue, 21 Feb 2017 01:21:00 +0900
parents 6cf2857526c7
children 95ec3ad62f62
line wrap: on
line diff
--- a/mercurial/localrepo.py	Tue Feb 21 01:21:00 2017 +0900
+++ b/mercurial/localrepo.py	Tue Feb 21 01:21:00 2017 +0900
@@ -56,6 +56,7 @@
     subrepo,
     tags as tagsmod,
     transaction,
+    txnutil,
     util,
 )
 
@@ -513,10 +514,8 @@
     @storecache('00changelog.i')
     def changelog(self):
         c = changelog.changelog(self.svfs)
-        if 'HG_PENDING' in encoding.environ:
-            p = encoding.environ['HG_PENDING']
-            if p.startswith(self.root):
-                c.readpending('00changelog.i.a')
+        if txnutil.mayhavepending(self.root):
+            c.readpending('00changelog.i.a')
         return c
 
     def _constructmanifest(self):