~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/status.py

(gz) Remove bzrlib/util/elementtree/ package (Martin Packman)

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
 
17
from __future__ import absolute_import
 
18
 
17
19
import sys
18
20
 
19
21
from bzrlib import (
34
36
def report_changes(to_file, old, new, specific_files, 
35
37
                   show_short_reporter, show_long_callback, 
36
38
                   short=False, want_unchanged=False, 
37
 
                   want_unversioned=False, show_ids=False):
 
39
                   want_unversioned=False, show_ids=False, classify=True):
38
40
    """Display summary of changes.
39
41
 
40
42
    This compares two trees with regards to a list of files, and delegates 
59
61
        files.
60
62
    :param show_ids: If set, includes each file's id.
61
63
    :param want_unversioned: If False, only shows versioned files.
 
64
    :param classify: Add special symbols to indicate file kind.
62
65
    """
63
66
 
64
67
    if short:
76
79
            delta.unversioned if not new.is_ignored(unversioned[0])]
77
80
        show_long_callback(to_file, delta, 
78
81
                           show_ids=show_ids,
79
 
                           show_unchanged=want_unchanged)
 
82
                           show_unchanged=want_unchanged,
 
83
                           classify=classify)
80
84
 
81
85
 
82
86
def show_tree_status(wt, show_unchanged=None,
88
92
                     short=False,
89
93
                     verbose=False,
90
94
                     versioned=False,
 
95
                     classify=True,
91
96
                     show_long_callback=_mod_delta.report_delta):
92
97
    """Display summary of changes.
93
98
 
117
122
    :param verbose: If True, show all merged revisions, not just
118
123
        the merge tips
119
124
    :param versioned: If True, only shows versioned files.
 
125
    :param classify: Add special symbols to indicate file kind.
120
126
    :param show_long_callback: A callback: message = show_long_callback(to_file, delta, 
121
127
        show_ids, show_unchanged, indent, filter), only used with the long output
122
128
    """
153
159
        try:
154
160
            for hook in hooks['pre_status']:
155
161
                hook(StatusHookParams(old, new, to_file, versioned,
156
 
                    show_ids, short, verbose))
 
162
                    show_ids, short, verbose, specific_files=specific_files))
157
163
 
158
164
            specific_files, nonexistents \
159
165
                = _filter_nonexistent(specific_files, old, new)
161
167
 
162
168
            # Reporter used for short outputs
163
169
            reporter = _mod_delta._ChangeReporter(output_file=to_file,
164
 
                unversioned_filter=new.is_ignored)
 
170
                unversioned_filter=new.is_ignored, classify=classify)
165
171
            report_changes(to_file, old, new, specific_files, 
166
172
                           reporter, show_long_callback, 
167
173
                           short=short, want_unchanged=show_unchanged, 
168
 
                           want_unversioned=want_unversioned, show_ids=show_ids)
 
174
                           want_unversioned=want_unversioned, show_ids=show_ids,
 
175
                           classify=classify)
169
176
 
170
177
            # show the ignored files among specific files (i.e. show the files
171
178
            # identified from input that we choose to ignore). 
217
224
                raise errors.PathsDoNotExist(nonexistents)
218
225
            for hook in hooks['post_status']:
219
226
                hook(StatusHookParams(old, new, to_file, versioned,
220
 
                    show_ids, short, verbose))
 
227
                    show_ids, short, verbose, specific_files=specific_files))
221
228
        finally:
222
229
            old.unlock()
223
230
            new.unlock()
411
418
    """
412
419
 
413
420
    def __init__(self, old_tree, new_tree, to_file, versioned, show_ids,
414
 
            short, verbose):
 
421
            short, verbose, specific_files=None):
415
422
        """Create a group of post_status hook parameters.
416
423
 
417
424
        :param old_tree: Start tree (basis tree) for comparison.
421
428
        :param show_ids: Show internal object ids.
422
429
        :param short: Use short status indicators.
423
430
        :param verbose: Verbose flag.
 
431
        :param specific_files: If set, a list of filenames whose status should be
 
432
            shown.  It is an error to give a filename that is not in the working
 
433
            tree, or in the working inventory or in the basis inventory.
424
434
        """
425
435
        self.old_tree = old_tree
426
436
        self.new_tree = new_tree
429
439
        self.show_ids = show_ids
430
440
        self.short = short
431
441
        self.verbose = verbose
 
442
        self.specific_files = specific_files
432
443
 
433
444
    def __eq__(self, other):
434
445
        return self.__dict__ == other.__dict__
435
446
 
436
447
    def __repr__(self):
437
 
        return "<%s(%s, %s, %s, %s, %s, %s, %s)>" % (self.__class__.__name__,
 
448
        return "<%s(%s, %s, %s, %s, %s, %s, %s, %s)>" % (self.__class__.__name__,
438
449
            self.old_tree, self.new_tree, self.to_file, self.versioned,
439
 
            self.show_ids, self.short, self.verbose)
 
450
            self.show_ids, self.short, self.verbose, self.specific_files)
440
451
 
441
452
 
442
453
def _show_shelve_summary(params):
444
455
 
445
456
    :param params: StatusHookParams.
446
457
    """
 
458
    # Don't show shelves if status of specific files is being shown, only if
 
459
    # no file arguments have been passed
 
460
    if params.specific_files:
 
461
        return
447
462
    get_shelf_manager = getattr(params.new_tree, 'get_shelf_manager', None)
448
463
    if get_shelf_manager is None:
449
464
        return