Rev 4052: Make ls aware of views (Eduardo O. Padoan) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Wed Feb 25 23:12:28 GMT 2009
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 4052
revision-id: pqm at pqm.ubuntu.com-20090225231224-r2fv2iqcgezje0zt
parent: pqm at pqm.ubuntu.com-20090225220024-b81h6glz8zi2ekfh
parent: ian.clatworthy at canonical.com-20090225222908-flpnjxwsxpmcyz60
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2009-02-25 23:12:24 +0000
message:
Make ls aware of views (Eduardo O. Padoan)
modified:
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/diff.py diff.py-20050309040759-26944fbbf2ebbf36
bzrlib/tests/blackbox/test_filtered_view_ops.py test_filtered_view_o-20081110012645-5t7ogtola0l33lkg-1
bzrlib/tests/workingtree_implementations/test_views.py test_views.py-20080729134135-v4zjnb85eu9srl80-1
bzrlib/views.py views.py-20080729082027-1ouh6t9cdobc0eea-1
------------------------------------------------------------
revno: 4048.1.2
revision-id: ian.clatworthy at canonical.com-20090225222908-flpnjxwsxpmcyz60
parent: ian.clatworthy at canonical.com-20090225132514-ltdzwbeswxjixt84
committer: Ian Clatworthy <ian.clatworthy at canonical.com>
branch nick: ianc-integration
timestamp: Thu 2009-02-26 08:29:08 +1000
message:
fix broken test for ls -r
modified:
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
------------------------------------------------------------
revno: 4048.1.1
revision-id: ian.clatworthy at canonical.com-20090225132514-ltdzwbeswxjixt84
parent: pqm at pqm.ubuntu.com-20090225063528-m6c41lna1xu4bdwm
parent: eduardo.padoan at gmail.com-20090224225613-4acsk5hc9xxkj5im
committer: Ian Clatworthy <ian.clatworthy at canonical.com>
branch nick: ianc-integration
timestamp: Wed 2009-02-25 23:25:14 +1000
message:
Make ls aware of views (Eduardo O. Padoan)
modified:
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/diff.py diff.py-20050309040759-26944fbbf2ebbf36
bzrlib/tests/blackbox/test_filtered_view_ops.py test_filtered_view_o-20081110012645-5t7ogtola0l33lkg-1
bzrlib/tests/workingtree_implementations/test_views.py test_views.py-20080729134135-v4zjnb85eu9srl80-1
bzrlib/views.py views.py-20080729082027-1ouh6t9cdobc0eea-1
------------------------------------------------------------
revno: 4032.4.6
revision-id: eduardo.padoan at gmail.com-20090224225613-4acsk5hc9xxkj5im
parent: eduardo.padoan at gmail.com-20090224191824-4djnk963syhx8lrt
committer: Eduardo Padoan <eduardo.padoan at gmail.com>
branch nick: lsview
timestamp: Tue 2009-02-24 19:56:13 -0300
message:
Fixed the 'ignoring ...' message for ls.
modified:
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/tests/blackbox/test_filtered_view_ops.py test_filtered_view_o-20081110012645-5t7ogtola0l33lkg-1
------------------------------------------------------------
revno: 4032.4.5
revision-id: eduardo.padoan at gmail.com-20090224191824-4djnk963syhx8lrt
parent: eduardo.padoan at gmail.com-20090223155657-yn119cfkr4mpdfru
committer: Eduardo Padoan <eduardo.padoan at gmail.com>
branch nick: lsview
timestamp: Tue 2009-02-24 16:18:24 -0300
message:
Check if the tree supports views only once when ls is called.
modified:
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
------------------------------------------------------------
revno: 4032.4.4
revision-id: eduardo.padoan at gmail.com-20090223155657-yn119cfkr4mpdfru
parent: eduardo.padoan at gmail.com-20090223155510-wyxf2xykkspqugjt
committer: Eduardo Padoan <eduardo.padoan at gmail.com>
branch nick: lsview
timestamp: Mon 2009-02-23 12:56:57 -0300
message:
Added tests for ls when using a view.
modified:
bzrlib/tests/blackbox/test_filtered_view_ops.py test_filtered_view_o-20081110012645-5t7ogtola0l33lkg-1
------------------------------------------------------------
revno: 4032.4.3
revision-id: eduardo.padoan at gmail.com-20090223155510-wyxf2xykkspqugjt
parent: eduardo.padoan at gmail.com-20090223055902-tvr42ej98tx72vyz
committer: Eduardo Padoan <eduardo.padoan at gmail.com>
branch nick: lsview
timestamp: Mon 2009-02-23 12:55:10 -0300
message:
Added tests for views.check_path_in_view()
modified:
bzrlib/tests/workingtree_implementations/test_views.py test_views.py-20080729134135-v4zjnb85eu9srl80-1
------------------------------------------------------------
revno: 4032.4.2
revision-id: eduardo.padoan at gmail.com-20090223055902-tvr42ej98tx72vyz
parent: eduardo.padoan at gmail.com-20090223055715-6cqqzjt7bo00v0zf
committer: Eduardo Padoan <eduardo.padoan at gmail.com>
branch nick: lsview
timestamp: Mon 2009-02-23 02:59:02 -0300
message:
Make ls show only files on the current view.
modified:
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
------------------------------------------------------------
revno: 4032.4.1
revision-id: eduardo.padoan at gmail.com-20090223055715-6cqqzjt7bo00v0zf
parent: pqm at pqm.ubuntu.com-20090223012623-0epa5dpnb7sk0tef
committer: Eduardo Padoan <eduardo.padoan at gmail.com>
branch nick: lsview
timestamp: Mon 2009-02-23 02:57:15 -0300
message:
Moved diff._check_path_in_view() to views.check_path_in_view()
modified:
bzrlib/diff.py diff.py-20050309040759-26944fbbf2ebbf36
bzrlib/views.py views.py-20080729082027-1ouh6t9cdobc0eea-1
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py 2009-02-25 15:36:48 +0000
+++ b/bzrlib/builtins.py 2009-02-25 23:12:24 +0000
@@ -2304,6 +2304,14 @@
if revision is not None or tree is None:
tree = _get_one_revision_tree('ls', revision, branch=branch)
+ apply_view = False
+ if isinstance(tree, WorkingTree) and tree.supports_views():
+ view_files = tree.views.lookup_view()
+ if view_files:
+ apply_view = True
+ view_str = views.view_display_str(view_files)
+ note("ignoring files outside view: %s" % view_str)
+
tree.lock_read()
try:
for fp, fc, fkind, fid, entry in tree.list_files(include_root=False):
@@ -2315,6 +2323,11 @@
continue
if kind is not None and fkind != kind:
continue
+ if apply_view:
+ try:
+ views.check_path_in_view(tree, fp)
+ except errors.FileOutsideView:
+ continue
kindch = entry.kind_character()
outstring = fp + kindch
if verbose:
=== modified file 'bzrlib/diff.py'
--- a/bzrlib/diff.py 2009-02-23 15:29:35 +0000
+++ b/bzrlib/diff.py 2009-02-25 13:25:14 +0000
@@ -334,7 +334,7 @@
bzrdir.BzrDir.open_containing_tree_or_branch(old_url)
if consider_relpath and relpath != '':
if working_tree is not None and apply_view:
- _check_path_in_view(working_tree, relpath)
+ views.check_path_in_view(working_tree, relpath)
specific_files.append(relpath)
old_tree = _get_tree_to_diff(old_revision_spec, working_tree, branch)
@@ -346,7 +346,7 @@
bzrdir.BzrDir.open_containing_tree_or_branch(new_url)
if consider_relpath and relpath != '':
if working_tree is not None and apply_view:
- _check_path_in_view(working_tree, relpath)
+ views.check_path_in_view(working_tree, relpath)
specific_files.append(relpath)
new_tree = _get_tree_to_diff(new_revision_spec, working_tree, branch,
basis_is_default=working_tree is None)
@@ -376,15 +376,6 @@
extra_trees = (working_tree,)
return old_tree, new_tree, specific_files, extra_trees
-
-def _check_path_in_view(tree, relpath):
- """If a working tree has a view enabled, check the path is within it."""
- if tree.supports_views():
- view_files = tree.views.lookup_view()
- if view_files and not osutils.is_inside_any(view_files, relpath):
- raise errors.FileOutsideView(relpath, view_files)
-
-
def _get_tree_to_diff(spec, tree=None, branch=None, basis_is_default=True):
if branch is None and tree is not None:
branch = tree.branch
=== modified file 'bzrlib/tests/blackbox/test_filtered_view_ops.py'
--- a/bzrlib/tests/blackbox/test_filtered_view_ops.py 2009-02-11 00:41:15 +0000
+++ b/bzrlib/tests/blackbox/test_filtered_view_ops.py 2009-02-24 22:56:13 +0000
@@ -142,6 +142,15 @@
'current view: a, b\n', err)
self.assertEquals('', out)
+ def test_view_on_ls(self):
+ wt = self.make_abc_tree_with_ab_view()
+ self.run_bzr('add')
+ out, err = self.run_bzr('ls')
+ out_lines = out.splitlines()
+ self.assertEquals('ignoring files outside view: a, b\n', err)
+ self.assertEquals('a', out_lines[0])
+ self.assertEquals('b', out_lines[1])
+
class TestViewTreeOperationss(TestCaseWithTransport):
=== modified file 'bzrlib/tests/workingtree_implementations/test_views.py'
--- a/bzrlib/tests/workingtree_implementations/test_views.py 2009-02-23 15:42:47 +0000
+++ b/bzrlib/tests/workingtree_implementations/test_views.py 2009-02-25 13:25:14 +0000
@@ -21,7 +21,7 @@
"""
-from bzrlib import errors
+from bzrlib import views, errors
from bzrlib.tests import TestSkipped
from bzrlib.workingtree import WorkingTree
@@ -141,6 +141,22 @@
self.assertRaises(errors.NoSuchView,
wt.views.delete_view, view_name + '2')
+ def test_check_path_in_view(self):
+ wt = self.make_branch_and_tree('wt')
+ view_current = 'view-name'
+ view_dict = {
+ view_current: ['dir-1'],
+ 'other-name': ['dir-2']}
+ wt.views.set_view_info(view_current, view_dict)
+ self.assertEqual(views.check_path_in_view(wt, 'dir-1'), None)
+ self.assertEqual(views.check_path_in_view(wt, 'dir-1/sub'), None)
+ self.assertRaises(errors.FileOutsideView,
+ views.check_path_in_view, wt, 'dir-2')
+ self.assertRaises(errors.FileOutsideView,
+ views.check_path_in_view, wt, 'dir-2/sub')
+ self.assertRaises(errors.FileOutsideView,
+ views.check_path_in_view, wt, 'other')
+
class TestUnsupportedViews(TestCaseWithWorkingTree):
"""Formats that don't support views should give reasonable errors."""
=== modified file 'bzrlib/views.py'
--- a/bzrlib/views.py 2009-02-23 15:42:47 +0000
+++ b/bzrlib/views.py 2009-02-25 13:25:14 +0000
@@ -27,6 +27,7 @@
from bzrlib import (
errors,
+ osutils,
)
@@ -273,3 +274,11 @@
return ", ".join(view_files)
else:
return ", ".join([v.encode(encoding, 'replace') for v in view_files])
+
+
+def check_path_in_view(tree, relpath):
+ """If a working tree has a view enabled, check the path is within it."""
+ if tree.supports_views():
+ view_files = tree.views.lookup_view()
+ if view_files and not osutils.is_inside_any(view_files, relpath):
+ raise errors.FileOutsideView(relpath, view_files)
More information about the bazaar-commits
mailing list