mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 07:17:55 +03:00
log: evaluate filesets on working copy, not its parent
When running "hg log 'set:added()'", we create two matchers: one used for producing the revset and one used for finding files to match. In 185b6b930e8c (graphlog: evaluate FILE/-I/-X filesets on the working dir, 2012-02-26), we started passing a revision argument along from what's currently in cmdutil._makelogrevset() to revset._matchfiles(). When the revision was an empty string, it referred to the working copy. This was subtly done with "repo[rev or None]". Then, in 5ff5c5c9e69f (revset: avoid recalculating filesets, 2014-10-22), that conversion from empty string to None was lost. Note that repo[''] is equivalent to repo['.'], not repo[None]. The consequence of this, to the user, is that when running "hg log 'set:added()'", the file matcher matches files added in the working copy, while the revset matcher matches revisions that touch files added in the parent of the working copy. As a result, only revisions that touch any files added in the parent of the working copy will be considered, but they will only be included if they also touch files added in the working copy. Fix the bug by converting '' to None again, but make it a little more explicit this time (plus, we now have tests for it).
This commit is contained in:
parent
90400ce919
commit
4b40ac0110
@ -1048,7 +1048,8 @@ def _matchfiles(repo, subset, x):
|
||||
# i18n: "_matchfiles" is a keyword
|
||||
raise error.ParseError(_('_matchfiles expected at most one '
|
||||
'revision'))
|
||||
rev = value
|
||||
if value != '': # empty means working directory; leave rev as None
|
||||
rev = value
|
||||
elif prefix == 'd:':
|
||||
if default is not None:
|
||||
# i18n: "_matchfiles" is a keyword
|
||||
|
@ -72,14 +72,17 @@ Test log
|
||||
content1_content2_content3-tracked | 1 +
|
||||
3 files changed, 3 insertions(+), 0 deletions(-)
|
||||
|
||||
BROKEN: rev 0 affects content1_missing_content*-tracked
|
||||
|
||||
$ hg log -T '{rev}\n' --stat 'set:added()'
|
||||
1
|
||||
content1_missing_content1-tracked | 1 -
|
||||
content1_missing_content3-tracked | 1 -
|
||||
2 files changed, 0 insertions(+), 2 deletions(-)
|
||||
|
||||
0
|
||||
content1_missing_content1-tracked | 1 +
|
||||
content1_missing_content3-tracked | 1 +
|
||||
2 files changed, 2 insertions(+), 0 deletions(-)
|
||||
|
||||
$ hg log -T '{rev}\n' --stat 'set:removed()'
|
||||
1
|
||||
content1_content2_content1-untracked | 2 +-
|
||||
@ -100,22 +103,37 @@ BROKEN: rev 0 affects content1_missing_content*-tracked
|
||||
content1_content2_content3-untracked | 1 +
|
||||
content1_content2_missing-untracked | 1 +
|
||||
7 files changed, 7 insertions(+), 0 deletions(-)
|
||||
|
||||
BROKEN: rev 0 affects content1_content1_missing-tracked,
|
||||
content1_content2_missing-tracked and content1_missing_missing-tracked.
|
||||
rev 1 affects content1_content2_missing-tracked,
|
||||
content1_missing_missing-tracked and missing_content2_missing-tracked
|
||||
|
||||
|
||||
$ hg log -T '{rev}\n' --stat 'set:deleted()'
|
||||
|
||||
BROKEN: rev 0 and 1 affect content1_missing_content*-untracked
|
||||
|
||||
1
|
||||
content1_content2_missing-tracked | 2 +-
|
||||
content1_missing_missing-tracked | 1 -
|
||||
missing_content2_missing-tracked | 1 +
|
||||
3 files changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
0
|
||||
content1_content1_missing-tracked | 1 +
|
||||
content1_content2_missing-tracked | 1 +
|
||||
content1_missing_missing-tracked | 1 +
|
||||
3 files changed, 3 insertions(+), 0 deletions(-)
|
||||
|
||||
$ hg log -T '{rev}\n' --stat 'set:unknown()'
|
||||
|
||||
BROKEN: rev 1 affects content1_content2_content2-tracked and
|
||||
missing_content2_content2-tracked
|
||||
|
||||
1
|
||||
content1_missing_content1-untracked | 1 -
|
||||
content1_missing_content3-untracked | 1 -
|
||||
2 files changed, 0 insertions(+), 2 deletions(-)
|
||||
|
||||
0
|
||||
content1_missing_content1-untracked | 1 +
|
||||
content1_missing_content3-untracked | 1 +
|
||||
2 files changed, 2 insertions(+), 0 deletions(-)
|
||||
|
||||
$ hg log -T '{rev}\n' --stat 'set:clean()'
|
||||
1
|
||||
content1_content2_content2-tracked | 2 +-
|
||||
missing_content2_content2-tracked | 1 +
|
||||
2 files changed, 2 insertions(+), 1 deletions(-)
|
||||
|
||||
0
|
||||
content1_content1_content1-tracked | 1 +
|
||||
content1_content2_content2-tracked | 1 +
|
||||
|
Loading…
Reference in New Issue
Block a user