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