예제 #1
0
def export_upstream(uri, tag, vcs_type, output_dir, show_uri, name):
    tag = tag if tag != ":{none}" else None
    output_dir = output_dir or os.getcwd()
    if uri.startswith("git@"):
        uri_is_path = False
    else:
        uri_parsed = urlparse(uri)
        uri = uri if uri_parsed.scheme else uri_parsed.path
        uri_is_path = False if uri_parsed.scheme else True
    name = name or "upstream"
    with temporary_directory() as tmp_dir:
        info(
            "Checking out repository at '{0}'".format(show_uri or uri)
            + (" to reference '{0}'.".format(tag) if tag else ".")
        )
        if uri_is_path:
            upstream_repo = get_vcs_client(vcs_type, uri)
        else:
            repo_path = os.path.join(tmp_dir, "upstream")
            upstream_repo = get_vcs_client(vcs_type, repo_path)
            if not upstream_repo.checkout(uri, tag or ""):
                error(
                    "Failed to clone repository at '{0}'".format(uri)
                    + (" to reference '{0}'.".format(tag) if tag else "."),
                    exit=True,
                )
        if get_root() is not None and has_submodules(upstream_repo.get_path()):
            error(
                """\
bloom does not support exporting git repositories with submodules, see:

- https://github.com/ros-infrastructure/bloom/issues/202
- https://github.com/ros-infrastructure/bloom/issues/217
- https://github.com/vcstools/vcstools/issues/84
""",
                exit=True,
            )
        tarball_prefix = "{0}-{1}".format(name, tag) if tag else name
        tarball_path = os.path.join(output_dir, tarball_prefix)
        full_tarball_path = tarball_path + ".tar.gz"
        info("Exporting to archive: '{0}'".format(full_tarball_path))
        if not upstream_repo.export_repository(tag or "", tarball_path):
            error("Failed to create archive of upstream repository at '{0}'".format(show_uri))
            if tag and vcs_type == "git":  # can only check for git repos
                with change_directory(upstream_repo.get_path()):
                    if not tag_exists(tag):
                        warning("'{0}' is not a tag in the upstream repository...".format(tag))
                    if not branch_exists(tag):
                        warning("'{0}' is not a branch in the upstream repository...".format(tag))
        if not os.path.exists(full_tarball_path):
            error("Tarball was not created.", exit=True)
        info("md5: {0}".format(calculate_file_md5(full_tarball_path)))
예제 #2
0
def export_upstream(uri, tag, vcs_type, output_dir, show_uri, name):
    tag = tag if tag != ':{none}' else None
    output_dir = output_dir or os.getcwd()
    if uri.startswith('git@'):
        uri_is_path = False
    else:
        uri_parsed = urlparse(uri)
        uri = uri if uri_parsed.scheme else uri_parsed.path
        uri_is_path = False if uri_parsed.scheme else True
    name = name or 'upstream'
    with temporary_directory() as tmp_dir:
        info("Checking out repository at '{0}'".format(show_uri or uri) +
             (" to reference '{0}'.".format(tag) if tag else '.'))
        if uri_is_path:
            upstream_repo = get_vcs_client(vcs_type, uri)
        else:
            repo_path = os.path.join(tmp_dir, 'upstream')
            upstream_repo = get_vcs_client(vcs_type, repo_path)
            if not upstream_repo.checkout(uri, tag or ''):
                error("Failed to clone repository at '{0}'".format(uri) +
                      (" to reference '{0}'.".format(tag) if tag else '.'),
                      exit=True)
        if get_root() is not None and has_submodules(upstream_repo.get_path()):
            error("""\
bloom does not support exporting git repositories with submodules, see:

- https://github.com/ros-infrastructure/bloom/issues/202
- https://github.com/ros-infrastructure/bloom/issues/217
- https://github.com/vcstools/vcstools/issues/84
""",
                  exit=True)
        tarball_prefix = '{0}-{1}'.format(name, tag) if tag else name
        tarball_path = os.path.join(output_dir, tarball_prefix)
        full_tarball_path = tarball_path + '.tar.gz'
        info("Exporting to archive: '{0}'".format(full_tarball_path))
        if not upstream_repo.export_repository(tag or '', tarball_path):
            error("Failed to create archive of upstream repository at '{0}'".
                  format(show_uri))
            if tag and vcs_type == 'git':  # can only check for git repos
                with change_directory(upstream_repo.get_path()):
                    if not tag_exists(tag):
                        warning(
                            "'{0}' is not a tag in the upstream repository...".
                            format(tag))
                    if not branch_exists(tag):
                        warning(
                            "'{0}' is not a branch in the upstream repository..."
                            .format(tag))
        if not os.path.exists(full_tarball_path):
            error("Tarball was not created.", exit=True)
        info("md5: {0}".format(calculate_file_md5(full_tarball_path)))
예제 #3
0
파일: release.py 프로젝트: vrabaud/bloom
def get_upstream_repo(uri, vcs_type):
    global upstream_repos
    if uri not in upstream_repos:
        temp_dir = tempfile.mkdtemp()
        upstream_dir = os.path.join(temp_dir, 'upstream')
        upstream_repos[uri] = (temp_dir, get_vcs_client(vcs_type, upstream_dir))
    return upstream_repos[uri][1]
예제 #4
0
def test_unary_package_repository(directory=None):
    """
    Release a single package catkin (melodic) repository.
    """
    directory = directory if directory is not None else os.getcwd()
    # Initialize rosdep
    rosdep_dir = os.path.join(directory, 'foo_rosdep')
    env = dict(os.environ)
    fake_distros = {'melodic': {'ubuntu': ['bionic']}}
    fake_rosdeps = {'catkin': {'ubuntu': []}, 'roscpp_core': {'ubuntu': []}}
    env.update(set_up_fake_rosdep(rosdep_dir, fake_distros, fake_rosdeps))
    # Setup
    upstream_dir = create_upstream_repository(['foo'], directory)
    upstream_url = 'file://' + upstream_dir
    release_url = create_release_repo(upstream_url, 'git', 'melodic_devel',
                                      'melodic')
    release_dir = os.path.join(directory, 'foo_release_clone')
    release_client = get_vcs_client('git', release_dir)
    assert release_client.checkout(release_url)
    versions = ['0.1.0', '0.1.1', '0.2.0']
    import bloom.commands.git.release
    for index in range(len(versions)):
        _test_unary_package_repository(release_dir,
                                       versions[index],
                                       directory,
                                       env=env)
        bloom.commands.git.release.upstream_repos = {}
        if index != len(versions) - 1:
            change_upstream_version(upstream_dir, versions[index + 1])
