Mercurial > public > mercurial-scm > hg-stable
diff mercurial/context.py @ 23712:bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
Before this patch, the result of "status()" on "workingcommitctx" may
incorrectly contain files other than ones to be committed, because
"workingctx._dirstatestatus()" returns the result of
"dirstate.status()" directly.
For correct matching, this patch overrides "_dirstatestatus" in
"workingcommitctx" and makes it return matched files only in
"self._status".
This patch uses empty list for "deleted", "unknown" and "ignored" of
status, because status between "changectx"s also makes them empty.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Wed, 31 Dec 2014 17:55:43 +0900 |
parents | 1e6fb8db666e |
children | 4b56219a5ac2 |
line wrap: on
line diff
--- a/mercurial/context.py Wed Dec 31 17:55:43 2014 +0900 +++ b/mercurial/context.py Wed Dec 31 17:55:43 2014 +0900 @@ -1646,6 +1646,32 @@ listignored, listclean, listunknown) return s + def _dirstatestatus(self, match=None, ignored=False, clean=False, + unknown=False): + """Return matched files only in ``self._status`` + + Uncommitted files appear "clean" via this context, even if + they aren't actually so in the working directory. + """ + match = match or matchmod.always(self._repo.root, self._repo.getcwd()) + if clean: + clean = [f for f in self._manifest if f not in self._changedset] + else: + clean = [] + return scmutil.status([f for f in self._status.modified if match(f)], + [f for f in self._status.added if match(f)], + [f for f in self._status.removed if match(f)], + [], [], [], clean) + + @propertycache + def _changedset(self): + """Return the set of files changed in this context + """ + changed = set(self._status.modified) + changed.update(self._status.added) + changed.update(self._status.removed) + return changed + class memctx(committablectx): """Use memctx to perform in-memory commits via localrepo.commitctx().