835
773
def merge_modified(self):
836
"""Return a dictionary of files modified by a merge.
838
The list is initialized by WorkingTree.set_merge_modified, which is
839
typically called after we make some automatic updates to the tree
842
This returns a map of file_id->sha1, containing only files which are
843
still in the working inventory and have that text hash.
846
775
hashfile = self._control_files.get('merge-hashes')
847
except errors.NoSuchFile:
849
778
merge_hashes = {}
851
780
if hashfile.next() != MERGE_MODIFIED_HEADER_1 + '\n':
852
raise errors.MergeModifiedFormatError()
781
raise MergeModifiedFormatError()
853
782
except StopIteration:
854
raise errors.MergeModifiedFormatError()
783
raise MergeModifiedFormatError()
855
784
for s in RioReader(hashfile):
856
# RioReader reads in Unicode, so convert file_ids back to utf8
857
file_id = osutils.safe_file_id(s.get("file_id"), warn=False)
785
file_id = s.get("file_id")
858
786
if file_id not in self.inventory:
860
text_hash = s.get("hash")
861
if text_hash == self.get_file_sha1(file_id):
862
merge_hashes[file_id] = text_hash
789
if hash == self.get_file_sha1(file_id):
790
merge_hashes[file_id] = hash
863
791
return merge_hashes
865
793
@needs_write_lock
866
794
def mkdir(self, path, file_id=None):
867
795
"""See MutableTree.mkdir()."""
868
796
if file_id is None:
869
file_id = generate_ids.gen_file_id(os.path.basename(path))
797
file_id = gen_file_id(os.path.basename(path))
870
798
os.mkdir(self.abspath(path))
871
799
self.add(path, file_id, 'directory')
874
802
def get_symlink_target(self, file_id):
875
file_id = osutils.safe_file_id(file_id)
876
803
return os.readlink(self.id2abspath(file_id))
879
def subsume(self, other_tree):
880
def add_children(inventory, entry):
881
for child_entry in entry.children.values():
882
inventory._byid[child_entry.file_id] = child_entry
883
if child_entry.kind == 'directory':
884
add_children(inventory, child_entry)
885
if other_tree.get_root_id() == self.get_root_id():
886
raise errors.BadSubsumeSource(self, other_tree,
887
'Trees have the same root')
889
other_tree_path = self.relpath(other_tree.basedir)
890
except errors.PathNotChild:
891
raise errors.BadSubsumeSource(self, other_tree,
892
'Tree is not contained by the other')
893
new_root_parent = self.path2id(osutils.dirname(other_tree_path))
894
if new_root_parent is None:
895
raise errors.BadSubsumeSource(self, other_tree,
896
'Parent directory is not versioned.')
897
# We need to ensure that the result of a fetch will have a
898
# versionedfile for the other_tree root, and only fetching into
899
# RepositoryKnit2 guarantees that.
900
if not self.branch.repository.supports_rich_root():
901
raise errors.SubsumeTargetNeedsUpgrade(other_tree)
902
other_tree.lock_tree_write()
904
new_parents = other_tree.get_parent_ids()
905
other_root = other_tree.inventory.root
906
other_root.parent_id = new_root_parent
907
other_root.name = osutils.basename(other_tree_path)
908
self.inventory.add(other_root)
909
add_children(self.inventory, other_root)
910
self._write_inventory(self.inventory)
911
# normally we don't want to fetch whole repositories, but i think
912
# here we really do want to consolidate the whole thing.
913
for parent_id in other_tree.get_parent_ids():
914
self.branch.fetch(other_tree.branch, parent_id)
915
self.add_parent_tree_id(parent_id)
918
other_tree.bzrdir.retire_bzrdir()
920
@needs_tree_write_lock
921
def extract(self, file_id, format=None):
922
"""Extract a subtree from this tree.
924
A new branch will be created, relative to the path for this tree.
928
segments = osutils.splitpath(path)
929
transport = self.branch.bzrdir.root_transport
930
for name in segments:
931
transport = transport.clone(name)
934
except errors.FileExists:
938
sub_path = self.id2path(file_id)
939
branch_transport = mkdirs(sub_path)
941
format = bzrdir.format_registry.make_bzrdir('dirstate-with-subtree')
943
branch_transport.mkdir('.')
944
except errors.FileExists:
946
branch_bzrdir = format.initialize_on_transport(branch_transport)
948
repo = branch_bzrdir.find_repository()
949
except errors.NoRepositoryPresent:
950
repo = branch_bzrdir.create_repository()
951
assert repo.supports_rich_root()
953
if not repo.supports_rich_root():
954
raise errors.RootNotRich()
955
new_branch = branch_bzrdir.create_branch()
956
new_branch.pull(self.branch)
957
for parent_id in self.get_parent_ids():
958
new_branch.fetch(self.branch, parent_id)
959
tree_transport = self.bzrdir.root_transport.clone(sub_path)
960
if tree_transport.base != branch_transport.base:
961
tree_bzrdir = format.initialize_on_transport(tree_transport)
962
branch.BranchReferenceFormat().initialize(tree_bzrdir, new_branch)
964
tree_bzrdir = branch_bzrdir
965
wt = tree_bzrdir.create_workingtree(NULL_REVISION)
966
wt.set_parent_ids(self.get_parent_ids())
967
my_inv = self.inventory
968
child_inv = Inventory(root_id=None)
969
new_root = my_inv[file_id]
970
my_inv.remove_recursive_id(file_id)
971
new_root.parent_id = None
972
child_inv.add(new_root)
973
self._write_inventory(my_inv)
974
wt._write_inventory(child_inv)
977
def _serialize(self, inventory, out_file):
978
xml5.serializer_v5.write_inventory(self._inventory, out_file)
980
def _deserialize(selt, in_file):
981
return xml5.serializer_v5.read_inventory(in_file)
984
"""Write the in memory inventory to disk."""
985
# TODO: Maybe this should only write on dirty ?
986
if self._control_files._lock_mode != 'w':
987
raise errors.NotWriteLocked(self)
989
self._serialize(self._inventory, sio)
991
self._control_files.put('inventory', sio)
992
self._inventory_is_modified = False
994
def _kind(self, relpath):
995
return osutils.file_kind(self.abspath(relpath))
997
def list_files(self, include_root=False):
805
def file_class(self, filename):
806
if self.path2id(filename):
808
elif self.is_ignored(filename):
813
def list_files(self):
998
814
"""Recursively list all files as (path, class, kind, id, entry).
1000
816
Lists, but does not descend into unversioned directories.
1098
913
new_children.sort()
1099
914
new_children = collections.deque(new_children)
1100
915
stack.append((f_ie.file_id, fp, fap, new_children))
1101
# Break out of inner loop,
1102
# so that we start outer loop with child
916
# Break out of inner loop, so that we start outer loop with child
1105
919
# if we finished all children, pop it off the stack
1108
922
@needs_tree_write_lock
1109
def move(self, from_paths, to_dir=None, after=False, **kwargs):
923
def move(self, from_paths, to_name):
1110
924
"""Rename files.
1112
to_dir must exist in the inventory.
926
to_name must exist in the inventory.
1114
If to_dir exists and is a directory, the files are moved into
928
If to_name exists and is a directory, the files are moved into
1115
929
it, keeping their old names.
1117
Note that to_dir is only the last component of the new name;
931
Note that to_name is only the last component of the new name;
1118
932
this doesn't change the directory.
1120
For each entry in from_paths the move mode will be determined
1123
The first mode moves the file in the filesystem and updates the
1124
inventory. The second mode only updates the inventory without
1125
touching the file on the filesystem. This is the new mode introduced
1128
move uses the second mode if 'after == True' and the target is not
1129
versioned but present in the working tree.
1131
move uses the second mode if 'after == False' and the source is
1132
versioned but no longer in the working tree, and the target is not
1133
versioned but present in the working tree.
1135
move uses the first mode if 'after == False' and the source is
1136
versioned and present in the working tree, and the target is not
1137
versioned and not present in the working tree.
1139
Everything else results in an error.
1141
934
This returns a list of (from_path, to_path) pairs for each
1142
935
entry that is moved.
1147
# check for deprecated use of signature
1149
to_dir = kwargs.get('to_name', None)
1151
raise TypeError('You must supply a target directory')
1153
symbol_versioning.warn('The parameter to_name was deprecated'
1154
' in version 0.13. Use to_dir instead',
1157
# check destination directory
938
## TODO: Option to move IDs only
1158
939
assert not isinstance(from_paths, basestring)
1159
940
inv = self.inventory
1160
to_abs = self.abspath(to_dir)
941
to_abs = self.abspath(to_name)
1161
942
if not isdir(to_abs):
1162
raise errors.BzrMoveFailedError('',to_dir,
1163
errors.NotADirectory(to_abs))
1164
if not self.has_filename(to_dir):
1165
raise errors.BzrMoveFailedError('',to_dir,
1166
errors.NotInWorkingDirectory(to_dir))
1167
to_dir_id = inv.path2id(to_dir)
1168
if to_dir_id is None:
1169
raise errors.BzrMoveFailedError('',to_dir,
1170
errors.NotVersionedError(path=str(to_dir)))
943
raise BzrError("destination %r is not a directory" % to_abs)
944
if not self.has_filename(to_name):
945
raise BzrError("destination %r not in working directory" % to_abs)
946
to_dir_id = inv.path2id(to_name)
947
if to_dir_id is None and to_name != '':
948
raise BzrError("destination %r is not a versioned directory" % to_name)
1172
949
to_dir_ie = inv[to_dir_id]
1173
950
if to_dir_ie.kind != 'directory':
1174
raise errors.BzrMoveFailedError('',to_dir,
1175
errors.NotADirectory(to_abs))
1177
# create rename entries and tuples
1178
for from_rel in from_paths:
1179
from_tail = splitpath(from_rel)[-1]
1180
from_id = inv.path2id(from_rel)
1182
raise errors.BzrMoveFailedError(from_rel,to_dir,
1183
errors.NotVersionedError(path=str(from_rel)))
1185
from_entry = inv[from_id]
1186
from_parent_id = from_entry.parent_id
1187
to_rel = pathjoin(to_dir, from_tail)
1188
rename_entry = WorkingTree._RenameEntry(from_rel=from_rel,
1190
from_tail=from_tail,
1191
from_parent_id=from_parent_id,
1192
to_rel=to_rel, to_tail=from_tail,
1193
to_parent_id=to_dir_id)
1194
rename_entries.append(rename_entry)
1195
rename_tuples.append((from_rel, to_rel))
1197
# determine which move mode to use. checks also for movability
1198
rename_entries = self._determine_mv_mode(rename_entries, after)
1200
original_modified = self._inventory_is_modified
951
raise BzrError("destination %r is not a directory" % to_abs)
953
to_idpath = inv.get_idpath(to_dir_id)
956
if not self.has_filename(f):
957
raise BzrError("%r does not exist in working tree" % f)
958
f_id = inv.path2id(f)
960
raise BzrError("%r is not versioned" % f)
961
name_tail = splitpath(f)[-1]
962
dest_path = pathjoin(to_name, name_tail)
963
if self.has_filename(dest_path):
964
raise BzrError("destination %r already exists" % dest_path)
965
if f_id in to_idpath:
966
raise BzrError("can't move %r to a subdirectory of itself" % f)
968
# OK, so there's a race here, it's possible that someone will
969
# create a file in this interval and then the rename might be
970
# left half-done. But we should have caught most problems.
971
orig_inv = deepcopy(self.inventory)
1203
self._inventory_is_modified = True
1204
self._move(rename_entries)
974
name_tail = splitpath(f)[-1]
975
dest_path = pathjoin(to_name, name_tail)
976
result.append((f, dest_path))
977
inv.rename(inv.path2id(f), to_dir_id, name_tail)
979
rename(self.abspath(f), self.abspath(dest_path))
981
raise BzrError("failed to rename %r to %r: %s" %
982
(f, dest_path, e[1]),
983
["rename rolled back"])
1206
985
# restore the inventory on error
1207
self._inventory_is_modified = original_modified
986
self._set_inventory(orig_inv)
1209
988
self._write_inventory(inv)
1210
return rename_tuples
1212
def _determine_mv_mode(self, rename_entries, after=False):
1213
"""Determines for each from-to pair if both inventory and working tree
1214
or only the inventory has to be changed.
1216
Also does basic plausability tests.
1218
inv = self.inventory
1220
for rename_entry in rename_entries:
1221
# store to local variables for easier reference
1222
from_rel = rename_entry.from_rel
1223
from_id = rename_entry.from_id
1224
to_rel = rename_entry.to_rel
1225
to_id = inv.path2id(to_rel)
1226
only_change_inv = False
1228
# check the inventory for source and destination
1230
raise errors.BzrMoveFailedError(from_rel,to_rel,
1231
errors.NotVersionedError(path=str(from_rel)))
1232
if to_id is not None:
1233
raise errors.BzrMoveFailedError(from_rel,to_rel,
1234
errors.AlreadyVersionedError(path=str(to_rel)))
1236
# try to determine the mode for rename (only change inv or change
1237
# inv and file system)
1239
if not self.has_filename(to_rel):
1240
raise errors.BzrMoveFailedError(from_id,to_rel,
1241
errors.NoSuchFile(path=str(to_rel),
1242
extra="New file has not been created yet"))
1243
only_change_inv = True
1244
elif not self.has_filename(from_rel) and self.has_filename(to_rel):
1245
only_change_inv = True
1246
elif self.has_filename(from_rel) and not self.has_filename(to_rel):
1247
only_change_inv = False
1249
# something is wrong, so lets determine what exactly
1250
if not self.has_filename(from_rel) and \
1251
not self.has_filename(to_rel):
1252
raise errors.BzrRenameFailedError(from_rel,to_rel,
1253
errors.PathsDoNotExist(paths=(str(from_rel),
1256
raise errors.RenameFailedFilesExist(from_rel, to_rel,
1257
extra="(Use --after to update the Bazaar id)")
1258
rename_entry.only_change_inv = only_change_inv
1259
return rename_entries
1261
def _move(self, rename_entries):
1262
"""Moves a list of files.
1264
Depending on the value of the flag 'only_change_inv', the
1265
file will be moved on the file system or not.
1267
inv = self.inventory
1270
for entry in rename_entries:
1272
self._move_entry(entry)
1274
self._rollback_move(moved)
1278
def _rollback_move(self, moved):
1279
"""Try to rollback a previous move in case of an filesystem error."""
1280
inv = self.inventory
1283
self._move_entry(_RenameEntry(entry.to_rel, entry.from_id,
1284
entry.to_tail, entry.to_parent_id, entry.from_rel,
1285
entry.from_tail, entry.from_parent_id,
1286
entry.only_change_inv))
1287
except errors.BzrMoveFailedError, e:
1288
raise errors.BzrMoveFailedError( '', '', "Rollback failed."
1289
" The working tree is in an inconsistent state."
1290
" Please consider doing a 'bzr revert'."
1291
" Error message is: %s" % e)
1293
def _move_entry(self, entry):
1294
inv = self.inventory
1295
from_rel_abs = self.abspath(entry.from_rel)
1296
to_rel_abs = self.abspath(entry.to_rel)
1297
if from_rel_abs == to_rel_abs:
1298
raise errors.BzrMoveFailedError(entry.from_rel, entry.to_rel,
1299
"Source and target are identical.")
1301
if not entry.only_change_inv:
1303
osutils.rename(from_rel_abs, to_rel_abs)
1305
raise errors.BzrMoveFailedError(entry.from_rel,
1307
inv.rename(entry.from_id, entry.to_parent_id, entry.to_tail)
1309
991
@needs_tree_write_lock
1310
def rename_one(self, from_rel, to_rel, after=False):
992
def rename_one(self, from_rel, to_rel):
1311
993
"""Rename one file.
1313
995
This can change the directory or the filename or both.
1315
rename_one has several 'modes' to work. First, it can rename a physical
1316
file and change the file_id. That is the normal mode. Second, it can
1317
only change the file_id without touching any physical file. This is
1318
the new mode introduced in version 0.15.
1320
rename_one uses the second mode if 'after == True' and 'to_rel' is not
1321
versioned but present in the working tree.
1323
rename_one uses the second mode if 'after == False' and 'from_rel' is
1324
versioned but no longer in the working tree, and 'to_rel' is not
1325
versioned but present in the working tree.
1327
rename_one uses the first mode if 'after == False' and 'from_rel' is
1328
versioned and present in the working tree, and 'to_rel' is not
1329
versioned and not present in the working tree.
1331
Everything else results in an error.
1333
997
inv = self.inventory
1336
# create rename entries and tuples
1337
from_tail = splitpath(from_rel)[-1]
1338
from_id = inv.path2id(from_rel)
1340
raise errors.BzrRenameFailedError(from_rel,to_rel,
1341
errors.NotVersionedError(path=str(from_rel)))
1342
from_entry = inv[from_id]
1343
from_parent_id = from_entry.parent_id
998
if not self.has_filename(from_rel):
999
raise BzrError("can't rename: old working file %r does not exist" % from_rel)
1000
if self.has_filename(to_rel):
1001
raise BzrError("can't rename: new working file %r already exists" % to_rel)
1003
file_id = inv.path2id(from_rel)
1005
raise BzrError("can't rename: old name %r is not versioned" % from_rel)
1007
entry = inv[file_id]
1008
from_parent = entry.parent_id
1009
from_name = entry.name
1011
if inv.path2id(to_rel):
1012
raise BzrError("can't rename: new name %r is already versioned" % to_rel)
1344
1014
to_dir, to_tail = os.path.split(to_rel)
1345
1015
to_dir_id = inv.path2id(to_dir)
1346
rename_entry = WorkingTree._RenameEntry(from_rel=from_rel,
1348
from_tail=from_tail,
1349
from_parent_id=from_parent_id,
1350
to_rel=to_rel, to_tail=to_tail,
1351
to_parent_id=to_dir_id)
1352
rename_entries.append(rename_entry)
1354
# determine which move mode to use. checks also for movability
1355
rename_entries = self._determine_mv_mode(rename_entries, after)
1357
# check if the target changed directory and if the target directory is
1359
if to_dir_id is None:
1360
raise errors.BzrMoveFailedError(from_rel,to_rel,
1361
errors.NotVersionedError(path=str(to_dir)))
1363
# all checks done. now we can continue with our actual work
1364
mutter('rename_one:\n'
1369
' to_dir_id {%s}\n',
1370
from_id, from_rel, to_rel, to_dir, to_dir_id)
1372
self._move(rename_entries)
1016
if to_dir_id is None and to_dir != '':
1017
raise BzrError("can't determine destination directory id for %r" % to_dir)
1019
mutter("rename_one:")
1020
mutter(" file_id {%s}" % file_id)
1021
mutter(" from_rel %r" % from_rel)
1022
mutter(" to_rel %r" % to_rel)
1023
mutter(" to_dir %r" % to_dir)
1024
mutter(" to_dir_id {%s}" % to_dir_id)
1026
inv.rename(file_id, to_dir_id, to_tail)
1028
from_abs = self.abspath(from_rel)
1029
to_abs = self.abspath(to_rel)
1031
rename(from_abs, to_abs)
1033
inv.rename(file_id, from_parent, from_name)
1034
raise BzrError("failed to rename %r to %r: %s"
1035
% (from_abs, to_abs, e[1]),
1036
["rename rolled back"])
1373
1037
self._write_inventory(inv)
1375
class _RenameEntry(object):
1376
def __init__(self, from_rel, from_id, from_tail, from_parent_id,
1377
to_rel, to_tail, to_parent_id, only_change_inv=False):
1378
self.from_rel = from_rel
1379
self.from_id = from_id
1380
self.from_tail = from_tail
1381
self.from_parent_id = from_parent_id
1382
self.to_rel = to_rel
1383
self.to_tail = to_tail
1384
self.to_parent_id = to_parent_id
1385
self.only_change_inv = only_change_inv
1387
1039
@needs_read_lock
1388
1040
def unknowns(self):
1389
1041
"""Return all unknown files.
2095
1658
if text == False:
2097
1660
ctype = {True: 'text conflict', False: 'contents conflict'}[text]
2098
conflicts.append(_mod_conflicts.Conflict.factory(ctype,
1661
conflicts.append(Conflict.factory(ctype, path=conflicted,
2100
1662
file_id=self.path2id(conflicted)))
2101
1663
return conflicts
2103
def walkdirs(self, prefix=""):
2104
"""Walk the directories of this tree.
2106
This API returns a generator, which is only valid during the current
2107
tree transaction - within a single lock_read or lock_write duration.
2109
If the tree is not locked, it may cause an error to be raised, depending
2110
on the tree implementation.
2112
disk_top = self.abspath(prefix)
2113
if disk_top.endswith('/'):
2114
disk_top = disk_top[:-1]
2115
top_strip_len = len(disk_top) + 1
2116
inventory_iterator = self._walkdirs(prefix)
2117
disk_iterator = osutils.walkdirs(disk_top, prefix)
2119
current_disk = disk_iterator.next()
2120
disk_finished = False
2122
if e.errno != errno.ENOENT:
2125
disk_finished = True
2127
current_inv = inventory_iterator.next()
2128
inv_finished = False
2129
except StopIteration:
2132
while not inv_finished or not disk_finished:
2133
if not disk_finished:
2134
# strip out .bzr dirs
2135
if current_disk[0][1][top_strip_len:] == '':
2136
# osutils.walkdirs can be made nicer -
2137
# yield the path-from-prefix rather than the pathjoined
2139
bzrdir_loc = bisect_left(current_disk[1], ('.bzr', '.bzr'))
2140
if current_disk[1][bzrdir_loc][0] == '.bzr':
2141
# we dont yield the contents of, or, .bzr itself.
2142
del current_disk[1][bzrdir_loc]
2144
# everything is unknown
2147
# everything is missing
2150
direction = cmp(current_inv[0][0], current_disk[0][0])
2152
# disk is before inventory - unknown
2153
dirblock = [(relpath, basename, kind, stat, None, None) for
2154
relpath, basename, kind, stat, top_path in current_disk[1]]
2155
yield (current_disk[0][0], None), dirblock
2157
current_disk = disk_iterator.next()
2158
except StopIteration:
2159
disk_finished = True
2161
# inventory is before disk - missing.
2162
dirblock = [(relpath, basename, 'unknown', None, fileid, kind)
2163
for relpath, basename, dkind, stat, fileid, kind in
2165
yield (current_inv[0][0], current_inv[0][1]), dirblock
2167
current_inv = inventory_iterator.next()
2168
except StopIteration:
2171
# versioned present directory
2172
# merge the inventory and disk data together
2174
for relpath, subiterator in itertools.groupby(sorted(
2175
current_inv[1] + current_disk[1], key=operator.itemgetter(0)), operator.itemgetter(1)):
2176
path_elements = list(subiterator)
2177
if len(path_elements) == 2:
2178
inv_row, disk_row = path_elements
2179
# versioned, present file
2180
dirblock.append((inv_row[0],
2181
inv_row[1], disk_row[2],
2182
disk_row[3], inv_row[4],
2184
elif len(path_elements[0]) == 5:
2186
dirblock.append((path_elements[0][0],
2187
path_elements[0][1], path_elements[0][2],
2188
path_elements[0][3], None, None))
2189
elif len(path_elements[0]) == 6:
2190
# versioned, absent file.
2191
dirblock.append((path_elements[0][0],
2192
path_elements[0][1], 'unknown', None,
2193
path_elements[0][4], path_elements[0][5]))
2195
raise NotImplementedError('unreachable code')
2196
yield current_inv[0], dirblock
2198
current_inv = inventory_iterator.next()
2199
except StopIteration:
2202
current_disk = disk_iterator.next()
2203
except StopIteration:
2204
disk_finished = True
2206
def _walkdirs(self, prefix=""):
2207
_directory = 'directory'
2208
# get the root in the inventory
2209
inv = self.inventory
2210
top_id = inv.path2id(prefix)
2214
pending = [(prefix, '', _directory, None, top_id, None)]
2217
currentdir = pending.pop()
2218
# 0 - relpath, 1- basename, 2- kind, 3- stat, 4-id, 5-kind
2219
top_id = currentdir[4]
2221
relroot = currentdir[0] + '/'
2224
# FIXME: stash the node in pending
2226
for name, child in entry.sorted_children():
2227
dirblock.append((relroot + name, name, child.kind, None,
2228
child.file_id, child.kind
2230
yield (currentdir[0], entry.file_id), dirblock
2231
# push the user specified dirs from dirblock
2232
for dir in reversed(dirblock):
2233
if dir[2] == _directory:
2236
@needs_tree_write_lock
2237
def auto_resolve(self):
2238
"""Automatically resolve text conflicts according to contents.
2240
Only text conflicts are auto_resolvable. Files with no conflict markers
2241
are considered 'resolved', because bzr always puts conflict markers
2242
into files that have text conflicts. The corresponding .THIS .BASE and
2243
.OTHER files are deleted, as per 'resolve'.
2244
:return: a tuple of ConflictLists: (un_resolved, resolved).
2246
un_resolved = _mod_conflicts.ConflictList()
2247
resolved = _mod_conflicts.ConflictList()
2248
conflict_re = re.compile('^(<{7}|={7}|>{7})')
2249
for conflict in self.conflicts():
2250
if (conflict.typestring != 'text conflict' or
2251
self.kind(conflict.file_id) != 'file'):
2252
un_resolved.append(conflict)
2254
my_file = open(self.id2abspath(conflict.file_id), 'rb')
2256
for line in my_file:
2257
if conflict_re.search(line):
2258
un_resolved.append(conflict)
2261
resolved.append(conflict)
2264
resolved.remove_files(self)
2265
self.set_conflicts(un_resolved)
2266
return un_resolved, resolved
2268
def _validate(self):
2269
"""Validate internal structures.
2271
This is meant mostly for the test suite. To give it a chance to detect
2272
corruption after actions have occurred. The default implementation is a
2275
:return: None. An exception should be raised if there is an error.
2280
1666
class WorkingTree2(WorkingTree):
2281
1667
"""This is the Format 2 working tree.