예제 #5
0
def test_upstream_tag_special_tag(directory=None):
    """
    Release a single package catkin (melodic) repository, first put
    an upstream tag into the release repository to test that bloom
    can handle it.
    """
    directory = directory if directory is not None else os.getcwd()
    # Initialize rosdep
    rosdep_dir = os.path.join(directory, 'foo_rosdep')
    env = dict(os.environ)
    fake_distros = {'melodic': {'ubuntu': ['bionic']}}
    fake_rosdeps = {'catkin': {'ubuntu': []}, 'roscpp_core': {'ubuntu': []}}
    env.update(set_up_fake_rosdep(rosdep_dir, fake_distros, fake_rosdeps))
    # Setup
    upstream_dir = create_upstream_repository(['foo'], directory)
    upstream_url = 'file://' + upstream_dir
    release_url = create_release_repo(upstream_url, 'git', 'melodic_devel',
                                      'melodic')
    release_dir = os.path.join(directory, 'foo_release_clone')
    release_client = get_vcs_client('git', release_dir)
    assert release_client.checkout(release_url)

    with change_directory(release_dir):
        user('git tag upstream/0.0.0@baz')

    import bloom.commands.git.release
    _test_unary_package_repository(release_dir, '0.1.0', directory, env=env)
예제 #6
0
def main(sysargs):
    parser = get_argument_parser()
    args = parser.parse_args(sys.argv[1:])
    repository = args.repository
    verbose = args.verbose

    # checkout target rpository
    info("Manually clone the repository")
    info("  git clone {0}".format(repository))
    git = get_vcs_client('git', tempfile.mktemp())
    info(fmt("@{gf}@!==> @|") +
             "Fetching repository from '{0}'".format(repository))
    ret = git.checkout(repository, verbose=verbose)
    if not ret:
        error("Could not checkout {}".format(repository))
        return 1

    # get the github repository info
    base_org, base_repo = get_gh_info(git.get_url())
    # get correct repo info (case sensitive)
    gh = get_github_interface()
    base_org, base_repo = get_gh_info(gh.get_repo(base_org, base_repo)['html_url'])

    base_branch = git.get_branches()[0] # is this ok?

    with change_directory(git.get_path()):
        # write travis yaml
        write_travis_yaml()
        # write readme
        write_readme_md(**locals())

        # create pull request
        open_pull_request(base_org=base_org, base_repo=base_repo, base_branch=base_branch, new_branch="add_travis")
예제 #7
0
 def do_work(self):
     vcsc = get_vcs_client(self.scm_type, os.path.join(self.path, self.localname))
     return {'scm': '--' + self.scm_type, # prefix '--' to allow copy&paste to set command
         'localname': self.localname,
         'path': self.path,
         'uri': vcsc.get_url(),
         'properties': self.element.get_properties()}
예제 #8
0
 def do_work(self):
     vcsc = get_vcs_client(self.scm_type, os.path.join(self.path, self.localname))
     return {'scm': '--' + self.scm_type, # prefix '--' to allow copy&paste to set command
         'localname': self.localname,
         'path': self.path,
         'uri': vcsc.get_url(),
         'properties': self.element.get_properties()}
def test_fuerte_package_repository(directory=None):
    """
    Release a single catkin stack (fuerte) repository.
    """
    directory = directory if directory is not None else os.getcwd()
    # Setup
    upstream_url = create_upstream_catkin_fuerte_repository('foo', directory)
    release_url = create_release_repo(upstream_url, 'git', 'fuerte_devel')
    release_dir = os.path.join(directory, 'foo_release_clone')
    release_client = get_vcs_client('git', release_dir)
    release_client.checkout(release_url)
    with change_directory(release_dir):
        ###
        ### Import upstream
        ###
        user('git-bloom-import-upstream --quiet')
        # does the upstream branch exist?
        assert branch_exists('upstream', local_only=True), "no upstream branch"
        # does the upstrea/0.1.0 tag exist?
        ret, out, err = user('git tag', return_io=True)
        assert out.count('upstream/0.1.0') == 1, "no upstream tag created"
        # Is the package.xml from upstream in the upstream branch now?
        with inbranch('upstream'):
            assert os.path.exists('stack.xml'), \
                   "upstream did not import: '" + os.getcwd() + "': " + \
                   str(os.listdir(os.getcwd()))
            assert open('stack.xml').read().count('0.1.0'), "not right file"

        ###
        ### Release generator
        ###
        with bloom_answer(bloom_answer.ASSERT_NO_QUESTION):
            ret = user('git-bloom-generate -y release -s upstream --quiet')
        # patch import should have reported OK
        assert ret == code.OK, "actually returned ({0})".format(ret)
        # do the proper branches exist?
        assert branch_exists('release/foo'), "no release/foo branch: " + \
                                             str(get_branches())
        assert branch_exists('patches/release/foo'), \
               "no patches/release/foo branch"
        # was the release tag created?
        ret, out, err = user('git tag', return_io=True)
        assert out.count('release/foo/0.1.0') == 1, "no release tag created"

        ###
        ### Release generator, again
        ###
        with bloom_answer(bloom_answer.ASSERT_NO_QUESTION):
            ret = user('git-bloom-generate -y release -s upstream --quiet')
        # patch import should have reported OK
        assert ret == code.OK, "actually returned ({0})".format(ret)
        # do the proper branches exist?
        assert branch_exists('release/foo'), "no release/foo branch: " + \
                                             str(get_branches())
        assert branch_exists('patches/release/foo'), \
               "no patches/release/foo branch"
        # was the release tag created?
        ret, out, err = user('git tag', return_io=True)
        assert out.count('release/foo/0.1.0') == 1, "no release tag created"
예제 #10
0
def get_release_repo(repository, distro):
    global _repositories
    url = get_repo_uri(repository, distro)
    if repository not in _repositories.values():
        temp_dir = tempfile.mkdtemp()
        _repositories[repository] = get_vcs_client("git", temp_dir)
        info(fmt("@{gf}@!==> @|") + "Fetching '{0}' repository from '{1}'".format(repository, url))
        _repositories[repository].checkout(url, "master")
    return _repositories[repository]
예제 #11
0
 def _get_vcsc(self):
     # lazy initializer
     if self.vcsc is None:
         try:
             self.vcsc = get_vcs_client(self._scmtype, self.get_path())
         except VcsError as exc:
             raise MultiProjectException(
                 "Unable to create vcs client of type %s for %s: %s" %
                 (self._scmtype, self.get_path(), exc))
     return self.vcsc
예제 #12
0
 def _get_vcsc(self):
     # lazy initializer
     if self.vcsc is None:
         try:
             self.vcsc = get_vcs_client(self._scmtype, self.get_path())
         except VcsError as exc:
             raise MultiProjectException(
                 "Unable to create vcs client of type %s for %s: %s" % (
                     self._scmtype, self.get_path(), exc))
     return self.vcsc
예제 #13
0
def auto_upstream_checkout(upstream_repo, upstream_url, devel_branch):
    info("Searching in upstream development branch for the name and version")
    info("  Upstream url: " + upstream_url)
    info("  Upstream type: " + upstream_repo.get_vcs_type_name())
    if devel_branch:
        info("  Upstream branch: " + str(devel_branch))
    # Handle special svn cases
    if upstream_repo.get_vcs_type_name() == 'svn':
        if devel_branch == '':
            upstream_url += '/trunk'
        else:
            upstream_url += '/branches/' + str(devel_branch)
        devel_branch = ''
    # Checkout to the upstream development branch
    retcode = try_vcstools_checkout(upstream_repo, upstream_url, devel_branch)
    if retcode != 0:
        return retcode
    # Look into the upstream devel branch for the version
    meta = get_upstream_meta(upstream_repo.get_path())
    if meta is None or None in meta.values():
        error("Failed to get the upstream meta data.")
        return 1
    # Summarize the package.xml/stack.xml contents
    info("Found upstream with version: " + ansi('boldon') + meta['version'] + \
         ansi('reset'))
    if meta['type'] == 'stack.xml':
        info("Upstream contains a stack called: " + ansi('boldon') + \
             meta['name'][0] + ansi('reset'))
    else:
        info("Upstream contains package" + \
             ('s: ' if len(meta['name']) > 1 else ': ') + ansi('boldon') + \
             ', '.join(meta['name']) + ansi('reset'))
    # If svn recreate upstream_repo and checkout to the tag
    if upstream_repo.get_vcs_type_name() == 'svn':
        # Remove the /trunk from the url
        upstream_url = '/'.join(upstream_url.split('/')[:-1])
        upstream_dir = upstream_repo.get_path()
        shutil.rmtree(upstream_dir)  # Delete old upstream
        upstream_repo = get_vcs_client('svn', upstream_dir)
        checkout_url = upstream_url + '/tags/' + meta['version']
        if not upstream_repo.checkout(checkout_url):
            got_it = False
            for name in meta['name']:
                warning("Didn't find the tagged version at " + checkout_url)
                checkout_url = upstream_url + '/tags/' + name + \
                               '-' + meta['version']
                warning("Trying " + checkout_url)
                if upstream_repo.checkout(checkout_url):
                    got_it = True
                    break
            if not got_it:
                error("Could not checkout upstream version")
                return 1
    # Return the meta data
    return meta
예제 #14
0
def get_release_repo(repository, distro):
    global _repositories
    url = get_repo_uri(repository, distro)
    if repository not in _repositories.values():
        temp_dir = tempfile.mkdtemp()
        _repositories[repository] = get_vcs_client('git', temp_dir)
        info(
            fmt("@{gf}@!==> @|") +
            "Fetching '{0}' repository from '{1}'".format(repository, url))
        _repositories[repository].checkout(url, 'master')
    return _repositories[repository]
예제 #15
0
def export_upstream(uri, tag, vcs_type, output_dir, show_uri, name):
    tag = tag if tag != ':{none}' else None
    output_dir = output_dir or os.getcwd()
    if uri.startswith('git@'):
        uri_is_path = False
    else:
        uri_parsed = urlparse(uri)
        uri = uri if uri_parsed.scheme else uri_parsed.path
        uri_is_path = False if uri_parsed.scheme else True
    name = name or 'upstream'
    with temporary_directory() as tmp_dir:
        info("Checking out repository at '{0}'".format(show_uri or uri) +
             (" to reference '{0}'.".format(tag) if tag else '.'))
        if uri_is_path:
            upstream_repo = get_vcs_client(vcs_type, uri)
        else:
            repo_path = os.path.join(tmp_dir, 'upstream')
            upstream_repo = get_vcs_client(vcs_type, repo_path)
            if not upstream_repo.checkout(uri, tag or ''):
                error("Failed to clone repository at '{0}'".format(uri) +
                      (" to reference '{0}'.".format(tag) if tag else '.'),
                      exit=True)
        tarball_prefix = '{0}-{1}'.format(name, tag) if tag else name
        tarball_path = os.path.join(output_dir, tarball_prefix)
        full_tarball_path = tarball_path + '.tar.gz'
        info("Exporting to archive: '{0}'".format(full_tarball_path))
        if not upstream_repo.export_repository(tag or '', tarball_path):
            error("Failed to create archive of upstream repository at '{0}'"
                  .format(show_uri))
            if tag and vcs_type == 'git':  # can only check for git repos
                with change_directory(upstream_repo.get_path()):
                    if not tag_exists(tag):
                        warning("'{0}' is not a tag in the upstream repository..."
                                .format(tag))
                    if not branch_exists(tag):
                        warning("'{0}' is not a branch in the upstream repository..."
                                .format(tag))
        if not os.path.exists(full_tarball_path):
            error("Tarball was not created.", exit=True)
        info("md5: {0}".format(calculate_file_md5(full_tarball_path)))
예제 #16
0
def export_upstream(uri, tag, vcs_type, output_dir, show_uri, name):
    tag = tag if tag != ':{none}' else None
    output_dir = output_dir or os.getcwd()
    if uri.startswith('git@'):
        uri_is_path = False
    else:
        uri_parsed = urlparse(uri)
        uri = uri if uri_parsed.scheme else uri_parsed.path
        uri_is_path = False if uri_parsed.scheme else True
    name = name or 'upstream'
    with temporary_directory() as tmp_dir:
        info("Checking out repository at '{0}'".format(show_uri or uri) +
            (" to reference '{0}'.".format(tag) if tag else '.'))
        if uri_is_path:
            upstream_repo = get_vcs_client(vcs_type, uri)
        else:
            repo_path = os.path.join(tmp_dir, 'upstream')
            upstream_repo = get_vcs_client(vcs_type, repo_path)
            if not upstream_repo.checkout(uri, tag or ''):
                error("Failed to clone repository at '{0}'".format(uri) +
                      (" to reference '{0}'.".format(tag) if tag else '.'),
                      exit=True)
        tarball_prefix = '{0}-{1}'.format(name, tag) if tag else name
        tarball_path = os.path.join(output_dir, tarball_prefix)
        full_tarball_path = tarball_path + '.tar.gz'
        info("Exporting to archive: '{0}'".format(full_tarball_path))
        if not upstream_repo.export_repository(tag or '', tarball_path):
            error("Failed to create archive of upstream repository at '{0}'"
                  .format(show_uri))
            if tag:
                with change_directory(upstream_repo.get_path()):
                    if not tag_exists(tag):
                        warning("'{0}' is not a tag in the upstream repository..."
                                .format(tag))
                    if not branch_exists(tag):
                        warning("'{0}' is not a branch in the upstream repository..."
                                .format(tag))
        if not os.path.exists(full_tarball_path):
            error("Tarball was not created.", exit=True)
        info("md5: {0}".format(calculate_file_md5(full_tarball_path)))
예제 #17
0
 def test_get_vcs_client(self):
     try:
         backup = vcstools.vcs_abstraction._VCS_TYPES
         vcstools.vcs_abstraction._VCS_TYPES = {}
         self.assertEqual([], get_registered_vcs_types())
         mock_class = Mock()
         mock_instance = Mock()
         # mock __init__ constructor
         mock_class.return_value = mock_instance
         register_vcs('foo', mock_class)
         self.assertEqual(mock_instance, get_vcs_client('foo', 'foopath'))
         self.assertRaises(ValueError, get_vcs_client, 'bar', 'barpath')
     finally:
         vcstools.vcs_abstraction._VCS_TYPES = backup
