/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 23:19:12 UTC
  • mfrom: (7180 work)
  • mto: This revision was merged to the branch mainline in revision 7294.
  • Revision ID: jelmer@jelmer.uk-20181116231912-e043vpq22bdkxa6q
Merge trunk.

Show diffs side-by-side

added added

removed removed

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