cmdrewrite: avoid accessing scmutil.status fields by index stable
authorMartin von Zweigbergk <martinvonz@google.com>
Fri, 15 Nov 2019 08:14:06 -0800
branchstable
changeset 5093 fd1d12497fdb
parent 5084 946ebd8f08ea
child 5094 a2391f919141
cmdrewrite: avoid accessing scmutil.status fields by index Support for indexed access is going away in Mercurial. Accessing the fields by name is clearer anyway.
hgext3rd/evolve/cmdrewrite.py
--- a/hgext3rd/evolve/cmdrewrite.py	Thu Jan 23 18:19:36 2020 +0700
+++ b/hgext3rd/evolve/cmdrewrite.py	Fri Nov 15 08:14:06 2019 -0800
@@ -291,8 +291,10 @@
 
 def _touchedbetween(repo, source, dest, match=None):
     touched = set()
-    for files in repo.status(source, dest, match=match)[:3]:
-        touched.update(files)
+    st = repo.status(source, dest, match=match)
+    touched.update(st.modified)
+    touched.update(st.added)
+    touched.update(st.removed)
     return touched
 
 def _commitfiltered(repo, ctx, match, target=None, message=None, user=None,
@@ -364,8 +366,8 @@
         # and considering only the files which are changed between oldctx and
         # ctx, and the status of what changed between oldctx and ctx will help
         # us in defining the exact behavior
-        m, a, r = repo.status(oldctx, ctx, match=match)[:3]
-        for f in m:
+        st = repo.status(oldctx, ctx, match=match)
+        for f in st.modified:
             # These are files which are modified between oldctx and ctx which
             # contains two cases: 1) Were modified in oldctx and some
             # modifications are uncommitted
@@ -381,7 +383,7 @@
                 continue
             ds.normallookup(f)
 
-        for f in a:
+        for f in st.added:
             # These are the files which are added between oldctx and ctx(new
             # one), which means the files which were removed in oldctx
             # but uncommitted completely while making the ctx
@@ -394,7 +396,7 @@
                 continue
             ds.remove(f)
 
-        for f in r:
+        for f in st.removed:
             # These are files which are removed between oldctx and ctx, which
             # means the files which were added in oldctx and were completely
             # uncommitted in ctx. If a added file is partially uncommitted, that
@@ -408,21 +410,21 @@
                 continue
             ds.add(f)
     else:
-        m, a, r = repo.status(oldctx.p1(), oldctx, match=match)[:3]
-        for f in m:
+        st = repo.status(oldctx.p1(), oldctx, match=match)
+        for f in st.modified:
             if ds[f] == b'r':
                 # modified + removed -> removed
                 continue
             ds.normallookup(f)
 
-        for f in a:
+        for f in st.added:
             if ds[f] == b'r':
                 # added + removed -> unknown
                 ds.drop(f)
             elif ds[f] != b'a':
                 ds.add(f)
 
-        for f in r:
+        for f in st.removed:
             if ds[f] == b'a':
                 # removed + added -> normal
                 ds.normallookup(f)
@@ -434,8 +436,8 @@
     if interactive:
         # Interactive had different meaning of the variables so restoring the
         # original meaning to use them
-        m, a, r = repo.status(oldctx.p1(), oldctx, match=match)[:3]
-    for f in (m + a):
+        st = repo.status(oldctx.p1(), oldctx, match=match)
+    for f in (st.modified + st.added):
         src = oldctx[f].renamed()
         if src:
             oldcopies[f] = src[0]
@@ -1230,8 +1232,8 @@
         rewriteutil.presplitupdate(repo, ui, prev, ctx)
 
         def haschanges(matcher=None):
-            modified, added, removed, deleted = repo.status(match=matcher)[:4]
-            return modified or added or removed or deleted
+            st = repo.status(match=matcher)
+            return st.modified or st.added or st.removed or st.deleted
         msg = (b"HG: This is the original pre-split commit message. "
                b"Edit it as appropriate.\n\n")
         msg += ctx.description()
@@ -1294,10 +1296,12 @@
                         ui.status(_(b'discarding remaining changes\n'))
                         target = newcommits[0]
                         if pats:
-                            status = repo.status(match=matcher)[:4]
+                            status = repo.status(match=matcher)
                             dirty = set()
-                            for i in status:
-                                dirty.update(i)
+                            dirty.update(status.modified)
+                            dirty.update(status.added)
+                            dirty.update(status.removed)
+                            dirty.update(status.deleted)
                             dirty = sorted(dirty)
                             cmdutil.revert(ui, repo, repo[target],
                                            (target, node.nullid), *dirty)