/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

  • Committer: Marius Kruger
  • Date: 2010-07-10 21:28:56 UTC
  • mto: (5384.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5385.
  • Revision ID: marius.kruger@enerweb.co.za-20100710212856-uq4ji3go0u5se7hx
* Update documentation
* add NEWS

Show diffs side-by-side

added added

removed removed

Lines of Context:
375
375
            recurse = True
376
376
            try:
377
377
                bzrdir = BzrDir.open_from_transport(current_transport)
378
 
            except errors.NotBranchError:
 
378
            except (errors.NotBranchError, errors.PermissionDenied):
379
379
                pass
380
380
            else:
381
381
                recurse, value = evaluate(bzrdir)
382
382
                yield value
383
383
            try:
384
384
                subdirs = list_current(current_transport)
385
 
            except errors.NoSuchFile:
 
385
            except (errors.NoSuchFile, errors.PermissionDenied):
386
386
                continue
387
387
            if recurse:
388
388
                for subdir in sorted(subdirs, reverse=True):
394
394
        """
395
395
        try:
396
396
            return [self.open_branch()]
397
 
        except errors.NotBranchError:
 
397
        except (errors.NotBranchError, errors.NoRepositoryPresent):
398
398
            return []
399
399
 
400
400
    @staticmethod
615
615
        """
616
616
        raise NotImplementedError(self.create_workingtree)
617
617
 
 
618
    def generate_backup_name(self, base):
 
619
        """Generate a non-existing backup file name based on base."""
 
620
        counter = 1
 
621
        name = "%s.~%d~" % (base, counter)
 
622
        while self.root_transport.has(name):
 
623
            counter += 1
 
624
            name = "%s.~%d~" % (base, counter)
 
625
        return name
 
626
 
618
627
    def backup_bzrdir(self):
619
628
        """Backup this bzr control directory.
620
629
 
621
630
        :return: Tuple with old path name and new path name
622
631
        """
623
 
        def name_gen(base='backup.bzr'):
624
 
            counter = 1
625
 
            name = "%s.~%d~" % (base, counter)
626
 
            while self.root_transport.has(name):
627
 
                counter += 1
628
 
                name = "%s.~%d~" % (base, counter)
629
 
            return name
630
632
 
631
 
        backup_dir=name_gen()
 
633
        backup_dir=self.generate_backup_name('backup.bzr')
632
634
        pb = ui.ui_factory.nested_progress_bar()
633
635
        try:
634
636
            # FIXME: bug 300001 -- the backup fails if the backup directory
1244
1246
        repository_policy = result.determine_repository_policy(
1245
1247
            force_new_repo, stacked_branch_url, require_stacking=stacked)
1246
1248
        result_repo, is_new_repo = repository_policy.acquire_repository()
1247
 
        if is_new_repo and revision_id is not None and not stacked:
 
1249
        is_stacked = stacked or (len(result_repo._fallback_repositories) != 0)
 
1250
        if is_new_repo and revision_id is not None and not is_stacked:
1248
1251
            fetch_spec = graph.PendingAncestryResult(
1249
1252
                [revision_id], source_repository)
1250
1253
        else:
1958
1961
            format_string = transport.get_bytes(".bzr/branch-format")
1959
1962
        except errors.NoSuchFile:
1960
1963
            raise errors.NotBranchError(path=transport.base)
1961
 
 
1962
1964
        try:
1963
1965
            return klass._formats[format_string]
1964
1966
        except KeyError:
2873
2875
            self.revisions[rev_id] = rev
2874
2876
 
2875
2877
    def _load_old_inventory(self, rev_id):
2876
 
        old_inv_xml = self.branch.repository.inventory_store.get(rev_id).read()
 
2878
        f = self.branch.repository.inventory_store.get(rev_id)
 
2879
        try:
 
2880
            old_inv_xml = f.read()
 
2881
        finally:
 
2882
            f.close()
2877
2883
        inv = xml4.serializer_v4.read_inventory_from_string(old_inv_xml)
2878
2884
        inv.revision_id = rev_id
2879
2885
        rev = self.revisions[rev_id]
2957
2963
                ie.revision = previous_ie.revision
2958
2964
                return
2959
2965
        if ie.has_text():
2960
 
            text = self.branch.repository._text_store.get(ie.text_id)
2961
 
            file_lines = text.readlines()
 
2966
            f = self.branch.repository._text_store.get(ie.text_id)
 
2967
            try:
 
2968
                file_lines = f.readlines()
 
2969
            finally:
 
2970
                f.close()
2962
2971
            w.add_lines(rev_id, previous_revisions, file_lines)
2963
2972
            self.text_count += 1
2964
2973
        else:
3245
3254
        # XXX: It's a bit ugly that the network name is here, because we'd
3246
3255
        # like to believe that format objects are stateless or at least
3247
3256
        # immutable,  However, we do at least avoid mutating the name after
3248
 
        # it's returned.  See <https://bugs.edge.launchpad.net/bzr/+bug/504102>
 
3257
        # it's returned.  See <https://bugs.launchpad.net/bzr/+bug/504102>
3249
3258
        self._network_name = None
3250
3259
 
3251
3260
    def __repr__(self):