# HG changeset patch # User Pierre-Yves David # Date 2021-07-07 22:58:44 # Node ID 0cef28b121a4a3752407a61215b4c82a5d048476 # Parent f927ad5a4e2c8ffdf4b1ff10104dc41d95bb983c context: use `dirstate.set_tracked` in `context.add` This is the new shiny API. Differential Revision: https://phab.mercurial-scm.org/D11014 diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -1701,12 +1701,8 @@ class workingctx(committablectx): % uipath(f) ) rejected.append(f) - elif ds[f] in b'amn': + elif not ds.set_tracked(f): ui.warn(_(b"%s already tracked!\n") % uipath(f)) - elif ds[f] == b'r': - ds.normallookup(f) - else: - ds.add(f) return rejected def forget(self, files, prefix=b""): diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -85,7 +85,7 @@ def requires_parents_change(func): def requires_no_parents_change(func): def wrap(self, *args, **kwargs): - if not self.pendingparentchange(): + if self.pendingparentchange(): msg = 'calling `%s` inside of a parentchange context' msg %= func.__name__ raise error.ProgrammingError(msg)