/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/status.py

  • Committer: Jelmer Vernooij
  • Date: 2018-11-16 19:47:19 UTC
  • mfrom: (7178 work)
  • mto: This revision was merged to the branch mainline in revision 7179.
  • Revision ID: jelmer@jelmer.uk-20181116194719-m5ut2wfuze5x9s1p
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
    revision as _mod_revision,
28
28
    )
29
29
from . import errors as errors
30
 
from .sixish import text_type
31
30
from .trace import mutter, warning
32
31
from .workingtree import ShelvingUnsupported
33
32
 
69
68
 
70
69
    if short:
71
70
        changes = new.iter_changes(old, want_unchanged, specific_files,
72
 
            require_versioned=False, want_unversioned=want_unversioned)
 
71
                                   require_versioned=False, want_unversioned=want_unversioned)
73
72
        _mod_delta.report_changes(changes, show_short_reporter)
74
73
    else:
75
74
        delta = new.changes_from(old, want_unchanged=want_unchanged,
76
 
                              specific_files=specific_files,
77
 
                              want_unversioned=want_unversioned)
 
75
                                 specific_files=specific_files,
 
76
                                 want_unversioned=want_unversioned)
78
77
        # filter out unknown files. We may want a tree method for
79
78
        # this
80
79
        delta.unversioned = [unversioned for unversioned in
81
 
            delta.unversioned if not new.is_ignored(unversioned[0])]
 
80
                             delta.unversioned if not new.is_ignored(unversioned[0])]
82
81
        show_long_callback(to_file, delta,
83
82
                           show_ids=show_ids,
84
83
                           show_unchanged=want_unchanged,
152
151
        with old.lock_read(), new.lock_read():
153
152
            for hook in hooks['pre_status']:
154
153
                hook(StatusHookParams(old, new, to_file, versioned,
155
 
                    show_ids, short, verbose, specific_files=specific_files))
 
154
                                      show_ids, short, verbose, specific_files=specific_files))
156
155
 
157
156
            specific_files, nonexistents \
158
157
                = _filter_nonexistent(specific_files, old, new)
160
159
 
161
160
            # Reporter used for short outputs
162
161
            reporter = _mod_delta._ChangeReporter(output_file=to_file,
163
 
                unversioned_filter=new.is_ignored, classify=classify)
 
162
                                                  unversioned_filter=new.is_ignored, classify=classify)
164
163
            report_changes(to_file, old, new, specific_files,
165
164
                           reporter, show_long_callback,
166
165
                           short=short, want_unversioned=want_unversioned,
171
170
            if specific_files is not None:
172
171
                # Ignored files is sorted because specific_files is already sorted
173
172
                ignored_files = [specific for specific in
174
 
                    specific_files if new.is_ignored(specific)]
 
173
                                 specific_files if new.is_ignored(specific)]
175
174
                if len(ignored_files) > 0 and not short:
176
175
                    to_file.write("ignored:\n")
177
176
                    prefix = ' '
185
184
            conflicts = new.conflicts()
186
185
            if specific_files is not None:
187
186
                conflicts = conflicts.select_conflicts(new, specific_files,
188
 
                    ignore_misses=True, recurse=True)[1]
 
187
                                                       ignore_misses=True, recurse=True)[1]
189
188
            if len(conflicts) > 0 and not short:
190
189
                to_file.write("conflicts:\n")
191
190
            for conflict in conflicts:
216
215
                raise errors.PathsDoNotExist(nonexistents)
217
216
            for hook in hooks['post_status']:
218
217
                hook(StatusHookParams(old, new, to_file, versioned,
219
 
                    show_ids, short, verbose, specific_files=specific_files))
 
218
                                      show_ids, short, verbose, specific_files=specific_files))
220
219
 
221
220
 
222
221
def _get_sorted_revisions(tip_revision, revision_ids, parent_map):
235
234
    # of any references pointing outside of this graph.
236
235
    parent_graph = {}
237
236
    for revision_id in revision_ids:
238
 
        if revision_id not in parent_map: # ghost
 
237
        if revision_id not in parent_map:  # ghost
239
238
            parent_graph[revision_id] = []
240
239
        else:
241
240
            # Only include parents which are in this sub-graph
242
241
            parent_graph[revision_id] = [p for p in parent_map[revision_id]
243
 
                                            if p in revision_ids]
 
242
                                         if p in revision_ids]
244
243
    sorter = tsort.MergeSorter(parent_graph, tip_revision)
245
244
    return sorter.iter_topo_order()
246
245
 
287
286
            rev = branch.repository.get_revision(merge)
288
287
        except errors.NoSuchRevision:
289
288
            # If we are missing a revision, just print out the revision id
