~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/conflicts.py

  • Committer: Aaron Bentley
  • Date: 2006-03-09 22:54:29 UTC
  • mto: (2027.1.2 revert-subpath-56549)
  • mto: This revision was merged to the branch mainline in revision 1647.
  • Revision ID: abentley@panoramicfeedback.com-20060309225429-9b81ae72b0f23221
Implemented conflict serialization

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
from bzrlib.commands import register_command
30
30
from bzrlib.errors import BzrCommandError, NotConflicted
31
31
from bzrlib.option import Option
 
32
from bzrlib.osutils import rename
 
33
from bzrlib.rio import Stanza
32
34
from bzrlib.workingtree import CONFLICT_SUFFIXES, WorkingTree
33
 
from bzrlib.osutils import rename
34
35
 
35
36
class cmd_conflicts(bzrlib.commands.Command):
36
37
    """List files with conflicts.
121
122
            raise
122
123
    if not conflicted:
123
124
        raise NotConflicted(filename)
 
125
 
 
126
 
 
127
def conflict_stanzas(conflicts):
 
128
    for conflict in conflicts:
 
129
        if conflict[0] in ('text conflict', 'path conflict', 
 
130
                           'contents conflict'):
 
131
            s = Stanza(type=conflict[0], path=conflict[2])
 
132
            if conflict[1] is not None:
 
133
                s.add('file_id', conflict[1]) 
 
134
            yield s
 
135
        else:
 
136
            mydict = {'type': conflict[0], 'action': conflict[1], 
 
137
                      'path': conflict[2]}
 
138
            if conflict[3] is not None:
 
139
                mydict['file_id'] = conflict[3]
 
140
            if len(conflict) > 4:
 
141
                mydict['conflict_path'] = conflict[4]
 
142
                if conflict[5] is not None:
 
143
                    mydict['conflict_file_id'] = conflict[5]
 
144
            yield Stanza(**mydict)
 
145
 
 
146
def stanza_conflicts(stanzas):
 
147
    for stanza in stanzas:
 
148
        try:
 
149
            file_id = stanza['file_id']
 
150
        except KeyError:
 
151
            file_id = None
 
152
        try:
 
153
            conflict_file_id = stanza['conflict_file_id']
 
154
        except KeyError:
 
155
            conflict_file_id = None
 
156
        if stanza.get('type') in ('text conflict', 'path conflict', 
 
157
                                  'contents conflict'):
 
158
            yield (stanza['type'], file_id, stanza['path'])
 
159
        else:
 
160
            my_list = [stanza['type'], stanza['action'],
 
161
                       stanza['path'], file_id]
 
162
            try:
 
163
                my_list.extend((stanza['conflict_path'], conflict_file_id))
 
164
            except KeyError:
 
165
                pass
 
166
            yield tuple(my_list)