3
"""Show paths used by bzr itself and push/pull locations for current branch
4
Written by Alexander Belchenko, 2006
7
from bzrlib.commands import register_command
8
from command import BzrToolsCommand
9
from bzrlib.option import Option
15
def _bzr_system_info(to_file):
21
from bzrlib.config import config_dir
22
from bzrlib import osutils
23
from bzrlib.plugin import DEFAULT_PLUGIN_PATH
24
from bzrlib import plugins
25
from bzrlib import trace
27
print >>to_file, FORMAT % ('Python interpreter', sys.executable)
28
print >>to_file, FORMAT % ('Python library',
29
os.path.dirname(site.__file__))
31
print >>to_file, FORMAT % ('bzr executable', osutils.realpath(sys.argv[0]))
32
print >>to_file, FORMAT % ('bzrlib', osutils.realpath(bzrlib.__path__[0]))
34
print >>to_file, FORMAT % ('bzr config dir', osutils.realpath(config_dir()))
36
dirs = os.environ.get('BZR_PLUGIN_PATH', DEFAULT_PLUGIN_PATH).split(os.pathsep)
37
dirs.insert(0, os.path.dirname(plugins.__file__))
39
print >>to_file, FORMAT % ('bzr plugins dir', osutils.realpath(dirs[0]))
41
print >>to_file, FORMAT % ('bzr plugins dirs', osutils.realpath(dirs[0]))
43
print >>to_file, FORMAT % ('', osutils.realpath(dir_))
45
print >>to_file, FORMAT % ('.bzr.log', osutils.realpath(trace._bzr_log_file.name))
46
#/def _bzr_system_info
49
class cmd_show_paths(BzrToolsCommand):
50
"""Show paths used by bzr itself and for current branch.
52
The standard "bzr info" command now includes this functionality.
54
If you run this command from branch you'll see
55
saved path locations for current branch:
57
* branch root - root directory of current branch
58
* pull from - default location for pull command
59
* push to - default location for push command
60
* bound to - for checkouts: location of repository branch
61
* submit to - default reference location for bundle generation
64
takes_options = [Option('system',
65
help='Show full bzr system information.'),
67
takes_args = ['branch?']
73
def run(self, system=False, branch=u'.'):
76
from bzrlib.branch import Branch
77
from bzrlib.errors import NotBranchError, NoWorkingTree
78
from bzrlib import urlutils, trace
79
from bzrlib.workingtree import WorkingTree
80
trace.warning('This command is obsolete. Use "bzr info" instead.')
83
if path.startswith("file://"):
84
return urlutils.local_path_from_url(path)
86
return urlutils.unescape(path)
88
to_file = getattr(self, 'outf', sys.stdout)
91
print >>to_file, "*** Main bzr paths info ***"
92
_bzr_system_info(to_file)
95
branch = Branch.open_containing(branch)[0]
99
print >>to_file, "*** Current branch paths info ***"
101
branch_root = branch.bzrdir.root_transport.base
102
print >>to_file, FORMAT % ('branch root', local_path(branch_root))
104
pull_loc = branch.get_parent() or 'None'
105
print >>to_file, FORMAT % ('branch pull from', local_path(pull_loc))
107
push_loc = branch.get_push_location() or 'None'
108
print >>to_file, FORMAT % ('branch push to', local_path(push_loc))
110
bound_loc = branch.get_bound_location() or 'None'
111
print >>to_file, FORMAT % ('bound to branch', local_path(bound_loc))
113
if hasattr(branch, 'get_submit_branch'):
114
submit_loc = branch.get_submit_branch() or 'None'
115
print >>to_file, FORMAT % ('submit to branch', local_path(submit_loc))
117
except NotBranchError:
120
#/class cmd_show_paths
123
register_command(cmd_show_paths)