Mercurial > hg
changeset 31259:6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
committablectx had a _manifest implementation that was only used by the derived
workingctx class. The other derived versions, like memctx and metadataonlyctx,
define their own _manifest functions.
Let's move the function down to workingctx, and let's break it into two parts,
the _manifest part that reads from self._status, and the part that actually
builds the new manifest. This separation will let us reuse the builder code in a
future patch to answer _buildstatus with varying status inputs, since workingctx
has special behavior for _buildstatus that the other ctx's don't have.
author | Durham Goode <durham@fb.com> |
---|---|
date | Tue, 07 Mar 2017 17:56:30 -0800 |
parents | c414e339e7af |
children | aac054e5389b |
files | mercurial/context.py |
diffstat | 1 files changed, 33 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/context.py Tue Mar 07 09:56:11 2017 -0800 +++ b/mercurial/context.py Tue Mar 07 17:56:30 2017 -0800 @@ -1266,35 +1266,6 @@ return self._repo.dirstate.flagfunc(self._buildflagfunc) @propertycache - def _manifest(self): - """generate a manifest corresponding to the values in self._status - - This reuse the file nodeid from parent, but we append an extra letter - when modified. Modified files get an extra 'm' while added files get - an extra 'a'. This is used by manifests merge to see that files - are different and by update logic to avoid deleting newly added files. - """ - parents = self.parents() - - man = parents[0].manifest().copy() - - ff = self._flagfunc - for i, l in ((addednodeid, self._status.added), - (modifiednodeid, self._status.modified)): - for f in l: - man[f] = i - try: - man.setflag(f, ff(f)) - except OSError: - pass - - for f in self._status.deleted + self._status.removed: - if f in man: - del man[f] - - return man - - @propertycache def _status(self): return self._repo.status() @@ -1655,6 +1626,39 @@ return s + @propertycache + def _manifest(self): + """generate a manifest corresponding to the values in self._status + + This reuse the file nodeid from parent, but we use special node + identifiers for added and modified files. This is used by manifests + merge to see that files are different and by update logic to avoid + deleting newly added files. + """ + return self._buildstatusmanifest(self._status) + + def _buildstatusmanifest(self, status): + """Builds a manifest that includes the given status results.""" + parents = self.parents() + + man = parents[0].manifest().copy() + + ff = self._flagfunc + for i, l in ((addednodeid, status.added), + (modifiednodeid, status.modified)): + for f in l: + man[f] = i + try: + man.setflag(f, ff(f)) + except OSError: + pass + + for f in status.deleted + status.removed: + if f in man: + del man[f] + + return man + def _buildstatus(self, other, s, match, listignored, listclean, listunknown): """build a status with respect to another context