Commit c6fb901b authored by Martin von Zweigbergk's avatar Martin von Zweigbergk
Browse files

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.
parent 93c89814a5d8
Pipeline #1076 passed with stage
in 13 minutes and 30 seconds
......@@ -290,8 +290,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,
......@@ -363,8 +365,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
......@@ -380,7 +382,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
......@@ -393,7 +395,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
......@@ -407,10 +409,10 @@
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)
......@@ -412,12 +414,12 @@
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)
......@@ -418,10 +420,10 @@
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)
......@@ -433,8 +435,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]
......@@ -1234,8 +1236,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()
......@@ -1298,5 +1300,5 @@
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()
......@@ -1302,6 +1304,8 @@
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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment