Replace GitMerge by GitRepository.merge()
authorGuido Günther <agx@sigxcpu.org>
Sun, 23 Oct 2011 11:40:07 +0000 (13:40 +0200)
committerGuido Günther <agx@sigxcpu.org>
Sun, 23 Oct 2011 14:20:33 +0000 (16:20 +0200)
gbp-pull
gbp/command_wrappers.py
gbp/git.py
git-import-orig

index 57a2510..8bb9ba5 100755 (executable)
--- a/gbp-pull
+++ b/gbp-pull
@@ -22,7 +22,7 @@
 
 import sys
 import os, os.path
-from gbp.command_wrappers import (GitFetch, GitMerge, Command,
+from gbp.command_wrappers import (GitFetch, Command,
                                   CommandExecFailed, PristineTar)
 from gbp.config import (GbpOptionParser, GbpOptionGroup)
 from gbp.errors import GbpError
@@ -61,7 +61,7 @@ def fast_forward_branch(branch, repo, options):
     if update:
         gbp.log.info("Updating '%s'" % branch)
         repo.set_branch(branch)
-        GitMerge(remote)()
+        repo.merge(remote)
     return update
 
 def main(argv):
index b768239..1fcfdbc 100644 (file)
@@ -240,15 +240,6 @@ class GitFetch(GitCommand):
         GitCommand.__init__(self, 'fetch', opts)
 
 
-# FIXME: move to gbp.git.merge
-class GitMerge(GitCommand):
-    """Wrap git merge"""
-    def __init__(self, branch, verbose=False):
-        verbose = [ ['--no-summary'], [] ][verbose]
-        GitCommand.__init__(self, 'merge', [branch] + verbose)
-        self.run_error = 'Couldn\'t merge from "%s"' % (branch,)
-
-
 # FIXME: move to gbp.git.create_tag
 class GitTag(GitCommand):
     """Wrap git tag"""
index cfd01bc..cb3d74b 100644 (file)
@@ -290,6 +290,16 @@ class GitRepository(object):
         remote += merge.replace("refs/heads","", 1)
         return remote
 
+    def merge(self, commit, verbose=False):
+        """
+        Merge changes from the named commit into the current branch
+
+        @param commit: the commit to merge from (usually a branch name)
+        @type commit: string
+        """
+        args = [ "--summary"  ] if verbose else [ "--no-summary" ]
+        self._git_command("merge", args + [ commit ])
+
     def is_fast_forward(self, from_branch, to_branch):
         """
         check if an update from from_branch to to_branch would be a fast
index c0ee20a..d9bc077 100755 (executable)
@@ -399,7 +399,7 @@ def main(argv):
                 gbp.log.info("Merging to '%s'" % options.debian_branch)
                 repo.set_branch(options.debian_branch)
                 try:
-                    gbpc.GitMerge(tag)()
+                    repo.merge(tag)
                 except gbpc.CommandExecFailed:
                     raise GbpError, """Merge failed, please resolve."""
                 if options.postimport: