~ubuntu-branches/ubuntu/oneiric/bzr-builddeb/oneiric

« back to all changes in this revision

Viewing changes to import_dsc.py

  • Committer: Bazaar Package Importer
  • Author(s): James Westby, James Westby, Jelmer Vernooij
  • Date: 2010-08-18 20:12:20 UTC
  • mfrom: (5.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20100818201220-yblzkx1w097ohh7h
Tags: 2.6
[ James Westby ]

* Don't fail if asked to use a .bz2 tarball that is already in the desired
  location. LP: #616786
* Don't crash if we are asked to merge-upstream with an unrelated branch.
  LP: #619614.
* Don't strip -n from the version we get in merge-upstream, as some
  upstreams have this in there, and trying to support both means supporting
  both badly. If you are used to doing "bzr merge-upstream --version
  <package version>" then it will no longer work for you, use the
  upstream version instead.
* Don't crash when doing merge-upstream with a branch that does a rename
  and then ships another file with the old path in the tarball that isn't
  in the branch.

[ Jelmer Vernooij ]

* Fix the auto-detection of merge mode.
* Don't crash on merge mode packages where there is no export-upstream
  if we can't find the tarball.
* Determine Bazaar home directory using bzrlib to prevent test
  isolation issues. LP: #614125

Show diffs side-by-side

added added

removed removed

Lines of Context:
952
952
            return br.repository.revision_tree(br.last_revision())
953
953
        upstream_trees = [get_last_revision_tree(o.upstream_branch)
954
954
            for o in other_branches]
 
955
        target_tree = None
955
956
        if upstream_branch is not None:
956
957
            if upstream_revision is None:
957
958
                upstream_revision = upstream_branch.last_revision()
959
960
                    last_revision=upstream_revision)
960
961
            upstream_branch.tags.merge_to(self.upstream_branch.tags)
961
962
            upstream_parents.append(upstream_revision)
962
 
            upstream_trees.insert(0,
963
 
                    self.upstream_branch.repository.revision_tree(
964
 
                        upstream_revision))
 
963
            target_tree = self.upstream_branch.repository.revision_tree(
 
964
                        upstream_revision)
965
965
        if file_ids_from is not None:
966
966
            upstream_trees = file_ids_from + upstream_trees
967
967
        if self.tree:
972
972
            self_tree.lock_read()
973
973
        try:
974
974
            import_dir(self.upstream_tree, upstream_part,
975
 
                    file_ids_from=upstream_trees + [self_tree])
 
975
                    file_ids_from=[self_tree] + upstream_trees,
 
976
                    target_tree=target_tree)
976
977
        finally:
977
978
            self_tree.unlock()
978
979
        self.upstream_tree.set_parent_ids(upstream_parents)
1461
1462
    _revid_of_upstream_version_from_branch = revid_of_upstream_version_from_branch
1462
1463
 
1463
1464
    def _export_previous_upstream_tree(self, previous_version, tempdir, upstream_branch=None):
1464
 
        previous_upstream_revision = get_snapshot_revision(previous_version.upstream_version)
1465
 
        if self.has_upstream_version_in_packaging_branch(
1466
 
                previous_version.upstream_version):
 
1465
        assert isinstance(previous_version, str), \
 
1466
            "Should pass upstream version as str, not Version."
 
1467
        previous_upstream_revision = get_snapshot_revision(previous_version)
 
1468
        if self.has_upstream_version_in_packaging_branch(previous_version):
1467
1469
            upstream_tip = self.revid_of_upstream_version_from_branch(
1468
 
                    previous_version.upstream_version)
 
1470
                    previous_version)
1469
1471
            self.extract_upstream_tree(upstream_tip, tempdir)
1470
 
        elif (upstream_branch is not None and 
 
1472
        elif (upstream_branch is not None and
1471
1473
              previous_upstream_revision is not None):
1472
1474
            upstream_tip = RevisionSpec.from_string(previous_upstream_revision).as_revision_id(upstream_branch)
1473
1475
            assert isinstance(upstream_tip, str)
1476
1478
            raise BzrCommandError("Unable to find the tag for the "
1477
1479
                    "previous upstream version, %s, in the branch: "
1478
1480
                    "%s" % (
1479
 
                previous_version.upstream_version,
1480
 
                self.upstream_tag_name(
1481
 
                    previous_version.upstream_version)))
 
1481
                previous_version,
 
1482
                self.upstream_tag_name(previous_version)))
1482
1483
 
1483
1484
    def merge_upstream(self, tarball_filename, version, previous_version,
1484
1485
            upstream_branch=None, upstream_revision=None, merge_type=None,
1485
1486
            force=False):
1486
1487
        assert self.upstream_branch is None, \
1487
1488
                "Should use self.upstream_branch if set"
 
1489
        assert isinstance(version, str), \
 
1490
            "Should pass version as str not %s" % str(type(version))
 
1491
        assert isinstance(previous_version, str), \
 
1492
            "Should pass previous_version as str not %s" % str(
 
1493
                    type(previous_version))
1488
1494
        tempdir = tempfile.mkdtemp(dir=os.path.join(self.tree.basedir, '..'))
1489
1495
        try:
1490
1496
            if previous_version is not None:
1491
1497
                self._export_previous_upstream_tree(previous_version, tempdir,
1492
 
                    upstream_branch) 
 
1498
                    upstream_branch)
1493
1499
            else:
1494
1500
                self._create_empty_upstream_tree(tempdir)
1495
 
            if self.has_upstream_version_in_packaging_branch(version.upstream_version):
 
1501
            if self.has_upstream_version_in_packaging_branch(version):
1496
1502
                raise UpstreamAlreadyImported(version)
 
1503
            if upstream_branch is not None:
 
1504
                upstream_branch.lock_read()
1497
1505
            try:
1498
1506
                if upstream_branch is not None:
1499
 
                    upstream_branch.lock_read()
1500
1507
                    if upstream_revision is None:
1501
1508
                        upstream_revision = upstream_branch.last_revision()
1502
1509
                    graph = self.branch.repository.get_graph(
1513
1520
                    if self.upstream_branch.last_revision() != NULL_REVISION:
1514
1521
                        parents = [self.upstream_branch.last_revision()]
1515
1522
                    _, new_revid = self.import_upstream(tarball_dir,
1516
 
                            version.upstream_version,
 
1523
                            version,
1517
1524
                            md5sum, parents, upstream_tarball=tarball_filename,
1518
1525
                            upstream_branch=upstream_branch,
1519
1526
                            upstream_revision=upstream_revision)