Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/context.py @ 23711:1e6fb8db666e
context: avoid breaking already fixed self._status at ctx.status()
Before this patch, "status()" on "workingcommitctx" with "always
match" object causes breaking "self._status" in
"workingctx._buildstatus()", because "workingctx._buildstatus()"
caches the result of "dirstate.status()" into "self._status" for
efficiency, even though it should be fixed at construction for
committing.
For example, template function "diff()" without any patterns in
"committemplate" implies "status()" on "workingcommitctx" with "always
match" object, via "basectx.diff()" and "patch.diff()".
Then, broken "self._status" causes committing unexpected files.
To avoid breaking already fixed "self._status" at "ctx.status()", this
patch overrides "_buildstatus" in "workingcommitctx".
This patch doesn't write out the result of template function "diff()"
in "committemplate" in "test-commit.t", because matching against files
to be committed still has an issue fixed in subsequent patch.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Wed, 31 Dec 2014 17:55:43 +0900 |
parents | 745e3b485632 |
children | bfce25d25c96 |
comparison
equal
deleted
inserted
replaced
23710:745e3b485632 | 23711:1e6fb8db666e |
---|---|
1632 def __init__(self, repo, changes, | 1632 def __init__(self, repo, changes, |
1633 text="", user=None, date=None, extra=None): | 1633 text="", user=None, date=None, extra=None): |
1634 super(workingctx, self).__init__(repo, text, user, date, extra, | 1634 super(workingctx, self).__init__(repo, text, user, date, extra, |
1635 changes) | 1635 changes) |
1636 | 1636 |
1637 def _buildstatus(self, other, s, match, | |
1638 listignored, listclean, listunknown): | |
1639 """Prevent ``workingctx._buildstatus`` from changing ``self._status`` | |
1640 """ | |
1641 s = self._dirstatestatus(match, listignored, listclean, listunknown) | |
1642 if other != self._repo['.']: | |
1643 # workingctx._buildstatus doesn't change self._status in this case | |
1644 superself = super(workingcommitctx, self) | |
1645 s = superself._buildstatus(other, s, match, | |
1646 listignored, listclean, listunknown) | |
1647 return s | |
1648 | |
1637 class memctx(committablectx): | 1649 class memctx(committablectx): |
1638 """Use memctx to perform in-memory commits via localrepo.commitctx(). | 1650 """Use memctx to perform in-memory commits via localrepo.commitctx(). |
1639 | 1651 |
1640 Revision information is supplied at initialization time while | 1652 Revision information is supplied at initialization time while |
1641 related files data and is made available through a callback | 1653 related files data and is made available through a callback |