aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--debian/NEWS8
-rw-r--r--docs/chapters/import.sgml18
-rw-r--r--docs/manpages/gbp-import-orig.sgml26
-rw-r--r--gbp/config.py4
-rw-r--r--gbp/scripts/import_orig.py18
-rw-r--r--tests/24_test_gbp_import_orig.py38
6 files changed, 93 insertions, 19 deletions
diff --git a/debian/NEWS b/debian/NEWS
index 03c08ce2..63f38294 100644
--- a/debian/NEWS
+++ b/debian/NEWS
@@ -1,3 +1,11 @@
+git-buildpackage (0.8.14) unstable; urgency=medium
+
+ gbp import-orig's --merge-mode option now defaults to 'auto' selecting
+ 'replace' for 3.0 (quilt) packages and 'merge' otherwise. If you want to
+ retain the old behaviour of 'merge' please do so in gbp.conf.
+
+ -- Guido Günther <agx@sigxcpu.org> Tue, 04 Apr 2017 07:20:04 +0200
+
git-buildpackage (0.6.26) unstable; urgency=medium
All gbp-* and git-* commands are now gone as announced in the
diff --git a/docs/chapters/import.sgml b/docs/chapters/import.sgml
index 3ae9e2b6..c401b916 100644
--- a/docs/chapters/import.sgml
+++ b/docs/chapters/import.sgml
@@ -60,10 +60,20 @@ by version number.
This puts the upstream sources onto the <option>upstream-branch</option> and
tags them accordingly (the default tag format is
<replaceable>upstream/%(version)s</replaceable>).
- The result is then merged onto the <option>debian-branch</option>.
- You can again specify different branch names via
- the <option>--upstream-branch</option> and
- <option>--debian-branch</option> options.
+ </para>
+ <para>
+ The result is then placed onto
+ the <option>debian-branch</option>. The way this happens is
+ determined by the <option>--merge-mode</option> option. The
+ default mode <option>auto</option> replaces the upstream sources
+ while preserving the <filename>debian/</filename> directory for
+ 3.0 (quilt) packages. A &git; merge is used for all other source
+ format versions.
+ </para>
+ <para>
+ You can again specify different branch names via
+ the <option>--upstream-branch</option> and
+ <option>--debian-branch</option> options.
</para>
<para>If you are using <filename>debian/watch</filename> to keep track of how to retrieve upstream sources, you can also simply use the <option>--uscan</option> option:
<programlisting>
diff --git a/docs/manpages/gbp-import-orig.sgml b/docs/manpages/gbp-import-orig.sgml
index f6d87a29..f0814d6f 100644
--- a/docs/manpages/gbp-import-orig.sgml
+++ b/docs/manpages/gbp-import-orig.sgml
@@ -23,7 +23,7 @@
&man.common.options.synopsis;
<arg><option>--upstream-version=</option><replaceable>version</replaceable></arg>
<arg><option>--[no-]merge</option></arg>
- <arg><option>--merge-mode=</option><replaceable>[merge|replace]</replaceable></arg>
+ <arg><option>--merge-mode=</option><replaceable>[auto|merge|replace]</replaceable></arg>
<arg><option>--upstream-branch=</option><replaceable>branch_name</replaceable></arg>
<arg><option>--debian-branch=</option><replaceable>branch_name</replaceable></arg>
<arg><option>--upstream-vcs-tag=</option><replaceable>tag-format</replaceable></arg>
@@ -88,16 +88,14 @@
The sources are placed on the upstream branch (default:
<replaceable>upstream</replaceable>), tagged and merged onto the
debian branch (default: <replaceable>master</replaceable>). This
- is either done using <command>git merge</command> in case
- of <option>--merge-mode=</option><replaceable>merge</replaceable>
- (the default) or by creating a new tree that consists of the new
+ is either done using plain <command>git merge</command>
+ or by creating a new tree that consists of the new
upstream version plus the <filename>debian/</filename>
- directory. This behaviour can be enabled via
- the <option>--merge-mode=</option><replaceable>replace</replaceable>
- option and is preferable for source format 3.0 (quilt) packages
- since direct modifications of the upstream sources are not
- allowed in that format and so a 1:1 replacement of the upstream
- sources is almost always desired.
+ directory. The later is used for source format 3.0
+ (quilt) packages since direct modifications of the upstream
+ sources are not allowed in that format and so a 1:1 replacement
+ of the upstream sources is almost always desired. It can
+ be tweaked via the <option>--merge-mode</option>.
</para>
<para>In case of an error &gbp-import-orig; will rollback (undo)
all changes it has done to the repository (see
@@ -127,14 +125,13 @@
</listitem>
</varlistentry>
<varlistentry>
- <term><option>--merge-mode=</option><replaceable>[merge|replace]</replaceable></term>
+ <term><option>--merge-mode=</option><replaceable>[auto|merge|replace]</replaceable></term>
<listitem>
<para>
How to fold the newly imported upstream source to the
&debian; packaging branch after import.
</para>
<para>
- The default mode
<replaceable>merge</replaceable> does a
&git; <command>merge</command> leaving you on your own in
case of merge conflict resolution.
@@ -149,6 +146,11 @@
similar to a <option>theirs</option> merge strategy while
preserving <filename>debian/</filename>.
</para>
+ <para>
+ The default is <replaceable>auto</replaceable> which
+ uses <replaceable>replace</replaceable> for 3.0 (quilt) packages
+ and <replaceable>merge</replaceable> otherwise.
+ </para>
</listitem>
</varlistentry>
<varlistentry>
diff --git a/gbp/config.py b/gbp/config.py
index 433bd207..0608e118 100644
--- a/gbp/config.py
+++ b/gbp/config.py
@@ -160,7 +160,7 @@ class GbpOptionParser(OptionParser):
'renumber': 'False',
'notify': 'auto',
'merge': 'True',
- 'merge-mode': 'merge',
+ 'merge-mode': 'auto',
'track': 'True',
'author-is-committer': 'False',
'author-date-is-committer-date': 'False',
@@ -292,7 +292,7 @@ class GbpOptionParser(OptionParser):
"After the import merge the result to the debian branch, "
"default is '%(merge)s'",
'merge-mode':
- "Howto merge the new upstream sources onto the debian branch"
+ "Howto merge the new upstream sources onto the debian branch, "
"default is '%(merge-mode)s'",
'track':
"Set up tracking for remote branches, "
diff --git a/gbp/scripts/import_orig.py b/gbp/scripts/import_orig.py
index 61ad7a26..2ff342e5 100644
--- a/gbp/scripts/import_orig.py
+++ b/gbp/scripts/import_orig.py
@@ -24,6 +24,7 @@ import tempfile
import time
import gbp.command_wrappers as gbpc
from gbp.deb import (DebianPkgPolicy, parse_changelog_repo)
+from gbp.deb.format import DebianSourceFormat
from gbp.deb.upstreamsource import DebianUpstreamSource, unpack_component_tarball
from gbp.deb.uscan import (Uscan, UscanError)
from gbp.deb.changelog import ChangeLog, NoChangeLogError
@@ -32,6 +33,7 @@ from gbp.config import GbpOptionParserDebian, GbpOptionGroup, no_upstream_branch
from gbp.errors import GbpError
from gbp.pkg import parse_archive_filename
from gbp.format import format_str
+from gbp.git.vfs import GitVfs
import gbp.log
from gbp.scripts.common import ExitCodes, is_download
from gbp.scripts.common.import_orig import (orig_needs_repack, cleanup_tmp_tree,
@@ -339,6 +341,22 @@ def debian_branch_merge(repo, tag, version, options):
extra_env=env)()
+def is_30_quilt(repo, options):
+ format_file = DebianSourceFormat.format_file
+ try:
+ content = GitVfs(repo, options.debian_branch).open(format_file).read()
+ except IOError:
+ return False
+ return str(DebianSourceFormat(content)) == "3.0 (quilt)"
+
+
+def debian_branch_merge_by_auto(repo, tag, version, options):
+ if is_30_quilt(repo, options):
+ return debian_branch_merge_by_replace(repo, tag, version, options)
+ else:
+ return debian_branch_merge_by_merge(repo, tag, version, options)
+
+
def debian_branch_merge_by_replace(repo, tag, version, options):
gbp.log.info("Replacing upstream source on '%s'" % options.debian_branch)
diff --git a/tests/24_test_gbp_import_orig.py b/tests/24_test_gbp_import_orig.py
index 4264e669..c7619c35 100644
--- a/tests/24_test_gbp_import_orig.py
+++ b/tests/24_test_gbp_import_orig.py
@@ -4,7 +4,9 @@
import os
import unittest
-from gbp.scripts.import_orig import (ImportOrigDebianGitRepository, GbpError)
+from collections import namedtuple
+
+from gbp.scripts.import_orig import (ImportOrigDebianGitRepository, GbpError, is_30_quilt)
from gbp.scripts.common.import_orig import download_orig
from . testutils import DebianGitTestRepo
@@ -69,3 +71,37 @@ class TestImportOrigDownload(DebianGitTestRepo):
url = "https://{host}/cgit/gbp/deb-testdata/tree/dsc-3.0/{pkg}".format(host=self.HOST,
pkg=pkg)
self.assertEqual(download_orig(url).path, '../%s' % pkg)
+
+
+class TestIs30Quilt(DebianGitTestRepo):
+ Options = namedtuple('Options', 'debian_branch')
+ format_file = 'debian/source/format'
+
+ def setUp(self):
+ DebianGitTestRepo.setUp(self)
+ os.chdir(self.repo.path)
+ os.makedirs('debian/source/')
+
+ def test_30_quilt(self):
+ options = self.Options(debian_branch='master')
+ with open(self.format_file, 'w') as f:
+ f.write('3.0 (quilt)\n')
+ self.repo.add_files([self.format_file])
+ self.repo.commit_all("Add %s" % self.format_file)
+ self.assertEquals(self.repo.branch, options.debian_branch)
+ self.assertTrue(is_30_quilt(self.repo, options))
+
+ def test_no_format(self):
+ options = self.Options(debian_branch='master')
+ self.assertFalse(os.path.exists(self.format_file))
+ self.assertFalse(is_30_quilt(self.repo, options))
+
+ def test_no_quilt(self):
+ options = self.Options(debian_branch='master')
+ with open(self.format_file, 'w') as f:
+ f.write('3.0 (nonexistent)')
+ self.assertFalse(is_30_quilt(self.repo, options))
+
+ def test_30_quilt_empty_repo(self):
+ options = self.Options(debian_branch='master')
+ self.assertFalse(is_30_quilt(self.repo, options))