diff options
author | Guido Günther <agx@sigxcpu.org> | 2011-02-09 22:50:59 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2011-02-09 22:53:10 +0100 |
commit | b92b88f95aacdbc1afcb0f2ad91a835fd3ad2612 (patch) | |
tree | 42676cd9f5b4d47e4ec9ead7c959b12328279776 | |
parent | d21506e3aa06dfd7f4acf953b2e58807b71677e0 (diff) |
git-import-dsc: auto create upstream branch
if it's missing. This allows to mass import old history of packages that
were native and switched to non-native later.
Closes: #610379
-rw-r--r-- | gbp/config.py | 5 | ||||
-rw-r--r-- | gbp/git.py | 14 | ||||
-rwxr-xr-x | git-import-dsc | 7 |
3 files changed, 22 insertions, 4 deletions
diff --git a/gbp/config.py b/gbp/config.py index d1211334..00b8dbc3 100644 --- a/gbp/config.py +++ b/gbp/config.py @@ -1,6 +1,6 @@ # vim: set fileencoding=utf-8 : # -# (C) 2006,2007,2010 Guido Guenther <agx@sigxcpu.org> +# (C) 2006,2007,2010,2011 Guido Guenther <agx@sigxcpu.org> """handles command line and config file option parsing for the gbp commands""" from optparse import OptionParser, OptionGroup, Option, OptionValueError @@ -99,6 +99,7 @@ class GbpOptionParser(OptionParser): 'track' : 'True', 'author-is-committer': 'False', 'author-date-is-committer-date': 'False', + 'create-missing-branches': 'False', } help = { 'debian-branch': @@ -163,6 +164,8 @@ class GbpOptionParser(OptionParser): "Use the authors's name also as the comitter's name, default is '%(author-is-committer)s'", 'author-date-is-committer-date': "Use the authors's date as the comitter's date, default is '%(author-date-is-committer-date)s'", + 'create-missing-branches': + "Create missing branches automatically, default is '%(create-missing-branches)s'", } config_files = [ '/etc/git-buildpackage/gbp.conf', os.path.expanduser('~/.gbp.conf'), @@ -1,12 +1,13 @@ # vim: set fileencoding=utf-8 : # -# (C) 2006,2007,2008 Guido Guenther <agx@sigxcpu.org> +# (C) 2006,2007,2008,2011 Guido Guenther <agx@sigxcpu.org> """provides git repository related helpers""" import re import subprocess import os.path -from command_wrappers import (GitAdd, GitRm, GitCheckoutBranch, GitInit, GitCommand, copy_from) +from command_wrappers import (GitAdd, GitBranch, GitRm, GitCheckoutBranch, + GitInit, GitCommand, copy_from) from errors import GbpError import log import dateutil.parser @@ -198,6 +199,15 @@ class GitRepository(object): if self.get_branch() != branch: GitCheckoutBranch(branch)() + def create_branch(self, branch, rev=None): + """create a new branch + @param rev: where to start the branch from + + if param is None the branch starts form the current HEAD + """ + self.__check_path() + GitBranch()(branch, rev) + def delete_branch(self, branch): self.__check_path() if self.get_branch() != branch: diff --git a/git-import-dsc b/git-import-dsc index 4c774acb..19f5f14c 100755 --- a/git-import-dsc +++ b/git-import-dsc @@ -1,7 +1,7 @@ #!/usr/bin/python -u # vim: set fileencoding=utf-8 : # -# (C) 2006,2007 Guido Guenther <agx@sigxcpu.org> +# (C) 2006,2007,2011 Guido Guenther <agx@sigxcpu.org> # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or @@ -173,6 +173,8 @@ def parse_args(argv): dest="debian_branch") branch_group.add_config_file_option(option_name="upstream-branch", dest="upstream_branch") + 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") @@ -270,6 +272,9 @@ def main(argv): else: branch = [options.upstream_branch, options.debian_branch][src.native] + if not repo.has_branch(branch) and options.create_missing_branches: + gbp.log.info("Creating missing branch '%s'" % branch) + repo.create_branch(branch) commit = repo.commit_dir(unpack_dir, "Imported %s" % msg, branch) |