Example #1
0
def annotate_file_tree(tree,
                       file_id,
                       to_file,
                       verbose=False,
                       full=False,
                       show_ids=False,
                       branch=None):
    """Annotate file_id in a tree.

    The tree should already be read_locked() when annotate_file_tree is called.

    :param tree: The tree to look for revision numbers and history from.
    :param file_id: The file_id to annotate.
    :param to_file: The file to output the annotation to.
    :param verbose: Show all details rather than truncating to ensure
        reasonable text width.
    :param full: XXXX Not sure what this does.
    :param show_ids: Show revision ids in the annotation output.
    :param branch: Branch to use for revision revno lookups
    """
    if branch is None:
        branch = tree.branch
    if to_file is None:
        to_file = sys.stdout

    # Handle the show_ids case
    annotations = list(tree.annotate_iter(file_id))
    if show_ids:
        return _show_id_annotations(annotations, to_file, full)

    if not getattr(tree, "get_revision_id", False):
        # Create a virtual revision to represent the current tree state.
        # Should get some more pending commit attributes, like pending tags,
        # bugfixes etc.
        current_rev = Revision(CURRENT_REVISION)
        current_rev.parent_ids = tree.get_parent_ids()
        try:
            current_rev.committer = branch.get_config_stack().get('email')
        except errors.NoWhoami:
            current_rev.committer = 'local user'
        current_rev.message = "?"
        current_rev.timestamp = round(time.time(), 3)
        current_rev.timezone = osutils.local_time_offset()
    else:
        current_rev = None
    annotation = list(_expand_annotations(annotations, branch, current_rev))
    _print_annotations(annotation, verbose, to_file, full)
Example #2
0
 def test_roundtrips_non_ascii(self):
     rev = Revision("revid1")
     rev.message = u"\n\xe5me"
     rev.committer = u'Erik B\xe5gfors'
     rev.timestamp = 1242385452
     rev.inventory_sha1 = "4a2c7fb50e077699242cf6eb16a61779c7b680a7"
     rev.timezone = 3600
     self.assertRoundTrips(chk_bencode_serializer, rev)
Example #3
0
 def test_roundtrips_xml_invalid_chars(self):
     rev = Revision("revid1")
     rev.message = "\t\ue000"
     rev.committer = u'Erik B\xe5gfors'
     rev.timestamp = 1242385452
     rev.timezone = 3600
     rev.inventory_sha1 = "4a2c7fb50e077699242cf6eb16a61779c7b680a7"
     self.assertRoundTrips(chk_bencode_serializer, rev)
 def test_roundtrips_non_ascii(self):
     rev = Revision("revid1")
     rev.message = u"\n\xe5me"
     rev.committer = u'Erik B\xe5gfors'
     rev.timestamp = 1242385452
     rev.inventory_sha1 = "4a2c7fb50e077699242cf6eb16a61779c7b680a7"
     rev.timezone = 3600
     self.assertRoundTrips(chk_bencode_serializer, rev)
 def test_roundtrips_xml_invalid_chars(self):
     rev = Revision("revid1")
     rev.message = "\t\ue000"
     rev.committer = u'Erik B\xe5gfors'
     rev.timestamp = 1242385452
     rev.timezone = 3600
     rev.inventory_sha1 = "4a2c7fb50e077699242cf6eb16a61779c7b680a7"
     self.assertRoundTrips(chk_bencode_serializer, rev)
Example #6
0
def annotate_file_tree(tree, file_id, to_file, verbose=False, full=False,
    show_ids=False, branch=None):
    """Annotate file_id in a tree.

    The tree should already be read_locked() when annotate_file_tree is called.

    :param tree: The tree to look for revision numbers and history from.
    :param file_id: The file_id to annotate.
    :param to_file: The file to output the annotation to.
    :param verbose: Show all details rather than truncating to ensure
        reasonable text width.
    :param full: XXXX Not sure what this does.
    :param show_ids: Show revision ids in the annotation output.
    :param branch: Branch to use for revision revno lookups
    """
    if branch is None:
        branch = tree.branch
    if to_file is None:
        to_file = sys.stdout

    # Handle the show_ids case
    annotations = list(tree.annotate_iter(file_id))
    if show_ids:
        return _show_id_annotations(annotations, to_file, full)

    if not getattr(tree, "get_revision_id", False):
        # Create a virtual revision to represent the current tree state.
        # Should get some more pending commit attributes, like pending tags,
        # bugfixes etc.
        current_rev = Revision(CURRENT_REVISION)
        current_rev.parent_ids = tree.get_parent_ids()
        try:
            current_rev.committer = branch.get_config_stack().get('email')
        except errors.NoWhoami:
            current_rev.committer = 'local user'
        current_rev.message = "?"
        current_rev.timestamp = round(time.time(), 3)
        current_rev.timezone = osutils.local_time_offset()
    else:
        current_rev = None
    annotation = list(_expand_annotations(annotations, branch,
        current_rev))
    _print_annotations(annotation, verbose, to_file, full)
Example #7
0
 def test_short_author(self):
     rev = Revision('a-id')
     rev.committer = 'John Doe <*****@*****.**>'
     lf = LogFormatter(None)
     self.assertEqual('John Doe', lf.short_author(rev))
     rev.properties['author'] = 'John Smith <*****@*****.**>'
     self.assertEqual('John Smith', lf.short_author(rev))
     rev.properties['author'] = 'John Smith'
     self.assertEqual('John Smith', lf.short_author(rev))
     rev.properties['author'] = '*****@*****.**'
     self.assertEqual('*****@*****.**', lf.short_author(rev))
     rev.properties['author'] = '<*****@*****.**>'
     self.assertEqual('*****@*****.**', lf.short_author(rev))
     rev.properties['author'] = 'John Smith [email protected]'
     self.assertEqual('John Smith', lf.short_author(rev))
Example #8
0
 def test_short_author(self):
     rev = Revision('a-id')
     rev.committer = 'John Doe <*****@*****.**>'
     lf = LogFormatter(None)
     self.assertEqual('John Doe', lf.short_author(rev))
     rev.properties['author'] = 'John Smith <*****@*****.**>'
     self.assertEqual('John Smith', lf.short_author(rev))
     rev.properties['author'] = 'John Smith'
     self.assertEqual('John Smith', lf.short_author(rev))
     rev.properties['author'] = '*****@*****.**'
     self.assertEqual('*****@*****.**', lf.short_author(rev))
     rev.properties['author'] = '<*****@*****.**>'
     self.assertEqual('*****@*****.**', lf.short_author(rev))
     rev.properties['author'] = 'John Smith [email protected]'
     self.assertEqual('John Smith', lf.short_author(rev))