~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to knit.py

  • Committer: Martin Pool
  • Date: 2005-06-27 08:05:56 UTC
  • mto: This revision was merged to the branch mainline in revision 852.
  • Revision ID: mbp@sourcefrog.net-20050627080556-4becc2f38180d035
Refactor parameters to add command

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
        self._v = []
57
57
 
58
58
        
59
 
    def add(self, text, basis=None):
 
59
    def add(self, parents, text):
60
60
        """Add a single text on top of the weave.
61
61
 
62
 
        Returns the index number of the newly added version."""
 
62
        Returns the index number of the newly added version.
 
63
 
 
64
        parents
 
65
            List or set of parent version numbers.
 
66
 
 
67
        text
 
68
            Sequence of lines to be added in the new version."""
63
69
        if not isinstance(text, list):
64
70
            raise ValueError("text should be a list, not %s" % type(text))
65
71
 
66
72
        idx = len(self._v)
67
73
 
68
 
        if basis:
69
 
            basis = frozenset(basis)
70
 
            delta = self._delta(basis, text)
 
74
        if parents:
 
75
            parents = frozenset(parents)
 
76
            delta = self._delta(parents, text)
71
77
 
72
78
            for i1, i2, newlines in delta:
73
79
                # TODO: handle lines being offset as we insert stuff
82
88
                
83
89
                self._l[i1:i1] = to_insert
84
90
 
85
 
            self._v.append(VerInfo(basis))
 
91
            self._v.append(VerInfo(parents))
86
92
        else:
87
 
            # special case; adding with no basis revision; can do this
 
93
            # special case; adding with no parents revision; can do this
88
94
            # more quickly by just appending unconditionally
89
95
            for line in text:
90
96
                self._l.append((idx, line))