~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to show_paths.py

  • Committer: Michael Ellerman
  • Date: 2005-11-29 07:12:26 UTC
  • mto: (0.3.1 shelf-dev) (325.1.2 bzrtools)
  • mto: This revision was merged to the branch mainline in revision 334.
  • Revision ID: michael@ellerman.id.au-20051129071226-a04b3f827880025d
Unshelve --pick was broken, because we deleted the whole patch, even when only
part of it was unshelved. So now if we unshelve part of a patch, the patch is
replaced with a new patch that has just the unshelved parts. That's a long way
of saying it does what you'd expect.

Implementing this required changing HunkSelector to return both the selected,
and unselected hunks (ie. patches to shelve, and patches to keep).

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
8
 
from bzrlib.option import Option
9
 
 
10
 
 
11
 
FORMAT = '%18s: %s'
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)
27
 
    print >>to_file, FORMAT % ('Python library',
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
46
 
 
47
 
 
48
 
class cmd_show_paths(Command):
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
 
                    ]
63
 
 
64
 
    def run(self, system=False):
65
 
        import sys
66
 
 
67
 
        from bzrlib.branch import Branch
68
 
        from bzrlib.errors import NotBranchError, NoWorkingTree
69
 
        from bzrlib import urlutils
70
 
        from bzrlib.workingtree import WorkingTree
71
 
 
72
 
        def local_path(path):
73
 
            if path.startswith("file://"):
74
 
                return urlutils.local_path_from_url(path)
75
 
            else:
76
 
                return urlutils.unescape(path)
77
 
 
78
 
        to_file = getattr(self, 'outf', sys.stdout)
79
 
 
80
 
        if system:
81
 
            print >>to_file, "*** Main bzr paths info ***"
82
 
            _bzr_system_info(to_file)
83
 
 
84
 
        try:
85
 
            try:
86
 
                branch = WorkingTree.open_containing(u'.')[0].branch
87
 
            except NoWorkingTree:
88
 
                branch = Branch.open_containing(u'.')[0]
89
 
 
90
 
 
91
 
            if system:
92
 
                print >>to_file
93
 
            print >>to_file, "*** Current branch paths info ***"
94
 
 
95
 
            branch_root = branch.bzrdir.root_transport.base
96
 
            print >>to_file, FORMAT % ('branch root', local_path(branch_root))
97
 
 
98
 
            pull_loc = branch.get_parent() or 'None'
99
 
            print >>to_file, FORMAT % ('branch pull from', local_path(pull_loc))
100
 
 
101
 
            push_loc = branch.get_push_location() or 'None'
102
 
            print >>to_file, FORMAT % ('branch push to', local_path(push_loc))
103
 
 
104
 
            bound_loc = branch.get_bound_location() or 'None'
105
 
            print >>to_file, FORMAT % ('bound to branch', local_path(bound_loc))
106
 
 
107
 
            if hasattr(branch, 'get_submit_branch'):
108
 
                submit_loc = branch.get_submit_branch() or 'None'
109
 
                print >>to_file, FORMAT % ('submit to branch', local_path(submit_loc))
110
 
 
111
 
        except NotBranchError:
112
 
            if not system:
113
 
                raise
114
 
#/class cmd_show_paths
115
 
 
116
 
 
117
 
register_command(cmd_show_paths)