[MERGE] bzr ls --debris

John Arbash Meinel john at arbash-meinel.com
Thu Jun 15 19:25:55 BST 2006


Aaron Bentley wrote:
> Hi all,
> 
> Here's an updated version of that patch that
> 1. renames the option to --debris
> 2. allows list_files to take a list of classifiers, with
> WorkingTree.debris_classifier being supplied by --debris.
> 
> Aaron

...

+    def test_ls_debris(self):
+        self.build_tree(['file',
+                         'file~',
+                         'file.BASE',
+                         'file.THIS',
+                         'file.OTHER',
+                         'test1234.tmp',
+                         'file.pyc'])
+        BzrDir.create_standalone_workingtree('.')
+        output = self.runbzr('ls --debris', backtick=True)

I thought 'self.runbzr' was mostly deprecated. Especially since you have
to pass the ugly 'backtick=True'.

What about using:

output = self.run_bzr('ls', '--debris')[0]

+        self.assertEqualDiff(output,
+                             'file.BASE\n'
+                             'file.OTHER\n'
+                             'file.THIS\n'
+                             'file~\n'
+                             'test1234.tmp\n')
+        wt = WorkingTree.open('.')
+        wt.add(['file.BASE', 'file~', 'test1234.tmp'])
+        output = self.runbzr('ls --debris', backtick=True)

Same here.

+        self.assertEqualDiff(output, 'file.OTHER\n' 'file.THIS\n')

...

Should debris_classifier be part of WorkingTree? It doesn't seem like
something WorkingTree is using directly. And seems more like we should
have maybe a separate file with customized classifiers.

Otherwise this looks fine.

+        classifiers = []
+        if debris:
+            classifiers.append(WorkingTree.debris_classifier)

         tree, relpath = WorkingTree.open_containing(u'.')
         if from_root:
@@ -1390,12 +1395,13 @@
         if revision is not None:
             tree = tree.branch.repository.revision_tree(
                 revision[0].in_history(tree.branch).rev_id)
-
-        for fp, fc, kind, fid, entry in tree.list_files():
+        for fp, fc, kind, fid, entry in \
+            tree.list_files(classifiers):
             if fp.startswith(relpath):
                 fp = fp[len(relpath):]
                 if non_recursive and '/' in fp:
                     continue
+
                 if not all and not selection[fc]:
                     continue
                 if verbose:


....

If we are switching to classifiers, then Tree.list_files also needs to
be fixed.
At the very least, we need to add a test which runs 'bzr ls --debris -r
1' so that this code path is tested.


-    def list_files(self):
+    def list_files(self, allow_detritus=False):
         # The only files returned by this are those from the version
         for path, entry in self.inventory.iter_entries():
             yield path, 'V', entry.kind, entry.file_id, entry
@@ -214,7 +214,7 @@
         assert self._inventory[file_id].kind == "root_directory"
         return "root_directory"

-    def list_files(self):
+    def list_files(self, allow_detritus=False):
         return iter([])

     def __contains__(self, file_id):


Other than needing to fix Tree.py, adding a test case, and deciding
whether or not 'debris_classifier' and 'is_debris_filename' should be
part of WorkingTree, +1.

John
=:->


-------------- 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/20060615/d90708d9/attachment.pgp 


More information about the bazaar mailing list