[PATCH 1 of 3 RFC] localrepo.status: separate working and parentworking

Nicolas Dumazet nicdumz at gmail.com
Sat Jul 24 21:12:53 CDT 2010


# HG changeset patch
# User Nicolas Dumazet <nicdumz.commits at gmail.com>
# Date 1278661953 -32400
# Node ID 8d31c81b74e3ad8d61a51cb0a112ebf8dfbf5171
# Parent  c47cb3193c534f6899e32e26bf9510da2ef0b7d5
localrepo.status: separate working and parentworking

parentworking was dependent on working variable, which makes codeflow
harder to understand.
Also rename the variables to use clearer names.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1030,22 +1030,23 @@
         else:
             ctx2 = self[node2]
 
-        working = ctx2.rev() is None
-        parentworking = working and ctx1 == self['.']
+        comparewithparent = ctx1 == self['.']
+        comparewithwdir = ctx2.rev() is None
+
         match = match or matchmod.always(self.root, self.getcwd())
         listignored, listclean, listunknown = ignored, clean, unknown
 
         # load earliest manifest first for caching reasons
-        if not working and ctx2.rev() < ctx1.rev():
+        if not comparewithwdir and ctx2.rev() < ctx1.rev():
             ctx2.manifest()
 
-        if not parentworking:
+        if not comparewithwdir or not comparewithparent:
             def bad(f, msg):
                 if f not in ctx1:
                     self.ui.warn('%s: %s\n' % (self.dirstate.pathto(f), msg))
             match.bad = bad
 
-        if working: # we need to scan the working dir
+        if comparewithwdir: # we need to scan the working dir
             subrepos = []
             if '.hgsub' in self.dirstate:
                 subrepos = ctx1.substate.keys()
@@ -1054,7 +1055,7 @@
             cmp, modified, added, removed, deleted, unknown, ignored, clean = s
 
             # check for any possibly clean files
-            if parentworking and cmp:
+            if comparewithparent and cmp:
                 fixup = []
                 # do a full compare of any files that might have changed
                 for f in sorted(cmp):
@@ -1081,9 +1082,9 @@
                     except error.LockError:
                         pass
 
-        if not parentworking:
+        if not comparewithwdir or not comparewithparent:
             mf1 = mfmatches(ctx1)
-            if working:
+            if comparewithwdir:
                 # we are comparing working dir against non-parent
                 # generate a pseudo-manifest for the working dir
                 mf2 = mfmatches(self['.'])


More information about the Mercurial-devel mailing list