~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/weave.py

  • Committer: Robert Collins
  • Date: 2006-03-02 07:08:36 UTC
  • mto: (1594.2.4 integration)
  • mto: This revision was merged to the branch mainline in revision 1596.
  • Revision ID: robertc@robertcollins.net-20060302070836-be71595e05a607b7
remove the weavestore assumptions about the number and nature of files it manages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
824
824
class WeaveFile(Weave):
825
825
    """A WeaveFile represents a Weave on disk and writes on change."""
826
826
 
 
827
    WEAVE_SUFFIX = '.weave'
 
828
    
827
829
    def __init__(self, name, transport, mode=None):
828
830
        super(WeaveFile, self).__init__(name)
829
831
        self._transport = transport
830
832
        self._mode = mode
831
833
        try:
832
 
            _read_weave_v5(self._transport.get(name), self)
 
834
            _read_weave_v5(self._transport.get(name + WeaveFile.WEAVE_SUFFIX), self)
833
835
        except errors.NoSuchFile:
834
836
            # new file, save it
835
837
            self._save()
839
841
        super(WeaveFile, self).add_lines(version_id, parents, lines)
840
842
        self._save()
841
843
 
 
844
    def copy_to(self, name, transport):
 
845
        """See VersionedFile.copy_to()."""
 
846
        # as we are all in memory always, just serialise to the new place.
 
847
        sio = StringIO()
 
848
        write_weave_v5(self, sio)
 
849
        sio.seek(0)
 
850
        transport.put(name + WeaveFile.WEAVE_SUFFIX, sio, self._mode)
 
851
 
842
852
    def create_empty(self, name, transport, mode=None):
843
853
        return WeaveFile(name, transport, mode)
844
854
 
847
857
        sio = StringIO()
848
858
        write_weave_v5(self, sio)
849
859
        sio.seek(0)
850
 
        self._transport.put(self._weave_name, sio, self._mode)
 
860
        self._transport.put(self._weave_name + WeaveFile.WEAVE_SUFFIX,
 
861
                            sio,
 
862
                            self._mode)
 
863
 
 
864
    @staticmethod
 
865
    def get_suffixes():
 
866
        """See VersionedFile.get_suffixes()."""
 
867
        return [WeaveFile.WEAVE_SUFFIX]
851
868
 
852
869
    def join(self, other, pb=None, msg=None, version_ids=None):
853
870
        """Join other into self and save."""