5594
5594
dry_run=dry_run, no_prompt=force)
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)
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))
5597
5644
# these get imported and then picked up by the scan for cmd_*
5598
5645
# TODO: Some more consistent way to split command definitions across files;
5599
5646
# we do need to load at least some information about them to know of