~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/status.py

  • Committer: Robert Collins
  • Date: 2010-04-08 04:34:03 UTC
  • mfrom: (5138 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5139.
  • Revision ID: robertc@robertcollins.net-20100408043403-56z0d07vdqrx7f3t
Update bugfix for 528114 to trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
# if known, but only if really going to the terminal (not into a file)
35
35
 
36
36
 
 
37
def report_changes(to_file, old, new, specific_files, 
 
38
                   show_short_reporter, show_long_callback, 
 
39
                   short=False, want_unchanged=False, 
 
40
                   want_unversioned=False, show_ids=False):
 
41
    """Display summary of changes.
 
42
 
 
43
    This compares two trees with regards to a list of files, and delegates 
 
44
    the display to underlying elements.
 
45
 
 
46
    For short output, it creates an iterator on all changes, and lets a given
 
47
    reporter display these changes.
 
48
 
 
49
    For stantard output, it creates a delta of the changes, and forwards it
 
50
    to a callback
 
51
 
 
52
    :param to_file: If set, write to this file (default stdout.)
 
53
    :param old: Start tree for the comparison
 
54
    :param end: End tree for the comparison
 
55
    :param specific_files: If set, a list of filenames whose status should be
 
56
        shown.  It is an error to give a filename that is not in the working
 
57
        tree, or in the working inventory or in the basis inventory.
 
58
    :param show_short_reporter: Reporter in charge of display for short output
 
59
    :param show_long_callback: Callback in charge of display for normal output
 
60
    :param short: If True, gives short SVN-style status lines.
 
61
    :param want_unchanged: Deprecated parameter. If set, includes unchanged
 
62
        files.
 
63
    :param show_ids: If set, includes each file's id.
 
64
    :param want_unversioned: If False, only shows versioned files.
 
65
    """
 
66
 
 
67
    if short:
 
68
        changes = new.iter_changes(old, want_unchanged, specific_files,
 
69
            require_versioned=False, want_unversioned=want_unversioned)
 
70
        _mod_delta.report_changes(changes, show_short_reporter)
 
71
        
 
72
    else:
 
73
        delta = new.changes_from(old, want_unchanged=want_unchanged,
 
74
                              specific_files=specific_files,
 
75
                              want_unversioned=want_unversioned)
 
76
        # filter out unknown files. We may want a tree method for
 
77
        # this
 
78
        delta.unversioned = [unversioned for unversioned in
 
79
            delta.unversioned if not new.is_ignored(unversioned[0])]
 
80
        show_long_callback(to_file, delta, 
 
81
                           show_ids=show_ids,
 
82
                           show_unchanged=want_unchanged)
 
83
 
 
84
 
37
85
def show_tree_status(wt, show_unchanged=None,
38
86
                     specific_files=None,
39
87
                     show_ids=False,
42
90
                     revision=None,
43
91
                     short=False,
44
92
                     verbose=False,
45
 
                     versioned=False):
 
93
                     versioned=False,
 
94
                     show_long_callback=_mod_delta.report_delta):
46
95
    """Display summary of changes.
47
96
 
48
97
    By default this compares the working tree to a previous revision.
71
120
    :param verbose: If True, show all merged revisions, not just
72
121
        the merge tips
73
122
    :param versioned: If True, only shows versioned files.
 
123
    :param show_long_callback: A callback: message = show_long_callback(to_file, delta, 
 
124
        show_ids, show_unchanged, indent, filter), only used with the long output
74
125
    """
75
126
    if show_unchanged is not None:
76
127
        warn("show_tree_status with show_unchanged has been deprecated "
106
157
            specific_files, nonexistents \
107
158
                = _filter_nonexistent(specific_files, old, new)
108
159
            want_unversioned = not versioned
109
 
            if short:
110
 
                changes = new.iter_changes(old, show_unchanged, specific_files,
111
 
                    require_versioned=False, want_unversioned=want_unversioned)
112
 
                reporter = _mod_delta._ChangeReporter(output_file=to_file,
113
 
                    unversioned_filter=new.is_ignored)
114
 
                _mod_delta.report_changes(changes, reporter)
115
 
            else:
116
 
                delta = new.changes_from(old, want_unchanged=show_unchanged,
117
 
                                      specific_files=specific_files,
118
 
                                      want_unversioned=want_unversioned)
119
 
                # filter out unknown files. We may want a tree method for
120
 
                # this
121
 
                delta.unversioned = [unversioned for unversioned in
122
 
                    delta.unversioned if not new.is_ignored(unversioned[0])]
123
 
                delta.show(to_file,
124
 
                           show_ids=show_ids,
125
 
                           show_unchanged=show_unchanged,
126
 
                           short_status=False)
 
160
 
 
161
            # Reporter used for short outputs
 
162
            reporter = _mod_delta._ChangeReporter(output_file=to_file,
 
163
                unversioned_filter=new.is_ignored)
 
164
            report_changes(to_file, old, new, specific_files, 
 
165
                           reporter, show_long_callback, 
 
166
                           short=short, want_unchanged=show_unchanged, 
 
167
                           want_unversioned=want_unversioned, show_ids=show_ids)
 
168
 
127
169
            # show the new conflicts only for now. XXX: get them from the
128
170
            # delta.
129
171
            conflicts = new.conflicts()