Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/merge.py @ 44318:c791ed6a2154
merge: introduce a revert_to() for that use-case
In the same vein as the previous patch.
Differential Revision: https://phab.mercurial-scm.org/D7901
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Wed, 15 Jan 2020 14:47:38 -0800 |
parents | f546d2170b0f |
children | e76d98546bd2 |
comparison
equal
deleted
inserted
replaced
44317:f546d2170b0f | 44318:c791ed6a2154 |
---|---|
2223 ancestor=None, | 2223 ancestor=None, |
2224 mergeancestor=False, | 2224 mergeancestor=False, |
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 ): |
2231 """ | 2232 """ |
2232 Perform a merge between the working directory and the given node | 2233 Perform a merge between the working directory and the given node |
2521 if not branchmerge: # just jump to the new rev | 2522 if not branchmerge: # just jump to the new rev |
2522 fp1, fp2, xp1, xp2 = fp2, nullid, xp2, b'' | 2523 fp1, fp2, xp1, xp2 = fp2, nullid, xp2, b'' |
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 |
2530 repo.vfs.write(b'updatestate', p2.hex()) | 2531 repo.vfs.write(b'updatestate', p2.hex()) |
2531 | 2532 |
2604 working copy. | 2605 working copy. |
2605 """ | 2606 """ |
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, |
2612 base=None, | 2631 base=None, |
2613 labels=None, | 2632 labels=None, |