Mercurial > hg
diff mercurial/dirstate.py @ 51069:a63e1f7987a7
dirstate: document the `changing_*` context manager
The methods that requires them have documentation, but the context themselves
had none. This is now fixed.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 12 Oct 2023 09:04:12 +0200 |
parents | 18c8c18993f0 |
children | 88ef80210d67 |
line wrap: on
line diff
--- a/mercurial/dirstate.py Tue Oct 10 10:47:46 2023 +0200 +++ b/mercurial/dirstate.py Thu Oct 12 09:04:12 2023 +0200 @@ -343,11 +343,52 @@ @contextlib.contextmanager def changing_parents(self, repo): + """Wrap a dirstate change related to a change of working copy parents + + This context scopes a series of dirstate modifications that match an + update of the working copy parents (typically `hg update`, `hg merge` + etc). + + The dirstate's methods that perform this kind of modifications require + this context to be present before being called. + Such methods are decorated with `@requires_changing_parents`. + + The new dirstate contents will be written to disk when the top-most + `changing_parents` context exits successfully. If an exception is + raised during a `changing_parents` context of any level, all changes + are invalidated. If this context is open within an open transaction, + the dirstate writing is delayed until that transaction is successfully + committed (and the dirstate is invalidated on transaction abort). + + The `changing_parents` operation is mutually exclusive with the + `changing_files` one. + """ with self._changing(repo, CHANGE_TYPE_PARENTS) as c: yield c @contextlib.contextmanager def changing_files(self, repo): + """Wrap a dirstate change related to the set of tracked files + + This context scopes a series of dirstate modifications that change the + set of tracked files. (typically `hg add`, `hg remove` etc) or some + dirstate stored information (like `hg rename --after`) but preserve + the working copy parents. + + The dirstate's methods that perform this kind of modifications require + this context to be present before being called. + Such methods are decorated with `@requires_changing_files`. + + The new dirstate contents will be written to disk when the top-most + `changing_files` context exits successfully. If an exception is raised + during a `changing_files` context of any level, all changes are + invalidated. If this context is open within an open transaction, the + dirstate writing is delayed until that transaction is successfully + committed (and the dirstate is invalidated on transaction abort). + + The `changing_files` operation is mutually exclusive with the + `changing_parents` one. + """ with self._changing(repo, CHANGE_TYPE_FILES) as c: yield c