def test_unary_package_repository(directory=None):
    """
    Release a single package catkin (groovy) repository.
    """
    directory = directory if directory is not None else os.getcwd()
    # Setup
    upstream_dir = create_upstream_repository(['foo'], directory)
    upstream_url = 'file://' + upstream_dir
    release_url = create_release_repo(upstream_url, 'git', 'groovy_devel')
    release_dir = os.path.join(directory, 'foo_release_clone')
    release_client = get_vcs_client('git', release_dir)
    release_client.checkout(release_url)
    versions = ['0.1.0', '0.1.1', '0.2.0']
    for index in range(len(versions)):
        _test_unary_package_repository(release_dir, versions[index], directory)
        if index != len(versions) - 1:
            change_upstream_version(upstream_dir, versions[index + 1])
예제 #19
0
def test_unary_package_repository(directory=None):
    """
    Release a single package catkin (groovy) repository.
    """
    directory = directory if directory is not None else os.getcwd()
    # Setup
    upstream_dir = create_upstream_repository(['foo'], directory)
    upstream_url = 'file://' + upstream_dir
    release_url = create_release_repo(upstream_url, 'git', 'groovy_devel',
                                      'groovy')
    release_dir = os.path.join(directory, 'foo_release_clone')
    release_client = get_vcs_client('git', release_dir)
    assert release_client.checkout(release_url)
    versions = ['0.1.0', '0.1.1', '0.2.0']
    import bloom.commands.git.release
    for index in range(len(versions)):
        _test_unary_package_repository(release_dir, versions[index], directory)
        bloom.commands.git.release.upstream_repos = {}
        if index != len(versions) - 1:
            change_upstream_version(upstream_dir, versions[index + 1])
예제 #20
0
def test_unary_package_repository(directory=None):
    """
    Release a single package catkin (groovy) repository.
    """
    directory = directory if directory is not None else os.getcwd()
    # Setup
    upstream_dir = create_upstream_repository(["foo"], directory)
    upstream_url = "file://" + upstream_dir
    release_url = create_release_repo(upstream_url, "git", "groovy_devel", "groovy")
    release_dir = os.path.join(directory, "foo_release_clone")
    release_client = get_vcs_client("git", release_dir)
    assert release_client.checkout(release_url)
    versions = ["0.1.0", "0.1.1", "0.2.0"]
    import bloom.commands.git.release

    for index in range(len(versions)):
        _test_unary_package_repository(release_dir, versions[index], directory)
        bloom.commands.git.release.upstream_repos = {}
        if index != len(versions) - 1:
            change_upstream_version(upstream_dir, versions[index + 1])
예제 #21
0
def main(sysargs):
    parser = get_argument_parser()
    args = parser.parse_args(sys.argv[1:])
    repository = args.repository
    verbose = args.verbose

    # checkout target rpository
    info("Manually clone the repository")
    info("  git clone {0}".format(repository))
    git = get_vcs_client('git', tempfile.mktemp())
    info(
        fmt("@{gf}@!==> @|") +
        "Fetching repository from '{0}'".format(repository))
    ret = git.checkout(repository, verbose=verbose)
    if not ret:
        error("Could not checkout {}".format(repository))
        return 1

    # get the github repository info
    base_org, base_repo = get_gh_info(git.get_url())
    # get correct repo info (case sensitive)
    gh = get_github_interface()
    base_org, base_repo = get_gh_info(
        gh.get_repo(base_org, base_repo)['html_url'])

    base_branch = git.get_branches()[0]  # is this ok?

    with change_directory(git.get_path()):
        # write travis yaml
        write_travis_yaml()
        # write readme
        write_readme_md(**locals())

        # create pull request
        open_pull_request(base_org=base_org,
                          base_repo=base_repo,
                          base_branch=base_branch,
                          new_branch="add_travis")
예제 #22
0
def test_upstream_tag_special_tag(directory=None):
    """
    Release a single package catkin (melodic) repository, first put
    an upstream tag into the release repository to test that bloom
    can handle it.
    """
    directory = directory if directory is not None else os.getcwd()
    # Setup
    upstream_dir = create_upstream_repository(['foo'], directory)
    upstream_url = 'file://' + upstream_dir
    release_url = create_release_repo(
        upstream_url,
        'git',
        'melodic_devel',
        'melodic')
    release_dir = os.path.join(directory, 'foo_release_clone')
    release_client = get_vcs_client('git', release_dir)
    assert release_client.checkout(release_url)

    with change_directory(release_dir):
        user('git tag upstream/0.0.0@baz')

    import bloom.commands.git.release
    _test_unary_package_repository(release_dir, '0.1.0', directory)
