Mercurial > public > mercurial-scm > hg
comparison mercurial/scmutil.py @ 50029:28dfb2df4ab9
commit: use `dirstate.change_files` to scope the associated `addremove`
This was significantly more complicated than I expected, because multiple
extensions get in the way.
I introduced a context that lazily open the transaction and associated context
to work around these complication. See the inline documentation for details.
Introducing the wrapping transaction remove the need for dirstate-guard (one of
the ultimate goal of all this), and slightly affect the result of a `hg
rollback` after a `hg commit --addremove`. That last part is deemed fine. It
aligns the behavior with what happens after a failed `hg commit --addremove` and
nobody should be using `hg rollback` anyway.
The small output change in the test come from the different transaction timing
and fact the transaction now backup the dirstate before the addremove, which
might mean "no file to backup" when the repository starts from an empty state.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 15 Feb 2023 11:51:58 +0100 |
parents | 1bd33932713d |
children | 4bddc2f72879 |
comparison
equal
deleted
inserted
replaced
50028:a46dfc2b58a3 | 50029:28dfb2df4ab9 |
---|---|
1217 repair.delayedstrip( | 1217 repair.delayedstrip( |
1218 repo.ui, repo, tostrip, operation, backup=backup | 1218 repo.ui, repo, tostrip, operation, backup=backup |
1219 ) | 1219 ) |
1220 | 1220 |
1221 | 1221 |
1222 def addremove(repo, matcher, prefix, uipathfn, opts=None): | 1222 def addremove(repo, matcher, prefix, uipathfn, opts=None, open_tr=None): |
1223 if opts is None: | 1223 if opts is None: |
1224 opts = {} | 1224 opts = {} |
1225 m = matcher | 1225 m = matcher |
1226 dry_run = opts.get(b'dry_run') | 1226 dry_run = opts.get(b'dry_run') |
1227 try: | 1227 try: |
1277 | 1277 |
1278 renames = _findrenames( | 1278 renames = _findrenames( |
1279 repo, m, added + unknown, removed + deleted, similarity, uipathfn | 1279 repo, m, added + unknown, removed + deleted, similarity, uipathfn |
1280 ) | 1280 ) |
1281 | 1281 |
1282 if not dry_run: | 1282 if not dry_run and (unknown or forgotten or deleted or renames): |
1283 if open_tr is not None: | |
1284 open_tr() | |
1283 _markchanges(repo, unknown + forgotten, deleted, renames) | 1285 _markchanges(repo, unknown + forgotten, deleted, renames) |
1284 | 1286 |
1285 for f in rejected: | 1287 for f in rejected: |
1286 if f in m.files(): | 1288 if f in m.files(): |
1287 return 1 | 1289 return 1 |