summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2011-10-22 14:25:13 +0200
committerGuido Günther <agx@sigxcpu.org>2011-10-23 16:20:31 +0200
commit9f168491bc9240919ffd48ca5450dc8b45137dc3 (patch)
treedd820b8bacc8bc6674753fd840a5972212d7fa24
parent83fd2c679fb4eb0aad0a05f95968603d04b3fab6 (diff)
Replace GitBranch by GitRepository.create_branch()
-rwxr-xr-xgbp-clone6
-rw-r--r--gbp/command_wrappers.py13
-rw-r--r--gbp/git.py7
-rwxr-xr-xgit-import-dsc4
-rwxr-xr-xgit-import-orig2
5 files changed, 11 insertions, 21 deletions
diff --git a/gbp-clone b/gbp-clone
index 94e2d46..056726e 100755
--- a/gbp-clone
+++ b/gbp-clone
@@ -25,7 +25,7 @@ import os, os.path
from gbp.config import (GbpOptionParser, GbpOptionGroup)
from gbp.git import (GitRepositoryError, GitRepository)
from gbp.command_wrappers import (GitClone, Command, CommandExecFailed,
- GitBranch, PristineTar)
+ PristineTar)
from gbp.errors import GbpError
import gbp.log
@@ -89,7 +89,7 @@ def main(argv):
local = remote.replace("origin/", "", 1)
if not repo.has_branch(local) and \
local != "HEAD":
- GitBranch()(local, remote)
+ repo.create_branch(local, remote)
else: # only track gbp's default branches
branches = [ options.debian_branch, options.upstream_branch ]
if options.pristine_tar:
@@ -99,7 +99,7 @@ def main(argv):
remote = 'origin/%s' % branch
if repo.has_branch(remote, remote=True) and \
not repo.has_branch(branch):
- GitBranch()(branch, remote)
+ repo.create_branch(branch, remote)
repo.set_branch(options.debian_branch)
diff --git a/gbp/command_wrappers.py b/gbp/command_wrappers.py
index f182e98..4c1de10 100644
--- a/gbp/command_wrappers.py
+++ b/gbp/command_wrappers.py
@@ -237,19 +237,6 @@ class GitClone(GitCommand):
GitCommand.__init__(self, 'clone')
self.run_error = "Couldn't clone git repository"
-# FIXME: move to gbp.git.create_branch
-class GitBranch(GitCommand):
- """Wrap git branch"""
- def __init__(self):
- GitCommand.__init__(self, 'branch')
-
- def __call__(self, branch, remote=None):
- self.run_error = 'Couldn\'t create branch "%s"' % (branch,)
- options = [branch]
- if remote:
- options += [ remote ]
- GitCommand.__call__(self, options)
-
# FIXME: move to gbp.git.fetch
class GitFetch(GitCommand):
diff --git a/gbp/git.py b/gbp/git.py
index aba2dce..23cbb3f 100644
--- a/gbp/git.py
+++ b/gbp/git.py
@@ -19,7 +19,7 @@
import re
import subprocess
import os.path
-from command_wrappers import (GitCommand, GitBranch, copy_from)
+from command_wrappers import (GitCommand, copy_from)
from errors import GbpError
import log
import dateutil.parser
@@ -336,7 +336,10 @@ class GitRepository(object):
If rev is None the branch starts form the current HEAD.
"""
- GitBranch()(branch, rev)
+ args = [ branch ]
+ args += [ rev ] if rev else []
+
+ self._git_command("branch", args)
def delete_branch(self, branch):
"""
diff --git a/git-import-dsc b/git-import-dsc
index 0332e42..ac19757 100755
--- a/git-import-dsc
+++ b/git-import-dsc
@@ -288,13 +288,13 @@ def main(argv):
if not src.native:
if is_empty:
- gbpc.GitBranch()(options.upstream_branch, commit)
+ repo.create_branch(options.upstream_branch, commit)
if options.pristine_tar:
gbpc.PristineTar().commit(src.tgz, 'refs/heads/%s' % options.upstream_branch)
parents = [ options.upstream_branch ]
if not src.native:
if is_empty and not repo.has_branch(options.debian_branch):
- gbpc.GitBranch()(options.debian_branch, commit)
+ repo.create_branch(options.debian_branch, commit)
if src.diff or src.deb_tgz:
apply_debian_patch(repo, upstream.unpacked, src, options, parents)
else:
diff --git a/git-import-orig b/git-import-orig
index cd0127d..c0ee20a 100755
--- a/git-import-orig
+++ b/git-import-orig
@@ -393,7 +393,7 @@ def main(argv):
msg="Upstream version %s" % version,
commit=commit)
if is_empty:
- gbpc.GitBranch()(options.upstream_branch, remote=commit)
+ repo.create_branch(options.upstream_branch, rev=commit)
repo.force_head(options.upstream_branch, hard=True)
elif options.merge:
gbp.log.info("Merging to '%s'" % options.debian_branch)