largefiles: access status fields by name rather than index
authorMartin von Zweigbergk <martinvonz@gmail.com>
Fri, 03 Oct 2014 22:10:08 -0700
changeset 22919 1982bdb7e2cc
parent 22918 31f34a213384
child 22920 e049338d1a7b
largefiles: access status fields by name rather than index
hgext/largefiles/lfutil.py
hgext/largefiles/overrides.py
hgext/largefiles/reposetup.py
--- a/hgext/largefiles/lfutil.py	Fri Oct 03 10:05:54 2014 -0700
+++ b/hgext/largefiles/lfutil.py	Fri Oct 03 22:10:08 2014 -0700
@@ -137,7 +137,7 @@
 def lfdirstatestatus(lfdirstate, repo, rev):
     match = match_.always(repo.root, repo.getcwd())
     unsure, s = lfdirstate.status(match, [], False, False, False)
-    modified, _added, _removed, _missing, _unknown, _ignored, clean = s
+    modified, clean = s.modified, s.clean
     for lfile in unsure:
         try:
             fctx = repo[rev][standin(lfile)]
--- a/hgext/largefiles/overrides.py	Fri Oct 03 10:05:54 2014 -0700
+++ b/hgext/largefiles/overrides.py	Fri Oct 03 22:10:08 2014 -0700
@@ -153,7 +153,8 @@
     manifest = repo[None].manifest()
     modified, added, deleted, clean = [[f for f in list
                                         if lfutil.standin(f) in manifest]
-                                       for list in [s[0], s[1], s[3], s[6]]]
+                                       for list in (s.modified, s.added,
+                                                    s.deleted, s.clean)]
 
     def warn(files, msg):
         for f in files:
@@ -353,10 +354,9 @@
         lfdirstate = lfutil.openlfdirstate(ui, repo)
         unsure, s = lfdirstate.status(match_.always(repo.root, repo.getcwd()),
                                       [], False, False, False)
-        modified = s[0]
 
         if opts['check']:
-            mod = len(modified) > 0
+            mod = len(s.modified) > 0
             for lfile in unsure:
                 standin = lfutil.standin(lfile)
                 if repo['.'][standin].data().strip() != \
@@ -660,12 +660,11 @@
     wlock = repo.wlock()
     try:
         lfdirstate = lfutil.openlfdirstate(ui, repo)
-        (modified, added, removed, missing, unknown, ignored, clean) = \
-            lfutil.lfdirstatestatus(lfdirstate, repo, repo['.'].rev())
+        s = lfutil.lfdirstatestatus(lfdirstate, repo, repo['.'].rev())
         lfdirstate.write()
-        for lfile in modified:
+        for lfile in s.modified:
             lfutil.updatestandin(repo, lfutil.standin(lfile))
-        for lfile in missing:
+        for lfile in s.deleted:
             if (os.path.exists(repo.wjoin(lfutil.standin(lfile)))):
                 os.unlink(repo.wjoin(lfutil.standin(lfile)))
 
@@ -954,17 +953,17 @@
 def overridebailifchanged(orig, repo):
     orig(repo)
     repo.lfstatus = True
-    modified, added, removed, deleted = repo.status()[:4]
+    s = repo.status()
     repo.lfstatus = False
-    if modified or added or removed or deleted:
+    if s.modified or s.added or s.removed or s.deleted:
         raise util.Abort(_('uncommitted changes'))
 
 # Fetch doesn't use cmdutil.bailifchanged so override it to add the check
 def overridefetch(orig, ui, repo, *pats, **opts):
     repo.lfstatus = True
-    modified, added, removed, deleted = repo.status()[:4]
+    s = repo.status()
     repo.lfstatus = False
-    if modified or added or removed or deleted:
+    if s.modified or s.added or s.removed or s.deleted:
         raise util.Abort(_('uncommitted changes'))
     return orig(ui, repo, *pats, **opts)
 
