예제 #1
0
파일: __init__.py 프로젝트: smits/bloom
 def post_rebase(self, destination):
     # Determine the current package being generated
     name = destination.split('/')[-1]
     distro = destination.split('/')[-2]
     # Retrieve the stackage
     stackage, kind = self.packages[name]
     # Ask to continue if interactive
     if self.interactive:
         if not maybe_continue('y'):
             error("Answered no to continue, aborting.")
             return code.ANSWERED_NO_TO_CONTINUE
     ### Start debian generation
     # Get time of day
     from dateutil import tz
     stamp = datetime.datetime.now(tz.tzlocal())
     # Convert stackage to debian data
     data = self.convert_stackage_to_debian_data(stackage, kind)
     # Get apt_installer from rosdep
     from rosdep2.catkin_support import get_installer
     self.apt_installer = get_installer(APT_INSTALLER)
     # Create debians for each distro
     with inbranch(destination):
         self.generate_debian(data, stamp, distro)
         # Create the tag name for later
         self.tag_names[destination] = self.generate_tag_name(data)
     # Update the patch configs
     patches_branch = 'patches/' + destination
     config = get_patch_config(patches_branch)
     # Store it
     self.store_original_config(config, patches_branch)
     # Modify the base so import/export patch works
     config['base'] = get_commit_hash(get_current_branch())
     # Set it
     set_patch_config(patches_branch, config)
예제 #2
0
파일: __init__.py 프로젝트: smits/bloom
 def pre_rebase(self, destination):
     # Get the stored configs is any
     patches_branch = 'patches/' + destination
     config = self.load_original_config(patches_branch)
     if config is not None:
         set_patch_config(patches_branch, config)
     # Remove back to the base
     remove_patches()
예제 #3
0
파일: rebase_cmd.py 프로젝트: hershwg/bloom
def rebase_patches(without_git_rebase=True, directory=None):
    ### Ensure a clean/valid working environment
    ret = ensure_clean_working_env(git_status=True, directory=directory)
    if ret != 0:
        return ret
    ### Make sure we need to actually call this
    # Get the current branch
    current_branch = get_current_branch(directory)
    # Get the patches branch
    patches_branch = "patches/" + current_branch
    # Get the current patches.conf
    config = get_patch_config(patches_branch, directory=directory)
    # Get the current upstream commit hash
    upstream_commit_hash = get_commit_hash(config["parent"], directory)
    # If the current upstream commit hash is the same as the stored one, noop
    if upstream_commit_hash == config["previous"]:
        debug(
            "Nothing to do: Current branch (" + current_branch + ")'s "
            "base commit hash is the same as the source branch (" + config["parent"] + ")'s commit hash."
        )
        debug("    Did you forget to update the parent branch first?")
        debug(
            "    Updating the parent branch can be done by calling "
            "'git-bloom-patch rebase' on it, or 'git-bloom-import-upsteam'"
            " if the parent branch is the upstream branch."
        )
        return 0
    else:
        debug(
            "rebase_patches: "
            + upstream_commit_hash
            + " == "
            + config["previous"]
            + ": "
            + str(upstream_commit_hash == config["previous"])
        )

    ### Execute the rebase
    if without_git_rebase:
        non_git_rebase(config["parent"], directory=directory)
    else:
        git_rebase(config["parent"], directory=directory)

    ### Update the patches information
    # Get the latest configs
    config = get_patch_config(patches_branch, directory)
    # Set the base to the current hash (before patches)
    config["base"] = get_commit_hash(current_branch, directory)
    # Set the new upstream hash to the previous upstream hash
    config["previous"] = get_commit_hash(config["parent"], directory)
    # Clear the trimbase (it needs to be reapplied)
    config["trimbase"] = ""
    # Write the new configs
    set_patch_config(patches_branch, config, directory)
    return 0
예제 #4
0
def trim(sub_dir=None, force=False, undo=False, directory=None):
    # Get the current branch
    current_branch = get_current_branch(directory)
    # Ensure the current branch is valid
    if current_branch is None:
        error("Could not determine current branch, are you in a git repo?")
        return code.NOT_ON_A_GIT_BRANCH
    # Construct the patches branch
    patches_branch = 'patches/' + current_branch
    try:
        # See if the patches branch exists
        if branch_exists(patches_branch, False, directory=directory):
            if not branch_exists(patches_branch, True, directory=directory):
                track_branches(patches_branch, directory)
        else:
            error("No patches branch (" + patches_branch + ") found, cannot "
                  "perform trim.")
            return code.BRANCH_DOES_NOT_EXIST
        # Get the parent branch from the patches branch
        config = get_patch_config(patches_branch, directory=directory)
        if config is None:
            error("Could not retrieve patches info.")
            return code.COULD_NOT_GET_PATCH_INFO
        # If sub_dir is set, try to set it
        new_config = _set_trim_sub_dir(sub_dir, force, config, directory)
        if new_config is None:
            return code.COULD_NOT_TRIM
        # Perform trime or undo
        if undo:
            new_config = _undo(new_config, directory)
            if new_config is None:
                return code.NOTHING_TO_DO
        else:
            new_config = _trim(new_config, force, directory)
        if new_config is None:
            return code.COULD_NOT_TRIM
        # Commit the new config
        set_patch_config(patches_branch, new_config, directory)
    finally:
        if current_branch:
            checkout(current_branch, directory=directory)
    return code.OK
예제 #5
0
def remove_patches(directory=None):
    # Get the current branch
    current_branch = get_current_branch(directory)
    # Ensure the current branch is valid
    if current_branch is None:
        error("Could not determine current branch, are you in a git repo?")
        return 1
    # Construct the patches branch
    patches_branch = 'patches/' + current_branch
    try:
        # See if the patches branch exists
        if branch_exists(patches_branch, False, directory=directory):
            if not branch_exists(patches_branch, True, directory=directory):
                track_branches(patches_branch, directory)
        else:
            error("No patches branch (" + patches_branch + ") found, cannot "
                  "remove patches.")
            return 1
        # Get the parent branch from the patches branch
        config = get_patch_config(patches_branch, directory=directory)
        parent, spec = config['parent'], config['base']
        if None in [parent, spec]:
            error("Could not retrieve patches info.")
            return 1
        debug("Removing patches from " + current_branch + " back to base "
              "commit " + spec)
        # Reset this branch using git revert --no-edit spec
        current_commit = get_commit_hash(current_branch, directory)
        command_spec = spec + '..' + current_commit
        execute_command(
            'git revert --no-edit -Xtheirs ' + command_spec, cwd=directory
        )
        # Update the base
        config['base'] = get_commit_hash(current_branch, directory)
        set_patch_config(patches_branch, config, directory=directory)
    finally:
        if current_branch:
            checkout(current_branch, directory=directory)
    return 0