/breezy/stretch-backports

To get this branch, use:
bzr branch https://code.breezy-vcs.org/breezy/stretch-backports

« back to all changes in this revision

Viewing changes to breezy/bzr/remote.py

Merge trunk, address review comments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
from .. import (
23
23
    bencode,
24
24
    branch,
 
25
    bzr as _mod_bzr,
25
26
    config as _mod_config,
26
27
    controldir,
27
28
    debug,
490
491
                warning('VFS BzrDir access triggered\n%s',
491
492
                    ''.join(traceback.format_stack()))
492
493
            self._real_bzrdir = _mod_bzrdir.BzrDir.open_from_transport(
493
 
                self.root_transport, probers=[_mod_bzrdir.BzrProber])
 
494
                self.root_transport, probers=[_mod_bzr.BzrProber])
494
495
            self._format._network_name = \
495
496
                self._real_bzrdir._format.network_name()
496
497
 
2536
2537
                mode='r|bz2')
2537
2538
            tmpdir = osutils.mkdtemp()
2538
2539
            try:
2539
 
                _extract_tar(tar, tmpdir)
 
2540
                tar.extractall(tmpdir)
2540
2541
                tmp_bzrdir = _mod_bzrdir.BzrDir.open(tmpdir)
2541
2542
                tmp_repo = tmp_bzrdir.open_repository()
2542
2543
                tmp_repo.copy_content_into(destination, revision_id)
2657
2658
            yield serializer.read_revision_from_string("".join(chunks))
2658
2659
 
2659
2660
    @needs_read_lock
2660
 
    def get_revisions(self, revision_ids):
2661
 
        if revision_ids is None:
2662
 
            revision_ids = self.all_revision_ids()
2663
 
        else:
2664
 
            for rev_id in revision_ids:
2665
 
                if not rev_id or not isinstance(rev_id, basestring):
2666
 
                    raise errors.InvalidRevisionId(
2667
 
                        revision_id=rev_id, branch=self)
 
2661
    def iter_revisions(self, revision_ids):
 
2662
        for rev_id in revision_ids:
 
2663
            if not rev_id or not isinstance(rev_id, bytes):
 
2664
                raise errors.InvalidRevisionId(
 
2665
                    revision_id=rev_id, branch=self)
2668
2666
        try:
2669
2667
            missing = set(revision_ids)
2670
 
            revs = {}
2671
2668
            for rev in self._iter_revisions_rpc(revision_ids):
2672
2669
                missing.remove(rev.revision_id)
2673
 
                revs[rev.revision_id] = rev
 
2670
                yield (rev.revision_id, rev)
 
2671
            for fallback in self._fallback_repositories:
 
2672
                if not missing:
 
2673
                    break
 
2674
                for (revid, rev) in fallback.iter_revisions(missing):
 
2675
                    if rev is not None:
 
2676
                        yield (revid, rev)
 
2677
                        missing.remove(revid)
 
2678
            for revid in missing:
 
2679
                yield (revid, None)
2674
2680
        except errors.UnknownSmartMethod:
2675
2681
            self._ensure_real()
2676
 
            return self._real_repository.get_revisions(revision_ids)
2677
 
        for fallback in self._fallback_repositories:
2678
 
            if not missing:
2679
 
                break
2680
 
            for revid in list(missing):
2681
 
                # XXX JRV 2011-11-20: It would be nice if there was a
2682
 
                # public method on Repository that could be used to query
2683
 
                # for revision objects *without* failing completely if one
2684
 
                # was missing. There is VersionedFileRepository._iter_revisions,
2685
 
                # but unfortunately that's private and not provided by
2686
 
                # all repository implementations.
2687
 
                try:
2688
 
                    revs[revid] = fallback.get_revision(revid)
2689
 
                except errors.NoSuchRevision:
2690
 
                    pass
2691
 
                else:
2692
 
                    missing.remove(revid)
2693
 
        if missing:
2694
 
            raise errors.NoSuchRevision(self, list(missing)[0])
2695
 
        return [revs[revid] for revid in revision_ids]
 
2682
            for entry in self._real_repository.iter_revisions(revision_ids):
 
2683
                yield entry
2696
2684
 
2697
2685
    def supports_rich_root(self):
2698
2686
        return self._format.rich_root_data
3893
3881
        # XXX: These should be returned by the set_last_revision_info verb
3894
3882
        old_revno, old_revid = self.last_revision_info()
3895
3883
        self._run_pre_change_branch_tip_hooks(revno, revision_id)
3896
 
        if not revision_id or not isinstance(revision_id, basestring):
 
3884
        if not revision_id or not isinstance(revision_id, bytes):
3897
3885
            raise errors.InvalidRevisionId(revision_id=revision_id, branch=self)
3898
3886
        try:
3899
3887
            response = self._call('Branch.set_last_revision_info',
4130
4118
        return self._bzrdir._real_bzrdir
4131
4119
 
4132
4120
 
4133
 
def _extract_tar(tar, to_dir):
4134
 
    """Extract all the contents of a tarfile object.
4135
 
 
4136
 
    A replacement for extractall, which is not present in python2.4
4137
 
    """
4138
 
    for tarinfo in tar:
4139
 
        tar.extract(tarinfo, to_dir)
4140
 
 
4141
 
 
4142
4121
error_translators = registry.Registry()
4143
4122
no_context_error_translators = registry.Registry()
4144
4123