~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/knit.py

  • Committer: Aaron Bentley
  • Date: 2006-04-18 00:19:54 UTC
  • mto: This revision was merged to the branch mainline in revision 1672.
  • Revision ID: aaron.bentley@utoronto.ca-20060418001954-c50f6819b61db0b3
Got plan-merge passing tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
817
817
            yield lineno, insert_id, dset, line
818
818
 
819
819
    def plan_merge(self, ver_a, ver_b):
 
820
        ancestors_b = set(self.get_ancestry(ver_b))
 
821
        def status_a(revision, text):
 
822
            if revision in ancestors_b:
 
823
                return 'killed-b', text
 
824
            else:
 
825
                return 'new-a', text
 
826
        
 
827
        ancestors_a = set(self.get_ancestry(ver_a))
 
828
        def status_b(revision, text):
 
829
            if revision in ancestors_a:
 
830
                return 'killed-a', text
 
831
            else:
 
832
                return 'new-b', text
 
833
 
820
834
        annotated_a = self.annotate(ver_a)
821
835
        annotated_b = self.annotate(ver_b)
822
836
        plain_a = [t for a, t in annotated_a]
828
842
        b_iter = iter(annotated_b)
829
843
        for ai, bi, l in blocks:
830
844
            for a_num, (revision, text) in xenumerate(a_iter, ai, a_cur):
831
 
                pass
 
845
                yield status_a(revision, text)
832
846
            for b_num, (revision, text) in xenumerate(b_iter, bi, b_cur):
833
 
                pass
 
847
                yield status_b(revision, text)
834
848
            for num, ((revision_a, text_a), (revision_b, text_b)) in \
835
849
                xenumerate(izip(a_iter, b_iter), l):
836
850
                assert text_a == text_b
837
851
                yield "unchanged", text_a
838
852
            a_cur = ai + l
839
853
            b_cur = bi + l
 
854
        # handle a final conflicting region
 
855
        for a_num, (revision, text) in xenumerate(a_iter, start=a_cur):
 
856
            yield status_a(revision, text)
 
857
        for b_num, (revision, text) in xenumerate(b_iter, start=b_cur):
 
858
            yield status_b(revision, text)
840
859
 
841
860
def xenumerate(iter, stop=None, start=0, step=1):
842
861
    count = start