Rev 3371: Remove more deprecated methods following the chain of deprecated functions outwards. in http://people.ubuntu.com/~robertc/baz2.0/versioned_files
Robert Collins
robertc at robertcollins.net
Fri May 2 01:28:02 BST 2008
At http://people.ubuntu.com/~robertc/baz2.0/versioned_files
------------------------------------------------------------
revno: 3371
revision-id: robertc at robertcollins.net-20080502002756-6z1deoxj2dsjunk2
parent: robertc at robertcollins.net-20080430053203-p0oegpfwxbh7yiz7
committer: Robert Collins <robertc at robertcollins.net>
branch nick: remove-deprecations
timestamp: Fri 2008-05-02 10:27:56 +1000
message:
Remove more deprecated methods following the chain of deprecated functions outwards.
modified:
bzrlib/repofmt/knitrepo.py knitrepo.py-20070206081537-pyy4a00xdas0j4pf-1
bzrlib/repofmt/pack_repo.py pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
bzrlib/repofmt/weaverepo.py presplitout.py-20070125045333-wfav3tsh73oxu3zk-1
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
bzrlib/revision.py revision.py-20050309040759-e77802c08f3999d5
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
bzrlib/tests/repository_implementations/test_repository.py test_repository.py-20060131092128-ad07f494f5c9d26c
bzrlib/tests/test_ancestry.py test_ancestry.py-20050913023709-69768e94848312c6
bzrlib/tests/test_revision.py testrevision.py-20050804210559-46f5e1eb67b01289
=== modified file 'bzrlib/repofmt/knitrepo.py'
--- a/bzrlib/repofmt/knitrepo.py 2008-04-25 23:14:10 +0000
+++ b/bzrlib/repofmt/knitrepo.py 2008-05-02 00:27:56 +0000
@@ -24,7 +24,6 @@
""")
from bzrlib import (
bzrdir,
- deprecated_graph,
errors,
knit,
lockable_files,
@@ -196,76 +195,6 @@
revision_id = osutils.safe_revision_id(revision_id)
return self.get_revision_reconcile(revision_id)
- @symbol_versioning.deprecated_method(symbol_versioning.one_four)
- @needs_read_lock
- def get_revision_graph(self, revision_id=None):
- """Return a dictionary containing the revision graph.
-
- :param revision_id: The revision_id to get a graph from. If None, then
- the entire revision graph is returned. This is a deprecated mode of
- operation and will be removed in the future.
- :return: a dictionary of revision_id->revision_parents_list.
- """
- if 'evil' in debug.debug_flags:
- mutter_callsite(3,
- "get_revision_graph scales with size of history.")
- # special case NULL_REVISION
- if revision_id == _mod_revision.NULL_REVISION:
- return {}
- a_weave = self._get_revision_vf()
- if revision_id is None:
- return a_weave.get_graph()
- if revision_id not in a_weave:
- raise errors.NoSuchRevision(self, revision_id)
- else:
- # add what can be reached from revision_id
- return a_weave.get_graph([revision_id])
-
- @needs_read_lock
- @symbol_versioning.deprecated_method(symbol_versioning.one_three)
- def get_revision_graph_with_ghosts(self, revision_ids=None):
- """Return a graph of the revisions with ghosts marked as applicable.
-
- :param revision_ids: an iterable of revisions to graph or None for all.
- :return: a Graph object with the graph reachable from revision_ids.
- """
- if 'evil' in debug.debug_flags:
- mutter_callsite(3,
- "get_revision_graph_with_ghosts scales with size of history.")
- result = deprecated_graph.Graph()
- vf = self._get_revision_vf()
- versions = set(vf.versions())
- if not revision_ids:
- pending = set(self.all_revision_ids())
- required = set([])
- else:
- pending = set(revision_ids)
- # special case NULL_REVISION
- if _mod_revision.NULL_REVISION in pending:
- pending.remove(_mod_revision.NULL_REVISION)
- required = set(pending)
- done = set([])
- while len(pending):
- revision_id = pending.pop()
- if not revision_id in versions:
- if revision_id in required:
- raise errors.NoSuchRevision(self, revision_id)
- # a ghost
- result.add_ghost(revision_id)
- # mark it as done so we don't try for it again.
- done.add(revision_id)
- continue
- parent_ids = vf.get_parents_with_ghosts(revision_id)
- for parent_id in parent_ids:
- # is this queued or done ?
- if (parent_id not in pending and
- parent_id not in done):
- # no, queue it.
- pending.add(parent_id)
- result.add_node(revision_id, parent_ids)
- done.add(revision_id)
- return result
-
def _get_revision_vf(self):
""":return: a versioned file containing the revisions."""
vf = self._revision_store.get_revision_file(self.get_transaction())
=== modified file 'bzrlib/repofmt/pack_repo.py'
--- a/bzrlib/repofmt/pack_repo.py 2008-04-04 00:06:58 +0000
+++ b/bzrlib/repofmt/pack_repo.py 2008-05-02 00:27:56 +0000
@@ -42,7 +42,6 @@
""")
from bzrlib import (
bzrdir,
- deprecated_graph,
errors,
knit,
lockable_files,
@@ -1918,61 +1917,6 @@
found_parents[key[0]] = parents
return found_parents
- @symbol_versioning.deprecated_method(symbol_versioning.one_four)
- @needs_read_lock
- def get_revision_graph(self, revision_id=None):
- """Return a dictionary containing the revision graph.
-
- :param revision_id: The revision_id to get a graph from. If None, then
- the entire revision graph is returned. This is a deprecated mode of
- operation and will be removed in the future.
- :return: a dictionary of revision_id->revision_parents_list.
- """
- if 'evil' in debug.debug_flags:
- mutter_callsite(3,
- "get_revision_graph scales with size of history.")
- # special case NULL_REVISION
- if revision_id == _mod_revision.NULL_REVISION:
- return {}
- if revision_id is None:
- revision_vf = self._get_revision_vf()
- return revision_vf.get_graph()
- g = self.get_graph()
- first = g.get_parent_map([revision_id])
- if revision_id not in first:
- raise errors.NoSuchRevision(self, revision_id)
- else:
- ancestry = {}
- children = {}
- NULL_REVISION = _mod_revision.NULL_REVISION
- ghosts = set([NULL_REVISION])
- for rev_id, parent_ids in g.iter_ancestry([revision_id]):
- if parent_ids is None: # This is a ghost
- ghosts.add(rev_id)
- continue
- ancestry[rev_id] = parent_ids
- for p in parent_ids:
- if p in children:
- children[p].append(rev_id)
- else:
- children[p] = [rev_id]
-
- if NULL_REVISION in ancestry:
- del ancestry[NULL_REVISION]
-
- # Find all nodes that reference a ghost, and filter the ghosts out
- # of their parent lists. To preserve the order of parents, and
- # avoid double filtering nodes, we just find all children first,
- # and then filter.
- children_of_ghosts = set()
- for ghost in ghosts:
- children_of_ghosts.update(children[ghost])
-
- for child in children_of_ghosts:
- ancestry[child] = tuple(p for p in ancestry[child]
- if p not in ghosts)
- return ancestry
-
def has_revisions(self, revision_ids):
"""See Repository.has_revisions()."""
revision_ids = set(revision_ids)
=== modified file 'bzrlib/repofmt/weaverepo.py'
--- a/bzrlib/repofmt/weaverepo.py 2008-04-10 06:19:49 +0000
+++ b/bzrlib/repofmt/weaverepo.py 2008-05-02 00:27:56 +0000
@@ -43,7 +43,6 @@
RepositoryFormat,
)
from bzrlib.store.text import TextStore
-from bzrlib.symbol_versioning import deprecated_method, one_four
from bzrlib.trace import mutter
@@ -145,42 +144,6 @@
self._check_revision_parents(rev, inv)
return revs
- @deprecated_method(one_four)
- @needs_read_lock
- def get_revision_graph(self, revision_id=None):
- """Return a dictionary containing the revision graph.
-
- :param revision_id: The revision_id to get a graph from. If None, then
- the entire revision graph is returned. This is a deprecated mode of
- operation and will be removed in the future.
- :return: a dictionary of revision_id->revision_parents_list.
- """
- if 'evil' in debug.debug_flags:
- mutter_callsite(2,
- "get_revision_graph scales with size of history.")
- # special case NULL_REVISION
- if revision_id == _mod_revision.NULL_REVISION:
- return {}
- a_weave = self.get_inventory_weave()
- all_revisions = self._eliminate_revisions_not_present(
- a_weave.versions())
- entire_graph = a_weave.get_parent_map(all_revisions)
- if revision_id is None:
- return entire_graph
- elif revision_id not in entire_graph:
- raise errors.NoSuchRevision(self, revision_id)
- else:
- # add what can be reached from revision_id
- result = {}
- pending = set([revision_id])
- while len(pending) > 0:
- node = pending.pop()
- result[node] = entire_graph[node]
- for revision_id in result[node]:
- if revision_id not in result:
- pending.add(revision_id)
- return result
-
def has_revisions(self, revision_ids):
"""See Repository.has_revisions()."""
result = set()
@@ -287,42 +250,6 @@
self._check_revision_parents(r, inv)
return r
- @deprecated_method(one_four)
- @needs_read_lock
- def get_revision_graph(self, revision_id=None):
- """Return a dictionary containing the revision graph.
-
- :param revision_id: The revision_id to get a graph from. If None, then
- the entire revision graph is returned. This is a deprecated mode of
- operation and will be removed in the future.
- :return: a dictionary of revision_id->revision_parents_list.
- """
- if 'evil' in debug.debug_flags:
- mutter_callsite(3,
- "get_revision_graph scales with size of history.")
- # special case NULL_REVISION
- if revision_id == _mod_revision.NULL_REVISION:
- return {}
- a_weave = self.get_inventory_weave()
- all_revisions = self._eliminate_revisions_not_present(
- a_weave.versions())
- entire_graph = a_weave.get_parent_map(all_revisions)
- if revision_id is None:
- return entire_graph
- elif revision_id not in entire_graph:
- raise errors.NoSuchRevision(self, revision_id)
- else:
- # add what can be reached from revision_id
- result = {}
- pending = set([revision_id])
- while len(pending) > 0:
- node = pending.pop()
- result[node] = entire_graph[node]
- for revision_id in result[node]:
- if revision_id not in result:
- pending.add(revision_id)
- return result
-
def has_revisions(self, revision_ids):
"""See Repository.has_revisions()."""
result = set()
=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py 2008-04-28 05:54:46 +0000
+++ b/bzrlib/repository.py 2008-05-02 00:27:56 +0000
@@ -25,7 +25,6 @@
bzrdir,
check,
debug,
- deprecated_graph,
errors,
generate_ids,
gpg,
@@ -1545,63 +1544,6 @@
"""
return self.get_revision(revision_id).inventory_sha1
- @needs_read_lock
- @deprecated_method(symbol_versioning.one_four)
- def get_revision_graph(self, revision_id=None):
- """Return a dictionary containing the revision graph.
-
- NB: This method should not be used as it accesses the entire graph all
- at once, which is much more data than most operations should require.
-
- :param revision_id: The revision_id to get a graph from. If None, then
- the entire revision graph is returned. This is a deprecated mode of
- operation and will be removed in the future.
- :return: a dictionary of revision_id->revision_parents_list.
- """
- raise NotImplementedError(self.get_revision_graph)
-
- @needs_read_lock
- @deprecated_method(symbol_versioning.one_three)
- def get_revision_graph_with_ghosts(self, revision_ids=None):
- """Return a graph of the revisions with ghosts marked as applicable.
-
- :param revision_ids: an iterable of revisions to graph or None for all.
- :return: a Graph object with the graph reachable from revision_ids.
- """
- if 'evil' in debug.debug_flags:
- mutter_callsite(3,
- "get_revision_graph_with_ghosts scales with size of history.")
- result = deprecated_graph.Graph()
- if not revision_ids:
- pending = set(self.all_revision_ids())
- required = set([])
- else:
- pending = set(revision_ids)
- # special case NULL_REVISION
- if _mod_revision.NULL_REVISION in pending:
- pending.remove(_mod_revision.NULL_REVISION)
- required = set(pending)
- done = set([])
- while len(pending):
- revision_id = pending.pop()
- try:
- rev = self.get_revision(revision_id)
- except errors.NoSuchRevision:
- if revision_id in required:
- raise
- # a ghost
- result.add_ghost(revision_id)
- continue
- for parent_id in rev.parent_ids:
- # is this queued or done ?
- if (parent_id not in pending and
- parent_id not in done):
- # no, queue it.
- pending.add(parent_id)
- result.add_node(revision_id, rev.parent_ids)
- done.add(revision_id)
- return result
-
def iter_reverse_revision_history(self, revision_id):
"""Iterate backwards through revision ids in the lefthand history
=== modified file 'bzrlib/revision.py'
--- a/bzrlib/revision.py 2008-03-26 21:42:35 +0000
+++ b/bzrlib/revision.py 2008-05-02 00:27:56 +0000
@@ -22,16 +22,8 @@
errors,
symbol_versioning,
)
-from bzrlib.deprecated_graph import (
- all_descendants,
- Graph,
- node_distances,
- select_farthest,
- )
from bzrlib.osutils import contains_whitespace
from bzrlib.progress import DummyProgress
-from bzrlib.symbol_versioning import (deprecated_function,
- )
NULL_REVISION="null:"
CURRENT_REVISION="current:"
@@ -125,22 +117,6 @@
return self.properties.get('author', self.committer)
- at deprecated_function(symbol_versioning.one_zero)
-def is_ancestor(revision_id, candidate_id, branch):
- """Return true if candidate_id is an ancestor of revision_id.
-
- A false negative will be returned if any intermediate descendent of
- candidate_id is not present in any of the revision_sources.
-
- revisions_source is an object supporting a get_revision operation that
- behaves like Branch's.
-
- This function is deprecated, it is better for callers to directly use
- Graph.is_ancestor() (just watch out that the parameter order is switched)
- """
- return branch.repository.get_graph().is_ancestor(candidate_id, revision_id)
-
-
def iter_ancestors(revision_id, revision_source, only_present=False):
ancestors = (revision_id,)
distance = 0
@@ -188,261 +164,6 @@
return matches
- at deprecated_function(symbol_versioning.one_four)
-def revision_graph(revision, revision_source):
- """Produce a graph of the ancestry of the specified revision.
-
- :return: root, ancestors map, descendants map
- """
- revision_source.lock_read()
- try:
- return _revision_graph(revision, revision_source)
- finally:
- revision_source.unlock()
-
-
-def _revision_graph(revision, revision_source):
- """See revision_graph."""
- from bzrlib.tsort import topo_sort
- graph = revision_source.get_revision_graph(revision)
- # mark all no-parent revisions as being NULL_REVISION parentage.
- for node, parents in graph.items():
- if len(parents) == 0:
- graph[node] = [NULL_REVISION]
- # add NULL_REVISION to the graph
- graph[NULL_REVISION] = []
-
- # pick a root. If there are multiple roots
- # this could pick a random one.
- topo_order = topo_sort(graph.items())
- root = topo_order[0]
-
- ancestors = {}
- descendants = {}
-
- # map the descendants of the graph.
- # and setup our set based return graph.
- for node in graph.keys():
- descendants[node] = {}
- for node, parents in graph.items():
- for parent in parents:
- descendants[parent][node] = 1
- ancestors[node] = set(parents)
-
- assert root not in descendants[root]
- assert root not in ancestors[root]
- return root, ancestors, descendants
-
-
- at deprecated_function(symbol_versioning.one_three)
-def combined_graph(revision_a, revision_b, revision_source):
- """Produce a combined ancestry graph.
- Return graph root, ancestors map, descendants map, set of common nodes"""
- root, ancestors, descendants = revision_graph(
- revision_a, revision_source)
- root_b, ancestors_b, descendants_b = revision_graph(
- revision_b, revision_source)
- if root != root_b:
- raise errors.NoCommonRoot(revision_a, revision_b)
- common = set()
- for node, node_anc in ancestors_b.iteritems():
- if node in ancestors:
- common.add(node)
- else:
- ancestors[node] = set()
- ancestors[node].update(node_anc)
- for node, node_dec in descendants_b.iteritems():
- if node not in descendants:
- descendants[node] = {}
- descendants[node].update(node_dec)
- return root, ancestors, descendants, common
-
-
- at deprecated_function(symbol_versioning.one_three)
-def common_ancestor(revision_a, revision_b, revision_source,
- pb=DummyProgress()):
- if None in (revision_a, revision_b):
- return None
- if NULL_REVISION in (revision_a, revision_b):
- return NULL_REVISION
- # trivial optimisation
- if revision_a == revision_b:
- return revision_a
- try:
- try:
- pb.update('Picking ancestor', 1, 3)
- graph = revision_source.get_revision_graph_with_ghosts(
- [revision_a, revision_b])
- # Shortcut the case where one of the tips is already included in
- # the other graphs ancestry.
- ancestry_a = graph.get_ancestry(revision_a, topo_sorted=False)
- if revision_b in ancestry_a:
- return revision_b
- ancestry_b = graph.get_ancestry(revision_b, topo_sorted=False)
- if revision_a in ancestry_b:
- return revision_a
- # convert to a NULL_REVISION based graph.
- ancestors = graph.get_ancestors()
- descendants = graph.get_descendants()
- common = set(ancestry_a)
- common.intersection_update(ancestry_b)
- descendants[NULL_REVISION] = {}
- ancestors[NULL_REVISION] = []
- for root in graph.roots:
- descendants[NULL_REVISION][root] = 1
- ancestors[root].append(NULL_REVISION)
- for ghost in graph.ghosts:
- # ghosts act as roots for the purpose of finding
- # the longest paths from the root: any ghost *might*
- # be directly attached to the root, so we treat them
- # as being such.
- # ghost now descends from NULL
- descendants[NULL_REVISION][ghost] = 1
- # that is it has an ancestor of NULL
- ancestors[ghost] = [NULL_REVISION]
- # ghost is common if any of ghosts descendants are common:
- for ghost_descendant in descendants[ghost]:
- if ghost_descendant in common:
- common.add(ghost)
-
- root = NULL_REVISION
- common.add(NULL_REVISION)
- except errors.NoCommonRoot:
- raise errors.NoCommonAncestor(revision_a, revision_b)
-
- pb.update('Picking ancestor', 2, 3)
- distances = node_distances (descendants, ancestors, root)
- pb.update('Picking ancestor', 3, 2)
- farthest = select_farthest(distances, common)
- if farthest is None or farthest == NULL_REVISION:
- raise errors.NoCommonAncestor(revision_a, revision_b)
- finally:
- pb.clear()
- return farthest
-
-
-class MultipleRevisionSources(object):
- """Proxy that looks in multiple branches for revisions."""
-
- @symbol_versioning.deprecated_method(symbol_versioning.one_three)
- def __init__(self, *args):
- object.__init__(self)
- assert len(args) != 0
- self._revision_sources = args
-
- def revision_parents(self, revision_id):
- for source in self._revision_sources:
- try:
- return source.revision_parents(revision_id)
- except (errors.WeaveRevisionNotPresent, errors.NoSuchRevision), e:
- pass
- raise e
-
- def get_revision(self, revision_id):
- for source in self._revision_sources:
- try:
- return source.get_revision(revision_id)
- except errors.NoSuchRevision, e:
- pass
- raise e
-
- def get_revision_graph(self, revision_id):
- # we could probe incrementally until the pending
- # ghosts list stop growing, but its cheaper for now
- # to just ask for the complete graph for each repository.
- graphs = []
- for source in self._revision_sources:
- ghost_graph = source.get_revision_graph_with_ghosts()
- graphs.append(ghost_graph)
- absent = 0
- for graph in graphs:
- if not revision_id in graph.get_ancestors():
- absent += 1
- if absent == len(graphs):
- raise errors.NoSuchRevision(self._revision_sources[0], revision_id)
-
- # combine the graphs
- result = {}
- pending = set([revision_id])
- def find_parents(node_id):
- """find the parents for node_id."""
- for graph in graphs:
- ancestors = graph.get_ancestors()
- try:
- return ancestors[node_id]
- except KeyError:
- pass
- raise errors.NoSuchRevision(self._revision_sources[0], node_id)
- while len(pending):
- # all the graphs should have identical parent lists
- node_id = pending.pop()
- try:
- result[node_id] = find_parents(node_id)
- for parent_node in result[node_id]:
- if not parent_node in result:
- pending.add(parent_node)
- except errors.NoSuchRevision:
- # ghost, ignore it.
- pass
- return result
-
- def get_revision_graph_with_ghosts(self, revision_ids):
- # query all the sources for their entire graphs
- # and then build a combined graph for just
- # revision_ids.
- graphs = []
- for source in self._revision_sources:
- ghost_graph = source.get_revision_graph_with_ghosts()
- graphs.append(ghost_graph.get_ancestors())
- for revision_id in revision_ids:
- absent = 0
- for graph in graphs:
- if not revision_id in graph:
- absent += 1
- if absent == len(graphs):
- raise errors.NoSuchRevision(self._revision_sources[0],
- revision_id)
-
- # combine the graphs
- result = Graph()
- pending = set(revision_ids)
- done = set()
- def find_parents(node_id):
- """find the parents for node_id."""
- for graph in graphs:
- try:
- return graph[node_id]
- except KeyError:
- pass
- raise errors.NoSuchRevision(self._revision_sources[0], node_id)
- while len(pending):
- # all the graphs should have identical parent lists
- node_id = pending.pop()
- try:
- parents = find_parents(node_id)
- for parent_node in parents:
- # queued or done?
- if (parent_node not in pending and
- parent_node not in done):
- # no, queue
- pending.add(parent_node)
- result.add_node(node_id, parents)
- done.add(node_id)
- except errors.NoSuchRevision:
- # ghost
- result.add_ghost(node_id)
- continue
- return result
-
- def lock_read(self):
- for source in self._revision_sources:
- source.lock_read()
-
- def unlock(self):
- for source in self._revision_sources:
- source.unlock()
-
-
def is_reserved_id(revision_id):
"""Determine whether a revision id is reserved
=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py 2008-04-07 04:44:56 +0000
+++ b/bzrlib/tests/__init__.py 2008-05-02 00:27:56 +0000
@@ -73,7 +73,6 @@
from bzrlib.merge import merge_inner
import bzrlib.merge3
import bzrlib.plugin
-from bzrlib.revision import common_ancestor
import bzrlib.store
from bzrlib import symbol_versioning
from bzrlib.symbol_versioning import (
=== modified file 'bzrlib/tests/repository_implementations/test_repository.py'
--- a/bzrlib/tests/repository_implementations/test_repository.py 2008-04-26 16:34:47 +0000
+++ b/bzrlib/tests/repository_implementations/test_repository.py 2008-05-02 00:27:56 +0000
@@ -950,64 +950,6 @@
self.assertEqual(set(repo.get_ancestry('rev3')),
set(repo.get_ancestry('rev3', topo_sorted=False)))
- def test_get_revision_graph(self):
- # we can get a mapping of id->parents for the entire revision graph or bits thereof.
- self.assertEqual({'rev1':(),
- 'rev2':('rev1', ),
- 'rev3':('rev2', ),
- 'rev4':('rev3', ),
- },
- self.applyDeprecated(one_four,
- self.bzrdir.open_repository().get_revision_graph, None))
- self.assertEqual({'rev1':()},
- self.applyDeprecated(one_four,
- self.bzrdir.open_repository().get_revision_graph, 'rev1'))
- self.assertEqual({'rev1':(),
- 'rev2':('rev1', )},
- self.applyDeprecated(one_four,
- self.bzrdir.open_repository().get_revision_graph, 'rev2'))
- self.assertRaises(errors.NoSuchRevision, self.applyDeprecated, one_four,
- self.bzrdir.open_repository().get_revision_graph, 'orphan')
- # and ghosts are not mentioned
- self.assertEqual({'rev1':(),
- 'rev2':('rev1', ),
- 'rev3':('rev2', ),
- },
- self.applyDeprecated(one_four,
- self.bzrdir.open_repository().get_revision_graph, 'rev3'))
- # and we can ask for the NULLREVISION graph
- self.assertEqual({},
- self.applyDeprecated(one_four,
- self.bzrdir.open_repository().get_revision_graph, NULL_REVISION))
-
- def test_get_revision_graph_with_ghosts(self):
- # we can get a graph object with roots, ghosts, ancestors and
- # descendants.
- repo = self.bzrdir.open_repository()
- graph = self.applyDeprecated(one_three,
- repo.get_revision_graph_with_ghosts, [])
- self.assertEqual(set(['rev1']), graph.roots)
- self.assertEqual(set(['ghost1', 'ghost2']), graph.ghosts)
- self.assertEqual({'rev1':[],
- 'rev2':['rev1'],
- 'rev3':['rev2', 'ghost1'],
- 'rev4':['rev3', 'ghost1', 'ghost2'],
- },
- graph.get_ancestors())
- self.assertEqual({'ghost1':{'rev3':1, 'rev4':1},
- 'ghost2':{'rev4':1},
- 'rev1':{'rev2':1},
- 'rev2':{'rev3':1},
- 'rev3':{'rev4':1},
- 'rev4':{},
- },
- graph.get_descendants())
- # and we can ask for the NULLREVISION graph
- graph = self.applyDeprecated(one_three,
- repo.get_revision_graph_with_ghosts, [NULL_REVISION])
- self.assertEqual({}, graph.get_ancestors())
- self.assertEqual({}, graph.get_descendants())
-
def test_reserved_id(self):
repo = self.make_repository('repository')
repo.lock_write()
=== modified file 'bzrlib/tests/test_ancestry.py'
--- a/bzrlib/tests/test_ancestry.py 2007-12-18 15:22:47 +0000
+++ b/bzrlib/tests/test_ancestry.py 2008-05-02 00:27:56 +0000
@@ -22,7 +22,6 @@
from bzrlib.tests import TestCaseWithMemoryTransport
from bzrlib.branch import Branch
from bzrlib.branchbuilder import BranchBuilder
-from bzrlib.revision import is_ancestor
from bzrlib.symbol_versioning import one_zero
@@ -43,23 +42,5 @@
rev_id_two, branch)
self.assertAncestryEqual([None, rev_id_one], rev_id_one, branch)
- def test_none_is_ancestor_empty_branch(self):
- branch = self.make_branch('.')
- self.assertTrue(self.applyDeprecated(one_zero,
- is_ancestor, 'null:', 'null:', branch))
-
- def test_none_is_ancestor_non_empty_branch(self):
- builder = BranchBuilder(self.get_transport())
- rev_id = builder.build_commit()
- branch = builder.get_branch()
- branch.lock_read()
- self.addCleanup(branch.unlock)
- self.assertTrue(self.applyDeprecated(one_zero,
- is_ancestor, 'null:', 'null:', branch))
- self.assertTrue(self.applyDeprecated(one_zero,
- is_ancestor, rev_id, 'null:', branch))
- self.assertFalse(self.applyDeprecated(one_zero,
- is_ancestor, 'null:', rev_id, branch))
-
# TODO: check that ancestry is updated to include indirectly merged revisions
=== modified file 'bzrlib/tests/test_revision.py'
--- a/bzrlib/tests/test_revision.py 2008-03-10 15:39:56 +0000
+++ b/bzrlib/tests/test_revision.py 2008-05-02 00:27:56 +0000
@@ -25,9 +25,7 @@
from bzrlib.branch import Branch
from bzrlib.errors import NoSuchRevision
from bzrlib.deprecated_graph import Graph
-from bzrlib.revision import (find_present_ancestors, combined_graph,
- common_ancestor,
- is_ancestor, MultipleRevisionSources,
+from bzrlib.revision import (find_present_ancestors,
NULL_REVISION)
from bzrlib.symbol_versioning import one_zero, one_three
from bzrlib.tests import TestCase, TestCaseWithTransport
@@ -126,39 +124,6 @@
result = sorted(branch.repository.get_ancestry(rev_id))
self.assertEquals(result, [None] + sorted(anc))
-
- def test_is_ancestor(self):
- """Test checking whether a revision is an ancestor of another revision"""
- br1, br2 = make_branches(self)
- revisions = br1.revision_history()
- revisions_2 = br2.revision_history()
- sources = br1
-
- br1.lock_read()
- br2.lock_read()
- self.addCleanup(br1.unlock)
- br2.lock_read()
- self.addCleanup(br2.unlock)
-
- self.assertTrue(self.applyDeprecated(one_zero,
- is_ancestor, revisions[0], revisions[0], br1))
- self.assertTrue(self.applyDeprecated(one_zero,
- is_ancestor, revisions[1], revisions[0], sources))
- self.assertFalse(self.applyDeprecated(one_zero,
- is_ancestor, revisions[0], revisions[1], sources))
- self.assertTrue(self.applyDeprecated(one_zero,
- is_ancestor, revisions_2[3], revisions[0], sources))
- # disabled mbp 20050914, doesn't seem to happen anymore
- ## self.assertRaises(NoSuchRevision, is_ancestor, revisions_2[3],
- ## revisions[0], br1)
- self.assertTrue(self.applyDeprecated(one_zero,
- is_ancestor, revisions[3], revisions_2[4], sources))
- self.assertTrue(self.applyDeprecated(one_zero,
- is_ancestor, revisions[3], revisions_2[4], br1))
- self.assertTrue(self.applyDeprecated(one_zero,
- is_ancestor, revisions[3], revisions_2[3], sources))
- ## self.assert_(not is_ancestor(revisions[3], revisions_2[3], br1))
-
class TestIntermediateRevisions(TestCaseWithTransport):
@@ -202,79 +167,6 @@
class TestCommonAncestor(TestCaseWithTransport):
"""Test checking whether a revision is an ancestor of another revision"""
- def assertCommonAncestorEqual(self, expected, sources, rev_a, rev_b):
- self.assertEqual(expected,
- self.applyDeprecated(one_three,
- common_ancestor, rev_a, rev_b, sources))
-
- def assertCommonAncestorIn(self, possible, sources, rev_a, rev_b):
- """assert that we pick one among multiple possible common ancestors"""
- self.assertTrue(self.applyDeprecated(one_three,
- common_ancestor, rev_a, rev_b, sources)
- in possible)
-
- def test_common_ancestor(self):
- """Pick a reasonable merge base"""
- br1, br2 = make_branches(self)
- revisions = br1.revision_history()
- revisions_2 = br2.revision_history()
- sources = self.applyDeprecated(one_three,
- MultipleRevisionSources, br1.repository, br2.repository)
- expected_ancestors_list = {revisions[3]:(0, 0),
- revisions[2]:(1, 1),
- revisions_2[4]:(2, 1),
- revisions[1]:(3, 2),
- revisions_2[3]:(4, 2),
- revisions[0]:(5, 3) }
- ancestors_list = find_present_ancestors(revisions[3], sources)
- self.assertEquals(len(expected_ancestors_list), len(ancestors_list))
- for key, value in expected_ancestors_list.iteritems():
- self.assertEqual(ancestors_list[key], value,
- "key %r, %r != %r" % (key, ancestors_list[key],
- value))
- self.assertCommonAncestorEqual(revisions[0], sources,
- revisions[0], revisions[0])
- self.assertCommonAncestorEqual(revisions[1], sources,
- revisions[1], revisions[2])
- self.assertCommonAncestorEqual(revisions[1], sources,
- revisions[1], revisions[1])
- self.assertCommonAncestorEqual(revisions[2], sources,
- revisions[2], revisions_2[4])
- self.assertCommonAncestorEqual(revisions_2[4], sources,
- revisions[3], revisions_2[4])
- self.assertCommonAncestorEqual(revisions_2[4], sources,
- revisions[4], revisions_2[5])
- self.assertCommonAncestorIn((revisions[4], revisions_2[5]), sources,
- revisions[5], revisions_2[6])
- self.assertCommonAncestorIn((revisions[4], revisions_2[5]), sources,
- revisions_2[6], revisions[5])
- self.assertCommonAncestorEqual(None, sources,
- None, revisions[5])
- self.assertCommonAncestorEqual(NULL_REVISION, sources,
- NULL_REVISION, NULL_REVISION)
- self.assertCommonAncestorEqual(NULL_REVISION, sources,
- revisions[0], NULL_REVISION)
- self.assertCommonAncestorEqual(NULL_REVISION, sources,
- NULL_REVISION, revisions[0])
-
- def test_combined(self):
- """combined_graph
- Ensure it's not order-sensitive
- """
- br1, br2 = make_branches(self)
- source = self.applyDeprecated(one_three,
- MultipleRevisionSources, br1.repository, br2.repository)
- combined_1 = self.applyDeprecated(one_three,
- combined_graph, br1.last_revision(),
- br2.last_revision(), source)
- combined_2 = self.applyDeprecated(one_three,
- combined_graph, br2.last_revision(),
- br1.last_revision(), source)
- self.assertEquals(combined_1[1], combined_2[1])
- self.assertEquals(combined_1[2], combined_2[2])
- self.assertEquals(combined_1[3], combined_2[3])
- self.assertEquals(combined_1, combined_2)
-
def test_get_history(self):
# TODO: test ghosts on the left hand branch's impact
# TODO: test ghosts on all parents, we should get some
@@ -294,48 +186,6 @@
history = rev.get_history(tree.branch.repository)
self.assertEqual([None, '1', '2' ,'3'], history)
- def test_common_ancestor_rootless_graph(self):
- # common_ancestor on a graph with no reachable roots - only
- # ghosts - should still return a useful value.
- graph = Graph()
- # add a ghost node which would be a root if it wasn't a ghost.
- graph.add_ghost('a_ghost')
- # add a normal commit on top of that
- graph.add_node('rev1', ['a_ghost'])
- # add a left-branch revision
- graph.add_node('left', ['rev1'])
- # add a right-branch revision
- graph.add_node('right', ['rev1'])
- source = MockRevisionSource(graph)
- self.assertCommonAncestorEqual('rev1', source, 'left', 'right')
-
-
-class TestMultipleRevisionSources(TestCaseWithTransport):
- """Tests for the MultipleRevisionSources adapter."""
-
- def test_get_revision_graph_merges_ghosts(self):
- # when we ask for the revision graph for B, which
- # is in repo 1 with a ghost of A, and which is not
- # in repo 2, which has A, the revision_graph()
- # should return A and B both.
- tree_1 = self.make_branch_and_tree('1')
- tree_1.set_parent_ids(['A'], allow_leftmost_as_ghost=True)
- tree_1.commit('foo', rev_id='B', allow_pointless=True)
- tree_2 = self.make_branch_and_tree('2')
- tree_2.commit('bar', rev_id='A', allow_pointless=True)
- source = self.applyDeprecated(one_three,
- MultipleRevisionSources, tree_1.branch.repository,
- tree_2.branch.repository)
- # get_revision_graph calls the deprecated
- # get_revision_graph_with_ghosts once for each repository.
- expected_warning = symbol_versioning.deprecation_string(
- tree_1.branch.repository.get_revision_graph_with_ghosts,
- one_three)
- rev_graph = self.callDeprecated([expected_warning, expected_warning],
- source.get_revision_graph, 'B')
- self.assertEqual({'B':['A'],
- 'A':[]}, rev_graph)
-
class TestReservedId(TestCase):
More information about the bazaar-commits
mailing list