Exemplo n.º 1
0
def _send_0_9(branch,
              revision_id,
              submit_branch,
              public_branch,
              no_patch,
              no_bundle,
              message,
              base_revision_id,
              local_target_branch=None):
    if not no_bundle:
        if not no_patch:
            patch_type = 'bundle'
        else:
            raise errors.BzrCommandError(
                gettext('Format 0.9 does not'
                        ' permit bundle with no patch'))
    else:
        if not no_patch:
            patch_type = 'diff'
        else:
            patch_type = None
    from bzrlib import merge_directive
    return merge_directive.MergeDirective.from_objects(
        branch.repository,
        revision_id,
        time.time(),
        osutils.local_time_offset(),
        submit_branch,
        public_branch=public_branch,
        patch_type=patch_type,
        message=message,
        local_target_branch=local_target_branch)
Exemplo n.º 2
0
def _send_4(branch, revision_id, target_branch, public_branch,
            no_patch, no_bundle, message,
            base_revision_id, local_target_branch=None):
    from bzrlib import merge_directive
    return merge_directive.MergeDirective2.from_objects(
        branch.repository, revision_id, time.time(),
        osutils.local_time_offset(), target_branch,
        public_branch=public_branch,
        include_patch=not no_patch,
        include_bundle=not no_bundle, message=message,
        base_revision_id=base_revision_id,
        local_target_branch=local_target_branch)
Exemplo n.º 3
0
def create_date_str(timestamp=None, offset=None):
    """Just a wrapper around format_date to provide the right format.

    We don't want to use '%a' in the time string, because it is locale
    dependant. We also want to force timezone original, and show_offset

    Without parameters this function yields the current date in the local
    time zone.
    """
    if timestamp is None and offset is None:
        timestamp = time.time()
        offset = local_time_offset()
    return format_date(timestamp, offset, date_fmt='%Y-%m-%d %H:%M:%S',
                       timezone='original', show_offset=True)
Exemplo n.º 4
0
 def get_merge_directive(self):
     from bzrlib.merge_directive import MergeDirective2
     from bzrlib import osutils
     import time
     return MergeDirective2.from_objects(self.branch.repository,
                                         self.branch.last_revision(),
                                         time.time(),
                                         osutils.local_time_offset(),
                                         self.submit_branch.get_url(),
                                         public_branch=None,
                                         include_patch=True,
                                         include_bundle=True,
                                         message=None,
                                         base_revision_id=None)
Exemplo n.º 5
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)
Exemplo n.º 6
0
 def test_random(self):
     t = time.time()
     o = local_time_offset()
     t2, o2 = timestamp.unpack_highres_date(timestamp.format_highres_date(t, o))
     self.assertEquals(t, t2)
     self.assertEquals(o, o2)
     t -= 24*3600*365*2 # Start 2 years ago
     o = -12*3600
     for count in xrange(500):
         t += random.random()*24*3600*30
         o = ((o/3600 + 13) % 25 - 12)*3600 # Add 1 wrap around from [-12, 12]
         date = timestamp.format_highres_date(t, o)
         t2, o2 = timestamp.unpack_highres_date(date)
         self.assertEquals(t, t2,
             'Failed on date %r, %s,%s diff:%s' % (date, t, o, t2-t))
         self.assertEquals(o, o2,
             'Failed on date %r, %s,%s diff:%s' % (date, t, o, t2-t))
Exemplo n.º 7
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)
Exemplo n.º 8
0
def _send_0_9(branch, revision_id, submit_branch, public_branch,
              no_patch, no_bundle, message,
              base_revision_id, local_target_branch=None):
    if not no_bundle:
        if not no_patch:
            patch_type = 'bundle'
        else:
            raise errors.BzrCommandError(gettext('Format 0.9 does not'
                ' permit bundle with no patch'))
    else:
        if not no_patch:
            patch_type = 'diff'
        else:
            patch_type = None
    from bzrlib import merge_directive
    return merge_directive.MergeDirective.from_objects(
        branch.repository, revision_id, time.time(),
        osutils.local_time_offset(), submit_branch,
        public_branch=public_branch, patch_type=patch_type,
        message=message, local_target_branch=local_target_branch)
Exemplo n.º 9
0
 def test_random(self):
     t = time.time()
     o = local_time_offset()
     t2, o2 = timestamp.unpack_highres_date(
         timestamp.format_highres_date(t, o))
     self.assertEqual(t, t2)
     self.assertEqual(o, o2)
     t -= 24 * 3600 * 365 * 2  # Start 2 years ago
     o = -12 * 3600
     for count in xrange(500):
         t += random.random() * 24 * 3600 * 30
         o = ((o / 3600 + 13) % 25 -
              12) * 3600  # Add 1 wrap around from [-12, 12]
         date = timestamp.format_highres_date(t, o)
         t2, o2 = timestamp.unpack_highres_date(date)
         self.assertEqual(
             t, t2,
             'Failed on date %r, %s,%s diff:%s' % (date, t, o, t2 - t))
         self.assertEqual(
             o, o2,
             'Failed on date %r, %s,%s diff:%s' % (date, t, o, t2 - t))
Exemplo n.º 10
0
def _send_4(branch,
            revision_id,
            target_branch,
            public_branch,
            no_patch,
            no_bundle,
            message,
            base_revision_id,
            local_target_branch=None):
    from bzrlib import merge_directive
    return merge_directive.MergeDirective2.from_objects(
        branch.repository,
        revision_id,
        time.time(),
        osutils.local_time_offset(),
        target_branch,
        public_branch=public_branch,
        include_patch=not no_patch,
        include_bundle=not no_bundle,
        message=message,
        base_revision_id=base_revision_id,
        local_target_branch=local_target_branch)