Rev 5203: (garyvdm for gagern) Add --directory (-d) option to a number of in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Tue May 4 18:32:52 BST 2010
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5203 [merge]
revision-id: pqm at pqm.ubuntu.com-20100504173248-nksnwwqdg0xki8r2
parent: pqm at pqm.ubuntu.com-20100504161538-nhdb4c9wi380e2aa
parent: martin.vgagern at gmx.net-20100503091915-pxo6gxs42gbesse3
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2010-05-04 18:32:48 +0100
message:
(garyvdm for gagern) Add --directory (-d) option to a number of
commands.
added:
bzrlib/tests/blackbox/test_deleted.py test_deleted.py-20100502192334-2n4phr831u3tq6bl-1
bzrlib/tests/blackbox/test_lookup_revision.py test_lookup_revision-20100502193624-95yx8byn08gv5rtr-1
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/option.py option.py-20051014052914-661fb36e76e7362f
bzrlib/tests/blackbox/__init__.py __init__.py-20051128053524-eba30d8255e08dc3
bzrlib/tests/blackbox/test_added.py test_added.py-20060119085008-6b8b90369d42a26c
bzrlib/tests/blackbox/test_annotate.py testannotate.py-20051013044000-457f44801bfa9d39
bzrlib/tests/blackbox/test_bound_branches.py test_bound_branches.py-20051109215527-2373188ad566c205
bzrlib/tests/blackbox/test_cat.py test_cat.py-20051201162916-f0937e4e19ea24b3
bzrlib/tests/blackbox/test_cat_revision.py test_cat_revision.py-20070410204634-fq8mnld5l5aza9e2-1
bzrlib/tests/blackbox/test_clean_tree.py test_clean_tree.py-20090219235516-em1ybc01twsqacx9-1
bzrlib/tests/blackbox/test_export.py test_export.py-20051229024010-e6c26658e460fb1c
bzrlib/tests/blackbox/test_ignore.py test_ignore.py-20060703063225-4tm8dc2pa7wwg2t3-1
bzrlib/tests/blackbox/test_ignored.py test_ignored.py-20060518234732-373c9c3035c3558f
bzrlib/tests/blackbox/test_ls.py test_ls.py-20060712232047-0jraqpecwngee12y-1
bzrlib/tests/blackbox/test_modified.py test_modified.py-20080424085848-nwqjenan4dq2vq3w-1
bzrlib/tests/blackbox/test_nick.py test_nick.py-20061105141046-p7zovcsit44uj4w9-1
bzrlib/tests/blackbox/test_re_sign.py test_re_sign.py-20060214165921-4d04eba231454693
bzrlib/tests/blackbox/test_unknowns.py test_unknowns.py-20070905015344-74tg6s1synijo2oe-1
=== modified file 'NEWS'
--- a/NEWS 2010-05-04 02:41:17 +0000
+++ b/NEWS 2010-05-04 17:32:48 +0000
@@ -30,6 +30,12 @@
pack operation.
(Parth Malwankar, #304320)
+* Support ``--directory`` option for a number of additional commands:
+ added, annotate, bind, cat, cat-revision, clean-tree, deleted,
+ export, ignore, ignored, lookup-revision, ls, modified, nick,
+ re-sign, unbind, unknowns.
+ (Martin von Gagern, #527878)
+
Bug Fixes
*********
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py 2010-05-03 09:07:50 +0000
+++ b/bzrlib/builtins.py 2010-05-04 17:32:48 +0000
@@ -232,6 +232,14 @@
return view_info
+def _open_directory_or_containing_tree_or_branch(filename, directory):
+ """Open the tree or branch containing the specified file, unless
+ the --directory option is used to specify a different branch."""
+ if directory is not None:
+ return (None, Branch.open(directory), filename)
+ return bzrdir.BzrDir.open_containing_tree_or_branch(filename)
+
+
# TODO: Make sure no commands unconditionally use the working directory as a
# branch. If a filename argument is used, the first of them should be used to
# specify the branch. (Perhaps this can be factored out into some kind of
@@ -340,7 +348,7 @@
hidden = True
takes_args = ['revision_id?']
- takes_options = ['revision']
+ takes_options = ['directory', 'revision']
# cat-revision is more for frontends so should be exact
encoding = 'strict'
@@ -353,14 +361,14 @@
self.outf.write(revtext.decode('utf-8'))
@display_command
- def run(self, revision_id=None, revision=None):
+ def run(self, revision_id=None, revision=None, directory=u'.'):
if revision_id is not None and revision is not None:
raise errors.BzrCommandError('You can only supply one of'
' revision_id or --revision')
if revision_id is None and revision is None:
raise errors.BzrCommandError('You must supply either'
' --revision or a revision_id')
- b = WorkingTree.open_containing(u'.')[0].branch
+ b = WorkingTree.open_containing(directory)[0].branch
revisions = b.repository.revisions
if revisions is None:
@@ -554,12 +562,9 @@
takes_args = ['revision_info*']
takes_options = [
'revision',
- Option('directory',
+ custom_help('directory',
help='Branch to examine, '
- 'rather than the one containing the working directory.',
- short_name='d',
- type=unicode,
- ),
+ 'rather than the one containing the working directory.'),
Option('tree', help='Show revno of working tree'),
]
@@ -960,12 +965,9 @@
takes_options = ['remember', 'overwrite', 'revision',
custom_help('verbose',
help='Show logs of pulled revisions.'),
- Option('directory',
+ custom_help('directory',
help='Branch to pull into, '
- 'rather than the one containing the working directory.',
- short_name='d',
- type=unicode,
- ),
+ 'rather than the one containing the working directory.'),
Option('local',
help="Perform a local pull in a bound "
"branch. Local pulls are not applied to "
@@ -1088,12 +1090,9 @@
Option('create-prefix',
help='Create the path leading up to the branch '
'if it does not already exist.'),
- Option('directory',
+ custom_help('directory',
help='Branch to push from, '
- 'rather than the one containing the working directory.',
- short_name='d',
- type=unicode,
- ),
+ 'rather than the one containing the working directory.'),
Option('use-existing-dir',
help='By default push will fail if the target'
' directory exists, but does not already'
@@ -2003,11 +2002,11 @@
# level of effort but possibly much less IO. (Or possibly not,
# if the directories are very large...)
_see_also = ['status', 'ls']
- takes_options = ['show-ids']
+ takes_options = ['directory', 'show-ids']
@display_command
- def run(self, show_ids=False):
- tree = WorkingTree.open_containing(u'.')[0]
+ def run(self, show_ids=False, directory=u'.'):
+ tree = WorkingTree.open_containing(directory)[0]
tree.lock_read()
self.add_cleanup(tree.unlock)
old = tree.basis_tree()
@@ -2028,15 +2027,15 @@
hidden = True
_see_also = ['status', 'ls']
- takes_options = [
+ takes_options = ['directory',
Option('null',
help='Write an ascii NUL (\\0) separator '
'between files rather than a newline.')
]
@display_command
- def run(self, null=False):
- tree = WorkingTree.open_containing(u'.')[0]
+ def run(self, null=False, directory=u'.'):
+ tree = WorkingTree.open_containing(directory)[0]
td = tree.changes_from(tree.basis_tree())
for path, id, kind, text_modified, meta_modified in td.modified:
if null:
@@ -2051,15 +2050,15 @@
hidden = True
_see_also = ['status', 'ls']
- takes_options = [
+ takes_options = ['directory',
Option('null',
help='Write an ascii NUL (\\0) separator '
'between files rather than a newline.')
]
@display_command
- def run(self, null=False):
- wt = WorkingTree.open_containing(u'.')[0]
+ def run(self, null=False, directory=u'.'):
+ wt = WorkingTree.open_containing(directory)[0]
wt.lock_read()
self.add_cleanup(wt.unlock)
basis = wt.basis_tree()
@@ -2073,7 +2072,7 @@
if inv.is_root(file_id) and len(basis_inv) == 0:
continue
path = inv.id2path(file_id)
- if not os.access(osutils.abspath(path), os.F_OK):
+ if not os.access(osutils.pathjoin(wt.basedir, path), os.F_OK):
continue
if null:
self.outf.write(path + '\0')
@@ -2539,12 +2538,13 @@
help='List entries of a particular kind: file, directory, symlink.',
type=unicode),
'show-ids',
+ 'directory',
]
@display_command
def run(self, revision=None, verbose=False,
recursive=False, from_root=False,
unknown=False, versioned=False, ignored=False,
- null=False, kind=None, show_ids=False, path=None):
+ null=False, kind=None, show_ids=False, path=None, directory=None):
if kind and kind not in ('file', 'directory', 'symlink'):
raise errors.BzrCommandError('invalid kind specified')
@@ -2562,8 +2562,8 @@
raise errors.BzrCommandError('cannot specify both --from-root'
' and PATH')
fs_path = path
- tree, branch, relpath = bzrdir.BzrDir.open_containing_tree_or_branch(
- fs_path)
+ tree, branch, relpath = \
+ _open_directory_or_containing_tree_or_branch(fs_path, directory)
# Calculate the prefix to use
prefix = None
@@ -2638,10 +2638,11 @@
hidden = True
_see_also = ['ls']
+ takes_options = ['directory']
@display_command
- def run(self):
- for f in WorkingTree.open_containing(u'.')[0].unknowns():
+ def run(self, directory=u'.'):
+ for f in WorkingTree.open_containing(directory)[0].unknowns():
self.outf.write(osutils.quotefn(f) + '\n')
@@ -2712,12 +2713,13 @@
_see_also = ['status', 'ignored', 'patterns']
takes_args = ['name_pattern*']
- takes_options = [
+ takes_options = ['directory',
Option('default-rules',
help='Display the default ignore rules that bzr uses.')
]
- def run(self, name_pattern_list=None, default_rules=None):
+ def run(self, name_pattern_list=None, default_rules=None,
+ directory=u'.'):
from bzrlib import ignores
if default_rules is not None:
# dump the default rules and exit
@@ -2734,7 +2736,7 @@
(len(name_pattern) > 1 and name_pattern[1] == ':')):
raise errors.BzrCommandError(
"NAME_PATTERN should not be an absolute path")
- tree, relpath = WorkingTree.open_containing(u'.')
+ tree, relpath = WorkingTree.open_containing(directory)
ignores.tree_ignores_add_patterns(tree, name_pattern_list)
ignored = globbing.Globster(name_pattern_list)
matches = []
@@ -2766,10 +2768,11 @@
encoding_type = 'replace'
_see_also = ['ignore', 'ls']
+ takes_options = ['directory']
@display_command
- def run(self):
- tree = WorkingTree.open_containing(u'.')[0]
+ def run(self, directory=u'.'):
+ tree = WorkingTree.open_containing(directory)[0]
tree.lock_read()
self.add_cleanup(tree.unlock)
for path, file_class, kind, file_id, entry in tree.list_files():
@@ -2788,15 +2791,16 @@
"""
hidden = True
takes_args = ['revno']
+ takes_options = ['directory']
@display_command
- def run(self, revno):
+ def run(self, revno, directory=u'.'):
try:
revno = int(revno)
except ValueError:
raise errors.BzrCommandError("not a valid revision-number: %r"
% revno)
- revid = WorkingTree.open_containing(u'.')[0].branch.get_rev_id(revno)
+ revid = WorkingTree.open_containing(directory)[0].branch.get_rev_id(revno)
self.outf.write("%s\n" % revid)
@@ -2829,7 +2833,7 @@
================= =========================
"""
takes_args = ['dest', 'branch_or_subdir?']
- takes_options = [
+ takes_options = ['directory',
Option('format',
help="Type of file to export to.",
type=unicode),
@@ -2844,11 +2848,11 @@
'revision in which it was changed.'),
]
def run(self, dest, branch_or_subdir=None, revision=None, format=None,
- root=None, filters=False, per_file_timestamps=False):
+ root=None, filters=False, per_file_timestamps=False, directory=u'.'):
from bzrlib.export import export
if branch_or_subdir is None:
- tree = WorkingTree.open_containing(u'.')[0]
+ tree = WorkingTree.open_containing(directory)[0]
b = tree.branch
subdir = None
else:
@@ -2873,7 +2877,7 @@
"""
_see_also = ['ls']
- takes_options = [
+ takes_options = ['directory',
Option('name-from-revision', help='The path name in the old tree.'),
Option('filters', help='Apply content filters to display the '
'convenience form.'),
@@ -2884,12 +2888,12 @@
@display_command
def run(self, filename, revision=None, name_from_revision=False,
- filters=False):
+ filters=False, directory=None):
if revision is not None and len(revision) != 1:
raise errors.BzrCommandError("bzr cat --revision takes exactly"
" one revision specifier")
tree, branch, relpath = \
- bzrdir.BzrDir.open_containing_tree_or_branch(filename)
+ _open_directory_or_containing_tree_or_branch(filename, directory)
branch.lock_read()
self.add_cleanup(branch.unlock)
return self._run(tree, branch, relpath, filename, revision,
@@ -3380,8 +3384,9 @@
_see_also = ['info']
takes_args = ['nickname?']
- def run(self, nickname=None):
- branch = Branch.open_containing(u'.')[0]
+ takes_options = ['directory']
+ def run(self, nickname=None, directory=u'.'):
+ branch = Branch.open_containing(directory)[0]
if nickname is None:
self.printme(branch)
else:
@@ -3793,12 +3798,9 @@
' completely merged into the source, pull from the'
' source rather than merging. When this happens,'
' you do not need to commit the result.'),
- Option('directory',
+ custom_help('directory',
help='Branch to merge into, '
- 'rather than the one containing the working directory.',
- short_name='d',
- type=unicode,
- ),
+ 'rather than the one containing the working directory.'),
Option('preview', help='Instead of merging, show a diff of the'
' merge.'),
Option('interactive', help='Select changes interactively.',
@@ -4578,15 +4580,16 @@
Option('long', help='Show commit date in annotations.'),
'revision',
'show-ids',
+ 'directory',
]
encoding_type = 'exact'
@display_command
def run(self, filename, all=False, long=False, revision=None,
- show_ids=False):
+ show_ids=False, directory=None):
from bzrlib.annotate import annotate_file, annotate_file_tree
wt, branch, relpath = \
- bzrdir.BzrDir.open_containing_tree_or_branch(filename)
+ _open_directory_or_containing_tree_or_branch(filename, directory)
if wt is not None:
wt.lock_read()
self.add_cleanup(wt.unlock)
@@ -4619,14 +4622,14 @@
hidden = True # is this right ?
takes_args = ['revision_id*']
- takes_options = ['revision']
+ takes_options = ['directory', 'revision']
- def run(self, revision_id_list=None, revision=None):
+ def run(self, revision_id_list=None, revision=None, directory=u'.'):
if revision_id_list is not None and revision is not None:
raise errors.BzrCommandError('You can only supply one of revision_id or --revision')
if revision_id_list is None and revision is None:
raise errors.BzrCommandError('You must supply either --revision or a revision_id')
- b = WorkingTree.open_containing(u'.')[0].branch
+ b = WorkingTree.open_containing(directory)[0].branch
b.lock_write()
self.add_cleanup(b.unlock)
return self._run(b, revision_id_list, revision)
@@ -4693,10 +4696,10 @@
_see_also = ['checkouts', 'unbind']
takes_args = ['location?']
- takes_options = []
+ takes_options = ['directory']
- def run(self, location=None):
- b, relpath = Branch.open_containing(u'.')
+ def run(self, location=None, directory=u'.'):
+ b, relpath = Branch.open_containing(directory)
if location is None:
try:
location = b.get_old_bound_location()
@@ -4729,10 +4732,10 @@
_see_also = ['checkouts', 'bind']
takes_args = []
- takes_options = []
+ takes_options = ['directory']
- def run(self):
- b, relpath = Branch.open_containing(u'.')
+ def run(self, directory=u'.'):
+ b, relpath = Branch.open_containing(directory)
if not b.unbind():
raise errors.BzrCommandError('Local branch is not bound')
@@ -4902,9 +4905,8 @@
'result in a dynamically allocated port. The default port '
'depends on the protocol.',
type=str),
- Option('directory',
- help='Serve contents of this directory.',
- type=unicode),
+ custom_help('directory',
+ help='Serve contents of this directory.'),
Option('allow-writes',
help='By default the server is a readonly server. Supplying '
'--allow-writes enables write access to the contents of '
@@ -5339,11 +5341,8 @@
Option('delete',
help='Delete this tag rather than placing it.',
),
- Option('directory',
- help='Branch in which to place the tag.',
- short_name='d',
- type=unicode,
- ),
+ custom_help('directory',
+ help='Branch in which to place the tag.'),
Option('force',
help='Replace existing tags.',
),
@@ -5392,11 +5391,8 @@
_see_also = ['tag']
takes_options = [
- Option('directory',
- help='Branch whose tags should be displayed.',
- short_name='d',
- type=unicode,
- ),
+ custom_help('directory',
+ help='Branch whose tags should be displayed.'),
RegistryOption.from_kwargs('sort',
'Sort tags by different criteria.', title='Sorting',
alpha='Sort tags lexicographically (default).',
@@ -5966,7 +5962,8 @@
To check what clean-tree will do, use --dry-run.
"""
- takes_options = [Option('ignored', help='Delete all ignored files.'),
+ takes_options = ['directory',
+ Option('ignored', help='Delete all ignored files.'),
Option('detritus', help='Delete conflict files, merge'
' backups, and failed selftest dirs.'),
Option('unknown',
@@ -5975,14 +5972,14 @@
' deleting them.'),
Option('force', help='Do not prompt before deleting.')]
def run(self, unknown=False, ignored=False, detritus=False, dry_run=False,
- force=False):
+ force=False, directory=u'.'):
from bzrlib.clean_tree import clean_tree
if not (unknown or ignored or detritus):
unknown = True
if dry_run:
force = True
- clean_tree('.', unknown=unknown, ignored=ignored, detritus=detritus,
- dry_run=dry_run, no_prompt=force)
+ clean_tree(directory, unknown=unknown, ignored=ignored,
+ detritus=detritus, dry_run=dry_run, no_prompt=force)
class cmd_reference(Command):
=== modified file 'bzrlib/option.py'
--- a/bzrlib/option.py 2010-04-20 08:47:38 +0000
+++ b/bzrlib/option.py 2010-05-03 09:19:15 +0000
@@ -570,6 +570,8 @@
_global_option('dry-run',
help="Show what would be done, but don't actually do anything.")
_global_option('name-from-revision', help='The path name in the old tree.')
+_global_option('directory', short_name='d', type=unicode,
+ help='Branch to operate on, instead of working directory')
diff_writer_registry = _mod_registry.Registry()
diff_writer_registry.register('plain', lambda x: x, 'Plaintext diff output.')
=== modified file 'bzrlib/tests/blackbox/__init__.py'
--- a/bzrlib/tests/blackbox/__init__.py 2010-04-26 13:51:08 +0000
+++ b/bzrlib/tests/blackbox/__init__.py 2010-05-03 09:19:15 +0000
@@ -52,6 +52,7 @@
'bzrlib.tests.blackbox.test_commit',
'bzrlib.tests.blackbox.test_conflicts',
'bzrlib.tests.blackbox.test_debug',
+ 'bzrlib.tests.blackbox.test_deleted',
'bzrlib.tests.blackbox.test_diff',
'bzrlib.tests.blackbox.test_dump_btree',
'bzrlib.tests.blackbox.test_dpush',
@@ -71,6 +72,7 @@
'bzrlib.tests.blackbox.test_locale',
'bzrlib.tests.blackbox.test_log',
'bzrlib.tests.blackbox.test_logformats',
+ 'bzrlib.tests.blackbox.test_lookup_revision',
'bzrlib.tests.blackbox.test_ls',
'bzrlib.tests.blackbox.test_lsprof',
'bzrlib.tests.blackbox.test_merge',
=== modified file 'bzrlib/tests/blackbox/test_added.py'
--- a/bzrlib/tests/blackbox/test_added.py 2009-03-23 14:59:43 +0000
+++ b/bzrlib/tests/blackbox/test_added.py 2010-05-02 20:10:25 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2006 Canonical Ltd
+# Copyright (C) 2006-2010 Canonical Ltd
# -*- coding: utf-8 -*-
#
# This program is free software; you can redistribute it and/or modify
@@ -67,3 +67,11 @@
# after commit, now no longer listed
tree.commit(message='add "%s"' % (name))
check_added('')
+
+ def test_added_directory(self):
+ """Test --directory option"""
+ tree = self.make_branch_and_tree('a')
+ self.build_tree(['a/README'])
+ tree.add('README')
+ out, err = self.run_bzr(['added', '--directory=a'])
+ self.assertEquals('README\n', out)
=== modified file 'bzrlib/tests/blackbox/test_annotate.py'
--- a/bzrlib/tests/blackbox/test_annotate.py 2010-03-24 14:15:01 +0000
+++ b/bzrlib/tests/blackbox/test_annotate.py 2010-05-02 20:10:25 +0000
@@ -278,3 +278,12 @@
os.chdir('branch')
out, err = self.run_bzr('annotate empty')
self.assertEqual('', out)
+
+ def test_annotate_directory(self):
+ """Test --directory option"""
+ wt = self.make_branch_and_tree('a')
+ self.build_tree_contents([('a/hello.txt', 'my helicopter\n')])
+ wt.add(['hello.txt'])
+ wt.commit('commit', committer='test at user')
+ out, err = self.run_bzr('annotate -d a hello.txt')
+ self.assertEqualDiff('1 test at us | my helicopter\n', out)
=== modified file 'bzrlib/tests/blackbox/test_bound_branches.py'
--- a/bzrlib/tests/blackbox/test_bound_branches.py 2010-02-04 16:06:36 +0000
+++ b/bzrlib/tests/blackbox/test_bound_branches.py 2010-05-02 20:10:25 +0000
@@ -422,6 +422,21 @@
self.check_revno(4)
self.check_revno(4, '../base')
+ def test_bind_directory(self):
+ """Test --directory option"""
+ tree = self.make_branch_and_tree('base')
+ self.build_tree(['base/a', 'base/b'])
+ tree.add('a', 'b')
+ tree.commit(message='init')
+ branch = tree.branch
+ tree.bzrdir.sprout('child')
+ self.run_bzr('bind --directory=child base')
+ d = BzrDir.open('child')
+ self.assertNotEqual(None, d.open_branch().get_master_branch())
+ self.run_bzr('unbind -d child')
+ self.assertEqual(None, d.open_branch().get_master_branch())
+ self.run_bzr('unbind --directory child', retcode=3)
+
class TestBind(script.TestCaseWithTransportAndScript):
=== modified file 'bzrlib/tests/blackbox/test_cat.py'
--- a/bzrlib/tests/blackbox/test_cat.py 2010-02-23 07:43:11 +0000
+++ b/bzrlib/tests/blackbox/test_cat.py 2010-05-02 18:16:37 +0000
@@ -199,3 +199,22 @@
self.vfs_transport_factory = memory.MemoryServer
self.run_bzr_error(['^bzr: ERROR: Not a branch'],
['cat', self.get_url()])
+
+ def test_cat_directory(self):
+ wt = self.make_branch_and_tree('a')
+ self.build_tree(['a/README'])
+ wt.add('README')
+ wt.commit('Making sure there is a basis_tree available')
+
+ out, err = self.run_bzr_subprocess(['cat', '--directory=a', 'README'])
+ self.assertEqual('contents of a/README\n', out)
+
+ def test_cat_remote_directory(self):
+ wt = self.make_branch_and_tree('a')
+ self.build_tree(['a/README'])
+ wt.add('README')
+ wt.commit('Making sure there is a basis_tree available')
+
+ url = self.get_readonly_url() + '/a'
+ out, err = self.run_bzr_subprocess(['cat', '-d', url, 'README'])
+ self.assertEqual('contents of a/README\n', out)
=== modified file 'bzrlib/tests/blackbox/test_cat_revision.py'
--- a/bzrlib/tests/blackbox/test_cat_revision.py 2010-02-15 20:23:34 +0000
+++ b/bzrlib/tests/blackbox/test_cat_revision.py 2010-05-02 20:10:25 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2004, 2005, 2007 Canonical Ltd
+# Copyright (C) 2004-2010 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -64,4 +64,10 @@
err = self.run_bzr('cat-revision abcd', retcode=3)[1]
self.assertContainsRe(err, 'The repository .* contains no revision abcd.')
-
+ def test_cat_revision_directory(self):
+ """Test --directory option"""
+ tree = self.make_branch_and_tree('a')
+ tree.commit('This revision', rev_id='abcd')
+ output, errors = self.run_bzr(['cat-revision', '-d', 'a', u'abcd'])
+ self.assertContainsRe(output, 'This revision')
+ self.assertEqual('', errors)
=== modified file 'bzrlib/tests/blackbox/test_clean_tree.py'
--- a/bzrlib/tests/blackbox/test_clean_tree.py 2009-03-23 14:59:43 +0000
+++ b/bzrlib/tests/blackbox/test_clean_tree.py 2010-05-02 20:10:25 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005, 2009 Canonical Ltd
+# Copyright (C) 2005-2010 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -62,3 +62,13 @@
self.failIfExists('name')
self.failIfExists('name~')
self.failIfExists('name.pyc')
+
+ def test_clean_tree_directory(self):
+ """Test --directory option"""
+ tree = self.make_branch_and_tree('a')
+ self.build_tree(['a/added', 'a/unknown', 'a/ignored'])
+ tree.add('added')
+ self.run_bzr('clean-tree -d a --unknown --ignored --force')
+ self.failIfExists('a/unknown')
+ self.failIfExists('a/ignored')
+ self.failUnlessExists('a/added')
=== added file 'bzrlib/tests/blackbox/test_deleted.py'
--- a/bzrlib/tests/blackbox/test_deleted.py 1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/blackbox/test_deleted.py 2010-05-02 20:10:25 +0000
@@ -0,0 +1,37 @@
+# Copyright (C) 2010 Canonical Ltd
+# -*- coding: utf-8 -*-
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+
+"""Black-box tests for 'bzr deleted', which shows newly deleted files."""
+
+import os
+
+from bzrlib.branch import Branch
+from bzrlib.tests.blackbox import ExternalBase
+
+
+class TestDeleted(ExternalBase):
+
+ def test_deleted_directory(self):
+ """Test --directory option"""
+ tree = self.make_branch_and_tree('a')
+ self.build_tree(['a/README'])
+ tree.add('README')
+ tree.commit('r1')
+ tree.remove('README')
+ out, err = self.run_bzr(['deleted', '--directory=a'])
+ self.assertEquals('README\n', out)
=== modified file 'bzrlib/tests/blackbox/test_export.py'
--- a/bzrlib/tests/blackbox/test_export.py 2010-04-19 04:10:53 +0000
+++ b/bzrlib/tests/blackbox/test_export.py 2010-05-02 20:10:25 +0000
@@ -313,3 +313,9 @@
har_st = os.stat('t/har')
self.assertEquals(315532800, har_st.st_mtime)
+ def test_export_directory(self):
+ """Test --directory option"""
+ self.example_branch()
+ self.run_bzr(['export', '--directory=branch', 'latest'])
+ self.assertEqual(['goodbye', 'hello'], sorted(os.listdir('latest')))
+ self.check_file_contents('latest/goodbye', 'baz')
=== modified file 'bzrlib/tests/blackbox/test_ignore.py'
--- a/bzrlib/tests/blackbox/test_ignore.py 2010-04-22 12:45:03 +0000
+++ b/bzrlib/tests/blackbox/test_ignore.py 2010-05-03 09:19:15 +0000
@@ -156,3 +156,9 @@
" and match your ignore pattern:\nb\n"\
"These files will continue to be version controlled"\
" unless you 'bzr remove' them.\n")
+
+ def test_ignore_directory(self):
+ """Test --directory option"""
+ tree = self.make_branch_and_tree('a')
+ self.run_bzr(['ignore', '--directory=a', 'README'])
+ self.check_file_contents('a/.bzrignore', 'README\n')
=== modified file 'bzrlib/tests/blackbox/test_ignored.py'
--- a/bzrlib/tests/blackbox/test_ignored.py 2009-03-23 14:59:43 +0000
+++ b/bzrlib/tests/blackbox/test_ignored.py 2010-05-02 20:10:25 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2006 Canonical Ltd
+# Copyright (C) 2006-2010 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -38,3 +38,11 @@
out, err = self.run_bzr('ignored')
self.assertEqual('', out)
self.assertEqual('', err)
+
+ def test_ignored_directory(self):
+ """Test --directory option"""
+ tree = self.make_branch_and_tree('a')
+ self.build_tree_contents([('a/README', 'contents'),
+ ('a/.bzrignore', 'README')])
+ out, err = self.run_bzr(['ignored', '--directory=a'])
+ self.assertStartsWith(out, 'README')
=== added file 'bzrlib/tests/blackbox/test_lookup_revision.py'
--- a/bzrlib/tests/blackbox/test_lookup_revision.py 1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/blackbox/test_lookup_revision.py 2010-05-02 20:10:25 +0000
@@ -0,0 +1,33 @@
+# Copyright (C) 2010 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+
+"""Black-box tests for bzr lookup-revision.
+"""
+
+import os
+
+from bzrlib import tests
+
+class TestLookupRevision(tests.TestCaseWithTransport):
+
+ def test_lookup_revison_directory(self):
+ """Test --directory option"""
+ tree = self.make_branch_and_tree('a')
+ tree.commit('This revision', rev_id='abcd')
+ out, err = self.run_bzr(['lookup-revision', '-d', 'a', '1'])
+ self.assertEqual('abcd\n', out)
+ self.assertEqual('', err)
=== modified file 'bzrlib/tests/blackbox/test_ls.py'
--- a/bzrlib/tests/blackbox/test_ls.py 2010-02-17 17:11:16 +0000
+++ b/bzrlib/tests/blackbox/test_ls.py 2010-05-02 20:10:25 +0000
@@ -18,7 +18,7 @@
import os
-from bzrlib import ignores
+from bzrlib import ignores, osutils
from bzrlib.tests import TestCaseWithTransport
@@ -235,3 +235,12 @@
'%s/a\n'
% (self.test_dir, self.test_dir),
self.test_dir, recursive=False)
+
+ def test_ls_directory(self):
+ """Test --directory option"""
+ self.wt = self.make_branch_and_tree('dir')
+ self.build_tree(['dir/sub/', 'dir/sub/file'])
+ self.wt.add(['sub', 'sub/file'])
+ self.wt.commit('commit')
+ self.ls_equals('sub/\nsub/file\n', '--directory=dir')
+ self.ls_equals('sub/file\n', '-d dir sub')
=== modified file 'bzrlib/tests/blackbox/test_modified.py'
--- a/bzrlib/tests/blackbox/test_modified.py 2009-03-23 14:59:43 +0000
+++ b/bzrlib/tests/blackbox/test_modified.py 2010-05-02 20:10:25 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2006 Canonical Ltd
+# Copyright (C) 2006-2010 Canonical Ltd
# -*- coding: utf-8 -*-
#
# This program is free software; you can redistribute it and/or modify
@@ -70,3 +70,12 @@
tree.commit(message='modified %s' %(name))
check_modified('')
+ def test_modified_directory(self):
+ """Test --directory option"""
+ tree = self.make_branch_and_tree('a')
+ self.build_tree(['a/README'])
+ tree.add('README')
+ tree.commit('r1')
+ self.build_tree_contents([('a/README', 'changed\n')])
+ out, err = self.run_bzr(['modified', '--directory=a'])
+ self.assertEquals('README\n', out)
=== modified file 'bzrlib/tests/blackbox/test_nick.py'
--- a/bzrlib/tests/blackbox/test_nick.py 2010-03-01 16:17:57 +0000
+++ b/bzrlib/tests/blackbox/test_nick.py 2010-05-02 20:10:25 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005, 2006 Canonical Ltd
+# Copyright (C) 2005-2010 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -78,3 +78,12 @@
child.branch.get_config().has_explicit_nickname())
osutils.rmtree('../base')
self.assertEqual('child', self.run_bzr('nick')[0][:-1])
+
+ def test_nick_directory(self):
+ """Test --directory option"""
+ self.make_branch_and_tree('me.dev')
+ nick = self.run_bzr(['nick', '--directory=me.dev'])[0]
+ self.assertEqual('me.dev\n', nick)
+ self.run_bzr(['nick', '-d', 'me.dev', 'moo'])
+ nick = self.run_bzr(['nick', '--directory', 'me.dev'])[0]
+ self.assertEqual('moo\n', nick)
=== modified file 'bzrlib/tests/blackbox/test_re_sign.py'
--- a/bzrlib/tests/blackbox/test_re_sign.py 2010-01-25 17:48:22 +0000
+++ b/bzrlib/tests/blackbox/test_re_sign.py 2010-05-02 20:10:25 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005 Canonical Ltd
+# Copyright (C) 2005-2010 Canonical Ltd
# -*- coding: utf-8 -*-
#
# This program is free software; you can redistribute it and/or modify
@@ -88,3 +88,16 @@
self.assertEqualSignature(repo, 'A')
self.assertEqualSignature(repo, 'B')
self.assertEqualSignature(repo, 'C')
+
+ def test_resign_directory(self):
+ """Test --directory option"""
+ wt = BzrDir.create_standalone_workingtree('a')
+ wt.commit("base A", allow_pointless=True, rev_id='A')
+ wt.commit("base B", allow_pointless=True, rev_id='B')
+ wt.commit("base C", allow_pointless=True, rev_id='C')
+ repo = wt.branch.repository
+ self.monkey_patch_gpg()
+ self.run_bzr('re-sign --directory=a -r revid:A')
+ self.assertEqualSignature(repo, 'A')
+ self.run_bzr('re-sign -d a B')
+ self.assertEqualSignature(repo, 'B')
=== modified file 'bzrlib/tests/blackbox/test_unknowns.py'
--- a/bzrlib/tests/blackbox/test_unknowns.py 2009-03-23 14:59:43 +0000
+++ b/bzrlib/tests/blackbox/test_unknowns.py 2010-05-02 20:10:25 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2007 Canonical Ltd
+# Copyright (C) 2007-2010 Canonical Ltd
# -*- coding: utf-8 -*-
#
# This program is free software; you can redistribute it and/or modify
@@ -45,3 +45,10 @@
# after all added, none shown
tree.add(['b', 'c'])
self.assertEquals(self.run_bzr('unknowns')[0], '')
+
+ def test_unknowns_directory(self):
+ """Test --directory option"""
+ tree = self.make_branch_and_tree('a')
+ self.build_tree(['a/README'])
+ out, err = self.run_bzr(['unknowns', '--directory=a'])
+ self.assertEquals('README\n', out)
More information about the bazaar-commits
mailing list