1490
1490
disk_top = disk_top[:-1]
1491
1491
top_strip_len = len(disk_top) + 1
1492
1492
disk_iterator = osutils.walkdirs(disk_top, prefix)
1493
current_inv = inventory_iterator.next()
1494
current_inv = inventory_iterator.next()
1495
inv_finished = False
1496
except StopIteration:
1494
1499
current_disk = disk_iterator.next()
1495
inv_finished = False
1496
1500
disk_finished = False
1497
1501
while not inv_finished or not disk_finished:
1498
1502
if not disk_finished:
1505
1509
if current_disk[1][bzrdir_loc][0] == '.bzr':
1506
1510
# we dont yield the contents of, or, .bzr itself.
1507
1511
del current_disk[1][bzrdir_loc]
1508
direction = cmp(current_inv[0][0], current_disk[0][0])
1513
# everything is unknown
1516
direction = cmp(current_inv[0][0], current_disk[0][0])
1509
1517
if direction < 0:
1510
# inventory is before disk - unknown.
1511
dirblock = [(relpath, basename, kind, stat, top_path[top_strip_len:], None, None) for relpath, basename, kind, stat, top_path in current_disk[1]]
1512
yield (current_disk[0][0], current_disk[0][1][top_strip_len:], None), dirblock
1518
# disk is before inventory - unknown
1519
dirblock = [(relpath, basename, kind, stat, None, None) for relpath, basename, kind, stat, top_path in current_disk[1]]
1520
yield (current_disk[0][0], None), dirblock
1514
1522
current_disk = disk_iterator.next()
1515
1523
except StopIteration:
1516
1524
disk_finished = True
1517
1525
elif direction > 0:
1518
# disk is before inventory - missing
1526
# inventory is before disk - missing.
1520
1528
current_inv = inventory_iterator.next()
1521
1529
except StopIteration:
1524
1532
# versioned present directory
1525
1533
# merge the inventory and disk data together
1526
# dirblock = [(relpath, basename, kind, stat, top_path, None, None, None) for relpath, basename, kind, stat, top_path in current_disk[1]]
1534
# dirblock = [(relpath, basename, kind, stat, None, None) for relpath, basename, kind, stat, top_path in current_disk[1]]
1527
1535
# yield current_inv
1529
1537
for relpath, subiterator in itertools.groupby(sorted(current_inv[1] + current_disk[1]), operator.itemgetter(1)):
1530
1538
path_elements = list(subiterator)
1531
1539
if len(path_elements) == 2:
1532
1540
# versioned, present file
1533
dirblock.append((path_elements[0][0], path_elements[0][1], path_elements[1][2], path_elements[1][3], path_elements[0][4], path_elements[0][5], path_elements[0][6]))
1541
dirblock.append((path_elements[0][0], path_elements[0][1], path_elements[1][2], path_elements[1][3], path_elements[0][4], path_elements[0][5]))
1534
1542
elif len(path_elements[0]) == 5:
1535
1543
# unknown disk file
1536
dirblock.append((path_elements[0][0], path_elements[0][1], path_elements[0][2], path_elements[0][3], path_elements[0][4][top_strip_len:], None, None))
1544
dirblock.append((path_elements[0][0], path_elements[0][1], path_elements[0][2], path_elements[0][3], None, None))
1537
1545
yield current_inv[0], dirblock
1539
1547
current_inv = inventory_iterator.next()
1544
1552
except StopIteration:
1545
1553
disk_finished = True
1547
#for dirinfo, dirblock in self._walkdirs(prefix):
1548
# yield dirinfo, dirblock
1550
1555
def _walkdirs(self, prefix=""):
1551
1556
_directory = 'directory'
1552
pending = [('', '', _directory, None, '', None, None)]
1557
# get the root in the inventory
1553
1558
inv = self.inventory
1559
top_id = inv.path2id(prefix)
1563
pending = [(prefix, '', _directory, None, top_id, None)]
1556
1566
currentdir = pending.pop()
1557
# 0 - relpath, 1- basename, 2- kind, 3- stat, 4-toppath
1567
# 0 - relpath, 1- basename, 2- kind, 3- stat, 4-id, 5-kind
1568
top_id = currentdir[4]
1559
1569
if currentdir[0]:
1560
1570
relroot = currentdir[0] + '/'
1563
1573
# FIXME: stash the node in pending
1564
entry = inv[inv.path2id(top)]
1565
1575
for name, child in entry.sorted_children():
1566
toppath = relroot + name
1567
dirblock.append((toppath, name, child.kind, None, toppath,
1576
dirblock.append((relroot + name, name, child.kind, None,
1568
1577
child.file_id, child.kind
1570
yield (currentdir[0], top, entry.file_id), dirblock
1579
yield (currentdir[0], entry.file_id), dirblock
1571
1580
# push the user specified dirs from dirblock
1572
1581
for dir in reversed(dirblock):
1573
1582
if dir[2] == _directory: