From b92b88f95aacdbc1afcb0f2ad91a835fd3ad2612 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Wed, 9 Feb 2011 22:50:59 +0100 Subject: 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 --- gbp/config.py | 5 ++++- gbp/git.py | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'gbp') 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 +# (C) 2006,2007,2010,2011 Guido Guenther """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'), diff --git a/gbp/git.py b/gbp/git.py index f9defd53..1ecab9f1 100644 --- a/gbp/git.py +++ b/gbp/git.py @@ -1,12 +1,13 @@ # vim: set fileencoding=utf-8 : # -# (C) 2006,2007,2008 Guido Guenther +# (C) 2006,2007,2008,2011 Guido Guenther """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: -- cgit v1.2.3