[PATCH] bzr: Specify files to diff on command line

Michael Ellerman michael+bazaar at ellerman.id.au
Mon Apr 11 17:50:25 BST 2005

Hi Martin & Bzr fans,

Chris Mason posted a patch the other day to allow specifying files on the diff 
command line, but I think we can be a bit faster about it.

I've reworked the list_files() functions so we can "descend" a file or a 
directory, and that way when we get a file_list in list_files() we can just 
call descend() on each item and it will do the right thing.

There's still a few wrinkles in here. We need to sanitise the path names 
coming from the command line, at the moment we assume they're relative to the 
repository root and don't contain any ../ weirdness etc. This breaks 'bzr 
diff .' anywhere other than the root for example. Also 'bzr diff foo/' will 
give you 'foo//bar' in your diff headers. There's also no support for '*' in 
cmd_args, so for now bzr diff requires an argument, use '*' to get the old 
behaviour. I could fix these but it's late and I'm going to bed, perhaps the 
lazy-web will fix it while I sleep =D

Some numbers. This is a kernel repo, there's 8 changed files, 14K diff. I ran 
these all multiple times, the numbers below are representative. Cache is hot.

	[michael at concordia 2.6.11] time quilt diff > /dev/null
	real    0m0.195s user    0m0.060s sys     0m0.075s

Quilt is fast, cause it knows what's changed and it has full text of both 
revisions already sitting on disk (actually problably in RAM).

	[michael at concordia 2.6.11] time bzr diff > /dev/null
	real    0m53.320s user    0m10.475s sys     0m1.648s

Not so fast =D - yet!

	[michael at concordia 2.6.11] time ~/src/baz/local/bzr diff > /dev/null
	real    0m52.888s user    0m10.585s sys     0m1.715s

This is my updated descend(), just to make sure it's not worse.

	[michael at concordiatime ~/src/baz/local/bzr diff $(quilt files) > /dev/null
	real    0m4.654s user    0m4.125s sys     0m0.061s

And *if* we knew what files had changed we'd be this fast. Although there are 
plenty of occaisions where *you* know what's changed and so I think this is 
still helpful.

	[michael at concordia 2.6.11] time ~/src/baz/local/bzr diff $(quilt files)
	real    0m4.413s user    0m3.889s sys     0m0.062s

Just as a test this is how long it takes us to startup, and run 
Branch.basis_tree() and Branch.working_tree() (ie. returning on line ~1011 of 
bzrlib/commands.py). So the actual diff routine on 8 files is almost free.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: bzr-diff-with-file-list.patch
Type: text/x-diff
Size: 7545 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20050412/e0c3a9ec/attachment.bin 

More information about the bazaar mailing list