~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/conflicts.py

  • Committer: Aaron Bentley
  • Date: 2006-04-05 04:54:00 UTC
  • mto: (2027.1.2 revert-subpath-56549)
  • mto: This revision was merged to the branch mainline in revision 1647.
  • Revision ID: aaron.bentley@utoronto.ca-20060405045400-7b57a53ee7fdaab6
Moved and renamed conflict functions

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
import os
23
23
import errno
24
24
 
25
 
import bzrlib.status
 
25
import bzrlib
26
26
from bzrlib.commands import register_command
27
27
from bzrlib.errors import BzrCommandError, NotConflicted, UnsupportedOperation
28
28
from bzrlib.option import Option
50
50
    """
51
51
    def run(self):
52
52
        from bzrlib.workingtree import WorkingTree
53
 
        from transform import conflicts_strings
54
53
        wt = WorkingTree.open_containing(u'.')[0]
55
 
        for conflict in conflicts_strings(wt.conflict_lines()):
 
54
        for conflict in conflicts_to_strings(wt.conflict_lines()):
56
55
            print conflict
57
56
 
58
57
class cmd_resolve(bzrlib.commands.Command):
117
116
            ids[file_id] = path
118
117
 
119
118
    for conflict, stanza in zip(tree_conflicts, 
120
 
        conflict_stanzas(tree_conflicts)):
 
119
        conflicts_to_stanzas(tree_conflicts)):
121
120
        selected = False
122
121
        for key in ('path', 'conflict_path'):
123
122
            try:
151
150
    return new_conflicts, selected_conflicts
152
151
 
153
152
def remove_conflict_files(tree, conflicts):
154
 
    for stanza in conflict_stanzas(conflicts):
 
153
    for stanza in conflicts_to_stanzas(conflicts):
155
154
        if stanza['type'] in ("text conflict", "contents conflict"):
156
155
            for suffix in CONFLICT_SUFFIXES:
157
156
                try:
189
188
        raise NotConflicted(filename)
190
189
 
191
190
 
192
 
def conflict_stanzas(conflicts):
 
191
def conflicts_to_stanzas(conflicts):
193
192
    for conflict in conflicts:
194
193
        yield conflict.as_stanza()
195
194
 
196
 
def stanza_conflicts(stanzas):
 
195
def stanzas_to_conflicts(stanzas):
197
196
    for stanza in stanzas:
198
197
        yield Conflict.factory(**stanza.as_dict())
199
198
 
200
199
 
 
200
def conflicts_to_strings(conflicts):
 
201
    """Generate strings for the provided conflicts"""
 
202
    for conflict in conflicts:
 
203
        yield str(conflict)
 
204
 
 
205
 
201
206
class Conflict(object):
202
207
    """Base class for all types of conflict"""
203
208
    def __init__(self, path, file_id=None):