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', help='Show full bzr system information'),
63
takes_args = ['branch?']
65
def run(self, system=False, branch=u'.'):
68
from bzrlib.branch import Branch
69
from bzrlib.errors import NotBranchError, NoWorkingTree
70
from bzrlib import urlutils
71
from bzrlib.workingtree import WorkingTree
74
if path.startswith("file://"):
75
return urlutils.local_path_from_url(path)
77
return urlutils.unescape(path)
79
to_file = getattr(self, 'outf', sys.stdout)
82
print >>to_file, "*** Main bzr paths info ***"
83
_bzr_system_info(to_file)
86
branch = Branch.open_containing(branch)[0]
90
print >>to_file, "*** Current branch paths info ***"
92
branch_root = branch.bzrdir.root_transport.base
93
print >>to_file, FORMAT % ('branch root', local_path(branch_root))
95
pull_loc = branch.get_parent() or 'None'
96
print >>to_file, FORMAT % ('branch pull from', local_path(pull_loc))
98
push_loc = branch.get_push_location() or 'None'
99
print >>to_file, FORMAT % ('branch push to', local_path(push_loc))
101
bound_loc = branch.get_bound_location() or 'None'
102
print >>to_file, FORMAT % ('bound to branch', local_path(bound_loc))
104
if hasattr(branch, 'get_submit_branch'):
105
submit_loc = branch.get_submit_branch() or 'None'
106
print >>to_file, FORMAT % ('submit to branch', local_path(submit_loc))
108
except NotBranchError:
111
#/class cmd_show_paths
114
register_command(cmd_show_paths)