~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/log.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-06-02 15:39:06 UTC
  • mfrom: (4393.2.2 bzr.ls-fix)
  • Revision ID: pqm@pqm.ubuntu.com-20090602153906-1q6bresxw669b34i
(Mattias Eriksson) Clear the terminal before outputing 'bzr ls'
        results.

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
    config,
70
70
    diff,
71
71
    errors,
 
72
    foreign,
72
73
    repository as _mod_repository,
73
74
    revision as _mod_revision,
74
75
    revisionspec,
1366
1367
        else:
1367
1368
            return ''
1368
1369
 
 
1370
    def show_foreign_info(self, rev, indent):
 
1371
        """Custom log displayer for foreign revision identifiers.
 
1372
 
 
1373
        :param rev: Revision object.
 
1374
        """
 
1375
        # Revision comes directly from a foreign repository
 
1376
        if isinstance(rev, foreign.ForeignRevision):
 
1377
            self._write_properties(indent, rev.mapping.vcs.show_foreign_revid(
 
1378
                rev.foreign_revid))
 
1379
            return
 
1380
 
 
1381
        # Imported foreign revision revision ids always contain :
 
1382
        if not ":" in rev.revision_id:
 
1383
            return
 
1384
 
 
1385
        # Revision was once imported from a foreign repository
 
1386
        try:
 
1387
            foreign_revid, mapping = \
 
1388
                foreign.foreign_vcs_registry.parse_revision_id(rev.revision_id)
 
1389
        except errors.InvalidRevisionId:
 
1390
            return
 
1391
 
 
1392
        self._write_properties(indent, 
 
1393
            mapping.vcs.show_foreign_revid(foreign_revid))
 
1394
 
1369
1395
    def show_properties(self, revision, indent):
1370
1396
        """Displays the custom properties returned by each registered handler.
1371
1397
 
1372
1398
        If a registered handler raises an error it is propagated.
1373
1399
        """
1374
1400
        for key, handler in properties_handler_registry.iteritems():
1375
 
            for key, value in handler(revision).items():
1376
 
                self.to_file.write(indent + key + ': ' + value + '\n')
 
1401
            self._write_properties(indent, handler(revision))
 
1402
 
 
1403
    def _write_properties(self, indent, properties):
 
1404
        for key, value in properties.items():
 
1405
            self.to_file.write(indent + key + ': ' + value + '\n')
1377
1406
 
1378
1407
    def show_diff(self, to_file, diff, indent):
1379
1408
        for l in diff.rstrip().split('\n'):
1403
1432
            to_file.write('\n')
1404
1433
            for parent_id in revision.rev.parent_ids:
1405
1434
                to_file.write(indent + 'parent: %s\n' % (parent_id,))
 
1435
        self.show_foreign_info(revision.rev, indent)
1406
1436
        self.show_properties(revision.rev, indent)
1407
1437
 
1408
1438
        committer = revision.rev.committer
1485
1515
                            self.show_timezone, date_fmt="%Y-%m-%d",
1486
1516
                            show_offset=False),
1487
1517
                tags, self.merge_marker(revision)))
 
1518
        self.show_foreign_info(revision.rev, indent+offset)
1488
1519
        self.show_properties(revision.rev, indent+offset)
1489
1520
        if self.show_ids:
1490
1521
            to_file.write(indent + offset + 'revision-id:%s\n'
1901
1932
 
1902
1933
 
1903
1934
properties_handler_registry = registry.Registry()
1904
 
properties_handler_registry.register_lazy("foreign",
1905
 
                                          "bzrlib.foreign",
1906
 
                                          "show_foreign_properties")
1907
1935
 
1908
1936
 
1909
1937
# adapters which revision ids to log are filtered. When log is called, the