~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/status.py

Fix status to work with checkouts

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
from bzrlib.errors import NoSuchRevision
21
21
from bzrlib.log import line_log
22
22
from bzrlib.osutils import is_inside_any
 
23
from bzrlib.symbol_versioning import *
23
24
 
24
25
# TODO: when showing single-line logs, truncate to the width of the terminal
25
26
# if known, but only if really going to the terminal (not into a file)
26
27
 
27
28
 
 
29
@deprecated_function(zero_eight)
28
30
def show_status(branch, show_unchanged=False,
29
31
                specific_files=None,
30
32
                show_ids=False,
60
62
        If one revision show compared it with working tree.
61
63
        If two revisions show status between first and second.
62
64
    """
 
65
    show_tree_status(branch.bzrdir.open_workingtree(), show_unchanged, 
 
66
                     specific_files, show_ids, to_file, show_pending, revision)
 
67
 
 
68
def show_tree_status(wt, show_unchanged=False,
 
69
                     specific_files=None,
 
70
                     show_ids=False,
 
71
                     to_file=None,
 
72
                     show_pending=True,
 
73
                     revision=None):
 
74
    """Display summary of changes.
 
75
 
 
76
    By default this compares the working tree to a previous revision. 
 
77
    If the revision argument is given, summarizes changes between the 
 
78
    working tree and another, or between two revisions.
 
79
 
 
80
    The result is written out as Unicode and to_file should be able 
 
81
    to encode that.
 
82
 
 
83
    show_unchanged
 
84
        If set, includes unchanged files.
 
85
 
 
86
    specific_files
 
87
        If set, only show the status of files in this list.
 
88
 
 
89
    show_ids
 
90
        If set, includes each file's id.
 
91
 
 
92
    to_file
 
93
        If set, write to this file (default stdout.)
 
94
 
 
95
    show_pending
 
96
        If set, write pending merges.
 
97
 
 
98
    revision
 
99
        If None the compare latest revision with working tree
 
100
        If one revision show compared it with working tree.
 
101
        If two revisions show status between first and second.
 
102
    """
63
103
    if to_file == None:
64
104
        to_file = sys.stdout
65
105
    
66
 
    branch.lock_read()
 
106
    wt.lock_read()
67
107
    try:
68
108
        new_is_working_tree = True
69
109
        if revision is None:
70
 
            new = branch.bzrdir.open_workingtree()
 
110
            new = wt
71
111
            old = new.basis_tree()
72
112
        elif len(revision) > 0:
73
113
            try:
74
 
                rev_id = revision[0].in_history(branch).rev_id
75
 
                old = branch.repository.revision_tree(rev_id)
 
114
                rev_id = revision[0].in_history(wt.branch).rev_id
 
115
                old = wt.branch.repository.revision_tree(rev_id)
76
116
            except NoSuchRevision, e:
77
117
                raise BzrCommandError(str(e))
78
118
            if (len(revision) > 1) and (revision[1].spec is not None):
79
119
                try:
80
 
                    rev_id = revision[1].in_history(branch).rev_id
81
 
                    new = branch.repository.revision_tree(rev_id)
 
120
                    rev_id = revision[1].in_history(wt.branch).rev_id
 
121
                    new = wt.branch.repository.revision_tree(rev_id)
82
122
                    new_is_working_tree = False
83
123
                except NoSuchRevision, e:
84
124
                    raise BzrCommandError(str(e))
85
125
            else:
86
 
                new = branch.bzrdir.open_workingtree()
 
126
                new = wt
87
127
                
88
128
        delta = compare_trees(old, new, want_unchanged=show_unchanged,
89
129
                              specific_files=specific_files)
97
137
        if new_is_working_tree and show_pending:
98
138
            show_pending_merges(new, to_file)
99
139
    finally:
100
 
        branch.unlock()
 
140
        wt.unlock()
101
141
 
102
142
def show_pending_merges(new, to_file):
103
143
    """Write out a display of pending merges in a working tree."""