Merge lp:~jelmer/bzr-builddeb/merge-upstream-merge-mode into lp:bzr-builddeb

Proposed by Jelmer Vernooij
Status: Merged
Merged at revision: 500
Proposed branch: lp:~jelmer/bzr-builddeb/merge-upstream-merge-mode
Merge into: lp:bzr-builddeb
Prerequisite: lp:~jelmer/bzr-builddeb/295274-merge-upstream-no-version
Diff against target: 232 lines (+74/-57)
6 files modified
cmds.py (+27/-18)
config.py (+1/-1)
debian/changelog (+3/-1)
tests/test_source_distiller.py (+1/-1)
tests/test_upstream.py (+41/-0)
upstream.py (+1/-36)
To merge this branch: bzr merge lp:~jelmer/bzr-builddeb/merge-upstream-merge-mode
Reviewer Review Type Date Requested Status
James Westby Approve
Review via email: mp+47218@code.launchpad.net

Description of the change

This makes it possible for 'bzr merge-upstream' to work in merge mode branches.

Instead of merging in the upstream branch we Do The Right Thing and only update the changelog with the new upstream version.

To post a comment you must log in.
Revision history for this message
James Westby (james-w) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'cmds.py'
--- cmds.py 2011-01-24 06:28:00 +0000
+++ cmds.py 2011-01-24 06:28:00 +0000
@@ -637,13 +637,6 @@
637 "working tree. You must commit before using this "637 "working tree. You must commit before using this "
638 "command.")638 "command.")
639 config = debuild_config(tree, tree)639 config = debuild_config(tree, tree)
640 if config.build_type == BUILD_TYPE_MERGE:
641 raise BzrCommandError("Merge upstream in merge mode is not "
642 "yet supported.")
643 if config.build_type == BUILD_TYPE_NATIVE:
644 raise BzrCommandError("Merge upstream in native mode is not "
645 "yet supported.")
646
647 primary_upstream_source = None640 primary_upstream_source = None
648641
649 if upstream_branch is None:642 if upstream_branch is None:
@@ -665,6 +658,15 @@
665 (current_version, package, distribution, distribution_name,658 (current_version, package, distribution, distribution_name,
666 changelog, larstiq) = self._get_changelog_info(tree, last_version,659 changelog, larstiq) = self._get_changelog_info(tree, last_version,
667 package, distribution)660 package, distribution)
661 contains_upstream_source = tree_contains_upstream_source(tree)
662 build_type = config.build_type
663 if build_type is None:
664 build_type = guess_build_type(tree, changelog.version,
665 contains_upstream_source)
666 need_upstream_tarball = (build_type != BUILD_TYPE_MERGE)
667 if build_type == BUILD_TYPE_NATIVE:
668 raise BzrCommandError("Merge upstream in native mode is not "
669 "supported.")
668670
669 if location is not None:671 if location is not None:
670 try:672 try:
@@ -705,7 +707,9 @@
705 version = primary_upstream_source.get_latest_version(707 version = primary_upstream_source.get_latest_version(
706 package, current_version)708 package, current_version)
707 target_dir = tempfile.mkdtemp() # FIXME: Cleanup?709 target_dir = tempfile.mkdtemp() # FIXME: Cleanup?
708 location = primary_upstream_source.fetch_tarball(package, version, target_dir)710 if need_upstream_tarball:
711 location = primary_upstream_source.fetch_tarball(
712 package, version, target_dir)
709 note("Using version string %s." % (version))713 note("Using version string %s." % (version))
710 # Look up the revision id from the version string714 # Look up the revision id from the version string
711 if upstream_branch_source is not None:715 if upstream_branch_source is not None:
@@ -713,21 +717,26 @@
713 package, version)717 package, version)
714 if version is None:718 if version is None:
715 raise BzrCommandError("You must specify the version number using --version.")719 raise BzrCommandError("You must specify the version number using --version.")
716 tarball_filename = self._get_tarball(config, tree, package,720 if need_upstream_tarball:
717 version, upstream_branch, upstream_revision, v3,721 tarball_filename = self._get_tarball(config, tree, package,
718 location)722 version, upstream_branch, upstream_revision, v3,
719 conflicts = self._do_merge(tree, tarball_filename, version,723 location)
720 current_version, upstream_branch, upstream_revision,724 conflicts = self._do_merge(tree, tarball_filename, version,
721 merge_type, force)725 current_version, upstream_branch, upstream_revision,
726 merge_type, force)
722 self._add_changelog_entry(tree, package, version,727 self._add_changelog_entry(tree, package, version,
723 distribution_name, changelog)728 distribution_name, changelog)
724 finally:729 finally:
725 tree.unlock()730 tree.unlock()
726 note("The new upstream version has been imported.")731 if not need_upstream_tarball:
727 if conflicts:732 note("An entry for the new upstream version has been added "
728 note("You should now resolve the conflicts, review the changes, and then commit.")733 "to the changelog.")
729 else:734 else:
730 note("You should now review the changes and then commit.")735 note("The new upstream version has been imported.")
736 if conflicts:
737 note("You should now resolve the conflicts, review the changes, and then commit.")
738 else:
739 note("You should now review the changes and then commit.")
731740
732741
733class cmd_import_dsc(Command):742class cmd_import_dsc(Command):
734743
=== modified file 'config.py'
--- config.py 2011-01-12 21:31:25 +0000
+++ config.py 2011-01-24 06:28:00 +0000
@@ -272,7 +272,7 @@
272 elif self.split:272 elif self.split:
273 return BUILD_TYPE_SPLIT273 return BUILD_TYPE_SPLIT
274 else:274 else:
275 return BUILD_TYPE_NORMAL275 return None
276276
277 quick_builder = _opt_property('quick-builder',277 quick_builder = _opt_property('quick-builder',
278 "A quick command to build with", True)278 "A quick command to build with", True)
279279
=== modified file 'debian/changelog'
--- debian/changelog 2011-01-24 06:28:00 +0000
+++ debian/changelog 2011-01-24 06:28:00 +0000
@@ -30,8 +30,10 @@
30 * If possible use uscan to find the latest upstream version string.30 * If possible use uscan to find the latest upstream version string.
31 LP: #29527431 LP: #295274
32 * Add --snapshot option to merge-upstream.32 * Add --snapshot option to merge-upstream.
33 * 'bzr merge-upstream' now also works in merge mode, and will simply
34 add a new entry for new upstream versions.
3335
34 -- Jelmer Vernooij <jelmer@debian.org> Sun, 23 Jan 2011 21:35:21 -080036 -- Jelmer Vernooij <jelmer@debian.org> Sun, 23 Jan 2011 21:57:08 -0800
3537
36bzr-builddeb (2.5) unstable; urgency=low38bzr-builddeb (2.5) unstable; urgency=low
3739
3840
=== modified file 'tests/test_source_distiller.py'
--- tests/test_source_distiller.py 2010-05-23 15:29:38 +0000
+++ tests/test_source_distiller.py 2011-01-24 06:28:00 +0000
@@ -37,7 +37,7 @@
37 NativeSourceDistiller,37 NativeSourceDistiller,
38 )38 )
39from bzrlib.plugins.builddeb.tests import SourcePackageBuilder39from bzrlib.plugins.builddeb.tests import SourcePackageBuilder
40from bzrlib.plugins.builddeb.upstream import (40from bzrlib.plugins.builddeb.tests.test_upstream import (
41 _MissingUpstreamProvider,41 _MissingUpstreamProvider,
42 _SimpleUpstreamProvider,42 _SimpleUpstreamProvider,
43 _TouchUpstreamProvider,43 _TouchUpstreamProvider,
4444
=== modified file 'tests/test_upstream.py'
--- tests/test_upstream.py 2011-01-24 06:28:00 +0000
+++ tests/test_upstream.py 2011-01-24 06:28:00 +0000
@@ -33,6 +33,7 @@
33 DebBuildConfig,33 DebBuildConfig,
34 )34 )
35from bzrlib.plugins.builddeb.errors import (35from bzrlib.plugins.builddeb.errors import (
36 MissingUpstreamTarball,
36 PackageVersionNotPresent,37 PackageVersionNotPresent,
37 WatchFileMissing,38 WatchFileMissing,
38 )39 )
@@ -40,7 +41,9 @@
40 AptSource,41 AptSource,
41 StackedUpstreamSource,42 StackedUpstreamSource,
42 UpstreamBranchSource,43 UpstreamBranchSource,
44 UpstreamProvider,
43 UScanSource,45 UScanSource,
46 Version,
44 )47 )
4548
4649
@@ -323,3 +326,41 @@
323 self.assertEquals(revid2,326 self.assertEquals(revid2,
324 source.version_as_revision("foo", "2.1+bzr2"))327 source.version_as_revision("foo", "2.1+bzr2"))
325 self.assertEquals(revid1, source.version_as_revision("foo", "2.1"))328 self.assertEquals(revid1, source.version_as_revision("foo", "2.1"))
329
330
331class _MissingUpstreamProvider(UpstreamProvider):
332 """For tests"""
333
334 def __init__(self):
335 pass
336
337 def provide(self, target_dir):
338 raise MissingUpstreamTarball("test_tarball")
339
340
341class _TouchUpstreamProvider(UpstreamProvider):
342 """For tests"""
343
344 def __init__(self, desired_tarball_name):
345 self.desired_tarball_name = desired_tarball_name
346
347 def provide(self, target_dir):
348 f = open(os.path.join(target_dir, self.desired_tarball_name), "wb")
349 f.write("I am a tarball, honest\n")
350 f.close()
351
352
353class _SimpleUpstreamProvider(UpstreamProvider):
354 """For tests"""
355
356 def __init__(self, package, version, store_dir):
357 self.package = package
358 self.version = Version(version)
359 self.store_dir = store_dir
360
361 def provide(self, target_dir):
362 path = (self.already_exists_in_target(target_dir)
363 or self.provide_from_store_dir(target_dir))
364 if path is not None:
365 return path
366 raise MissingUpstreamTarball(self._tarball_names()[0])
326367
=== modified file 'upstream.py'
--- upstream.py 2011-01-24 06:28:00 +0000
+++ upstream.py 2011-01-24 06:28:00 +0000
@@ -507,39 +507,4 @@
507 tarball_name(self.package, self.version.upstream_version, format='lzma')]507 tarball_name(self.package, self.version.upstream_version, format='lzma')]
508508
509509
510class _MissingUpstreamProvider(UpstreamProvider):510
511 """For tests"""
512
513 def __init__(self):
514 pass
515
516 def provide(self, target_dir):
517 raise MissingUpstreamTarball("test_tarball")
518
519
520class _TouchUpstreamProvider(UpstreamProvider):
521 """For tests"""
522
523 def __init__(self, desired_tarball_name):
524 self.desired_tarball_name = desired_tarball_name
525
526 def provide(self, target_dir):
527 f = open(os.path.join(target_dir, self.desired_tarball_name), "wb")
528 f.write("I am a tarball, honest\n")
529 f.close()
530
531
532class _SimpleUpstreamProvider(UpstreamProvider):
533 """For tests"""
534
535 def __init__(self, package, version, store_dir):
536 self.package = package
537 self.version = Version(version)
538 self.store_dir = store_dir
539
540 def provide(self, target_dir):
541 path = (self.already_exists_in_target(target_dir)
542 or self.provide_from_store_dir(target_dir))
543 if path is not None:
544 return path
545 raise MissingUpstreamTarball(self._tarball_names()[0])

Subscribers

People subscribed via source and target branches