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 Command, register_command
8
from bzrlib.option import Option
14
def _bzr_system_info(to_file):
20
from bzrlib.config import config_dir
21
from bzrlib import osutils
22
from bzrlib.plugin import DEFAULT_PLUGIN_PATH
23
from bzrlib import plugins
24
from bzrlib import trace
26
print >>to_file, FORMAT % ('Python interpreter', sys.executable)
27
print >>to_file, FORMAT % ('Python library',
28
os.path.dirname(site.__file__))
30
print >>to_file, FORMAT % ('bzr executable', osutils.realpath(sys.argv[0]))
31
print >>to_file, FORMAT % ('bzrlib', osutils.realpath(bzrlib.__path__[0]))
33
print >>to_file, FORMAT % ('bzr config dir', osutils.realpath(config_dir()))
35
dirs = os.environ.get('BZR_PLUGIN_PATH', DEFAULT_PLUGIN_PATH).split(os.pathsep)
36
dirs.insert(0, os.path.dirname(plugins.__file__))
38
print >>to_file, FORMAT % ('bzr plugins dir', osutils.realpath(dirs[0]))
40
print >>to_file, FORMAT % ('bzr plugins dirs', osutils.realpath(dirs[0]))
42
print >>to_file, FORMAT % ('', osutils.realpath(dir_))
44
print >>to_file, FORMAT % ('.bzr.log', osutils.realpath(trace._bzr_log_file.name))
45
#/def _bzr_system_info
48
class cmd_show_paths(Command):
49
"""Show paths used by bzr itself and for current branch.
51
If you run this command from branch you'll see
52
saved path locations for current branch:
54
* branch root - root directory of current branch
55
* pull from - default location for pull command
56
* push to - default location for push command
57
* bound to - for checkouts: location of repository branch
58
* submit to - default reference location for bundle generation
61
takes_options = [Option('system',
62
help='Show full bzr system information.'),
64
takes_args = ['branch?']
66
def run(self, system=False, branch=u'.'):
69
from bzrlib.branch import Branch
70
from bzrlib.errors import NotBranchError, NoWorkingTree
71
from bzrlib import urlutils
72
from bzrlib.workingtree import WorkingTree
75
if path.startswith("file://"):
76
return urlutils.local_path_from_url(path)
78
return urlutils.unescape(path)
80
to_file = getattr(self, 'outf', sys.stdout)
83
print >>to_file, "*** Main bzr paths info ***"
84
_bzr_system_info(to_file)
87
branch = Branch.open_containing(branch)[0]
91
print >>to_file, "*** Current branch paths info ***"
93
branch_root = branch.bzrdir.root_transport.base
94
print >>to_file, FORMAT % ('branch root', local_path(branch_root))
96
pull_loc = branch.get_parent() or 'None'
97
print >>to_file, FORMAT % ('branch pull from', local_path(pull_loc))
99
push_loc = branch.get_push_location() or 'None'
100
print >>to_file, FORMAT % ('branch push to', local_path(push_loc))
102
bound_loc = branch.get_bound_location() or 'None'
103
print >>to_file, FORMAT % ('bound to branch', local_path(bound_loc))
105
if hasattr(branch, 'get_submit_branch'):
106
submit_loc = branch.get_submit_branch() or 'None'
107
print >>to_file, FORMAT % ('submit to branch', local_path(submit_loc))
109
except NotBranchError:
112
#/class cmd_show_paths
115
register_command(cmd_show_paths)