~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/weave.py

  • Committer: Robert Collins
  • Date: 2005-08-25 01:56:02 UTC
  • mto: (974.1.50) (1185.1.10) (1092.3.1)
  • mto: This revision was merged to the branch mainline in revision 1139.
  • Revision ID: robertc@robertcollins.net-20050825015601-b4ac37f043068e82
break smart_add into smart_add and smart_add_branch which will accept a branch parameter

Show diffs side-by-side

added added

removed removed

Lines of Context:
87
87
 
88
88
 
89
89
import sha
90
 
from cStringIO import StringIO
 
90
 
91
91
 
92
92
 
93
93
class WeaveError(Exception):
181
181
 
182
182
    _name_map
183
183
        For each name, the version number.
184
 
 
185
 
    _weave_name
186
 
        Descriptive name of this weave; typically the filename if known.
187
 
        Set by read_weave.
188
184
    """
189
185
 
190
 
    __slots__ = ['_weave', '_parents', '_sha1s', '_names', '_name_map',
191
 
                 '_weave_name']
 
186
    __slots__ = ['_weave', '_parents', '_sha1s', '_names', '_name_map']
192
187
    
193
 
    def __init__(self, weave_name=None):
 
188
    def __init__(self):
194
189
        self._weave = []
195
190
        self._parents = []
196
191
        self._sha1s = []
197
192
        self._names = []
198
193
        self._name_map = {}
199
 
        self._weave_name = weave_name
200
194
 
201
195
 
202
196
    def __eq__(self, other):
215
209
        try:
216
210
            return self._name_map[name]
217
211
        except KeyError:
218
 
            raise WeaveError("name %s not present in weave %s" %
219
 
                             (name, self._weave_name))
 
212
            raise WeaveError("name %s not present in weave" % name)
220
213
 
221
214
        
222
215
    def add(self, name, parents, text):
458
451
 
459
452
        The set typically but not necessarily corresponds to a version.
460
453
        """
461
 
        for i in versions:
462
 
            if not isinstance(i, int):
463
 
                raise ValueError(i)
464
 
            
465
454
        included = self.inclusions(versions)
466
455
 
467
456
        istack = []
518
507
            yield line
519
508
 
520
509
 
521
 
    def get_text(self, version):
522
 
        assert isinstance(version, int)
523
 
        s = StringIO()
524
 
        s.writelines(self.get_iter(version))
525
 
        return s.getvalue()
526
 
 
527
 
 
528
510
    def get(self, index):
529
511
        return list(self.get_iter(index))
530
512