~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/weave.py

  • Committer: Martin Pool
  • Date: 2005-08-18 05:22:01 UTC
  • Revision ID: mbp@sourcefrog.net-20050818052201-54c5e07b377e2af8
- don't store redundant version number at end of insert blocks

This introduces a new weavefile version (v4); the code can't read old ones.

Show diffs side-by-side

added added

removed removed

Lines of Context:
101
101
 
102
102
    * a nonnegative index number.
103
103
 
104
 
    * a version-id string.
 
104
    * a version-id string. (not implemented yet)
105
105
 
106
106
    Typically the index number will be valid only inside this weave and
107
107
    the version-id is used to reference it in the larger world.
118
118
    The instruction can be '{' or '}' for an insertion block, and '['
119
119
    and ']' for a deletion block respectively.  The version is the
120
120
    integer version index.  There is no replace operator, only deletes
121
 
    and inserts.
 
121
    and inserts.  For '}', the end of an insertion, there is no
 
122
    version parameter because it always closes the most recently
 
123
    opened insertion.
122
124
 
123
125
    Constraints/notes:
124
126
 
216
218
            if text:
217
219
                self._weave.append(('{', new_version))
218
220
                self._weave.extend(text)
219
 
                self._weave.append(('}', new_version))
 
221
                self._weave.append(('}', None))
220
222
        
221
223
            return new_version
222
224
 
288
290
                # we don't destroy ourselves
289
291
                i = i2 + offset
290
292
                self._weave[i:i] = ([('{', new_version)] 
291
 
                                + text[j1:j2] 
292
 
                                + [('}', new_version)])
 
293
                                    + text[j1:j2] 
 
294
                                    + [('}', None)])
293
295
                offset += 2 + (j2 - j1)
294
296
 
295
297
        return new_version
385
387
                if c == '{':
386
388
                    istack.append(v)
387
389
                elif c == '}':
388
 
                    oldv = istack.pop()
 
390
                    istack.pop()
389
391
                elif c == '[':
390
392
                    assert v not in dset
391
393
                    dset.add(v)
432
434
                    assert v not in istack
433
435
                    istack.append(v)
434
436
                elif c == '}':
435
 
                    oldv = istack.pop()
436
 
                    assert oldv == v
 
437
                    istack.pop()
437
438
                elif c == '[':
438
439
                    if v in included:
439
440
                        assert v not in dset