~launchpad-pqm/bzr-loom/trunk

« back to all changes in this revision

Viewing changes to loom_io.py

  • Committer: Robert Collins
  • Date: 2006-07-18 07:26:37 UTC
  • Revision ID: robertc@robertcollins.net-20060718072637-f7e78f4fcde20d2f
Introduce leading space before threads lines in current-loom, for putting conflict status in eventually.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
# This belongs in a format object at some point.
28
28
_CURRENT_LOOM_FORMAT_STRING = "Loom current 1"
29
29
 
 
30
# the current loom format :
 
31
# first line is the format signature
 
32
# second line is the list of parents
 
33
# third line and beyond are the current threads.
 
34
# each thread line has one field for current status
 
35
## planned # one field for each parent
 
36
# one field for the current revision id
 
37
# and then the rest of the line for the thread name.
 
38
 
30
39
 
31
40
class LoomWriter(object):
32
41
    """LoomWriter objects are used to serialise looms."""
56
65
        lines = [_CURRENT_LOOM_FORMAT_STRING + '\n']
57
66
        lines.append(' '.join(self._state.get_parents()) + '\n')
58
67
        for thread, rev_id in self._state.get_threads():
59
 
            lines.append('%s %s\n' % (rev_id, thread))
 
68
            # leading space for conflict status
 
69
            lines.append(' %s %s\n' % (rev_id, thread))
60
70
        stream.write(''.join(lines).encode('utf8'))
61
71
 
62
72
 
108
118
        parent_count = len(self.read_parents())
109
119
        # skip the format and parent lines, and the trailing \n line.
110
120
        for line in self._content[2:-1]:
111
 
            rev_id, name = line.split(' ', 1)
 
121
            conflict_status, rev_id, name = line.split(' ', 2)
112
122
            parents = []
113
123
            for pos in range(parent_count):
114
124
                parents.append(None)