/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-05-06 11:48:54 UTC
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@jelmer.uk-20180506114854-h4qd9ojaqy8wxjsd
Move .mailmap to root.

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
 
        delta.unversioned = [change for change in delta.unversioned
80
 
                             if not new.is_ignored(change.path[1])]
 
79
        delta.unversioned = [unversioned for unversioned in
 
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,
128
128
    if to_file is None:
129
129
        to_file = sys.stdout
130
130
 
131
 
    with wt.lock_read():
 
131
    wt.lock_read()
 
132
    try:
132
133
        new_is_working_tree = True
133
134
        if revision is None:
134
135
            if wt.last_revision() != wt.branch.last_revision():
148
149
                    raise errors.BzrCommandError(str(e))
149
150
            else:
150
151
                new = wt
151
 
        with old.lock_read(), new.lock_read():
 
152
        old.lock_read()
 
153
        new.lock_read()
 
154
        try:
152
155
            for hook in hooks['pre_status']:
153
 
                hook(StatusHookParams(
154
 
                    old, new, to_file, versioned, show_ids, short, verbose,
155
 
                    specific_files=specific_files))
 
156
                hook(StatusHookParams(old, new, to_file, versioned,
 
157
                    show_ids, short, verbose, specific_files=specific_files))
156
158
 
157
159
            specific_files, nonexistents \
158
160
                = _filter_nonexistent(specific_files, old, new)
159
161
            want_unversioned = not versioned
160
162
 
161
163
            # Reporter used for short outputs
162
 
            reporter = _mod_delta._ChangeReporter(
163
 
                output_file=to_file, unversioned_filter=new.is_ignored,
164
 
                classify=classify)
 
164
            reporter = _mod_delta._ChangeReporter(output_file=to_file,
 
165
                unversioned_filter=new.is_ignored, classify=classify)
165
166
            report_changes(to_file, old, new, specific_files,
166
167
                           reporter, show_long_callback,
167
168
                           short=short, want_unversioned=want_unversioned,
172
173
            if specific_files is not None:
173
174
                # Ignored files is sorted because specific_files is already sorted
174
175
                ignored_files = [specific for specific in
175
 
                                 specific_files if new.is_ignored(specific)]
 
176
                    specific_files if new.is_ignored(specific)]
176
177
                if len(ignored_files) > 0 and not short:
177
178
                    to_file.write("ignored:\n")
178
179
                    prefix = ' '
185
186
            # delta.
186
187
            conflicts = new.conflicts()
187
188
            if specific_files is not None:
188
 
                conflicts = conflicts.select_conflicts(
189
 
                    new, specific_files, ignore_misses=True, recurse=True)[1]
 
189
                conflicts = conflicts.select_conflicts(new, specific_files,
 
190
                    ignore_misses=True, recurse=True)[1]
190
191
            if len(conflicts) > 0 and not short:
191
192
                to_file.write("conflicts:\n")
192
193
            for conflict in conflicts:
194
195
                    prefix = 'C  '
195
196
                else:
196
197
                    prefix = ' '
197
 
                to_file.write("%s %s\n" % (prefix, conflict.describe()))
 
198
                to_file.write("%s %s\n" % (prefix, unicode(conflict)))
198
199
            # Show files that were requested but don't exist (and are
199
200
            # not versioned).  We don't involve delta in this; these
200
201
            # paths are really the province of just the status
216
217
            if nonexistents:
217
218
                raise errors.PathsDoNotExist(nonexistents)
218
219
            for hook in hooks['post_status']:
219
 
                hook(StatusHookParams(
220
 
                    old, new, to_file, versioned, show_ids, short, verbose,
221
 
                    specific_files=specific_files))
 
220
                hook(StatusHookParams(old, new, to_file, versioned,
 
221
                    show_ids, short, verbose, specific_files=specific_files))
 
222
        finally:
 
223
            old.unlock()
 
224
            new.unlock()
 
225
    finally:
 
226
        wt.unlock()
222
227
 
223
228
 
224
229
def _get_sorted_revisions(tip_revision, revision_ids, parent_map):
237
242
    # of any references pointing outside of this graph.
238
243
    parent_graph = {}
239
244
    for revision_id in revision_ids:
240
 
        if revision_id not in parent_map:  # ghost
 
245
        if revision_id not in parent_map: # ghost
241
246
            parent_graph[revision_id] = []
242
247
        else:
243
248
            # Only include parents which are in this sub-graph
244
249
            parent_graph[revision_id] = [p for p in parent_map[revision_id]
245
 
                                         if p in revision_ids]
 
250
                                            if p in revision_ids]
246
251
    sorter = tsort.MergeSorter(parent_graph, tip_revision)
247
252
    return sorter.iter_topo_order()
248
253
 
289
294
            rev = branch.repository.get_revision(merge)
