[Updated] D8876: merge: pass mergeresult obj instead of actions in applyupdates() (API)
pulkit (Pulkit Goyal)
phabricator at mercurial-scm.org
Sat Aug 8 16:55:59 UTC 2020
Closed by commit rHGb9b055f15035: merge: pass mergeresult obj instead of actions in applyupdates() (API) (authored by pulkit).
This revision was automatically updated to reflect the committed changes.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D8876?vs=22257&id=22334
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D8876/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D8876
AFFECTED FILES
hgext/remotefilelog/__init__.py
mercurial/merge.py
mercurial/narrowspec.py
mercurial/sparse.py
CHANGE DETAILS
diff --git a/mercurial/sparse.py b/mercurial/sparse.py
--- a/mercurial/sparse.py
+++ b/mercurial/sparse.py
@@ -269,19 +269,17 @@
sparsematch = matcher(repo, includetemp=False)
dirstate = repo.dirstate
- actions = []
+ mresult = mergemod.mergeresult()
dropped = []
tempincludes = readtemporaryincludes(repo)
for file in tempincludes:
if file in dirstate and not sparsematch(file):
message = _(b'dropping temporarily included sparse files')
- actions.append((file, None, message))
+ mresult.addfile(file, b'r', None, message)
dropped.append(file)
- typeactions = mergemod.emptyactions()
- typeactions[b'r'] = actions
mergemod.applyupdates(
- repo, typeactions, repo[None], repo[b'.'], False, wantfiledata=False
+ repo, mresult, repo[None], repo[b'.'], False, wantfiledata=False
)
# Fix dirstate
@@ -429,22 +427,25 @@
addtemporaryincludes(repo, temporaryfiles)
# Add the new files to the working copy so they can be merged, etc
- actions = []
+ tmresult = mergemod.mergeresult()
message = b'temporarily adding to sparse checkout'
wctxmanifest = repo[None].manifest()
for file in temporaryfiles:
if file in wctxmanifest:
fctx = repo[None][file]
- actions.append((file, (fctx.flags(), False), message))
+ tmresult.addfile(
+ file,
+ mergestatemod.ACTION_GET,
+ (fctx.flags(), False),
+ message,
+ )
- typeactions = mergemod.emptyactions()
- typeactions[mergestatemod.ACTION_GET] = actions
mergemod.applyupdates(
- repo, typeactions, repo[None], repo[b'.'], False, wantfiledata=False
+ repo, tmresult, repo[None], repo[b'.'], False, wantfiledata=False
)
dirstate = repo.dirstate
- for file, flags, msg in actions:
+ for file, flags, msg in tmresult.getactions([mergestatemod.ACTION_GET]):
dirstate.normal(file)
profiles = activeconfig(repo)[2]
@@ -497,7 +498,7 @@
_(b'could not update sparseness due to pending changes')
)
- # Calculate actions
+ # Calculate merge result
dirstate = repo.dirstate
ctx = repo[b'.']
added = []
@@ -505,8 +506,7 @@
dropped = []
mf = ctx.manifest()
files = set(mf)
-
- actions = {}
+ mresult = mergemod.mergeresult()
for file in files:
old = origsparsematch(file)
@@ -516,17 +516,17 @@
if (new and not old) or (old and new and not file in dirstate):
fl = mf.flags(file)
if repo.wvfs.exists(file):
- actions[file] = (b'e', (fl,), b'')
+ mresult.addfile(file, b'e', (fl,), b'')
lookup.append(file)
else:
- actions[file] = (b'g', (fl, False), b'')
+ mresult.addfile(file, b'g', (fl, False), b'')
added.append(file)
# Drop files that are newly excluded, or that still exist in
# the dirstate.
elif (old and not new) or (not old and not new and file in dirstate):
dropped.append(file)
if file not in pending:
- actions[file] = (b'r', [], b'')
+ mresult.addfile(file, b'r', [], b'')
# Verify there are no pending changes in newly included files
abort = False
@@ -550,13 +550,8 @@
if old and not new:
dropped.append(file)
- # Apply changes to disk
- typeactions = mergemod.emptyactions()
- for f, (m, args, msg) in pycompat.iteritems(actions):
- typeactions[m].append((f, args, msg))
-
mergemod.applyupdates(
- repo, typeactions, repo[None], repo[b'.'], False, wantfiledata=False
+ repo, mresult, repo[None], repo[b'.'], False, wantfiledata=False
)
# Fix dirstate
diff --git a/mercurial/narrowspec.py b/mercurial/narrowspec.py
--- a/mercurial/narrowspec.py
+++ b/mercurial/narrowspec.py
@@ -272,15 +272,19 @@
def _writeaddedfiles(repo, pctx, files):
- actions = merge.emptyactions()
- addgaction = actions[mergestatemod.ACTION_GET].append
+ mresult = merge.mergeresult()
mf = repo[b'.'].manifest()
for f in files:
if not repo.wvfs.exists(f):
- addgaction((f, (mf.flags(f), False), b"narrowspec updated"))
+ mresult.addfile(
+ f,
+ mergestatemod.ACTION_GET,
+ (mf.flags(f), False),
+ b"narrowspec updated",
+ )
merge.applyupdates(
repo,
- actions,
+ mresult,
wctx=repo[None],
mctx=repo[b'.'],
overwrite=False,
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1328,7 +1328,7 @@
def applyupdates(
repo,
- actions,
+ mresult,
wctx,
mctx,
overwrite,
@@ -1338,6 +1338,7 @@
):
"""apply the merge action list to the working directory
+ mresult is a mergeresult object representing result of the merge
wctx is the working copy context
mctx is the context to be merged into the working copy
commitinfo is a mapping of information which needs to be stored somewhere
@@ -1349,6 +1350,7 @@
batchget.
"""
+ actions = mresult.actionsdict
_prefetchfiles(repo, mctx, actions)
updated, merged, removed = 0, 0, 0
@@ -1613,6 +1615,8 @@
mfiles = {a[0] for a in actions[mergestatemod.ACTION_MERGE]}
for k, acts in pycompat.iteritems(extraactions):
actions[k].extend(acts)
+ for a in acts:
+ mresult.addfile(a[0], k, *a[1:])
if k == mergestatemod.ACTION_GET and wantfiledata:
# no filedata until mergestate is updated to provide it
for a in acts:
@@ -1638,6 +1642,9 @@
actions[mergestatemod.ACTION_MERGE] = [
a for a in actions[mergestatemod.ACTION_MERGE] if a[0] in mfiles
]
+ for a in mresult.getactions([mergestatemod.ACTION_MERGE]):
+ if a[0] not in mfiles:
+ mresult.removefile(a[0])
progress.complete()
assert len(getfiledata) == (
@@ -2016,7 +2023,7 @@
wantfiledata = updatedirstate and not branchmerge
stats, getfiledata = applyupdates(
repo,
- actions,
+ mresult,
wc,
p2,
overwrite,
@@ -2029,7 +2036,7 @@
with repo.dirstate.parentchange():
repo.setparents(fp1, fp2)
mergestatemod.recordupdates(
- repo, actions, branchmerge, getfiledata
+ repo, mresult.actionsdict, branchmerge, getfiledata
)
# update completed, clear state
util.unlink(repo.vfs.join(b'updatestate'))
diff --git a/hgext/remotefilelog/__init__.py b/hgext/remotefilelog/__init__.py
--- a/hgext/remotefilelog/__init__.py
+++ b/hgext/remotefilelog/__init__.py
@@ -480,16 +480,16 @@
# prefetch files before update
def applyupdates(
- orig, repo, actions, wctx, mctx, overwrite, wantfiledata, **opts
+ orig, repo, mresult, wctx, mctx, overwrite, wantfiledata, **opts
):
if isenabled(repo):
manifest = mctx.manifest()
files = []
- for f, args, msg in actions[mergestatemod.ACTION_GET]:
+ for f, args, msg in mresult.getactions([mergestatemod.ACTION_GET]):
files.append((f, hex(manifest[f])))
# batch fetch the needed files from the server
repo.fileservice.prefetch(files)
- return orig(repo, actions, wctx, mctx, overwrite, wantfiledata, **opts)
+ return orig(repo, mresult, wctx, mctx, overwrite, wantfiledata, **opts)
# Prefetch merge checkunknownfiles
To: pulkit, #hg-reviewers, indygreg
Cc: indygreg, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20200808/220c1073/attachment-0002.html>
More information about the Mercurial-patches
mailing list