From a7a1c8a1be4c8bd83df7b09e5f72243bfd1f18a7 Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Wed, 12 Feb 2014 15:11:30 +0200 Subject: [PATCH] import-orig: implement --create-missing-branches option Create the upstream branch if it does not exist. Use the same option name that import-dsc has. Signed-off-by: Markus Lehtonen --- docs/manpages/gbp-import-orig.sgml | 10 ++++++++++ gbp/config.py | 3 ++- gbp/scripts/import_orig.py | 17 ++++++++++++----- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/docs/manpages/gbp-import-orig.sgml b/docs/manpages/gbp-import-orig.sgml index 3d79bac..db3433b 100644 --- a/docs/manpages/gbp-import-orig.sgml +++ b/docs/manpages/gbp-import-orig.sgml @@ -26,6 +26,7 @@ branch_name branch_name + tag_name gpg-keyid @@ -106,6 +107,15 @@ + + + + + Create missing upstream branch if it does not exist. + + + + =tag_name diff --git a/gbp/config.py b/gbp/config.py index 75d35fe..d999c9e 100644 --- a/gbp/config.py +++ b/gbp/config.py @@ -29,7 +29,8 @@ import gbp.tristate no_upstream_branch_msg = """ Repository does not have branch '%s' for upstream sources. If there is none see file:///usr/share/doc/git-buildpackage/manual-html/gbp.import.html#GBP.IMPORT.CONVERT -on howto create it otherwise use --upstream-branch to specify it. +on howto create it or check the --create-missing-branches option. Otherwise, +use --upstream-branch to specify it. """ def expand_path(option, opt, value): diff --git a/gbp/scripts/import_orig.py b/gbp/scripts/import_orig.py index 2efb4b3..43fde23 100644 --- a/gbp/scripts/import_orig.py +++ b/gbp/scripts/import_orig.py @@ -211,6 +211,9 @@ def build_parser(name): branch_group.add_option("--upstream-vcs-tag", dest="vcs_tag", help="Upstream VCS tag add to the merge commit") branch_group.add_boolean_config_file_option(option_name="merge", dest="merge") + branch_group.add_boolean_config_file_option( + option_name="create-missing-branches", + dest="create_missing_branches") tag_group.add_boolean_config_file_option(option_name="sign-tags", dest="sign_tags") @@ -285,7 +288,11 @@ def main(argv): is_empty = False if initial_branch else True if not repo.has_branch(options.upstream_branch) and not is_empty: - raise GbpError(no_upstream_branch_msg % options.upstream_branch) + if options.create_missing_branches: + gbp.log.info("Will create missing branch '%s'" % + options.upstream_branch) + else: + raise GbpError(no_upstream_branch_msg % options.upstream_branch) (sourcepackage, version) = detect_name_and_version(repo, source, options) @@ -336,10 +343,10 @@ def main(argv): parents = None commit = repo.commit_dir(source.unpacked, - msg=msg, - branch=import_branch, - other_parents=parents, - ) + msg=msg, + branch=import_branch, + other_parents=parents, + create_missing_branch=options.create_missing_branches) if options.pristine_tar: if pristine_orig: -- 2.7.4