[PATCH 2 of 5] context: make unknown/ignored/clean of cached status empty for equivalence

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Tue Dec 30 18:19:09 CST 2014


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1419984806 -32400
#      Wed Dec 31 09:13:26 2014 +0900
# Node ID 6535600e847a3acfe6bb7aa7775d1d15cceab1af
# Parent  2e71da5fccb1612f96c8a814bd9641d419f72489
context: make unknown/ignored/clean of cached status empty for equivalence

Before this patch, "workingctx.status" caches the result of
"dirstate.status" directly into "self._status".

But "dirstate.status" is invoked with False "list*" arguments in
normal "self._status" accessing route, and this makes
"unknown"/"ignored"/"clean" of status empty.

This patch makes "unknown"/"ignored"/"clean" of cached status empty
for equivalence. Making them empty is executed only when at least one
of "unknown", "ignored" or "clean" has files, for efficiency.

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1446,7 +1446,12 @@
                                                      listunknown)
         elif match.always():
             # cache for performance
-            self._status = s
+            if s.unknown or s.ignored or s.clean:
+                # "_status" is cached with list*=False in the normal route
+                self._status = scmutil.status(s.modified, s.added, s.removed,
+                                              s.deleted, [], [], [])
+            else:
+                self._status = s
         return s
 
     def _matchstatus(self, other, match):
diff --git a/tests/test-context.py b/tests/test-context.py
--- a/tests/test-context.py
+++ b/tests/test-context.py
@@ -83,9 +83,16 @@
 wctx = repo[None]
 print 'wctx._status=%s' % (str(wctx._status))
 
+print '=== with "pattern match":'
 print actx1.status(other=wctx,
                    match=scmutil.matchfiles(repo, ['bar-m', 'foo']))
 print 'wctx._status=%s' % (str(wctx._status))
 print actx2.status(other=wctx,
                    match=scmutil.matchfiles(repo, ['bar-m', 'foo']))
 print 'wctx._status=%s' % (str(wctx._status))
+
+print '=== with "always match" and "listclean=True":'
+print actx1.status(other=wctx, listclean=True)
+print 'wctx._status=%s' % (str(wctx._status))
+print actx2.status(other=wctx, listclean=True)
+print 'wctx._status=%s' % (str(wctx._status))
diff --git a/tests/test-context.py.out b/tests/test-context.py.out
--- a/tests/test-context.py.out
+++ b/tests/test-context.py.out
@@ -14,7 +14,13 @@
 = checking context.status():
 == checking workingctx.status:
 wctx._status=<status modified=['bar-m'], added=['bar-a'], removed=['bar-r'], deleted=[], unknown=[], ignored=[], clean=[]>
+=== with "pattern match":
 <status modified=['bar-m'], added=[], removed=[], deleted=[], unknown=[], ignored=[], clean=[]>
 wctx._status=<status modified=['bar-m'], added=['bar-a'], removed=['bar-r'], deleted=[], unknown=[], ignored=[], clean=[]>
 <status modified=[], added=['bar-m'], removed=[], deleted=[], unknown=[], ignored=[], clean=[]>
 wctx._status=<status modified=['bar-m'], added=['bar-a'], removed=['bar-r'], deleted=[], unknown=[], ignored=[], clean=[]>
+=== with "always match" and "listclean=True":
+<status modified=['bar-m'], added=['bar-a'], removed=['bar-r'], deleted=[], unknown=[], ignored=[], clean=['foo']>
+wctx._status=<status modified=['bar-m'], added=['bar-a'], removed=['bar-r'], deleted=[], unknown=[], ignored=[], clean=[]>
+<status modified=[], added=['bar-a', 'bar-m'], removed=[], deleted=[], unknown=[], ignored=[], clean=['foo']>
+wctx._status=<status modified=['bar-m'], added=['bar-a'], removed=['bar-r'], deleted=[], unknown=[], ignored=[], clean=[]>


More information about the Mercurial-devel mailing list