Rev 455: Print the tag assigned when importing a tarball via import-upstream. in http://people.canonical.com/~robertc/baz2.0/plugins/builddeb/trunk

Robert Collins robertc at robertcollins.net
Tue May 4 07:51:24 BST 2010


At http://people.canonical.com/~robertc/baz2.0/plugins/builddeb/trunk

------------------------------------------------------------
revno: 455
revision-id: robertc at robertcollins.net-20100504065123-6p42izy54wzzrq8w
parent: robertc at robertcollins.net-20100504025914-ts27jh1nn2btr3v6
committer: Robert Collins <robertc at robertcollins.net>
branch nick: trunk
timestamp: Tue 2010-05-04 18:51:23 +1200
message:
  Print the tag assigned when importing a tarball via import-upstream.
=== modified file 'cmds.py'
--- a/cmds.py	2010-05-04 02:58:53 +0000
+++ b/cmds.py	2010-05-04 06:51:23 +0000
@@ -812,8 +812,9 @@
         tree.lock_read()
         dbs = DistributionBranchSet()
         dbs.add_branch(db)
-        db.import_upstream_tarball(location, version, parents,
+        tag_name, _ = db.import_upstream_tarball(location, version, parents,
             upstream_branch=upstream)
+        self.outf.write('Imported %s as %s.\n' % (location, tag_name))
 
 
 class cmd_bd_do(Command):

=== modified file 'import_dsc.py'
--- a/import_dsc.py	2010-05-04 02:45:38 +0000
+++ b/import_dsc.py	2010-05-04 06:51:23 +0000
@@ -928,6 +928,7 @@
         :param upstream_parents: the parents to give the upstream revision
         :param timestamp: a tuple of (timestamp, timezone) to use for
             the commit, or None to use the current time.
+        :return: (tag_name, revision_id) of the imported tarball.
         """
         # Should we just dump the upstream part on whatever is currently
         # there, or try and pull all of the other upstream versions
@@ -992,8 +993,8 @@
         revid = self.upstream_tree.commit("Import upstream version %s" \
                 % (version,),
                 revprops=revprops, timestamp=timestamp, timezone=timezone)
-        self.tag_upstream_version(version, revid=revid)
-        return revid
+        tag_name, _ = self.tag_upstream_version(version, revid=revid)
+        return tag_name, revid
 
     def import_upstream_tarball(self, tarball_filename, version, parents,
         md5sum=None, upstream_branch=None):
@@ -1007,12 +1008,13 @@
         :param upstream_branch: An upstream branch to associate with the
             tarball.
         :param md5sum: hex digest of the md5sum of the tarball, if known.
+        :return: (tag_name, revision_id) of the imported tarball.
         """
         if not md5sum:
             md5sum = md5sum_filename(tarball_filename)
         tarball_dir = self._extract_tarball_to_tempdir(tarball_filename)
         try:
-            self.import_upstream(tarball_dir, version, md5sum, parents,
+            return self.import_upstream(tarball_dir, version, md5sum, parents,
                 upstream_tarball=tarball_filename,
                 upstream_branch=upstream_branch)
         finally:
@@ -1237,7 +1239,7 @@
                     # from another branch:
                     upstream_parents = self.upstream_parents(versions,
                             version.upstream_version)
-                    new_revid = self.import_upstream(upstream_part,
+                    _, new_revid = self.import_upstream(upstream_part,
                             version.upstream_version,
                             upstream_md5, upstream_parents,
                             upstream_tarball=upstream_tarball,
@@ -1507,7 +1509,7 @@
                     parents = []
                     if self.upstream_branch.last_revision() != NULL_REVISION:
                         parents = [self.upstream_branch.last_revision()]
-                    new_revid = self.import_upstream(tarball_dir,
+                    _, new_revid = self.import_upstream(tarball_dir,
                             version.upstream_version,
                             md5sum, parents, upstream_tarball=tarball_filename,
                             upstream_branch=upstream_branch,

=== modified file 'tests/blackbox/test_import_upstream.py'
--- a/tests/blackbox/test_import_upstream.py	2010-05-04 02:45:38 +0000
+++ b/tests/blackbox/test_import_upstream.py	2010-05-04 06:51:23 +0000
@@ -91,8 +91,11 @@
         self.make_debian_dir(tree.bzrdir.root_transport.local_abspath('debian'))
         tree.smart_add(['working'])
         tree.commit('save changes')
-        self.run_bzr(['import-upstream', self.upstream_version,
-            os.path.abspath(self.upstream_tarball_name)], working_dir='working')
+        tar_path = "../%s" % self.upstream_tarball_name
+        out, err = self.run_bzr(['import-upstream', self.upstream_version,
+            tar_path], working_dir='working')
+        self.assertEqual('Imported %s as upstream-%s.\n' % (tar_path,
+            self.upstream_version), out)
         tree.lock_read()
         self.addCleanup(tree.unlock)
         self.assertFalse(tree.has_changes())




More information about the bazaar-commits mailing list