~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

  • Committer: John Arbash Meinel
  • Date: 2008-05-28 21:53:46 UTC
  • mfrom: (3453 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3458.
  • Revision ID: john@arbash-meinel.com-20080528215346-l8plys9h9ps624pn
merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
453
453
    The Repository builds on top of Stores and a Transport, which respectively 
454
454
    describe the disk data format and the way of accessing the (possibly 
455
455
    remote) disk.
 
456
 
 
457
    :ivar _transport: Transport for file access to repository, typically
 
458
        pointing to .bzr/repository.
456
459
    """
457
460
 
458
461
    # What class to use for a CommitBuilder. Often its simpler to change this
607
610
        """Construct the current default format repository in a_bzrdir."""
608
611
        return RepositoryFormat.get_default_format().initialize(a_bzrdir)
609
612
 
610
 
    def __init__(self, _format, a_bzrdir, control_files, _revision_store, control_store, text_store):
 
613
    def __init__(self, _format, a_bzrdir, control_files,
 
614
                 _revision_store, control_store, text_store):
611
615
        """instantiate a Repository.
612
616
 
613
617
        :param _format: The format of the repository on disk.
622
626
        # the following are part of the public API for Repository:
623
627
        self.bzrdir = a_bzrdir
624
628
        self.control_files = control_files
 
629
        self._transport = control_files._transport
 
630
        self.base = self._transport.base
625
631
        self._revision_store = _revision_store
626
632
        # backwards compatibility
627
633
        self.weave_store = text_store
637
643
        # on whether escaping is required.
638
644
        self._warn_if_deprecated()
639
645
        self._write_group = None
640
 
        self.base = control_files._transport.base
641
646
 
642
647
    def __repr__(self):
643
648
        return '%s(%r)' % (self.__class__.__name__,
652
657
        """
653
658
        if self.__class__ is not other.__class__:
654
659
            return False
655
 
        return (self.control_files._transport.base ==
656
 
                other.control_files._transport.base)
 
660
        return (self._transport.base == other._transport.base)
657
661
 
658
662
    def is_in_write_group(self):
659
663
        """Return True if there is an open write group.
1695
1699
        """See graph._StackedParentsProvider.get_parent_map"""
1696
1700
        parent_map = {}
1697
1701
        for revision_id in keys:
 
1702
            if revision_id is None:
 
1703
                raise ValueError('get_parent_map(None) is not valid')
1698
1704
            if revision_id == _mod_revision.NULL_REVISION:
1699
1705
                parent_map[revision_id] = ()
1700
1706
            else:
1936
1942
 
1937
1943
 
1938
1944
class MetaDirRepository(Repository):
1939
 
    """Repositories in the new meta-dir layout."""
 
1945
    """Repositories in the new meta-dir layout.
 
1946
    
 
1947
    :ivar _transport: Transport for access to repository control files,
 
1948
        typically pointing to .bzr/repository.
 
1949
    """
1940
1950
 
1941
1951
    def __init__(self, _format, a_bzrdir, control_files, _revision_store, control_store, text_store):
1942
1952
        super(MetaDirRepository, self).__init__(_format,
1945
1955
                                                _revision_store,
1946
1956
                                                control_store,
1947
1957
                                                text_store)
1948
 
        dir_mode = self.control_files._dir_mode
1949
 
        file_mode = self.control_files._file_mode
 
1958
        self._transport = control_files._transport
1950
1959
 
1951
1960
    @needs_read_lock
1952
1961
    def is_shared(self):
1953
1962
        """Return True if this repository is flagged as a shared repository."""
1954
 
        return self.control_files._transport.has('shared-storage')
 
1963
        return self._transport.has('shared-storage')
1955
1964
 
1956
1965
    @needs_write_lock
1957
1966
    def set_make_working_trees(self, new_value):
1965
1974
        """
1966
1975
        if new_value:
1967
1976
            try:
1968
 
                self.control_files._transport.delete('no-working-trees')
 
1977
                self._transport.delete('no-working-trees')
1969
1978
            except errors.NoSuchFile:
1970
1979
                pass
1971
1980
        else:
1972
 
            self.control_files.put_utf8('no-working-trees', '')
 
1981
            self._transport.put_bytes('no-working-trees', '',
 
1982
                mode=self.control_files._file_mode)
1973
1983
    
1974
1984
    def make_working_trees(self):
1975
1985
        """Returns the policy for making working trees on new branches."""
1976
 
        return not self.control_files._transport.has('no-working-trees')
 
1986
        return not self._transport.has('no-working-trees')
1977
1987
 
1978
1988
 
1979
1989
class MetaDirVersionedFileRepository(MetaDirRepository):
2208
2218
        """Upload the initial blank content."""
2209
2219
        control_files = self._create_control_files(a_bzrdir)
2210
2220
        control_files.lock_write()
 
2221
        transport = control_files._transport
 
2222
        if shared == True:
 
2223
            utf8_files += [('shared-storage', '')]
2211
2224
        try:
2212
 
            control_files._transport.mkdir_multi(dirs,
2213
 
                    mode=control_files._dir_mode)
2214
 
            for file, content in files:
2215
 
                control_files.put(file, content)
2216
 
            for file, content in utf8_files:
2217
 
                control_files.put_utf8(file, content)
2218
 
            if shared == True:
2219
 
                control_files.put_utf8('shared-storage', '')
 
2225
            transport.mkdir_multi(dirs, mode=a_bzrdir._get_dir_mode())
 
2226
            for (filename, content_stream) in files:
 
2227
                transport.put_file(filename, content_stream,
 
2228
                    mode=a_bzrdir._get_file_mode())
 
2229
            for (filename, content_bytes) in utf8_files:
 
2230
                transport.put_bytes_non_atomic(filename, content_bytes,
 
2231
                    mode=a_bzrdir._get_file_mode())
2220
2232
        finally:
2221
2233
            control_files.unlock()
2222
2234
 
2506
2518
        except (errors.RepositoryUpgradeRequired, NotImplemented):
2507
2519
            pass
2508
2520
        # FIXME do not peek!
2509
 
        if self.source.control_files._transport.listable():
 
2521
        if self.source._transport.listable():
2510
2522
            pb = ui.ui_factory.nested_progress_bar()
2511
2523
            try:
2512
2524
                self.target.weave_store.copy_all_ids(