95
94
if committer is None:
96
95
self._committer = self._config.username()
98
assert isinstance(committer, basestring), type(committer)
99
97
self._committer = committer
101
99
self.new_inventory = Inventory(None)
328
326
if kind != parent_entry.kind:
330
328
if kind == 'file':
331
assert content_summary[2] is not None, \
332
"Files must not have executable = None"
329
if content_summary[2] is None:
330
raise ValueError("Files must not have executable = None")
334
332
if (# if the file length changed we have to store:
335
333
parent_entry.text_size != content_summary[1] or
501
499
:returns: The validator(which is a sha1 digest, though what is sha'd is
502
500
repository format specific) of the serialized inventory.
504
assert self.is_in_write_group()
502
if not self.is_in_write_group():
503
raise AssertionError("%r not in write group" % (self,))
505
504
_mod_revision.check_not_reserved_id(revision_id)
506
assert inv.revision_id is None or inv.revision_id == revision_id, \
507
"Mismatch between inventory revision" \
508
" id and insertion revid (%r, %r)" % (inv.revision_id, revision_id)
509
assert inv.root is not None
505
if not (inv.revision_id is None or inv.revision_id == revision_id):
506
raise AssertionError(
507
"Mismatch between inventory revision"
508
" id and insertion revid (%r, %r)"
509
% (inv.revision_id, revision_id))
511
raise AssertionError()
510
512
inv_lines = self._serialise_inventory_to_lines(inv)
511
513
inv_vf = self.get_inventory_weave()
512
514
return self._inventory_add_lines(inv_vf, revision_id, parents,
1095
1097
raise errors.InvalidRevisionId(revision_id=rev_id, branch=self)
1096
1098
revs = self._revision_store.get_revisions(revision_ids,
1097
1099
self.get_transaction())
1099
assert not isinstance(rev.revision_id, unicode)
1100
for parent_id in rev.parent_ids:
1101
assert not isinstance(parent_id, unicode)
1104
1102
@needs_read_lock
1502
1500
:return: An iterator of inventories.
1504
assert None not in revision_ids
1505
assert _mod_revision.NULL_REVISION not in revision_ids
1502
if ((None in revision_ids)
1503
or (_mod_revision.NULL_REVISION in revision_ids)):
1504
raise ValueError('cannot get null revision inventory')
1506
1505
return self._iter_inventories(revision_ids)
1508
1507
def _iter_inventories(self, revision_ids):
1536
1535
def get_inventory_xml(self, revision_id):
1537
1536
"""Get inventory XML as a file object."""
1539
assert isinstance(revision_id, str), type(revision_id)
1540
1538
iw = self.get_inventory_weave()
1541
1539
return iw.get_text(revision_id)
1542
1540
except IndexError:
1549
1547
return self.get_revision(revision_id).inventory_sha1
1552
@deprecated_method(symbol_versioning.one_four)
1553
def get_revision_graph(self, revision_id=None):
1554
"""Return a dictionary containing the revision graph.
1556
NB: This method should not be used as it accesses the entire graph all
1557
at once, which is much more data than most operations should require.
1559
:param revision_id: The revision_id to get a graph from. If None, then
1560
the entire revision graph is returned. This is a deprecated mode of
1561
operation and will be removed in the future.
1562
:return: a dictionary of revision_id->revision_parents_list.
1564
raise NotImplementedError(self.get_revision_graph)
1567
@deprecated_method(symbol_versioning.one_three)
1568
def get_revision_graph_with_ghosts(self, revision_ids=None):
1569
"""Return a graph of the revisions with ghosts marked as applicable.
1571
:param revision_ids: an iterable of revisions to graph or None for all.
1572
:return: a Graph object with the graph reachable from revision_ids.
1574
if 'evil' in debug.debug_flags:
1576
"get_revision_graph_with_ghosts scales with size of history.")
1577
result = deprecated_graph.Graph()
1578
if not revision_ids:
1579
pending = set(self.all_revision_ids())
1582
pending = set(revision_ids)
1583
# special case NULL_REVISION
1584
if _mod_revision.NULL_REVISION in pending:
1585
pending.remove(_mod_revision.NULL_REVISION)
1586
required = set(pending)
1589
revision_id = pending.pop()
1591
rev = self.get_revision(revision_id)
1592
except errors.NoSuchRevision:
1593
if revision_id in required:
1596
result.add_ghost(revision_id)
1598
for parent_id in rev.parent_ids:
1599
# is this queued or done ?
1600
if (parent_id not in pending and
1601
parent_id not in done):
1603
pending.add(parent_id)
1604
result.add_node(revision_id, rev.parent_ids)
1605
done.add(revision_id)
1608
1549
def iter_reverse_revision_history(self, revision_id):
1609
1550
"""Iterate backwards through revision ids in the lefthand history
2446
2387
target_ids = set(self.target.all_revision_ids())
2447
2388
if revision_id is not None:
2448
2389
source_ids = self.source.get_ancestry(revision_id)
2449
assert source_ids[0] is None
2390
if source_ids[0] is not None:
2391
raise AssertionError()
2450
2392
source_ids.pop(0)
2452
2394
source_ids = self.source.all_revision_ids()
2613
2555
# - RBC 20060209
2614
2556
if revision_id is not None:
2615
2557
source_ids = self.source.get_ancestry(revision_id)
2616
assert source_ids[0] is None
2558
if source_ids[0] is not None:
2559
raise AssertionError()
2617
2560
source_ids.pop(0)
2619
2562
source_ids = self.source._all_possible_ids()
2682
2625
"""See InterRepository.missing_revision_ids()."""
2683
2626
if revision_id is not None:
2684
2627
source_ids = self.source.get_ancestry(revision_id)
2685
assert source_ids[0] is None
2628
if source_ids[0] is not None:
2629
raise AssertionError()
2686
2630
source_ids.pop(0)
2688
2632
source_ids = self.source.all_revision_ids()
2795
2739
return self._walk_to_common_revisions([revision_id])
2796
2740
elif revision_id is not None:
2797
2741
source_ids = self.source.get_ancestry(revision_id)
2798
assert source_ids[0] is None
2742
if source_ids[0] is not None:
2743
raise AssertionError()
2799
2744
source_ids.pop(0)
2801
2746
source_ids = self.source.all_revision_ids()
2962
2907
# Is source's model compatible with target's model?
2963
2908
source._ensure_real()
2964
2909
real_source = source._real_repository
2965
assert not isinstance(real_source, remote.RemoteRepository), (
2966
"We don't support remote repos backed by remote repos yet.")
2910
if isinstance(real_source, remote.RemoteRepository):
2911
raise NotImplementedError(
2912
"We don't support remote repos backed by remote repos yet.")
2967
2913
return InterRepository._same_model(real_source, target)
2969
2915
@needs_write_lock