Revision argument causes no matches to be found

Bug #667443 reported by Ben Jansen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
bzr-grep
In Progress
Medium
Parth Malwankar

Bug Description

If I specify a revision, bzr-grep outputs no results. For example, using the branch at lp:bzr-diff-revid, you see that without '-r' grep locates on instance of 'getattr' in the working tree. However, adding "-r -1" (for head) causes no match to be found. I've experimented and it appears that all values for the revision option cause matches to be missed.

aogail@bjansen-miroku> bzr st
aogail@bjansen-miroku> bzr grep getattr
__init__.py: if getattr(tree, 'get_revision_id', None) is None:
aogail@bjansen-miroku> bzr grep -r -1 getattr
aogail@bjansen-miroku>

Revision history for this message
Parth Malwankar (parthm) wrote :

I can reproduce this.
Seems like the 'getattr' is found if we specify the file on the command line but for some reason its missed when we don't do that.

[bzr-diff-revid]% bzr cat -r -1 __init__.py | grep getattr
    if getattr(tree, 'get_revision_id', None) is None:
[bzr-diff-revid]% bzr grep -r -1 getattr
[bzr-diff-revid]% bzr grep -r -2 getattr
[bzr-diff-revid]% bzr grep -r -2 getattr __init__.py
__init__.py~3: if getattr(tree, 'get_revision_id', None) is None:
[bzr-diff-revid]% bzr grep -r -1 getattr __init__.py
__init__.py~4: if getattr(tree, 'get_revision_id', None) is None:
[bzr-diff-revid]% bzr grep -r last:1 getattr __init__.py
__init__.py~4: if getattr(tree, 'get_revision_id', None) is None:
[bzr-diff-revid]% bzr grep -r last:1 getattr
[bzr-diff-revid]%

Changed in bzr-grep:
status: New → In Progress
importance: Undecided → High
assignee: nobody → Parth Malwankar (parthm)
Revision history for this message
Parth Malwankar (parthm) wrote :

I looked into this some more. It looks format related. After I upgraded the format from 0.92 to 2a it worked fine.

[bzr-diff-revid-2]% bzr grep -r -1 getattr
__init__.py~4: if getattr(tree, 'get_revision_id', None) is None:
[bzr-diff-revid-2]% bzr info
Standalone tree (format: 2a)
Location:
  branch root: .

Related branches:
  parent branch: bzr+ssh://bazaar.launchpad.net/%2Bbranch/bzr-diff-revid/
[bzr-diff-revid-2]%

I will investigate this further but am lowering the priority to medium. As a workaround please consider upgrading the format to 2a. As a bonus it comes with other goodies like performance and lower memory requirements :-)

I was initially surprised that something so fundamental was broken as we do have tests for this :-)

Changed in bzr-grep:
importance: High → Medium
Revision history for this message
Ben Jansen (aogail) wrote :

Ah. FWIW, this bug also occurs on the 1.14 format. Unfortunately we have a large internal project on 1.14 that isn't going to upgrade any time soon from what I can tell.

Revision history for this message
Parth Malwankar (parthm) wrote :

There is something funny happening here. If I create a standalone repo from scratch the command seems to work fine. I tried this for pack-0.92 and 1.14. Is there something different about your repo. Is it shared? Maybe imported from svn?
I can reproduce this on bzr-diff-revid. The format for bzr-diff-revid is:

Format:
       control: Meta directory format 1
  working tree: Working tree format 6
        branch: Branch format 6
    repository: Packs containing knits without subtree support

The format when I init with pack-0.92 is:

Format:
       control: Meta directory format 1
  working tree: Working tree format 4
        branch: Branch format 6
    repository: Packs containing knits without subtree support

So there is a minor difference in working tree format.

Log of test done with 1.14 and pack-0.92:

[tmp]% bzr init grepfail --format=1.14
Created a standalone tree (format: 1.14)
[tmp]% cd grepfail
[grepfail]% touch abc
[grepfail]% bzr add
adding abc
[grepfail]% echo "hello" > abc
[grepfail]% bzr ci -m "added abc"
Committing to: /home/parthm/tmp/grepfail/
added abc
Committed revision 1.
[grepfail]% echo "world" >> abc
[grepfail]% bzr ci -m "added world"
Committing to: /home/parthm/tmp/grepfail/
modified abc
Committed revision 2.
[grepfail]% bzr grep -r -1 hello
abc~2:hello
[grepfail]% cd ..

[tmp]% bzr init grepfail-92 --format=pack-0.92
Created a standalone tree (format: pack-0.92)
[tmp]% cd grepfail-92
[grepfail-92]% echo hello > abc
[grepfail-92]% bzr add
adding abc
[grepfail-92]% bzr ci -m "added abc"
Committing to: /home/parthm/tmp/grepfail-92/
added abc
Committed revision 1.
[grepfail-92]% echo world >> abc
[grepfail-92]% bzr ci -m "added world"
Committing to: /home/parthm/tmp/grepfail-92/
modified abc
Committed revision 2.
[grepfail-92]% bzr grep -r -1 hello
abc~2:hello
[grepfail-92]%

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.