290
295
        except errors.NoSuchRevision:
291
296
            # If we are missing a revision, just print out the revision id
292
 
            to_file.write(first_prefix + '(ghost) ' +
293
 
                          merge.decode('utf-8') + '\n')
 
297
            to_file.write(first_prefix + '(ghost) ' + merge + '\n')
294
298
            other_revisions.append(merge)
295
299
            continue
296
300
 
310
314
 
311
315
        # Display the revisions brought in by this merge.
312
316
        rev_id_iterator = _get_sorted_revisions(merge, merge_extra,
313
 
                                                branch.repository.get_parent_map(merge_extra))
 
317
                            branch.repository.get_parent_map(merge_extra))
314
318
        # Skip the first node
315
319
        num, first, depth, eom = next(rev_id_iterator)
316
320
        if first != merge:
317
321
            raise AssertionError('Somehow we misunderstood how'
318
 
                                 ' iter_topo_order works %s != %s' % (first, merge))
 
322
                ' iter_topo_order works %s != %s' % (first, merge))
319
323
        for num, sub_merge, depth, eom in rev_id_iterator:
320
324
            rev = revisions[sub_merge]
321
325
            if rev is None:
322
 
                to_file.write(sub_prefix + '(ghost) ' +
323
 
                              sub_merge.decode('utf-8') + '\n')
 
326
                to_file.write(sub_prefix + '(ghost) ' + sub_merge + '\n')
324
327
                continue
325
328
            show_log_message(revisions[sub_merge], sub_prefix)
326
329
 
344
347
    s = old_tree.filter_unversioned_files(orig_paths)
345
348
    s = new_tree.filter_unversioned_files(s)
346
349
    nonexistent = [path for path in s if not new_tree.has_filename(path)]
347
 
    remaining = [path for path in orig_paths if path not in nonexistent]
 
350
    remaining   = [path for path in orig_paths if not path in nonexistent]
348
351
    # Sorting the 'remaining' list doesn't have much effect in
349
352
    # practice, since the various status output sections will sort
350
353
    # their groups individually.  But for consistency of this
366
369
        notified.
367
370
        """
368
371
        _mod_hooks.Hooks.__init__(self, "breezy.status", "hooks")
369
 
        self.add_hook(
370
 
            'post_status',
 
372
        self.add_hook('post_status',
371
373
            "Called with argument StatusHookParams after Bazaar has "
372
374
            "displayed the status. StatusHookParams has the attributes "
373
375
            "(old_tree, new_tree, to_file, versioned, show_ids, short, "
375
377
            "line options specified by the user for the status command. "
376
378
            "to_file is the output stream for writing.",
377
379
            (2, 3))
378
 
        self.add_hook(
379
 
            'pre_status',
 
380
        self.add_hook('pre_status',
380
381
            "Called with argument StatusHookParams before Bazaar "
381
382
            "displays the status. StatusHookParams has the attributes "
382
383
            "(old_tree, new_tree, to_file, versioned, show_ids, short, "
399
400
    """
400
401
 
401
402
    def __init__(self, old_tree, new_tree, to_file, versioned, show_ids,
402
 
                 short, verbose, specific_files=None):
 
403
            short, verbose, specific_files=None):
403
404
        """Create a group of post_status hook parameters.
404
405
 
405
406
        :param old_tree: Start tree (basis tree) for comparison.
410
411
        :param short: Use short status indicators.
411
412
        :param verbose: Verbose flag.
412
413
        :param specific_files: If set, a list of filenames whose status should be
413
 
            shown.  It is an error to give a filename that is not in the
414
 
            working tree, or in the working inventory or in the basis inventory.
 
414
            shown.  It is an error to give a filename that is not in the working
 
415
            tree, or in the working inventory or in the basis inventory.
415
416
        """
416
417
        self.old_tree = old_tree
417
418
        self.new_tree = new_tree
426
427
        return self.__dict__ == other.__dict__
427
428
 
428
429
    def __repr__(self):
429
 
        return "<%s(%s, %s, %s, %s, %s, %s, %s, %s)>" % (
430
 
            self.__class__.__name__, self.old_tree, self.new_tree,
431
 
            self.to_file, self.versioned, self.show_ids, self.short,
432
 
            self.verbose, self.specific_files)
 
430
        return "<%s(%s, %s, %s, %s, %s, %s, %s, %s)>" % (self.__class__.__name__,
 
431
            self.old_tree, self.new_tree, self.to_file, self.versioned,
 
432
            self.show_ids, self.short, self.verbose, self.specific_files)
433
433
 
434
434
 
435
435
def _show_shelve_summary(params):
465
465
 
466
466
 
467
467
hooks.install_named_hook('post_status', _show_shelve_summary,
468
 
                         'brz status')
 
468
    'brz status')
 
469