comparison mercurial/commands.py @ 50301:9fc0d244a753 stable

dirstate: fix a potential traceback when in `copy` and `rename` Before this changes, calling `hg copy` or `hg rename` could trigger a traceback about using an invalidated dirstate. This wasn't caught by the test as it needed the blackbox extension to preload the dirstate first in a way "refresh" invalidates it. Changing the context creation patterns fixes it.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 15 Mar 2023 05:49:56 +0100
parents e27a5a012323
children 80784ac09460 c5e93c915ab6
comparison
equal deleted inserted replaced
50300:edcc35a4f1dc 50301:9fc0d244a753
2496 2496
2497 Returns 0 on success, 1 if errors are encountered. 2497 Returns 0 on success, 1 if errors are encountered.
2498 """ 2498 """
2499 opts = pycompat.byteskwargs(opts) 2499 opts = pycompat.byteskwargs(opts)
2500 2500
2501 context = repo.dirstate.changing_files 2501 context = lambda repo: repo.dirstate.changing_files(repo)
2502 rev = opts.get(b'at_rev') 2502 rev = opts.get(b'at_rev')
2503 ctx = None 2503 ctx = None
2504 if rev: 2504 if rev:
2505 ctx = logcmdutil.revsingle(repo, rev) 2505 ctx = logcmdutil.revsingle(repo, rev)
2506 if ctx.rev() is not None: 2506 if ctx.rev() is not None:
6010 This command takes effect with the next commit by default. 6010 This command takes effect with the next commit by default.
6011 6011
6012 Returns 0 on success, 1 if errors are encountered. 6012 Returns 0 on success, 1 if errors are encountered.
6013 """ 6013 """
6014 opts = pycompat.byteskwargs(opts) 6014 opts = pycompat.byteskwargs(opts)
6015 context = repo.dirstate.changing_files 6015 context = lambda repo: repo.dirstate.changing_files(repo)
6016 rev = opts.get(b'at_rev') 6016 rev = opts.get(b'at_rev')
6017 ctx = None 6017 ctx = None
6018 if rev: 6018 if rev:
6019 ctx = logcmdutil.revsingle(repo, rev) 6019 ctx = logcmdutil.revsingle(repo, rev)
6020 if ctx.rev() is not None: 6020 if ctx.rev() is not None: