Beispiel #1
0
def repo_push(src_repo, dst_repo, pb, overwrite=False):
    src_repo.lock_read()
    try:
        dst_repo.lock_write()
        try:
            src_repo_trans = src_repo.bzrdir.root_transport
            dst_repo_trans = dst_repo.bzrdir.root_transport

            pb.update('Getting list of branches', 0, 1)
            branches = list_branches(src_repo)
            note('Pushing %d branches from %s to %s' %
                 (len(branches), src_repo_trans.base, dst_repo_trans.base))

            # XXX: ideally this would only fetch the tips of the
            # branches we found previously.
            pb.update('Fetching entire repo', 0, 1)
            dst_repo.fetch(src_repo, pb=pb)

            # Now synchronise the revision histories of the local and
            # remote branches.  The previous fetch() call has made
            # sure that the corresponding revisions exist in dst_repo.
            for index, src_branch in enumerate(branches):
                pb.update('Updating branches', index, len(branches))
                relpath = src_repo_trans.relpath(
                    src_branch.bzrdir.root_transport.base)
                format = BranchFormat.find_format(src_branch.bzrdir)
                dst_branch = get_branch(dst_repo, relpath, format)

                src_history = src_branch.revision_history()
                dst_history = dst_branch.revision_history()

                # If we aren't overwriting and the destination history
                # is not a subset of the source history, error out.
                # XXX this implementation is buggy in some cases
                if not overwrite and (src_history[:len(dst_history)] !=
                                      dst_history):
                    raise errors.BzrCommandError('Branch %s has diverged' %
                                                 relpath)

                # push tags
                src_branch.tags.merge_to(dst_branch.tags)

                if src_history != dst_history:
                    dst_branch.set_revision_history(src_history)
                    note('%d revision(s) pushed to %s' %
                         (len(src_history) - len(dst_history), relpath))
        finally:
            dst_repo.unlock()
    finally:
        src_repo.unlock()
Beispiel #2
0
def repo_push(src_repo, dst_repo, pb, overwrite=False):
    src_repo.lock_read()
    try:
        dst_repo.lock_write()
        try:
            src_repo_trans = src_repo.bzrdir.root_transport
            dst_repo_trans = dst_repo.bzrdir.root_transport

            pb.update('Getting list of branches', 0, 1)
            branches = list_branches(src_repo)
            note('Pushing %d branches from %s to %s'
                 % (len(branches), src_repo_trans.base, dst_repo_trans.base))
            
            # XXX: ideally this would only fetch the tips of the
            # branches we found previously.
            pb.update('Fetching entire repo', 0, 1)
            dst_repo.fetch(src_repo, pb=pb)

            # Now synchronise the revision histories of the local and
            # remote branches.  The previous fetch() call has made
            # sure that the corresponding revisions exist in dst_repo.
            for index, src_branch in enumerate(branches):
                pb.update('Updating branches', index, len(branches))
                relpath = src_repo_trans.relpath(
                    src_branch.bzrdir.root_transport.base)
                format = BranchFormat.find_format(src_branch.bzrdir)
                dst_branch = get_branch(dst_repo, relpath, format)

                src_history = src_branch.revision_history()
                dst_history = dst_branch.revision_history()

                # If we aren't overwriting and the destination history
                # is not a subset of the source history, error out.
                # XXX this implementation is buggy in some cases
                if not overwrite and (src_history[:len(dst_history)] !=
                                      dst_history):
                    raise errors.BzrCommandError('Branch %s has diverged'
                                                 % relpath)

                # push tags
                src_branch.tags.merge_to(dst_branch.tags)

                if src_history != dst_history:
                    dst_branch.set_revision_history(src_history)
                    note('%d revision(s) pushed to %s'
                         % (len(src_history) - len(dst_history), relpath))
        finally:
            dst_repo.unlock()
    finally:
        src_repo.unlock()
Beispiel #3
0
 def check_format(format, url):
     dir = format._matchingbzrdir.initialize(url)
     dir.create_repository()
     format.initialize(dir)
     found_format = BranchFormat.find_format(dir)
     self.failUnless(isinstance(found_format, format.__class__))
Beispiel #4
0
 def check_format(format, url):
     dir = format._matchingbzrdir.initialize(url)
     dir.create_repository()
     format.initialize(dir)
     found_format = BranchFormat.find_format(dir)
     self.failUnless(isinstance(found_format, format.__class__))