##// END OF EJS Templates
merge: introduce a revert_to() for that use-case...
Martin von Zweigbergk -
r44744:c791ed6a default
parent child Browse files
Show More
@@ -735,15 +735,7 b' def replacerev(ui, repo, ctx, filedata, '
735
735
736 wctx = context.overlayworkingctx(repo)
736 wctx = context.overlayworkingctx(repo)
737 wctx.setbase(repo[newp1node])
737 wctx.setbase(repo[newp1node])
738 merge.update(
738 merge.revert_to(ctx, wc=wctx)
739 repo,
740 ctx.rev(),
741 branchmerge=False,
742 force=True,
743 ancestor=p1rev,
744 mergeancestor=False,
745 wc=wctx,
746 )
747 copies.graftcopies(wctx, ctx, ctx.p1())
739 copies.graftcopies(wctx, ctx, ctx.p1())
748
740
749 for path in filedata.keys():
741 for path in filedata.keys():
@@ -584,15 +584,8 b' def dorecord('
584 [os.unlink(repo.wjoin(c)) for c in newlyaddedandmodifiedfiles]
584 [os.unlink(repo.wjoin(c)) for c in newlyaddedandmodifiedfiles]
585 # 3a. apply filtered patch to clean repo (clean)
585 # 3a. apply filtered patch to clean repo (clean)
586 if backups:
586 if backups:
587 # Equivalent to hg.revert
588 m = scmutil.matchfiles(repo, set(backups.keys()) | alsorestore)
587 m = scmutil.matchfiles(repo, set(backups.keys()) | alsorestore)
589 mergemod.update(
588 mergemod.revert_to(repo[b'.'], matcher=m)
590 repo,
591 repo.dirstate.p1(),
592 branchmerge=False,
593 force=True,
594 matcher=m,
595 )
596
589
597 # 3b. (apply)
590 # 3b. (apply)
598 if dopatch:
591 if dopatch:
@@ -2225,6 +2225,7 b' def update('
2225 labels=None,
2225 labels=None,
2226 matcher=None,
2226 matcher=None,
2227 mergeforce=False,
2227 mergeforce=False,
2228 updatedirstate=True,
2228 updatecheck=None,
2229 updatecheck=None,
2229 wc=None,
2230 wc=None,
2230 ):
2231 ):
@@ -2523,7 +2524,7 b' def update('
2523 # If we're doing a partial update, we need to skip updating
2524 # If we're doing a partial update, we need to skip updating
2524 # the dirstate.
2525 # the dirstate.
2525 always = matcher is None or matcher.always()
2526 always = matcher is None or matcher.always()
2526 updatedirstate = always and not wc.isinmemory()
2527 updatedirstate = updatedirstate and always and not wc.isinmemory()
2527 if updatedirstate:
2528 if updatedirstate:
2528 repo.hook(b'preupdate', throw=True, parent1=xp1, parent2=xp2)
2529 repo.hook(b'preupdate', throw=True, parent1=xp1, parent2=xp2)
2529 # note that we're in the middle of an update
2530 # note that we're in the middle of an update
@@ -2606,6 +2607,24 b' def clean_update(ctx, wc=None):'
2606 return update(ctx.repo(), ctx.rev(), branchmerge=False, force=True, wc=wc)
2607 return update(ctx.repo(), ctx.rev(), branchmerge=False, force=True, wc=wc)
2607
2608
2608
2609
2610 def revert_to(ctx, matcher=None, wc=None):
2611 """Revert the working copy to the given commit.
2612
2613 The working copy will keep its current parent(s) but its content will
2614 be the same as in the given commit.
2615 """
2616
2617 return update(
2618 ctx.repo(),
2619 ctx.rev(),
2620 branchmerge=False,
2621 force=True,
2622 updatedirstate=False,
2623 matcher=matcher,
2624 wc=wc,
2625 )
2626
2627
2609 def graft(
2628 def graft(
2610 repo,
2629 repo,
2611 ctx,
2630 ctx,
General Comments 0
You need to be logged in to leave comments. Login now