##// END OF EJS Templates
merge: pass mergeresult obj instead of actions in applyupdates() (API)...
Pulkit Goyal -
r45894:b9b055f1 default
parent child Browse files
Show More
@@ -480,16 +480,16 b' def storewrapper(orig, requirements, pat'
480
480
481 # prefetch files before update
481 # prefetch files before update
482 def applyupdates(
482 def applyupdates(
483 orig, repo, actions, wctx, mctx, overwrite, wantfiledata, **opts
483 orig, repo, mresult, wctx, mctx, overwrite, wantfiledata, **opts
484 ):
484 ):
485 if isenabled(repo):
485 if isenabled(repo):
486 manifest = mctx.manifest()
486 manifest = mctx.manifest()
487 files = []
487 files = []
488 for f, args, msg in actions[mergestatemod.ACTION_GET]:
488 for f, args, msg in mresult.getactions([mergestatemod.ACTION_GET]):
489 files.append((f, hex(manifest[f])))
489 files.append((f, hex(manifest[f])))
490 # batch fetch the needed files from the server
490 # batch fetch the needed files from the server
491 repo.fileservice.prefetch(files)
491 repo.fileservice.prefetch(files)
492 return orig(repo, actions, wctx, mctx, overwrite, wantfiledata, **opts)
492 return orig(repo, mresult, wctx, mctx, overwrite, wantfiledata, **opts)
493
493
494
494
495 # Prefetch merge checkunknownfiles
495 # Prefetch merge checkunknownfiles
@@ -1328,7 +1328,7 b' def emptyactions():'
1328
1328
1329 def applyupdates(
1329 def applyupdates(
1330 repo,
1330 repo,
1331 actions,
1331 mresult,
1332 wctx,
1332 wctx,
1333 mctx,
1333 mctx,
1334 overwrite,
1334 overwrite,
@@ -1338,6 +1338,7 b' def applyupdates('
1338 ):
1338 ):
1339 """apply the merge action list to the working directory
1339 """apply the merge action list to the working directory
1340
1340
1341 mresult is a mergeresult object representing result of the merge
1341 wctx is the working copy context
1342 wctx is the working copy context
1342 mctx is the context to be merged into the working copy
1343 mctx is the context to be merged into the working copy
1343 commitinfo is a mapping of information which needs to be stored somewhere
1344 commitinfo is a mapping of information which needs to be stored somewhere
@@ -1349,6 +1350,7 b' def applyupdates('
1349 batchget.
1350 batchget.
1350 """
1351 """
1351
1352
1353 actions = mresult.actionsdict
1352 _prefetchfiles(repo, mctx, actions)
1354 _prefetchfiles(repo, mctx, actions)
1353
1355
1354 updated, merged, removed = 0, 0, 0
1356 updated, merged, removed = 0, 0, 0
@@ -1613,6 +1615,8 b' def applyupdates('
1613 mfiles = {a[0] for a in actions[mergestatemod.ACTION_MERGE]}
1615 mfiles = {a[0] for a in actions[mergestatemod.ACTION_MERGE]}
1614 for k, acts in pycompat.iteritems(extraactions):
1616 for k, acts in pycompat.iteritems(extraactions):
1615 actions[k].extend(acts)
1617 actions[k].extend(acts)
1618 for a in acts:
1619 mresult.addfile(a[0], k, *a[1:])
1616 if k == mergestatemod.ACTION_GET and wantfiledata:
1620 if k == mergestatemod.ACTION_GET and wantfiledata:
1617 # no filedata until mergestate is updated to provide it
1621 # no filedata until mergestate is updated to provide it
1618 for a in acts:
1622 for a in acts:
@@ -1638,6 +1642,9 b' def applyupdates('
1638 actions[mergestatemod.ACTION_MERGE] = [
1642 actions[mergestatemod.ACTION_MERGE] = [
1639 a for a in actions[mergestatemod.ACTION_MERGE] if a[0] in mfiles
1643 a for a in actions[mergestatemod.ACTION_MERGE] if a[0] in mfiles
1640 ]
1644 ]
1645 for a in mresult.getactions([mergestatemod.ACTION_MERGE]):
1646 if a[0] not in mfiles:
1647 mresult.removefile(a[0])
1641
1648
1642 progress.complete()
1649 progress.complete()
1643 assert len(getfiledata) == (
1650 assert len(getfiledata) == (
@@ -2016,7 +2023,7 b' def update('
2016 wantfiledata = updatedirstate and not branchmerge
2023 wantfiledata = updatedirstate and not branchmerge
2017 stats, getfiledata = applyupdates(
2024 stats, getfiledata = applyupdates(
2018 repo,
2025 repo,
2019 actions,
2026 mresult,
2020 wc,
2027 wc,
2021 p2,
2028 p2,
2022 overwrite,
2029 overwrite,
@@ -2029,7 +2036,7 b' def update('
2029 with repo.dirstate.parentchange():
2036 with repo.dirstate.parentchange():
2030 repo.setparents(fp1, fp2)
2037 repo.setparents(fp1, fp2)
2031 mergestatemod.recordupdates(
2038 mergestatemod.recordupdates(
2032 repo, actions, branchmerge, getfiledata
2039 repo, mresult.actionsdict, branchmerge, getfiledata
2033 )
2040 )
2034 # update completed, clear state
2041 # update completed, clear state
2035 util.unlink(repo.vfs.join(b'updatestate'))
2042 util.unlink(repo.vfs.join(b'updatestate'))
@@ -272,15 +272,19 b' def _deletecleanfiles(repo, files):'
272
272
273
273
274 def _writeaddedfiles(repo, pctx, files):
274 def _writeaddedfiles(repo, pctx, files):
275 actions = merge.emptyactions()
275 mresult = merge.mergeresult()
276 addgaction = actions[mergestatemod.ACTION_GET].append
277 mf = repo[b'.'].manifest()
276 mf = repo[b'.'].manifest()
278 for f in files:
277 for f in files:
279 if not repo.wvfs.exists(f):
278 if not repo.wvfs.exists(f):
280 addgaction((f, (mf.flags(f), False), b"narrowspec updated"))
279 mresult.addfile(
280 f,
281 mergestatemod.ACTION_GET,
282 (mf.flags(f), False),
283 b"narrowspec updated",
284 )
281 merge.applyupdates(
285 merge.applyupdates(
282 repo,
286 repo,
283 actions,
287 mresult,
284 wctx=repo[None],
288 wctx=repo[None],
285 mctx=repo[b'.'],
289 mctx=repo[b'.'],
286 overwrite=False,
290 overwrite=False,
@@ -269,19 +269,17 b' def prunetemporaryincludes(repo):'
269
269
270 sparsematch = matcher(repo, includetemp=False)
270 sparsematch = matcher(repo, includetemp=False)
271 dirstate = repo.dirstate
271 dirstate = repo.dirstate
272 actions = []
272 mresult = mergemod.mergeresult()
273 dropped = []
273 dropped = []
274 tempincludes = readtemporaryincludes(repo)
274 tempincludes = readtemporaryincludes(repo)
275 for file in tempincludes:
275 for file in tempincludes:
276 if file in dirstate and not sparsematch(file):
276 if file in dirstate and not sparsematch(file):
277 message = _(b'dropping temporarily included sparse files')
277 message = _(b'dropping temporarily included sparse files')
278 actions.append((file, None, message))
278 mresult.addfile(file, b'r', None, message)
279 dropped.append(file)
279 dropped.append(file)
280
280
281 typeactions = mergemod.emptyactions()
282 typeactions[b'r'] = actions
283 mergemod.applyupdates(
281 mergemod.applyupdates(
284 repo, typeactions, repo[None], repo[b'.'], False, wantfiledata=False
282 repo, mresult, repo[None], repo[b'.'], False, wantfiledata=False
285 )
283 )
286
284
287 # Fix dirstate
285 # Fix dirstate
@@ -429,22 +427,25 b' def filterupdatesactions(repo, wctx, mct'
429 addtemporaryincludes(repo, temporaryfiles)
427 addtemporaryincludes(repo, temporaryfiles)
430
428
431 # Add the new files to the working copy so they can be merged, etc
429 # Add the new files to the working copy so they can be merged, etc
432 actions = []
430 tmresult = mergemod.mergeresult()
433 message = b'temporarily adding to sparse checkout'
431 message = b'temporarily adding to sparse checkout'
434 wctxmanifest = repo[None].manifest()
432 wctxmanifest = repo[None].manifest()
435 for file in temporaryfiles:
433 for file in temporaryfiles:
436 if file in wctxmanifest:
434 if file in wctxmanifest:
437 fctx = repo[None][file]
435 fctx = repo[None][file]
438 actions.append((file, (fctx.flags(), False), message))
436 tmresult.addfile(
437 file,
438 mergestatemod.ACTION_GET,
439 (fctx.flags(), False),
440 message,
441 )
439
442
440 typeactions = mergemod.emptyactions()
441 typeactions[mergestatemod.ACTION_GET] = actions
442 mergemod.applyupdates(
443 mergemod.applyupdates(
443 repo, typeactions, repo[None], repo[b'.'], False, wantfiledata=False
444 repo, tmresult, repo[None], repo[b'.'], False, wantfiledata=False
444 )
445 )
445
446
446 dirstate = repo.dirstate
447 dirstate = repo.dirstate
447 for file, flags, msg in actions:
448 for file, flags, msg in tmresult.getactions([mergestatemod.ACTION_GET]):
448 dirstate.normal(file)
449 dirstate.normal(file)
449
450
450 profiles = activeconfig(repo)[2]
451 profiles = activeconfig(repo)[2]
@@ -497,7 +498,7 b' def refreshwdir(repo, origstatus, origsp'
497 _(b'could not update sparseness due to pending changes')
498 _(b'could not update sparseness due to pending changes')
498 )
499 )
499
500
500 # Calculate actions
501 # Calculate merge result
501 dirstate = repo.dirstate
502 dirstate = repo.dirstate
502 ctx = repo[b'.']
503 ctx = repo[b'.']
503 added = []
504 added = []
@@ -505,8 +506,7 b' def refreshwdir(repo, origstatus, origsp'
505 dropped = []
506 dropped = []
506 mf = ctx.manifest()
507 mf = ctx.manifest()
507 files = set(mf)
508 files = set(mf)
508
509 mresult = mergemod.mergeresult()
509 actions = {}
510
510
511 for file in files:
511 for file in files:
512 old = origsparsematch(file)
512 old = origsparsematch(file)
@@ -516,17 +516,17 b' def refreshwdir(repo, origstatus, origsp'
516 if (new and not old) or (old and new and not file in dirstate):
516 if (new and not old) or (old and new and not file in dirstate):
517 fl = mf.flags(file)
517 fl = mf.flags(file)
518 if repo.wvfs.exists(file):
518 if repo.wvfs.exists(file):
519 actions[file] = (b'e', (fl,), b'')
519 mresult.addfile(file, b'e', (fl,), b'')
520 lookup.append(file)
520 lookup.append(file)
521 else:
521 else:
522 actions[file] = (b'g', (fl, False), b'')
522 mresult.addfile(file, b'g', (fl, False), b'')
523 added.append(file)
523 added.append(file)
524 # Drop files that are newly excluded, or that still exist in
524 # Drop files that are newly excluded, or that still exist in
525 # the dirstate.
525 # the dirstate.
526 elif (old and not new) or (not old and not new and file in dirstate):
526 elif (old and not new) or (not old and not new and file in dirstate):
527 dropped.append(file)
527 dropped.append(file)
528 if file not in pending:
528 if file not in pending:
529 actions[file] = (b'r', [], b'')
529 mresult.addfile(file, b'r', [], b'')
530
530
531 # Verify there are no pending changes in newly included files
531 # Verify there are no pending changes in newly included files
532 abort = False
532 abort = False
@@ -550,13 +550,8 b' def refreshwdir(repo, origstatus, origsp'
550 if old and not new:
550 if old and not new:
551 dropped.append(file)
551 dropped.append(file)
552
552
553 # Apply changes to disk
554 typeactions = mergemod.emptyactions()
555 for f, (m, args, msg) in pycompat.iteritems(actions):
556 typeactions[m].append((f, args, msg))
557
558 mergemod.applyupdates(
553 mergemod.applyupdates(
559 repo, typeactions, repo[None], repo[b'.'], False, wantfiledata=False
554 repo, mresult, repo[None], repo[b'.'], False, wantfiledata=False
560 )
555 )
561
556
562 # Fix dirstate
557 # Fix dirstate
General Comments 0
You need to be logged in to leave comments. Login now