[PATCH] fix for ls --non-recursive with a path

rod rod at pu-gh.com
Sun Nov 16 15:28:23 GMT 2008


When executing "ls --non-recursive" specifying a path nothing is
returned.  This seems to be caused because of a check done to see if
the path of the object (file or directory, sorry I don't know the
bazaar terminology) contains a "/".  If it does then this is not
included in the output.  But, the path of these objects will contain
any path that I specified at the command line, so this will always
match and never return any results.

You can reproduce this by executing the following command inside the
main bazaar branch (you will get no results, when you should get a
listing of the files and folders in the root folder - you can also try
specifying subfolders eg. "bzrlib")

$> bzr ls --non-recursive ./

The following patch removes the prefix of any path specified when
doing the --non-recursive check.

=== modified file 'bzrlib/builtins.py'
--- bzrlib/builtins.py  2008-11-13 14:42:06 +0000
+++ bzrlib/builtins.py  2008-11-16 15:23:59 +0000
@@ -1968,7 +1968,7 @@
             for fp, fc, fkind, fid, entry in
tree.list_files(include_root=False):
                 if fp.startswith(relpath):
                     fp = osutils.pathjoin(prefix, fp[len(relpath):])
-                    if non_recursive and '/' in fp:
+                    if non_recursive and path is not None and '/' in
fp.replace(path,""):
                         continue
                     if not all and not selection[fc]:
                         continue

I also noticed that when specifying the --from-root argument, it
doesn't seem to matter if you use --non-recursive or not.  But I don't
know what the expected behaviour here should be.

Thanks,
rod.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: non-recursive.patch
Type: application/octet-stream
Size: 597 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20081116/390cf1d6/attachment.obj 


More information about the bazaar mailing list