dirstate: separate 'lookup' status field from others
authorMartin von Zweigbergk <martinvonz@gmail.com>
Fri, 03 Oct 2014 21:44:10 -0700
changeset 22911 509e2cbee679
parent 22910 4f2a5c7cdf78
child 22912 3b8e6c095239
dirstate: separate 'lookup' status field from others The status tuple returned from dirstate.status() has an additional field compared to the other status tuples: lookup/unsure. This field is just an optimization and not something most callers care about (they want the resolved value of 'modified' or 'clean'). To prepare for a single future status type, let's separate out the 'lookup' field from the rest by having dirstate.status() return a pair: (lookup, status).
hgext/largefiles/lfutil.py
hgext/largefiles/overrides.py
hgext/largefiles/reposetup.py
mercurial/context.py
mercurial/dirstate.py
--- a/hgext/largefiles/lfutil.py	Mon Oct 13 14:18:47 2014 -0700
+++ b/hgext/largefiles/lfutil.py	Fri Oct 03 21:44:10 2014 -0700
@@ -136,8 +136,8 @@
 
 def lfdirstatestatus(lfdirstate, repo, rev):
     match = match_.always(repo.root, repo.getcwd())
-    s = lfdirstate.status(match, [], False, False, False)
-    unsure, modified, added, removed, missing, unknown, ignored, clean = s
+    unsure, s = lfdirstate.status(match, [], False, False, False)
+    modified, added, removed, missing, unknown, ignored, clean = s
     for lfile in unsure:
         try:
             fctx = repo[rev][standin(lfile)]
--- a/hgext/largefiles/overrides.py	Mon Oct 13 14:18:47 2014 -0700
+++ b/hgext/largefiles/overrides.py	Fri Oct 03 21:44:10 2014 -0700
@@ -351,9 +351,9 @@
     wlock = repo.wlock()
     try:
         lfdirstate = lfutil.openlfdirstate(ui, repo)
-        s = lfdirstate.status(match_.always(repo.root, repo.getcwd()),
-            [], False, False, False)
-        (unsure, modified, added, removed, missing, unknown, ignored, clean) = s
+        unsure, s = lfdirstate.status(match_.always(repo.root, repo.getcwd()),
+                                      [], False, False, False)
+        modified = s[0]
 
         if opts['check']:
             mod = len(modified) > 0
@@ -1110,9 +1110,9 @@
         return orig(repo, pats, opts, dry_run, similarity)
     # Get the list of missing largefiles so we can remove them
     lfdirstate = lfutil.openlfdirstate(repo.ui, repo)
-    s = lfdirstate.status(match_.always(repo.root, repo.getcwd()), [], False,
-        False, False)
-    (unsure, modified, added, removed, missing, unknown, ignored, clean) = s
+    unsure, s = lfdirstate.status(match_.always(repo.root, repo.getcwd()), [],
+                                  False, False, False)
+    missing = s[3]
 
     # Call into the normal remove code, but the removing of the standin, we want
     # to have handled by original addremove.  Monkey patching here makes sure
@@ -1288,9 +1288,10 @@
             # update standins for linear-merge or force-branch-merge,
             # because largefiles in the working directory may be modified
             lfdirstate = lfutil.openlfdirstate(repo.ui, repo)
-            s = lfdirstate.status(match_.always(repo.root, repo.getcwd()),
-                                  [], False, False, False)
-            unsure, modified, added = s[:3]
+            unsure, s = lfdirstate.status(match_.always(repo.root,
+                                                        repo.getcwd()),
+                                          [], False, False, False)
+            modified, added = s[:2]
             for lfile in unsure + modified + added:
                 lfutil.updatestandin(repo, lfutil.standin(lfile))
 
--- a/hgext/largefiles/reposetup.py	Mon Oct 13 14:18:47 2014 -0700
+++ b/hgext/largefiles/reposetup.py	Fri Oct 03 21:44:10 2014 -0700
@@ -159,10 +159,10 @@
                                     if sfindirstate(f)]
                     # Don't waste time getting the ignored and unknown
                     # files from lfdirstate
-                    s = lfdirstate.status(match, [], False,
-                            listclean, False)
-                    (unsure, modified, added, removed, missing, _unknown,
-                            _ignored, clean) = s
+                    unsure, s = lfdirstate.status(match, [], False, listclean,
+                                                  False)
+                    (modified, added, removed, missing, _unknown, _ignored,
+                     clean) = s
                     if parentworking:
                         for lfile in unsure:
                             standin = lfutil.standin(lfile)
@@ -296,9 +296,9 @@
                     # large.
                     lfdirstate = lfutil.openlfdirstate(ui, self)
                     dirtymatch = match_.always(self.root, self.getcwd())
-                    s = lfdirstate.status(dirtymatch, [], False, False, False)
-                    (unsure, modified, added, removed, _missing, _unknown,
-                            _ignored, _clean) = s
+                    unsure, s = lfdirstate.status(dirtymatch, [], False, False,
+                                                  False)
+                    modified, added, removed = s[:3]
                     modifiedfiles = unsure + modified + added + removed
                     lfiles = lfutil.listlfiles(self)
                     # this only loops through largefiles that exist (not
--- a/mercurial/context.py	Mon Oct 13 14:18:47 2014 -0700
+++ b/mercurial/context.py	Fri Oct 03 21:44:10 2014 -0700
@@ -1418,9 +1418,9 @@
         subrepos = []
         if '.hgsub' in self:
             subrepos = sorted(self.substate)
-        s = self._repo.dirstate.status(match, subrepos, listignored,
-                                       listclean, listunknown)
-        cmp, modified, added, removed, deleted, unknown, ignored, clean = s
+        cmp, s = self._repo.dirstate.status(match, subrepos, listignored,
+                                            listclean, listunknown)
+        modified, added, removed, deleted, unknown, ignored, clean = s
 
         # check for any possibly clean files
         if cmp:
--- a/mercurial/dirstate.py	Mon Oct 13 14:18:47 2014 -0700
+++ b/mercurial/dirstate.py	Fri Oct 03 21:44:10 2014 -0700
@@ -809,8 +809,8 @@
 
     def status(self, match, subrepos, ignored, clean, unknown):
         '''Determine the status of the working copy relative to the
-        dirstate and return a tuple of lists (unsure, modified, added,
-        removed, deleted, unknown, ignored, clean), where:
+        dirstate and return a nested tuple of lists (unsure, (modified, added,
+        removed, deleted, unknown, ignored, clean)), where:
 
           unsure:
             files that might have been modified since the dirstate was
@@ -908,8 +908,8 @@
             elif state == 'r':
                 radd(fn)
 
-        return (lookup, modified, added, removed, deleted, unknown, ignored,
-                clean)
+        return (lookup, (modified, added, removed, deleted, unknown, ignored,
+                         clean))
 
     def matches(self, match):
         '''