~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/test_weave.py

  • Committer: Robert Collins
  • Date: 2005-10-07 23:35:42 UTC
  • mfrom: (1393.1.70)
  • mto: (1185.1.51)
  • mto: This revision was merged to the branch mainline in revision 1422.
  • Revision ID: robertc@robertcollins.net-20051007233541-eb80a1c86fa1405f
merge from martins newformat

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
from pprint import pformat
27
27
 
28
 
from bzrlib.weave import Weave, WeaveFormatError, WeaveError
 
28
from bzrlib.weave import Weave, WeaveFormatError, WeaveError, reweave
29
29
from bzrlib.weavefile import write_weave, read_weave
30
30
from bzrlib.selftest import TestCase
31
31
from bzrlib.osutils import sha_string
873
873
        eq(sorted(wa.iter_names()), ['v1', 'v2', 'v3', 'x1',])
874
874
        eq(wa.get_text('x1'), 'line from x1\n')
875
875
 
876
 
    def test_join_with_ghosts(self):
 
876
    def test_reweave_with_empty(self):
 
877
        wb = Weave()
 
878
        wr = reweave(self.weave1, wb)
 
879
        eq = self.assertEquals
 
880
        eq(sorted(wr.iter_names()), ['v1', 'v2', 'v3'])
 
881
        eq(wr.get_lines('v3'), ['hello\n', 'cruel\n', 'world\n'])
 
882
 
 
883
    def test_reweave_with_ghosts(self):
877
884
        """Join that inserts parents of an existing revision.
878
885
 
879
886
        This can happen when merging from another branch who
881
888
        this test the second weave knows of an additional parent of 
882
889
        v2.  Any revisions which are in common still have to have the 
883
890
        same text."""
884
 
        return ###############################
885
891
        wa = self.weave1.copy()
886
892
        wb = Weave()
887
893
        wb.add('x1', [], ['line from x1\n'])
888
894
        wb.add('v1', [], ['hello\n'])
889
895
        wb.add('v2', ['v1', 'x1'], ['hello\n', 'world\n'])
890
 
        wa.join(wb)
 
896
        wc = reweave(wa, wb)
891
897
        eq = self.assertEquals
892
 
        eq(sorted(wa.iter_names()), ['v1', 'v2', 'v3', 'x1',])
893
 
        eq(wa.get_text('x1'), 'line from x1\n')
 
898
        eq(sorted(wc.iter_names()), ['v1', 'v2', 'v3', 'x1',])
 
899
        eq(wc.get_text('x1'), 'line from x1\n')
 
900
        eq(wc.get_lines('v2'), ['hello\n', 'world\n'])
 
901
        eq(wc.parent_names('v2'), ['v1', 'x1'])
894
902
 
895
903
 
896
904
if __name__ == '__main__':