Find removed code?

JP Vossen jp at jpsdomain.org
Sat Dec 29 05:46:33 UTC 2012


Summary: here's a way to find "missing" lines that worked for me.

Is there a better way?


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I'm using bzr with etckeeper and I needed to find out when a certain 
machine left one of my DNS zone files.  I have about 100 etckeeper 
commits with log messages like "daily autocommit" so that's useless, and 
'bzr blame' won't help because the record *not* in the file.  That's the 
point, I wanted to know when it left and ideally, why.

Google and 'bzr help' didn't help.  'git log -S' (pickax) seemed useful, 
except that...I hate git and am using bzr... :-)

I tried 'bzr log -p | grep foo' and that sort-of worked, except that it 
did not provide any details about when/what revno the change happened. 
'bzr log -p | less' then manually searching for the string then paging 
around in the file does "work" but it's clunky at best.

'bzr grep -r 1.. foo <file>' was close enough.  It returned 
"filepath~N:string" which gave me a much more complete view than 'log 
-p' did, since it showed all revnos when the string existed, not just 
when it appeared and disappeared like 'log' did.

Since I was mostly interested in when it appeared and disappeared, I 
eyeballed the "filepath~N:string" output and built:
for revno in 24 28 49 77 89; do bzr log -r $revno <file>; done

As expected, that gave me useless (in this case) etckeeper log messages, 
but it also gave me dates.  And poking around 'bzr cat -r $revno | less' 
gave me enough clues as to what else was going on to answer my question.

Since I was  mostly interested in when it appeared and disappeared I 
could have picked that out of the 'bzr log -p | less' output, but I 
thought I'd keep looking and I think the 'bzr grep' was more generally 
useful.

So, I'm posting this as an FYI to any who find it via Google and to ask 
the list if I missing a better way.

For the record, this was bzr 2.1.2 with the grep 0.4.0 bzr-plugin from 
the stock Debian Squeeze repos.

Thanks,
JP
----------------------------|:::======|-------------------------------
JP Vossen, CISSP            |:::======|      http://bashcookbook.com/
My Account, My Opinions     |=========|      http://www.jpsdomain.org/
----------------------------|=========|-------------------------------
"Microsoft Tax" = the additional hardware & yearly fees for the add-on
software required to protect Windows from its own poorly designed and
implemented self, while the overhead incidentally flattens Moore's Law.



More information about the bazaar mailing list