Mercurial > hg
changeset 50112:62158471d038
strip: use a `changing_parents` context for --keep update
These are now properly scoped.
note: it would be neat to reuse this in `hg rollback`.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sun, 19 Feb 2023 02:50:46 +0100 |
parents | 0ca8dc8a135f |
children | dae8dda6f582 |
files | mercurial/strip.py |
diffstat | 1 files changed, 21 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/strip.py Sun Feb 19 02:47:28 2023 +0100 +++ b/mercurial/strip.py Sun Feb 19 02:50:46 2023 +0100 @@ -241,31 +241,32 @@ revs = sorted(rootnodes) if update and opts.get(b'keep'): - urev = _findupdatetarget(repo, revs) - uctx = repo[urev] + with repo.dirstate.changing_parents(repo): + urev = _findupdatetarget(repo, revs) + uctx = repo[urev] - # only reset the dirstate for files that would actually change - # between the working context and uctx - descendantrevs = repo.revs(b"only(., %d)", uctx.rev()) - changedfiles = [] - for rev in descendantrevs: - # blindly reset the files, regardless of what actually changed - changedfiles.extend(repo[rev].files()) + # only reset the dirstate for files that would actually change + # between the working context and uctx + descendantrevs = repo.revs(b"only(., %d)", uctx.rev()) + changedfiles = [] + for rev in descendantrevs: + # blindly reset the files, regardless of what actually changed + changedfiles.extend(repo[rev].files()) - # reset files that only changed in the dirstate too - dirstate = repo.dirstate - dirchanges = [ - f for f in dirstate if not dirstate.get_entry(f).maybe_clean - ] - changedfiles.extend(dirchanges) + # reset files that only changed in the dirstate too + dirstate = repo.dirstate + dirchanges = [ + f for f in dirstate if not dirstate.get_entry(f).maybe_clean + ] + changedfiles.extend(dirchanges) - repo.dirstate.rebuild(urev, uctx.manifest(), changedfiles) - repo.dirstate.write(repo.currenttransaction()) + repo.dirstate.rebuild(urev, uctx.manifest(), changedfiles) + repo.dirstate.write(repo.currenttransaction()) - # clear resolve state - mergestatemod.mergestate.clean(repo) + # clear resolve state + mergestatemod.mergestate.clean(repo) - update = False + update = False strip( ui,