def test_multi_package_repository(directory=None):
    """
    Release a multi package catkin (groovy) repository.
    """
    directory = directory if directory is not None else os.getcwd()
    # Setup
    pkgs = ['foo', 'bar', 'baz']
    upstream_dir = create_upstream_repository(pkgs, directory)
    upstream_url = 'file://' + upstream_dir
    release_url = create_release_repo(upstream_url, 'git', 'groovy_devel')
    release_dir = os.path.join(directory, 'foo_release_clone')
    release_client = get_vcs_client('git', release_dir)
    release_client.checkout(release_url)
    with change_directory(release_dir):
        ###
        ### Import upstream
        ###
        user('git-bloom-import-upstream --quiet')
        # does the upstream branch exist?
        assert branch_exists('upstream', local_only=True), "no upstream branch"
        # does the upstrea/0.1.0 tag exist?
        ret, out, err = user('git tag', return_io=True)
        assert out.count('upstream/0.1.0') == 1, "no upstream tag created"
        # Is the package.xml from upstream in the upstream branch now?
        with inbranch('upstream'):
            for pkg in pkgs:
                with change_directory(pkg):
                    assert os.path.exists('package.xml'), \
                           "upstream did not import: " + os.listdir()
                    with open('package.xml') as f:
                        assert f.read().count('0.1.0'), "not right file"

        ###
        ### Release generator
        ###
        with bloom_answer(bloom_answer.ASSERT_NO_QUESTION):
            ret = user('git-bloom-generate -y release -s upstream --quiet')
        # patch import should have reported OK
        assert ret == code.OK, "actually returned ({0})".format(ret)
        # Check the environment after the release generator
        ret, out, err = user('git tag', return_io=True)
        for pkg in pkgs:
            # Does the release/pkg branch exist?
            assert branch_exists('release/' + pkg), \
                   "no release/" + pkg + " branch"
            # Does the patches/release/pkg branch exist?
            assert branch_exists('patches/release/' + pkg), \
                   "no patches/release/" + pkg + " branch"
            # Did the release tag get created?
            assert out.count('release/' + pkg + '/0.1.0') == 1, \
                   "no release tag created for " + pkg
            # Is there a package.xml in the top level?
            with inbranch('release/' + pkg):
                assert os.path.exists('package.xml'), "release branch invalid"
                # Is it the correct package.xml for this pkg?
                package_xml = open('package.xml', 'r').read()
                assert package_xml.count('<name>' + pkg + '</name>'), \
                       "incorrect package.xml for " + str(pkg)

        # Make a patch
        with inbranch('release/' + pkgs[0]):
            user('echo "This is a change" >> README.md')
            user('git add README.md')
            user('git commit -m "added a readme"')

        ###
        ### Release generator, again
        ###
        with bloom_answer(bloom_answer.ASSERT_NO_QUESTION):
            ret = user(
                'git-bloom-generate -y release -s upstream', silent=False
            )
        # patch import should have reported OK
        assert ret == code.OK, "actually returned ({0})".format(ret)
        # Check the environment after the release generator
        ret, out, err = user('git tag', return_io=True)
        for pkg in pkgs:
            # Does the release/pkg branch exist?
            assert branch_exists('release/' + pkg), \
                   "no release/" + pkg + " branch"
            # Does the patches/release/pkg branch exist?
            assert branch_exists('patches/release/' + pkg), \
                   "no patches/release/" + pkg + " branch"
            # Did the release tag get created?
            assert out.count('release/' + pkg + '/0.1.0') == 1, \
                   "no release tag created for " + pkg
            # Is there a package.xml in the top level?
            with inbranch('release/' + pkg):
                assert os.path.exists('package.xml'), "release branch invalid"
                # Is it the correct package.xml for this pkg?
                with open('package.xml', 'r') as f:
                    assert f.read().count('<name>' + pkg + '</name>'), \
                       "incorrect package.xml for " + str(pkg)

        ###
        ### ROSDebian Generator
        ###
        with bloom_answer(bloom_answer.ASSERT_NO_QUESTION):
            ret, out, err = user('git-bloom-generate -y rosdebian '
                                 '-p release groovy', return_io=True,
                                 auto_assert=False)
            if ret != 0:
                print(out)
                print(err)
            assert ret == 0
        expected = "Debian Distributions: ['oneiric', 'precise', 'quantal']"
        assert out.count(expected) > 0, "not using expected ubuntu distros"
        # generator should have reported OK
        assert ret == code.OK, "actually returned ({0})".format(ret)
        # Check the environment after the release generator
        ret, out, err = user('git tag', return_io=True)
        for pkg in pkgs:
            for distro in ['oneiric', 'precise', 'quantal']:
                # Does the debian/distro/pkg branch exist?
                assert branch_exists('debian/groovy/' + distro + '/' + pkg), \
                       "no release/" + pkg + " branch"
                # Does the patches/debian/distro/pkg branch exist?
                patches_branch = 'patches/debian/groovy/' + distro + '/' + pkg
                assert branch_exists(patches_branch), \
                       "no patches/release/" + pkg + " branch"
                # Did the debian tag get created?
                tag = 'debian/ros-groovy-' + pkg + '_0.1.0-0_' + distro
                assert out.count(tag) == 1, \
                   "no release tag created for '" + pkg + "': `" + out + "`"
            # Is there a package.xml in the top level?
            with inbranch('debian/groovy/' + distro + '/' + pkg):
                assert os.path.exists('package.xml'), "release branch invalid"
                # Is it the correct package.xml for this pkg?
                with open('package.xml', 'r') as f:
                    assert f.read().count('<name>' + pkg + '</name>'), \
                       "incorrect package.xml for " + str(pkg)