@@ -979,7 +978,7 @@
         s = repo.status(match=m, clean=True)
     finally:
         repo.lfstatus = False
-    forget = sorted(s[0] + s[1] + s[3] + s[6])
+    forget = sorted(s.modified + s.added + s.deleted + s.clean)
     forget = [f for f in forget if lfutil.standin(f) in repo[None].manifest()]
 
     for f in forget:
@@ -1112,14 +1111,13 @@
     lfdirstate = lfutil.openlfdirstate(repo.ui, repo)
     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
     # we don't remove the standin in the largefiles code, preventing a very
     # confused state later.
-    if missing:
-        m = [repo.wjoin(f) for f in missing]
+    if s.deleted:
+        m = [repo.wjoin(f) for f in s.deleted]
         repo._isaddremove = True
         removelargefiles(repo.ui, repo, *m, **opts)
         repo._isaddremove = False
@@ -1146,15 +1144,13 @@
         r = oldstatus(node1, node2, match, ignored, clean, unknown,
                       listsubrepos)
         lfdirstate = lfutil.openlfdirstate(ui, repo)
-        modified, added, removed, deleted, unknown, ignored, clean = r
-        unknown = [f for f in unknown if lfdirstate[f] == '?']
-        ignored = [f for f in ignored if lfdirstate[f] == '?']
-        return scmutil.status(modified, added, removed, deleted,
-                              unknown, ignored, clean)
+        unknown = [f for f in r.unknown if lfdirstate[f] == '?']
+        ignored = [f for f in r.ignored if lfdirstate[f] == '?']
+        return scmutil.status(r.modified, r.added, r.removed, r.deleted,
+                              unknown, ignored, r.clean)
     repo.status = overridestatus
     orig(ui, repo, *dirs, **opts)
     repo.status = oldstatus
-
 def overriderollback(orig, ui, repo, **opts):
     wlock = repo.wlock()
     try:
@@ -1292,8 +1288,7 @@
             unsure, s = lfdirstate.status(match_.always(repo.root,
                                                         repo.getcwd()),
                                           [], False, False, False)
-            modified, added = s[:2]
-            for lfile in unsure + modified + added:
+            for lfile in unsure + s.modified + s.added:
                 lfutil.updatestandin(repo, lfutil.standin(lfile))
 
         if linearmerge:
--- a/hgext/largefiles/reposetup.py	Fri Oct 03 10:05:54 2014 -0700
+++ b/hgext/largefiles/reposetup.py	Fri Oct 03 22:10:08 2014 -0700
@@ -161,8 +161,8 @@
                     # files from lfdirstate
                     unsure, s = lfdirstate.status(match, [], False, listclean,
                                                   False)
-                    (modified, added, removed, missing, _unknown, _ignored,
-                     clean) = s
+                    (modified, added, removed, clean) = (s.modified, s.added,
+                                                         s.removed, s.clean)
                     if parentworking:
                         for lfile in unsure:
                             standin = lfutil.standin(lfile)
@@ -222,7 +222,7 @@
                     normals = [[fn for fn in filelist
                                 if not lfutil.isstandin(fn)]
                                for filelist in result]
-                    lfstatus = (modified, added, removed, missing, [], [],
+                    lfstatus = (modified, added, removed, s.deleted, [], [],
                                 clean)
                     result = [sorted(list1 + list2)
                               for (list1, list2) in zip(normals, lfstatus)]
@@ -298,8 +298,7 @@
                     dirtymatch = match_.always(self.root, self.getcwd())
                     unsure, s = lfdirstate.status(dirtymatch, [], False, False,
                                                   False)
-                    modified, added, removed = s[:3]
-                    modifiedfiles = unsure + modified + added + removed
+                    modifiedfiles = unsure + s.modified + s.added + s.removed
                     lfiles = lfutil.listlfiles(self)
                     # this only loops through largefiles that exist (not
                     # removed/renamed)