Mercurial > public > mercurial-scm > hg-stable
diff hgext/largefiles/overrides.py @ 50085: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 | 0b4a6912292e |
children | c3c8ac540513 |
line wrap: on
line diff
--- a/hgext/largefiles/overrides.py Sun Feb 05 15:38:23 2023 +0100 +++ b/hgext/largefiles/overrides.py Wed Feb 15 11:51:58 2023 +0100 @@ -1545,11 +1545,19 @@ @eh.wrapfunction(scmutil, b'addremove') -def scmutiladdremove(orig, repo, matcher, prefix, uipathfn, opts=None): +def scmutiladdremove( + orig, + repo, + matcher, + prefix, + uipathfn, + opts=None, + open_tr=None, +): if opts is None: opts = {} if not lfutil.islfilesrepo(repo): - return orig(repo, matcher, prefix, uipathfn, opts) + return orig(repo, matcher, prefix, uipathfn, opts, open_tr=open_tr) # Get the list of missing largefiles so we can remove them lfdirstate = lfutil.openlfdirstate(repo.ui, repo) unsure, s, mtime_boundary = lfdirstate.status( @@ -1560,6 +1568,10 @@ unknown=False, ) + # open the transaction and changing_files context + if open_tr is not None: + open_tr() + # Call into the normal remove code, but the removing of the standin, we want # to have handled by original addremove. Monkey patching here makes sure # we don't remove the standin in the largefiles code, preventing a very @@ -1592,7 +1604,8 @@ # function to take care of the rest. Make sure it doesn't do anything with # largefiles by passing a matcher that will ignore them. matcher = composenormalfilematcher(matcher, repo[None].manifest(), added) - return orig(repo, matcher, prefix, uipathfn, opts) + + return orig(repo, matcher, prefix, uipathfn, opts, open_tr=open_tr) # Calling purge with --all will cause the largefiles to be deleted.