예제 #24
0
def test_multi_package_repository(directory=None):
    """
    Release a multi package catkin (groovy) repository.
    """
    directory = directory if directory is not None else os.getcwd()
    # Setup
    pkgs = ['foo', 'bar_ros', 'baz']
    upstream_dir = create_upstream_repository(pkgs,
                                              directory,
                                              format_versions=[1, 2, 3])
    upstream_url = 'file://' + upstream_dir
    release_url = create_release_repo(upstream_url, 'git', 'groovy_devel',
                                      'groovy')
    release_dir = os.path.join(directory, 'foo_release_clone')
    release_client = get_vcs_client('git', release_dir)
    assert release_client.checkout(release_url)
    with change_directory(release_dir):
        # First run everything
        with bloom_answer(bloom_answer.ASSERT_NO_QUESTION):
            cmd = 'git-bloom-release{0} groovy'
            if 'BLOOM_VERBOSE' not in os.environ:
                cmd = cmd.format(' --quiet')
            else:
                cmd = cmd.format('')
            user(cmd, silent=False)
        ###
        ### Import upstream
        ###
        # does the upstream branch exist?
        assert branch_exists('upstream', local_only=True), "no upstream branch"
        # does the upstrea/0.1.0 tag exist?
        ret, out, err = user('git tag', return_io=True)
        assert out.count('upstream/0.1.0') == 1, "no upstream tag created"
        # Is the package.xml from upstream in the upstream branch now?
        with inbranch('upstream'):
            for pkg in pkgs:
                with change_directory(pkg):
                    assert os.path.exists(
                        os.path.join('debian', 'something.udev')), \
                        "Lost the debian overlaid files in upstream branch"
                    assert os.path.exists('white space.txt~'), \
                        "Lost file with whitespace in name in upstream branch"
                    assert os.path.exists('package.xml'), \
                        "upstream did not import: " + os.listdir()
                    with open('package.xml') as f:
                        assert f.read().count('0.1.0'), "not right file"

        ###
        ### Release generator
        ###
        # Check the environment after the release generator
        ret, out, err = user('git tag', return_io=True)
        for pkg in pkgs:
            # Does the release/pkg branch exist?
            assert branch_exists('release/groovy/' + pkg), \
                "no release/groovy/" + pkg + " branch"
            # Does the patches/release/pkg branch exist?
            assert branch_exists('patches/release/groovy/' + pkg), \
                "no patches/release/groovy/" + pkg + " branch"
            # Did the release tag get created?
            assert out.count('release/groovy/' + pkg + '/0.1.0-0') == 1, \
                "no release tag created for " + pkg
            # Is there a package.xml in the top level?
            with inbranch('release/groovy/' + pkg):
                assert os.path.exists('package.xml'), "release branch invalid"
                # Is it the correct package.xml for this pkg?
                package_xml = open('package.xml', 'r').read()
                assert package_xml.count('<name>' + pkg + '</name>'), \
                    "incorrect package.xml for " + str(pkg)

        # Make a patch
        with inbranch('release/groovy/' + pkgs[0]):
            user('echo "This is a change" >> README.md')
            user('git add README.md')
            user('git commit -m "added a readme" --allow-empty')

        ###
        ### Release generator, again
        ###
        with bloom_answer(bloom_answer.ASSERT_NO_QUESTION):
            ret = user('git-bloom-generate -y rosrelease groovy -s upstream')
        # patch import should have reported OK
        assert ret == code.OK, "actually returned ({0})".format(ret)
        # Check the environment after the release generator
        ret, out, err = user('git tag', return_io=True)
        for pkg in pkgs:
            # Does the release/pkg branch exist?
            assert branch_exists('release/groovy/' + pkg), \
                "no release/groovy/" + pkg + " branch"
            # Does the patches/release/pkg branch exist?
            assert branch_exists('patches/release/groovy/' + pkg), \
                "no patches/release/groovy/" + pkg + " branch"
            # Did the release tag get created?
            assert out.count('release/groovy/' + pkg + '/0.1.0-0') == 1, \
                "no release tag created for " + pkg
            # Is there a package.xml in the top level?
            with inbranch('release/groovy/' + pkg):
                assert os.path.exists(os.path.join('debian', 'something.udev')), \
                    "Lost the debian overlaid files in release branch"
                assert os.path.exists('white space.txt~'), \
                    "Lost file with whitespace in name in release branch"
                assert os.path.exists('package.xml'), "release branch invalid"
                # Is it the correct package.xml for this pkg?
                with open('package.xml', 'r') as f:
                    assert f.read().count('<name>' + pkg + '</name>'), \
                        "incorrect package.xml for " + str(pkg)

        ###
        ### ROSDebian Generator
        ###
        # Check the environment after the release generator
        ret, out, err = user('git tag', return_io=True)
        for pkg in pkgs:
            for distro in ['oneiric', 'precise', 'quantal']:
                pkg_san = sanitize_package_name(pkg)
                # Does the debian/distro/pkg branch exist?
                assert branch_exists('debian/groovy/' + distro + '/' + pkg), \
                    "no debian/groovy/" + pkg + " branch"
                # Does the patches/debian/distro/pkg branch exist?
                patches_branch = 'patches/debian/groovy/' + distro + '/' + pkg
                assert branch_exists(patches_branch), \
                    "no " + patches_branch + " branch"
                # Did the debian tag get created?
                tag = 'debian/ros-groovy-' + pkg_san + '_0.1.0-0_' + distro
                assert out.count(tag) == 1, \
                    "no '" + tag + "'' tag created for '" + pkg + "': `\n" + \
                    out + "\n`"
            # Is there a package.xml in the top level?
            with inbranch('debian/groovy/' + distro + '/' + pkg):
                assert os.path.exists(
                    os.path.join('debian', 'something.udev')), \
                    "Lost the debian overlaid files in debian branch"
                assert os.path.exists('white space.txt~'), \
                    "Lost file with whitespace in name in debian branch"
                assert os.path.exists('package.xml'), "debian branch invalid"
                # Is there blank lins due to no Conflicts/Replaces?
                # See: https://github.com/ros-infrastructure/bloom/pull/329
                with open(os.path.join('debian', 'control'), 'r') as f:
                    assert f.read().count('\n\nHomepage:') == 0, \
                        "Extra blank line before Homepage detected."
                # Is it the correct package.xml for this pkg?
                with open('package.xml', 'r') as f:
                    package_xml = f.read()
                    assert package_xml.count('<name>' + pkg + '</name>'), \
                        "incorrect package.xml for " + str(pkg)
                    format_version = int(
                        re.search('format="(\d+)"', package_xml).group(1))
                # Is there a copyright file for this pkg?
                if format_version <= 2:
                    assert not os.path.exists(
                        os.path.join('debian', 'copyright')), \
                        "debian/copyright should not be generated"
                else:
                    with open('debian/copyright', 'r') as f:
                        assert pkg + ' license' in f.read(), \
                            "debian/copyright does not include right license text"
예제 #25
0
def test_multi_package_repository(directory=None):
    """
    Release a multi package catkin (groovy) repository.
    """
    directory = directory if directory is not None else os.getcwd()
    # Setup
    pkgs = ['foo', 'bar_ros', 'baz']
    upstream_dir = create_upstream_repository(pkgs, directory)
    upstream_url = 'file://' + upstream_dir
    release_url = create_release_repo(
        upstream_url,
        'git',
        'groovy_devel',
        'groovy')
    release_dir = os.path.join(directory, 'foo_release_clone')
    release_client = get_vcs_client('git', release_dir)
    assert release_client.checkout(release_url)
    with change_directory(release_dir):
        # First run everything
        with bloom_answer(bloom_answer.ASSERT_NO_QUESTION):
            cmd = 'git-bloom-release{0} groovy'
            if 'BLOOM_VERBOSE' not in os.environ:
                cmd = cmd.format(' --quiet')
            else:
                cmd = cmd.format('')
            user(cmd, silent=False)
        ###
        ### Import upstream
        ###
        # does the upstream branch exist?
        assert branch_exists('upstream', local_only=True), "no upstream branch"
        # does the upstrea/0.1.0 tag exist?
        ret, out, err = user('git tag', return_io=True)
        assert out.count('upstream/0.1.0') == 1, "no upstream tag created"
        # Is the package.xml from upstream in the upstream branch now?
        with inbranch('upstream'):
            for pkg in pkgs:
                with change_directory(pkg):
                    assert os.path.exists(
                        os.path.join('debian', 'something.udev')), \
                        "Lost the debian overlaid files in upstream branch"
                    assert os.path.exists('white space.txt~'), \
                        "Lost file with whitespace in name in upstream branch"
                    assert os.path.exists('package.xml'), \
                        "upstream did not import: " + os.listdir()
                    with open('package.xml') as f:
                        assert f.read().count('0.1.0'), "not right file"

        ###
        ### Release generator
        ###
        # Check the environment after the release generator
        ret, out, err = user('git tag', return_io=True)
        for pkg in pkgs:
            # Does the release/pkg branch exist?
            assert branch_exists('release/groovy/' + pkg), \
                "no release/groovy/" + pkg + " branch"
            # Does the patches/release/pkg branch exist?
            assert branch_exists('patches/release/groovy/' + pkg), \
                "no patches/release/groovy/" + pkg + " branch"
            # Did the release tag get created?
            assert out.count('release/groovy/' + pkg + '/0.1.0-0') == 1, \
                "no release tag created for " + pkg
            # Is there a package.xml in the top level?
            with inbranch('release/groovy/' + pkg):
                assert os.path.exists('package.xml'), "release branch invalid"
                # Is it the correct package.xml for this pkg?
                package_xml = open('package.xml', 'r').read()
                assert package_xml.count('<name>' + pkg + '</name>'), \
                    "incorrect package.xml for " + str(pkg)

        # Make a patch
        with inbranch('release/groovy/' + pkgs[0]):
            user('echo "This is a change" >> README.md')
            user('git add README.md')
            user('git commit -m "added a readme" --allow-empty')

        ###
        ### Release generator, again
        ###
        with bloom_answer(bloom_answer.ASSERT_NO_QUESTION):
            ret = user('git-bloom-generate -y rosrelease groovy -s upstream')
        # patch import should have reported OK
        assert ret == code.OK, "actually returned ({0})".format(ret)
        # Check the environment after the release generator
        ret, out, err = user('git tag', return_io=True)
        for pkg in pkgs:
            # Does the release/pkg branch exist?
            assert branch_exists('release/groovy/' + pkg), \
                "no release/groovy/" + pkg + " branch"
            # Does the patches/release/pkg branch exist?
            assert branch_exists('patches/release/groovy/' + pkg), \
                "no patches/release/groovy/" + pkg + " branch"
            # Did the release tag get created?
            assert out.count('release/groovy/' + pkg + '/0.1.0-0') == 1, \
                "no release tag created for " + pkg
            # Is there a package.xml in the top level?
            with inbranch('release/groovy/' + pkg):
                assert os.path.exists(os.path.join('debian', 'something.udev')), \
                    "Lost the debian overlaid files in release branch"
                assert os.path.exists('white space.txt~'), \
                    "Lost file with whitespace in name in release branch"
                assert os.path.exists('package.xml'), "release branch invalid"
                # Is it the correct package.xml for this pkg?
                with open('package.xml', 'r') as f:
                    assert f.read().count('<name>' + pkg + '</name>'), \
                        "incorrect package.xml for " + str(pkg)

        ###
        ### ROSDebian Generator
        ###
        # Check the environment after the release generator
        ret, out, err = user('git tag', return_io=True)
        for pkg in pkgs:
            for distro in ['oneiric', 'precise', 'quantal']:
                pkg_san = sanitize_package_name(pkg)
                # Does the debian/distro/pkg branch exist?
                assert branch_exists('debian/groovy/' + distro + '/' + pkg), \
                    "no debian/groovy/" + pkg + " branch"
                # Does the patches/debian/distro/pkg branch exist?
                patches_branch = 'patches/debian/groovy/' + distro + '/' + pkg
                assert branch_exists(patches_branch), \
                    "no " + patches_branch + " branch"
                # Did the debian tag get created?
                tag = 'debian/ros-groovy-' + pkg_san + '_0.1.0-0_' + distro
                assert out.count(tag) == 1, \
                    "no '" + tag + "'' tag created for '" + pkg + "': `\n" + \
                    out + "\n`"
            # Is there a package.xml in the top level?
            with inbranch('debian/groovy/' + distro + '/' + pkg):
                assert os.path.exists(
                    os.path.join('debian', 'something.udev')), \
                    "Lost the debian overlaid files in debian branch"
                assert os.path.exists('white space.txt~'), \
                    "Lost file with whitespace in name in debian branch"
                assert os.path.exists('package.xml'), "debian branch invalid"
                # Is there blank lins due to no Conflicts/Replaces?
                # See: https://github.com/ros-infrastructure/bloom/pull/329
                with open(os.path.join('debian', 'control'), 'r') as f:
                    assert f.read().count('\n\nHomepage:') == 0, \
                        "Extra blank line before Homepage detected."
                # Is it the correct package.xml for this pkg?
                with open('package.xml', 'r') as f:
                    assert f.read().count('<name>' + pkg + '</name>'), \
                        "incorrect package.xml for " + str(pkg)
