Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 50005:16b78c0de506
locking: take the `wlock` for the full `hg remove` duration
Otherwise, there is a race condition window between the time we resolve the
file to remove with the matcher and the time we lock the repo and modify the
dirstate.
For example, the working copy might have been updated away, or purged, and the
matched files would no longer be correct.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 13 Dec 2022 04:22:46 +0100 |
parents | 3c34a224c232 |
children | feaa5d08bb19 |
comparison
equal
deleted
inserted
replaced
50004:3c34a224c232 | 50005:16b78c0de506 |
---|---|
5943 after, force = opts.get(b'after'), opts.get(b'force') | 5943 after, force = opts.get(b'after'), opts.get(b'force') |
5944 dryrun = opts.get(b'dry_run') | 5944 dryrun = opts.get(b'dry_run') |
5945 if not pats and not after: | 5945 if not pats and not after: |
5946 raise error.InputError(_(b'no files specified')) | 5946 raise error.InputError(_(b'no files specified')) |
5947 | 5947 |
5948 m = scmutil.match(repo[None], pats, opts) | 5948 with repo.wlock(): |
5949 subrepos = opts.get(b'subrepos') | 5949 m = scmutil.match(repo[None], pats, opts) |
5950 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True) | 5950 subrepos = opts.get(b'subrepos') |
5951 return cmdutil.remove( | 5951 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True) |
5952 ui, repo, m, b"", uipathfn, after, force, subrepos, dryrun=dryrun | 5952 return cmdutil.remove( |
5953 ) | 5953 ui, repo, m, b"", uipathfn, after, force, subrepos, dryrun=dryrun |
5954 ) | |
5954 | 5955 |
5955 | 5956 |
5956 @command( | 5957 @command( |
5957 b'rename|move|mv', | 5958 b'rename|move|mv', |
5958 [ | 5959 [ |