[Pkg-bazaar-commits] r144 ./bzr-builddeb/people/jdw/merge_upstream: Repack the tarball after merge-upstream (well before actually).

James Westby jw+debian at jameswestby.net
Sun Jul 8 10:19:58 UTC 2007


------------------------------------------------------------
revno: 144
committer: James Westby <jw+debian at jameswestby.net>
branch nick: merge_upstream
timestamp: Sun 2007-07-08 11:19:58 +0100
message:
  Repack the tarball after merge-upstream (well before actually).
  
  When you do a merge-upstream then you want the tarball placing
  where it can be found in the correct format. As it can now be
  remote first download it and repack to the correct place, and
  then use the local copy for the merging.
modified:
  __init__.py
  builder.py
  util.py
-------------- next part --------------
=== modified file '__init__.py'
--- a/__init__.py	2007-07-01 14:23:31 +0000
+++ b/__init__.py	2007-07-08 10:19:58 +0000
@@ -41,7 +41,7 @@
                     StopBuild,
                     )
 from properties import BuildProperties
-from util import goto_branch, find_changelog, is_clean
+from util import goto_branch, find_changelog, is_clean, tarball_name
 
 dont_purge_opt = Option('dont-purge',
     help="Don't purge the build directory after building")
@@ -293,19 +293,59 @@
 
   You must supply the source to import from, and the version number of the
   new release. The source can be a .tar.gz, .tar, .tar.bz2, .tgz or .zip
-  archive, or a directory.
+  archive, or a directory. The source may also be a remote file.
+
+  If there is no debian changelog in the branch to retrieve the package
+  name from then you must pass the --package option. If this version
+  will change the name of the source package then you can use this option
+  to set the new name.
   """
-  takes_args = ['filename', 'version']
+  takes_args = ['path', 'version']
   aliases = ['mu']
 
-  def run(self, filename, version):
-
-    from merge_upstream import merge_upstream
+  package_opt = Option('package', help="The name of the source package.",
+                            type=str)
+  takes_options = [package_opt]
+
+  def run(self, path, version, package=None):
+
     from bzrlib.errors import (NoSuchTag,
                                TagAlreadyExists,
                                )
+    from errors import MissingChangelogError
+    from merge_upstream import merge_upstream
+    from repack_tarball import repack_tarball
 
     tree, relpath = WorkingTree.open_containing('.')
+
+    config = DebBuildConfig([(local_conf, True), (global_conf, True),
+                             (default_conf, False)], branch=tree.branch)
+
+    if config.merge:
+      raise BzrCommandError("Merge upstream in merge mode is not yet "
+                            "supported")
+    if config.native:
+      raise BzrCommandError("Merge upstream in native mode is not yet "
+                            "supported")
+    if config.export_upstream:
+      raise BzrCommandError("Merge upstream in export upstream is not yet "
+                            "supported")
+
+    if package is None:
+      try:
+        package = find_changelog(tree, False)[0].package
+      except MissingChangelogError:
+        raise BzrCommandError("There is no changelog to rertrieve the package "
+                              "information from, please use the --package option "
+                              "to give the name of the package")
+
+    orig_dir = config.orig_dir or '../tarballs'
+    orig_dir = os.path.join(tree.basedir, orig_dir)
+
+    dest_name = tarball_name(package, version)
+    repack_tarball(path, dest_name, target_dir=orig_dir)
+    filename = os.path.join(orig_dir, dest_name)
+
     try:
       merge_upstream(tree, filename, version)
     # TODO: tidy all of this up, and be more precise in what is wrong and
@@ -319,7 +359,9 @@
                             "been performed, as there is already a tag "
                             "for this upstream version. If that is not the "
                             "case then delete that tag and try again.")
-    # TODO: also repack the tarball.
+    info("The new upstream version has been imported. You should now update "
+         "the changelog (try dch -v %s), and then commit. Note that debcommit "
+         "will not do what you want in this case." % str(version))
 
 
 register_command(cmd_merge_upstream)

=== modified file 'builder.py'
--- a/builder.py	2007-05-03 18:40:14 +0000
+++ b/builder.py	2007-07-08 10:19:58 +0000
@@ -37,7 +37,7 @@
                     BuildFailedError,
                     StopBuild,
                     )
-from util import recursive_copy
+from util import recursive_copy, tarball_name
 
 def remove_dir(base, dir):
   """Removes a directory from within a base."""
@@ -113,7 +113,7 @@
     """Returns the name that the upstream tarball should have."""
     package = self._properties.package()
     upstream = self._properties.upstream_version()
-    return package+"_"+upstream+".orig.tar.gz"
+    return tarball_name(package, upstream)
 
   def export(self, use_existing=False):
     """Export the package in to a clean dir for building.

=== modified file 'util.py'
--- a/util.py	2007-07-01 14:23:31 +0000
+++ b/util.py	2007-07-08 10:19:58 +0000
@@ -91,4 +91,8 @@
     changelog = Changelog(contents, max_blocks=1)
     return changelog, larstiq
 
+def tarball_name(package, version):
+  """Return the name of the .orig.tar.gz for the given pakcage and version."""
+
+  return "%s_%s.orig.tar.gz" % (package, str(version))
 



More information about the Pkg-bazaar-commits mailing list