comparison mercurial/strip.py @ 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 f254fc73d956
children d1502345f89c
comparison
equal deleted inserted replaced
50111:0ca8dc8a135f 50112:62158471d038
239 del q.applied[start:end] 239 del q.applied[start:end]
240 q.savedirty() 240 q.savedirty()
241 241
242 revs = sorted(rootnodes) 242 revs = sorted(rootnodes)
243 if update and opts.get(b'keep'): 243 if update and opts.get(b'keep'):
244 urev = _findupdatetarget(repo, revs) 244 with repo.dirstate.changing_parents(repo):
245 uctx = repo[urev] 245 urev = _findupdatetarget(repo, revs)
246 246 uctx = repo[urev]
247 # only reset the dirstate for files that would actually change 247
248 # between the working context and uctx 248 # only reset the dirstate for files that would actually change
249 descendantrevs = repo.revs(b"only(., %d)", uctx.rev()) 249 # between the working context and uctx
250 changedfiles = [] 250 descendantrevs = repo.revs(b"only(., %d)", uctx.rev())
251 for rev in descendantrevs: 251 changedfiles = []
252 # blindly reset the files, regardless of what actually changed 252 for rev in descendantrevs:
253 changedfiles.extend(repo[rev].files()) 253 # blindly reset the files, regardless of what actually changed
254 254 changedfiles.extend(repo[rev].files())
255 # reset files that only changed in the dirstate too 255
256 dirstate = repo.dirstate 256 # reset files that only changed in the dirstate too
257 dirchanges = [ 257 dirstate = repo.dirstate
258 f for f in dirstate if not dirstate.get_entry(f).maybe_clean 258 dirchanges = [
259 ] 259 f for f in dirstate if not dirstate.get_entry(f).maybe_clean
260 changedfiles.extend(dirchanges) 260 ]
261 261 changedfiles.extend(dirchanges)
262 repo.dirstate.rebuild(urev, uctx.manifest(), changedfiles) 262
263 repo.dirstate.write(repo.currenttransaction()) 263 repo.dirstate.rebuild(urev, uctx.manifest(), changedfiles)
264 264 repo.dirstate.write(repo.currenttransaction())
265 # clear resolve state 265
266 mergestatemod.mergestate.clean(repo) 266 # clear resolve state
267 267 mergestatemod.mergestate.clean(repo)
268 update = False 268
269 update = False
269 270
270 strip( 271 strip(
271 ui, 272 ui,
272 repo, 273 repo,
273 revs, 274 revs,