diff mercurial/phases.py @ 31073:6afd8a87a657

phases: check HG_PENDING strictly Before this patch, checking HG_PENDING in phases.py might cause unintentional reading unrelated 'phaseroots.pending' in, because it just examines existence of HG_PENDING environment variable. This patch uses txnutil.trypending() 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 bf81d3b7b2ba
children b7cef987356d
line wrap: on
line diff
--- a/mercurial/phases.py	Tue Feb 21 01:21:00 2017 +0900
+++ b/mercurial/phases.py	Tue Feb 21 01:21:00 2017 +0900
@@ -113,9 +113,9 @@
     short,
 )
 from . import (
-    encoding,
     error,
     smartset,
+    txnutil,
 )
 
 allphases = public, draft, secret = range(3)
@@ -137,15 +137,7 @@
     dirty = False
     roots = [set() for i in allphases]
     try:
-        f = None
-        if 'HG_PENDING' in encoding.environ:
-            try:
-                f = repo.svfs('phaseroots.pending')
-            except IOError as inst:
-                if inst.errno != errno.ENOENT:
-                    raise
-        if f is None:
-            f = repo.svfs('phaseroots')
+        f, pending = txnutil.trypending(repo.root, repo.svfs, 'phaseroots')
         try:
             for line in f:
                 phase, nh = line.split()