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
79
from bzrlib.workingtree import WorkingTree
82
if path.startswith("file://"):
83
return urlutils.local_path_from_url(path)
85
return urlutils.unescape(path)
87
to_file = getattr(self, 'outf', sys.stdout)
90
print >>to_file, "*** Main bzr paths info ***"
91
_bzr_system_info(to_file)
94
branch = Branch.open_containing(branch)[0]
98
print >>to_file, "*** Current branch paths info ***"
100
branch_root = branch.bzrdir.root_transport.base
101
print >>to_file, FORMAT % ('branch root', local_path(branch_root))
103
pull_loc = branch.get_parent() or 'None'
104
print >>to_file, FORMAT % ('branch pull from', local_path(pull_loc))
106
push_loc = branch.get_push_location() or 'None'
107
print >>to_file, FORMAT % ('branch push to', local_path(push_loc))
109
bound_loc = branch.get_bound_location() or 'None'
110
print >>to_file, FORMAT % ('bound to branch', local_path(bound_loc))
112
if hasattr(branch, 'get_submit_branch'):
113
submit_loc = branch.get_submit_branch() or 'None'
114
print >>to_file, FORMAT % ('submit to branch', local_path(submit_loc))
116
except NotBranchError:
119
#/class cmd_show_paths
122
register_command(cmd_show_paths)