~abentley/bzrtools/bzrtools.dev

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
License: Free for bzr users
6
"""
7
8
from bzrlib.commands import Command, register_command
9
10
11
class cmd_show_paths(Command):
12
    """Show paths used by bzr itself and push/pull locations for current branch"""
13
14
    def run(self):
15
        import os
16
        import sys
17
18
        import bzrlib
19
        from bzrlib.branch import Branch
20
        from bzrlib.config import config_dir
21
        from bzrlib.errors import NotBranchError, NoWorkingTree
22
        from bzrlib import osutils
23
        from bzrlib.plugin import DEFAULT_PLUGIN_PATH
24
        from bzrlib import plugins
25
        from bzrlib import trace
26
        from bzrlib.workingtree import WorkingTree
27
28
        FORMAT = '%16s: %s'
29
30
        print FORMAT % ('bzr executable', osutils.realpath(sys.argv[0]))
31
        print FORMAT % ('bzrlib', osutils.realpath(bzrlib.__path__[0]))
32
33
        print 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 FORMAT % ('bzr plugins dir', osutils.realpath(dirs[0]))
39
        else:
40
            print FORMAT % ('bzr plugins dirs', osutils.realpath(dirs[0]))
41
            for dir_ in dirs[1:]:
42
                print FORMAT % ('', osutils.realpath(dir_))
43
44
        print FORMAT % ('.bzr.log', osutils.realpath(trace._bzr_log_file.name))
45
46
        try:
47
            try:
48
                branch = WorkingTree.open_containing(u'.')[0].branch
49
            except NoWorkingTree:
50
                branch = Branch.open_containing(u'.')[0]
51
52
            pull_loc = branch.get_parent() or 'None'
53
            print FORMAT % ('branch pull from', pull_loc)
54
55
            push_loc = branch.get_push_location() or 'None'
56
            print FORMAT % ('branch push to', push_loc)
57
        except NotBranchError:
58
            pass
59
60
61
register_command(cmd_show_paths)