~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/weave.py

  • Committer: Robert Collins
  • Date: 2006-03-01 08:40:35 UTC
  • mto: (1594.2.4 integration)
  • mto: This revision was merged to the branch mainline in revision 1596.
  • Revision ID: robertc@robertcollins.net-20060301084035-ce00abd11fe4da31
Change weave store to be a versioned store, using WeaveFiles which maintain integrity without needing explicit 'put' operations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
191
191
    def __repr__(self):
192
192
        return "Weave(%r)" % self._weave_name
193
193
 
194
 
 
195
194
    def copy(self):
196
195
        """Return a deep copy of self.
197
196
        
211
210
        return self._parents == other._parents \
212
211
               and self._weave == other._weave \
213
212
               and self._sha1s == other._sha1s 
214
 
 
215
213
    
216
214
    def __ne__(self, other):
217
215
        return not self.__eq__(other)
841
839
class WeaveFile(Weave):
842
840
    """A WeaveFile represents a Weave on disk and writes on change."""
843
841
 
844
 
    def __init__(self, name, transport):
 
842
    def __init__(self, name, transport, mode=None):
845
843
        super(WeaveFile, self).__init__(name)
846
844
        self._transport = transport
 
845
        self._mode = mode
847
846
        try:
848
847
            _read_weave_v5(self._transport.get(name), self)
849
848
        except errors.NoSuchFile:
860
859
        sio = StringIO()
861
860
        write_weave_v5(self, sio)
862
861
        sio.seek(0)
863
 
        self._transport.put(self._weave_name, sio)
 
862
        self._transport.put(self._weave_name, sio, self._mode)
864
863
 
865
864
    def join(self, other, pb=None, msg=None, version_ids=None):
866
865
        """Join other into self and save."""