예제 #26
0
def test_multi_package_repository(directory=None):
    """
    Release a multi package catkin (groovy) repository.
    """
    directory = directory if directory is not None else os.getcwd()
    # Setup
    pkgs = ["foo", "bar", "baz"]
    upstream_dir = create_upstream_repository(pkgs, directory)
    upstream_url = "file://" + upstream_dir
    release_url = create_release_repo(upstream_url, "git", "groovy_devel", "groovy")
    release_dir = os.path.join(directory, "foo_release_clone")
    release_client = get_vcs_client("git", release_dir)
    assert release_client.checkout(release_url)
    with change_directory(release_dir):
        # First run everything
        with bloom_answer(bloom_answer.ASSERT_NO_QUESTION):
            cmd = "git-bloom-release{0} groovy"
            if "BLOOM_VERBOSE" not in os.environ:
                cmd = cmd.format(" --quiet")
            else:
                cmd = cmd.format("")
            user(cmd, silent=False)
        ###
        ### Import upstream
        ###
        # does the upstream branch exist?
        assert branch_exists("upstream", local_only=True), "no upstream branch"
        # does the upstrea/0.1.0 tag exist?
        ret, out, err = user("git tag", return_io=True)
        assert out.count("upstream/0.1.0") == 1, "no upstream tag created"
        # Is the package.xml from upstream in the upstream branch now?
        with inbranch("upstream"):
            for pkg in pkgs:
                with change_directory(pkg):
                    assert os.path.exists("package.xml"), "upstream did not import: " + os.listdir()
                    with open("package.xml") as f:
                        assert f.read().count("0.1.0"), "not right file"

        ###
        ### Release generator
        ###
        # Check the environment after the release generator
        ret, out, err = user("git tag", return_io=True)
        for pkg in pkgs:
            # Does the release/pkg branch exist?
            assert branch_exists("release/groovy/" + pkg), "no release/groovy/" + pkg + " branch"
            # Does the patches/release/pkg branch exist?
            assert branch_exists("patches/release/groovy/" + pkg), "no patches/release/groovy/" + pkg + " branch"
            # Did the release tag get created?
            assert out.count("release/groovy/" + pkg + "/0.1.0-0") == 1, "no release tag created for " + pkg
            # Is there a package.xml in the top level?
            with inbranch("release/groovy/" + pkg):
                assert os.path.exists("package.xml"), "release branch invalid"
                # Is it the correct package.xml for this pkg?
                package_xml = open("package.xml", "r").read()
                assert package_xml.count("<name>" + pkg + "</name>"), "incorrect package.xml for " + str(pkg)

        # Make a patch
        with inbranch("release/groovy/" + pkgs[0]):
            user('echo "This is a change" >> README.md')
            user("git add README.md")
            user('git commit -m "added a readme" --allow-empty')

        ###
        ### Release generator, again
        ###
        with bloom_answer(bloom_answer.ASSERT_NO_QUESTION):
            ret = user("git-bloom-generate -y rosrelease groovy -s upstream")
        # patch import should have reported OK
        assert ret == code.OK, "actually returned ({0})".format(ret)
        # Check the environment after the release generator
        ret, out, err = user("git tag", return_io=True)
        for pkg in pkgs:
            # Does the release/pkg branch exist?
            assert branch_exists("release/groovy/" + pkg), "no release/groovy/" + pkg + " branch"
            # Does the patches/release/pkg branch exist?
            assert branch_exists("patches/release/groovy/" + pkg), "no patches/release/groovy/" + pkg + " branch"
            # Did the release tag get created?
            assert out.count("release/groovy/" + pkg + "/0.1.0-0") == 1, "no release tag created for " + pkg
            # Is there a package.xml in the top level?
            with inbranch("release/groovy/" + pkg):
                assert os.path.exists("package.xml"), "release branch invalid"
                # Is it the correct package.xml for this pkg?
                with open("package.xml", "r") as f:
                    assert f.read().count("<name>" + pkg + "</name>"), "incorrect package.xml for " + str(pkg)

        ###
        ### ROSDebian Generator
        ###
        # Check the environment after the release generator
        ret, out, err = user("git tag", return_io=True)
        for pkg in pkgs:
            for distro in ["oneiric", "precise", "quantal"]:
                # Does the debian/distro/pkg branch exist?
                assert branch_exists("debian/groovy/" + distro + "/" + pkg), "no release/" + pkg + " branch"
                # Does the patches/debian/distro/pkg branch exist?
                patches_branch = "patches/debian/groovy/" + distro + "/" + pkg
                assert branch_exists(patches_branch), "no patches/release/" + pkg + " branch"
                # Did the debian tag get created?
                tag = "debian/ros-groovy-" + pkg + "_0.1.0-0_" + distro
                assert out.count(tag) == 1, "no release tag created for '" + pkg + "': `" + out + "`"
            # Is there a package.xml in the top level?
            with inbranch("debian/groovy/" + distro + "/" + pkg):
                assert os.path.exists("package.xml"), "release branch invalid"
                # Is it the correct package.xml for this pkg?
                with open("package.xml", "r") as f:
                    assert f.read().count("<name>" + pkg + "</name>"), "incorrect package.xml for " + str(pkg)
