~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/status.py

 * bzr add now lists how many files were ignored per glob.  add --verbose
   lists the specific files.  (Aaron Bentley)

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
import sys
18
 
 
 
18
from bzrlib.osutils import is_inside_any
19
19
from bzrlib.delta import compare_trees
 
20
from bzrlib.log import line_log
20
21
from bzrlib.errors import NoSuchRevision
21
 
from bzrlib.log import line_log
22
 
from bzrlib.osutils import is_inside_any
23
 
from bzrlib.symbol_versioning import *
24
22
 
25
23
# TODO: when showing single-line logs, truncate to the width of the terminal
26
24
# if known, but only if really going to the terminal (not into a file)
27
25
 
28
26
 
29
 
@deprecated_function(zero_eight)
30
27
def show_status(branch, show_unchanged=False,
31
28
                specific_files=None,
32
29
                show_ids=False,
35
32
                revision=None):
36
33
    """Display summary of changes.
37
34
 
38
 
    Please use show_tree_status instead.
39
 
 
40
 
    By default this compares the working tree to a previous revision. 
41
 
    If the revision argument is given, summarizes changes between the 
42
 
    working tree and another, or between two revisions.
43
 
 
44
 
    The result is written out as Unicode and to_file should be able 
45
 
    to encode that.
46
 
 
47
 
    show_unchanged
48
 
        If set, includes unchanged files.
49
 
 
50
 
    specific_files
51
 
        If set, only show the status of files in this list.
52
 
 
53
 
    show_ids
54
 
        If set, includes each file's id.
55
 
 
56
 
    to_file
57
 
        If set, write to this file (default stdout.)
58
 
 
59
 
    show_pending
60
 
        If set, write pending merges.
61
 
 
62
 
    revision
63
 
        If None the compare latest revision with working tree
64
 
        If one revision show compared it with working tree.
65
 
        If two revisions show status between first and second.
66
 
    """
67
 
    show_tree_status(branch.bzrdir.open_workingtree(), show_unchanged, 
68
 
                     specific_files, show_ids, to_file, show_pending, revision)
69
 
 
70
 
 
71
 
def show_tree_status(wt, show_unchanged=False,
72
 
                     specific_files=None,
73
 
                     show_ids=False,
74
 
                     to_file=None,
75
 
                     show_pending=True,
76
 
                     revision=None):
77
 
    """Display summary of changes.
78
 
 
79
35
    By default this compares the working tree to a previous revision. 
80
36
    If the revision argument is given, summarizes changes between the 
81
37
    working tree and another, or between two revisions.
106
62
    if to_file == None:
107
63
        to_file = sys.stdout
108
64
    
109
 
    wt.lock_read()
 
65
    branch.lock_read()
110
66
    try:
111
67
        new_is_working_tree = True
112
68
        if revision is None:
113
 
            new = wt
114
 
            old = new.basis_tree()
 
69
            old = branch.basis_tree()
 
70
            new = branch.working_tree()
115
71
        elif len(revision) > 0:
116
72
            try:
117
 
                rev_id = revision[0].in_history(wt.branch).rev_id
118
 
                old = wt.branch.repository.revision_tree(rev_id)
 
73
                rev_id = revision[0].in_history(branch).rev_id
 
74
                old = branch.revision_tree(rev_id)
119
75
            except NoSuchRevision, e:
120
76
                raise BzrCommandError(str(e))
121
 
            if (len(revision) > 1) and (revision[1].spec is not None):
 
77
            if len(revision) > 1:
122
78
                try:
123
 
                    rev_id = revision[1].in_history(wt.branch).rev_id
124
 
                    new = wt.branch.repository.revision_tree(rev_id)
 
79
                    rev_id = revision[1].in_history(branch).rev_id
 
80
                    new = branch.revision_tree(rev_id)
125
81
                    new_is_working_tree = False
126
82
                except NoSuchRevision, e:
127
83
                    raise BzrCommandError(str(e))
128
84
            else:
129
 
                new = wt
 
85
                new = branch.working_tree()
130
86
                
 
87
 
131
88
        delta = compare_trees(old, new, want_unchanged=show_unchanged,
132
89
                              specific_files=specific_files)
 
90
 
133
91
        delta.show(to_file,
134
92
                   show_ids=show_ids,
135
93
                   show_unchanged=show_unchanged)
140
98
        if new_is_working_tree and show_pending:
141
99
            show_pending_merges(new, to_file)
142
100
    finally:
143
 
        wt.unlock()
 
101
        branch.unlock()
144
102
 
145
103
def show_pending_merges(new, to_file):
146
104
    """Write out a display of pending merges in a working tree."""
151
109
    print >>to_file, 'pending merges:'
152
110
    last_revision = branch.last_revision()
153
111
    if last_revision is not None:
154
 
        ignore = set(branch.repository.get_ancestry(last_revision))
 
112
        ignore = set(branch.get_ancestry(last_revision))
155
113
    else:
156
114
        ignore = set()
157
115
    for merge in new.pending_merges():
158
116
        ignore.add(merge)
159
117
        try:
160
 
            m_revision = branch.repository.get_revision(merge)
 
118
            m_revision = branch.get_revision(merge)
161
119
            print >> to_file, ' ', line_log(m_revision, 77)
162
 
            inner_merges = branch.repository.get_ancestry(merge)
 
120
            inner_merges = branch.get_ancestry(merge)
163
121
            inner_merges.reverse()
164
122
            for mmerge in inner_merges:
165
123
                if mmerge in ignore:
166
124
                    continue
167
 
                mm_revision = branch.repository.get_revision(mmerge)
 
125
                mm_revision = branch.get_revision(mmerge)
168
126
                print >> to_file, '   ', line_log(mm_revision, 75)
169
127
                ignore.add(mmerge)
170
128
        except NoSuchRevision: