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, |