1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
#!/usr/bin/python
"""Show paths used by bzr itself and push/pull locations for current branch
Written by Alexander Belchenko, 2006
"""
from bzrlib.commands import Command, register_command
from bzrlib.option import Option
FORMAT = '%18s: %s'
def _bzr_system_info(to_file):
import os
import site
import sys
import bzrlib
from bzrlib.config import config_dir
from bzrlib import osutils
from bzrlib.plugin import DEFAULT_PLUGIN_PATH
from bzrlib import plugins
from bzrlib import trace
print >>to_file, FORMAT % ('Python interpreter', sys.executable)
print >>to_file, FORMAT % ('Python library',
os.path.dirname(site.__file__))
print >>to_file, FORMAT % ('bzr executable', osutils.realpath(sys.argv[0]))
print >>to_file, FORMAT % ('bzrlib', osutils.realpath(bzrlib.__path__[0]))
print >>to_file, FORMAT % ('bzr config dir', osutils.realpath(config_dir()))
dirs = os.environ.get('BZR_PLUGIN_PATH', DEFAULT_PLUGIN_PATH).split(os.pathsep)
dirs.insert(0, os.path.dirname(plugins.__file__))
if len(dirs) == 1:
print >>to_file, FORMAT % ('bzr plugins dir', osutils.realpath(dirs[0]))
else:
print >>to_file, FORMAT % ('bzr plugins dirs', osutils.realpath(dirs[0]))
for dir_ in dirs[1:]:
print >>to_file, FORMAT % ('', osutils.realpath(dir_))
print >>to_file, FORMAT % ('.bzr.log', osutils.realpath(trace._bzr_log_file.name))
#/def _bzr_system_info
class cmd_show_paths(Command):
"""Show paths used by bzr itself and for current branch.
If you run this command from branch you'll see
saved path locations for current branch:
* branch root - root directory of current branch
* pull from - default location for pull command
* push to - default location for push command
* bound to - for checkouts: location of repository branch
* submit to - default reference location for bundle generation
"""
takes_options = [Option('system', help='Show full bzr system information'),
]
takes_args = ['branch?']
def run(self, system=False, branch=u'.'):
import sys
from bzrlib.branch import Branch
from bzrlib.errors import NotBranchError, NoWorkingTree
from bzrlib import urlutils
from bzrlib.workingtree import WorkingTree
def local_path(path):
if path.startswith("file://"):
return urlutils.local_path_from_url(path)
else:
return urlutils.unescape(path)
to_file = getattr(self, 'outf', sys.stdout)
if system:
print >>to_file, "*** Main bzr paths info ***"
_bzr_system_info(to_file)
try:
branch = Branch.open_containing(branch)[0]
if system:
print >>to_file
print >>to_file, "*** Current branch paths info ***"
branch_root = branch.bzrdir.root_transport.base
print >>to_file, FORMAT % ('branch root', local_path(branch_root))
pull_loc = branch.get_parent() or 'None'
print >>to_file, FORMAT % ('branch pull from', local_path(pull_loc))
push_loc = branch.get_push_location() or 'None'
print >>to_file, FORMAT % ('branch push to', local_path(push_loc))
bound_loc = branch.get_bound_location() or 'None'
print >>to_file, FORMAT % ('bound to branch', local_path(bound_loc))
if hasattr(branch, 'get_submit_branch'):
submit_loc = branch.get_submit_branch() or 'None'
print >>to_file, FORMAT % ('submit to branch', local_path(submit_loc))
except NotBranchError:
if not system:
raise
#/class cmd_show_paths
register_command(cmd_show_paths)
|