Marking directories in 'bzr status'
John Arbash Meinel
john at arbash-meinel.com
Tue Dec 5 17:25:02 GMT 2006
Ralf Doering wrote:
> Hi,
>
> I wonder if we break anything if we add a trailing slash to the output
> for directories when doing 'bzr status'? This is especially helpful
> for "unknown" entries to decide whether one has to fiddle with
> '--no-recurse' on 'bzr add'.
>
> Adding this slash is simple and involves only a few lines in
> bzrlib/status.py. I attached a simple patch for this (made against
> bzr.dev branch, but should apply cleanly against 0.12 and 0.13)
>
> Ralf
>
Unfortunately, this isn't quite a complete fix.
1) 'bzr status' can be run from a subdirectory, which still outputs the
complete path of files. So this would be checking the wrong path for
some of the files.
2) It might have some performance implications, especially for large
trees. 'os.path.isdir()' does a 'lstat()' of the supplied path. Looking
closely at the code, it seems to only be called for unknown files, so
hopefully that list is small.
3) It is possible that the target tree isn't actually the working tree.
You can do 'bzr status -r -3..-2' for example. Now there shouldn't be
any unknown files when comparing 2 revision trees, but it seems a little
incorrect to depend on this without being explicit about it.
Our unknows/extras handling is incorrect anyway, though. Because at the
moment we recurse through the whole directory structure to find changes
between the source and the target, and *then* we recurse again to look
for unknown files. Fortunately it is doing readdir() and then filtering
rather than doing stats of all the files a second time.
But in reality our delta operator should be capable of generating proper
entries for unknowns, so that we only recurse 1 time. And that would
also mean that we already have the file kind, etc.
Anyway, the attached fix does what you want, even when we are in a
subdirectory. It isn't a perfect fix, but it is api compatible (we add
an optional parameter to list_paths()) And it also ensures that things
work when in a sub-directory, etc.
I'd really rather see this sort of thing cleaned up at a different
level, though.
It also gives support to Aaron's argument that Tree and RevisionTree
shouldn't have an .unknowns() member.
A better fix might be to have unknowns() yield more information than
just plain paths. Then we wouldn't have to worry about stating them
after the fact.
But the best fix is to change 'delta.changes_from()' so that it can
include information about both missing files, and unknown files.
Aaron, does your _iter_changes_from help with any of this?
John
=:->
-------------- next part --------------
A non-text attachment was scrubbed...
Name: add_slash_to_unknowns.diff
Type: text/x-patch
Size: 1802 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20061205/1fa2b752/attachment.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20061205/1fa2b752/attachment.pgp
More information about the bazaar
mailing list