81
81
def tree_files_for_add(file_list):
82
"""Add handles files a bit differently so it a custom implementation."""
83
Return a tree and list of absolute paths from a file list.
85
Similar to tree_files, but add handles files a bit differently, so it a
86
custom implementation. In particular, MutableTreeTree.smart_add expects
87
absolute paths, which it immediately converts to relative paths.
89
# FIXME Would be nice to just return the relative paths like
90
# internal_tree_files does, but there are a large number of unit tests
91
# that assume the current interface to mutabletree.smart_add
84
tree = WorkingTree.open_containing(file_list[0])[0]
93
tree, relpath = WorkingTree.open_containing(file_list[0])
85
94
if tree.supports_views():
86
95
view_files = tree.views.lookup_view()
88
97
for filename in file_list:
89
98
if not osutils.is_inside_any(view_files, filename):
90
99
raise errors.FileOutsideView(filename, view_files)
100
file_list = file_list[:]
101
file_list[0] = tree.abspath(relpath)
92
103
tree = WorkingTree.open_containing(u'.')[0]
93
104
if tree.supports_views():
3257
3268
if cache_dir is not None:
3258
3269
tree_creator.TreeCreator.CACHE_ROOT = osutils.abspath(cache_dir)
3260
print 'testing: %s' % (osutils.realpath(sys.argv[0]),)
3261
print ' %s (%s python%s)' % (
3263
bzrlib.version_string,
3264
bzrlib._format_version_tuple(sys.version_info),
3267
3270
if testspecs_list is not None:
3268
3271
pattern = '|'.join(testspecs_list)
5596
5594
dry_run=dry_run, no_prompt=force)
5599
def _create_prefix(cur_transport):
5600
needed = [cur_transport]
5601
# Recurse upwards until we can create a directory successfully
5603
new_transport = cur_transport.clone('..')
5604
if new_transport.base == cur_transport.base:
5605
raise errors.BzrCommandError(
5606
"Failed to create path prefix for %s."
5607
% cur_transport.base)
5609
new_transport.mkdir('.')
5610
except errors.NoSuchFile:
5611
needed.append(new_transport)
5612
cur_transport = new_transport
5597
class cmd_reference(Command):
5598
"""list, view and set branch locations for nested trees.
5600
If no arguments are provided, lists the branch locations for nested trees.
5601
If one argument is provided, display the branch location for that tree.
5602
If two arguments are provided, set the branch location for that tree.
5607
takes_args = ['path?', 'location?']
5609
def run(self, path=None, location=None):
5611
if path is not None:
5613
tree, branch, relpath =(
5614
bzrdir.BzrDir.open_containing_tree_or_branch(branchdir))
5615
if path is not None:
5618
tree = branch.basis_tree()
5620
info = branch._get_all_reference_info().iteritems()
5621
self._display_reference_info(tree, branch, info)
5615
# Now we only need to create child directories
5617
cur_transport = needed.pop()
5618
cur_transport.ensure_base()
5623
file_id = tree.path2id(path)
5625
raise errors.NotVersionedError(path)
5626
if location is None:
5627
info = [(file_id, branch.get_reference_info(file_id))]
5628
self._display_reference_info(tree, branch, info)
5630
branch.set_reference_info(file_id, path, location)
5632
def _display_reference_info(self, tree, branch, info):
5634
for file_id, (path, location) in info:
5636
path = tree.id2path(file_id)
5637
except errors.NoSuchId:
5639
ref_list.append((path, location))
5640
for path, location in sorted(ref_list):
5641
self.outf.write('%s %s\n' % (path, location))
5621
5644
# these get imported and then picked up by the scan for cmd_*
5628
5651
from bzrlib.bundle.commands import (
5629
5652
cmd_bundle_info,
5654
from bzrlib.foreign import cmd_dpush
5631
5655
from bzrlib.sign_my_commits import cmd_sign_my_commits
5632
5656
from bzrlib.weave_commands import cmd_versionedfile_list, \
5633
5657
cmd_weave_plan_merge, cmd_weave_merge_text