Mercurial > hg-stable
changeset 50102:2264e775512b
subrepo: use `changing_files` context in subrepository code
This is better, not ideal, but better.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 25 Jan 2023 12:51:26 +0100 |
parents | bbe3a65bbd96 |
children | 3c431f7551dd |
files | mercurial/subrepo.py |
diffstat | 1 files changed, 63 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/subrepo.py Sat Feb 04 12:14:19 2023 +0100 +++ b/mercurial/subrepo.py Wed Jan 25 12:51:26 2023 +0100 @@ -569,15 +569,20 @@ @annotatesubrepoerror def add(self, ui, match, prefix, uipathfn, explicitonly, **opts): - return cmdutil.add( - ui, - self._repo, - match, - prefix, - uipathfn, - explicitonly, - **opts, - ) + # XXX Ideally, we could let the caller take the `changing_files` + # context. However this is not an abstraction that make sense for + # other repository types, and leaking that details purely related to + # dirstate seems unfortunate. So for now the context will be used here. + with self._repo.wlock(), self._repo.dirstate.changing_files(self._repo): + return cmdutil.add( + ui, + self._repo, + match, + prefix, + uipathfn, + explicitonly, + **opts, + ) @annotatesubrepoerror def addremove(self, m, prefix, uipathfn, opts): @@ -586,7 +591,18 @@ # be used to process sibling subrepos however. opts = copy.copy(opts) opts[b'subrepos'] = True - return scmutil.addremove(self._repo, m, prefix, uipathfn, opts) + # XXX Ideally, we could let the caller take the `changing_files` + # context. However this is not an abstraction that make sense for + # other repository types, and leaking that details purely related to + # dirstate seems unfortunate. So for now the context will be used here. + with self._repo.wlock(), self._repo.dirstate.changing_files(self._repo): + return scmutil.addremove( + self._repo, + m, + prefix, + uipathfn, + opts, + ) @annotatesubrepoerror def cat(self, match, fm, fntemplate, prefix, **opts): @@ -952,16 +968,21 @@ @annotatesubrepoerror def forget(self, match, prefix, uipathfn, dryrun, interactive): - return cmdutil.forget( - self.ui, - self._repo, - match, - prefix, - uipathfn, - True, - dryrun=dryrun, - interactive=interactive, - ) + # XXX Ideally, we could let the caller take the `changing_files` + # context. However this is not an abstraction that make sense for + # other repository types, and leaking that details purely related to + # dirstate seems unfortunate. So for now the context will be used here. + with self._repo.wlock(), self._repo.dirstate.changing_files(self._repo): + return cmdutil.forget( + self.ui, + self._repo, + match, + prefix, + uipathfn, + True, + dryrun=dryrun, + interactive=interactive, + ) @annotatesubrepoerror def removefiles( @@ -975,17 +996,22 @@ dryrun, warnings, ): - return cmdutil.remove( - self.ui, - self._repo, - matcher, - prefix, - uipathfn, - after, - force, - subrepos, - dryrun, - ) + # XXX Ideally, we could let the caller take the `changing_files` + # context. However this is not an abstraction that make sense for + # other repository types, and leaking that details purely related to + # dirstate seems unfortunate. So for now the context will be used here. + with self._repo.wlock(), self._repo.dirstate.changing_files(self._repo): + return cmdutil.remove( + self.ui, + self._repo, + matcher, + prefix, + uipathfn, + after, + force, + subrepos, + dryrun, + ) @annotatesubrepoerror def revert(self, substate, *pats, **opts): @@ -1015,7 +1041,12 @@ pats = [b'set:modified()'] else: pats = [] - cmdutil.revert(self.ui, self._repo, ctx, *pats, **opts) + # XXX Ideally, we could let the caller take the `changing_files` + # context. However this is not an abstraction that make sense for + # other repository types, and leaking that details purely related to + # dirstate seems unfortunate. So for now the context will be used here. + with self._repo.wlock(), self._repo.dirstate.changing_files(self._repo): + cmdutil.revert(self.ui, self._repo, ctx, *pats, **opts) def shortid(self, revid): return revid[:12]