290
 
            to_file.write(first_prefix + '(ghost) ' + merge.decode('utf-8') + '\n')
 
289
            to_file.write(first_prefix + '(ghost) ' +
 
290
                          merge.decode('utf-8') + '\n')
291
291
            other_revisions.append(merge)
292
292
            continue
293
293
 
307
307
 
308
308
        # Display the revisions brought in by this merge.
309
309
        rev_id_iterator = _get_sorted_revisions(merge, merge_extra,
310
 
                            branch.repository.get_parent_map(merge_extra))
 
310
                                                branch.repository.get_parent_map(merge_extra))
311
311
        # Skip the first node
312
312
        num, first, depth, eom = next(rev_id_iterator)
313
313
        if first != merge:
314
314
            raise AssertionError('Somehow we misunderstood how'
315
 
                ' iter_topo_order works %s != %s' % (first, merge))
 
315
                                 ' iter_topo_order works %s != %s' % (first, merge))
316
316
        for num, sub_merge, depth, eom in rev_id_iterator:
317
317
            rev = revisions[sub_merge]
318
318
            if rev is None:
319
 
                to_file.write(sub_prefix + '(ghost) ' + sub_merge.decode('utf-8') + '\n')
 
319
                to_file.write(sub_prefix + '(ghost) ' +
 
320
                              sub_merge.decode('utf-8') + '\n')
320
321
                continue
321
322
            show_log_message(revisions[sub_merge], sub_prefix)
322
323
 
340
341
    s = old_tree.filter_unversioned_files(orig_paths)
341
342
    s = new_tree.filter_unversioned_files(s)
342
343
    nonexistent = [path for path in s if not new_tree.has_filename(path)]
343
 
    remaining   = [path for path in orig_paths if not path in nonexistent]
 
344
    remaining = [path for path in orig_paths if not path in nonexistent]
344
345
    # Sorting the 'remaining' list doesn't have much effect in
345
346
    # practice, since the various status output sections will sort
346
347
    # their groups individually.  But for consistency of this
362
363
        notified.
363
364
        """
364
365
        _mod_hooks.Hooks.__init__(self, "breezy.status", "hooks")
365
 
        self.add_hook('post_status',
 
366
        self.add_hook(
 
367
            'post_status',
366
368
            "Called with argument StatusHookParams after Bazaar has "
367
369
            "displayed the status. StatusHookParams has the attributes "
368
370
            "(old_tree, new_tree, to_file, versioned, show_ids, short, "
370
372
            "line options specified by the user for the status command. "
371
373
            "to_file is the output stream for writing.",
372
374
            (2, 3))
373
 
        self.add_hook('pre_status',
 
375
        self.add_hook(
 
376
            'pre_status',
374
377
            "Called with argument StatusHookParams before Bazaar "
375
378
            "displays the status. StatusHookParams has the attributes "
376
379
            "(old_tree, new_tree, to_file, versioned, show_ids, short, "
393
396
    """
394
397
 
395
398
    def __init__(self, old_tree, new_tree, to_file, versioned, show_ids,
396
 
            short, verbose, specific_files=None):
 
399
                 short, verbose, specific_files=None):
397
400
        """Create a group of post_status hook parameters.
398
401
 
399
402
        :param old_tree: Start tree (basis tree) for comparison.
404
407
        :param short: Use short status indicators.
405
408
        :param verbose: Verbose flag.
406
409
        :param specific_files: If set, a list of filenames whose status should be
407
 
            shown.  It is an error to give a filename that is not in the working
408
 
            tree, or in the working inventory or in the basis inventory.
 
410
            shown.  It is an error to give a filename that is not in the
 
411
            working tree, or in the working inventory or in the basis inventory.
409
412
        """
410
413
        self.old_tree = old_tree
411
414
        self.new_tree = new_tree
420
423
        return self.__dict__ == other.__dict__
421
424
 
422
425
    def __repr__(self):
423
 
        return "<%s(%s, %s, %s, %s, %s, %s, %s, %s)>" % (self.__class__.__name__,
424
 
            self.old_tree, self.new_tree, self.to_file, self.versioned,
425
 
            self.show_ids, self.short, self.verbose, self.specific_files)
 
426
        return "<%s(%s, %s, %s, %s, %s, %s, %s, %s)>" % (
 
427
            self.__class__.__name__, self.old_tree, self.new_tree,
 
428
            self.to_file, self.versioned, self.show_ids, self.short,
 
429
            self.verbose, self.specific_files)
426
430
 
427
431
 
428
432
def _show_shelve_summary(params):
458
462
 
459
463
 
460
464
hooks.install_named_hook('post_status', _show_shelve_summary,
461
 
    'brz status')
462
 
 
 
465
                         'brz status')