예제 #27
0
def import_upstream(cwd, tmp_dir, args):
    # Ensure the bloom and upstream branches are tracked locally
    track_branches(['bloom', 'upstream'])

    # Create a clone of the bloom_repo to help isolate the activity
    bloom_repo_clone_dir = os.path.join(tmp_dir, 'bloom_clone')
    os.makedirs(bloom_repo_clone_dir)
    os.chdir(bloom_repo_clone_dir)
    bloom_repo = get_vcs_client('git', bloom_repo_clone_dir)
    bloom_repo.checkout('file://{0}'.format(cwd))

    # Ensure the bloom and upstream branches are tracked from the original
    track_branches(['bloom', 'upstream'])

    ### Fetch the upstream tag
    upstream_repo = None
    upstream_repo_dir = os.path.join(tmp_dir, 'upstream_repo')
    # If explicit svn url just export and git-import-orig
    if args.explicit_svn_url is not None:
        if args.upstream_version is None:
            error("'--explicit-svn-url' must be specified with "
                  "'--upstream-version'")
            return 1
        info("Checking out upstream at version " + ansi('boldon') + \
             str(args.upstream_version) + ansi('reset') + \
             " from repository at " + ansi('boldon') + \
             str(args.explicit_svn_url) + ansi('reset'))
        upstream_repo = get_vcs_client('svn', upstream_repo_dir)
        retcode = try_vcstools_checkout(upstream_repo, args.explicit_svn_url)
        if retcode != 0:
            return retcode
        meta = {
            'name': None,
            'version': args.upstream_version,
            'type': 'manual'
        }
    # Else fetching from bloom configs
    else:
        # Check for a bloom branch
        check_for_bloom()
        # Parse the bloom config file
        upstream_url, upstream_type, upstream_branch = parse_bloom_conf()
        # If the upstream_tag is specified, don't search just fetch
        upstream_repo = get_vcs_client(upstream_type, upstream_repo_dir)
        if args.upstream_tag is not None:
            warning("Using specified upstream tag '" + args.upstream_tag + "'")
            if upstream_type == 'svn':
                upstream_url += '/tags/' + args.upstream_tag
                upstream_tag = ''
            else:
                upstream_tag = args.upstream_tag
            retcode = try_vcstools_checkout(upstream_repo,
                                            upstream_url,
                                            upstream_tag)
            if retcode != 0:
                return retcode
            meta = {
                'name': None,
                'version': args.upstream_tag,
                'type': 'manual'
            }
        # We have to search for the upstream tag
        else:
            if args.upstream_devel is not None:
                warning("Overriding the bloom.conf upstream branch with " +
                        args.upstream_devel)
                devel_branch = args.upstream_devel
            else:
                devel_branch = upstream_branch
            if args.upstream_version is None:
                meta = auto_upstream_checkout(
                    upstream_repo, upstream_url, devel_branch
                )
            else:
                meta = {
                    'version': args.upstream_version
                }
            if type(meta) not in [dict] and meta != 0:
                return meta

    ### Export the repository
    version = meta['version']

    # Export the repository to a tar ball
    tarball_prefix = 'upstream-' + str(version)
    info('Exporting version {0}'.format(version))
    tarball_path = os.path.join(tmp_dir, tarball_prefix)
    if upstream_repo.get_vcs_type_name() == 'svn':
        upstream_repo.export_repository('', tarball_path)
    else:
        if args.upstream_tag is not None:
            upstream_repo.export_repository(args.upstream_tag, tarball_path)
        else:
            upstream_repo.export_repository(version, tarball_path)

    # Get the gbp version elements from either the last tag or the default
    last_tag = get_last_tag_by_version()
    if last_tag == '':
        gbp_major, gbp_minor, gbp_patch = segment_version(version)
    else:
        gbp_major, gbp_minor, gbp_patch = \
            get_versions_from_upstream_tag(last_tag)
        info("The latest upstream tag in the release repository is "
              + ansi('boldon') + last_tag + ansi('reset'))
        # Ensure the new version is greater than the last tag
        last_tag_version = '.'.join([gbp_major, gbp_minor, gbp_patch])
        if parse_version(version) < parse_version(last_tag_version):
            warning("""\
Version discrepancy:
    The upstream version, {0}, is not newer than the previous \
release version, {1}.
""".format(version, last_tag_version))
        if parse_version(version) <= parse_version(last_tag_version):
            if args.replace:
                # Remove the conflicting tag first
                warning("""\
The upstream version, {0}, is equal to or less than a previous \
import version.
    Removing conflicting tag before continuing \
because the '--replace' options was specified.\
""".format(version))
            else:
                warning("""\
The upstream version, {0}, is equal to a previous import version. \
git-buildpackage will fail, if you want to replace the existing \
upstream import use the '--replace' option.\
""".format(version))
    if args.replace:
        if tag_exists('upstream/' + version):
            execute_command('git tag -d {0}'.format('upstream/' + version))
            execute_command('git push origin :refs/tags/'
                            '{0}'.format('upstream/' + version))

    # Look for upstream branch
    if not branch_exists('upstream', local_only=True):
        create_branch('upstream', orphaned=True, changeto=True)

    # Go to the bloom branch during import
    bloom_repo.update('bloom')

    # Detect if git-import-orig is installed
    tarball_path += '.tar.gz'
    import_orig(tarball_path, 'upstream', upstream_repo.get_url(), version)

    # Push changes back to the original bloom repo
    execute_command('git push --all -f')
    execute_command('git push --tags')