Rev 86: Fix some uses of get_revision_graph(). in file:///data/jelmer/bzr-rebase/trunk/
Jelmer Vernooij
jelmer at samba.org
Thu May 29 13:14:42 BST 2008
At file:///data/jelmer/bzr-rebase/trunk/
------------------------------------------------------------
revno: 86
revision-id: jelmer at samba.org-20080529121441-u3ej7p7ztkdpzxjp
parent: jelmer at samba.org-20080518144701-moplzmp1nr504zzc
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Thu 2008-05-29 14:14:41 +0200
message:
Fix some uses of get_revision_graph().
modified:
__init__.py __init__.py-20070626215909-fi0s39bkwxn4gcto-1
rebase.py rebase.py-20070626221123-ellanmf93nw8z9r1-1
test_rebase.py test_rebase.py-20070626221123-ellanmf93nw8z9r1-2
=== modified file '__init__.py'
--- a/__init__.py 2008-05-18 14:47:01 +0000
+++ b/__init__.py 2008-05-29 12:14:41 +0000
@@ -203,7 +203,7 @@
replace_map = generate_simple_plan(
revhistory, start_revid, stop_revid, onto,
wt.branch.repository.get_ancestry(onto),
- wt.branch.repository.revision_parents,
+ wt.branch.repository.get_graph(),
lambda revid: regenerate_default_revid(wt.branch.repository, revid),
not always_rebase_merges
)
=== modified file 'rebase.py'
--- a/rebase.py 2008-05-18 13:57:53 +0000
+++ b/rebase.py 2008-05-29 12:14:41 +0000
@@ -125,7 +125,7 @@
def generate_simple_plan(history, start_revid, stop_revid, onto_revid,
- onto_ancestry, get_parents, generate_revid,
+ onto_ancestry, graph, generate_revid,
skip_full_merged=False):
"""Create a simple rebase plan that replays history based
on one revision being replayed on top of another.
@@ -135,7 +135,7 @@
:param stop_revid: Id of revision until which to stop replaying
:param onto_revid: Id of revision on top of which to replay
:param onto_ancestry: Ancestry of onto_revid
- :param get_parents: Function for obtaining the parents of a revision
+ :param graph: Graph object
:param generate_revid: Function for generating new revision ids
:param skip_full_merged: Skip revisions that merge already merged
revisions.
@@ -154,13 +154,15 @@
else:
stop_revno = None
new_parent = onto_revid
- for oldrevid in history[start_revno:stop_revno]:
- oldparents = list(get_parents(oldrevid))
- assert isinstance(oldparents, list)
- assert oldparents == [] or \
+ todo = history[start_revno:stop_revno]
+ parent_map = graph.get_parent_map(todo)
+ for oldrevid in todo:
+ oldparents = parent_map[oldrevid]
+ assert isinstance(oldparents, tuple), "not tuple: %r" % oldparents
+ assert oldparents == () or \
oldparents[0] == history[history.index(oldrevid)-1]
if len(oldparents) > 1:
- parents = [new_parent] + filter(lambda p: p not in onto_ancestry or p == onto_revid, oldparents[1:])
+ parents = (new_parent,) + tuple(filter(lambda p: p not in onto_ancestry or p == onto_revid, oldparents[1:]))
if len(parents) == 1 and skip_full_merged:
continue
else:
@@ -275,6 +277,7 @@
i += 1
revid = todo.pop()
(newrevid, newparents) = replace_map[revid]
+ assert isinstance(newparents, tuple)
if filter(repository.has_revision, newparents) != newparents:
# Not all parents present yet, avoid for now
continue
@@ -283,7 +286,7 @@
continue
replay_fn(repository, revid, newrevid, newparents)
assert repository.has_revision(newrevid)
- assert list(repository.get_parent_map([newrevid])[newrevid]) == newparents, \
+ assert repository.get_parent_map([newrevid])[newrevid] == newparents, \
"expected parents %r, got %r" % (newparents,
repository.get_parent_map([newrevid])[newrevid])
if dependencies.has_key(newrevid):
=== modified file 'test_rebase.py'
--- a/test_rebase.py 2008-05-11 18:52:36 +0000
+++ b/test_rebase.py 2008-05-29 12:14:41 +0000
@@ -17,7 +17,7 @@
from bzrlib.conflicts import ConflictList
from bzrlib.errors import UnknownFormatError, NoSuchFile, ConflictsInTree
-from bzrlib.graph import Graph
+from bzrlib.graph import Graph, DictParentsProvider
from bzrlib.revision import NULL_REVISION
from bzrlib.tests import TestCase, TestCaseWithTransport
from bzrlib.trace import mutter
@@ -104,7 +104,7 @@
generate_simple_plan(b.revision_history(), "bla2", None,
"bloe",
["bloe", "bla"],
- b.repository.revision_parents,
+ b.repository.get_graph(),
lambda y: "new"+y))
b.repository.unlock()
@@ -127,7 +127,7 @@
self.assertEquals({'bla2': ('newbla2', ["bloe"]), 'bla3': ('newbla3', ['newbla2'])},
generate_simple_plan(b.revision_history(), "bla2", None, "bloe",
["bloe", "bla"],
- b.repository.revision_parents,
+ b.repository.get_graph(),
lambda y: "new"+y))
b.repository.unlock()
@@ -194,16 +194,17 @@
E -> (E', [D', C])
"""
parents_map = {
- "A": [],
- "B": ["A"],
- "C": ["B"],
- "D": ["A"],
- "E": ["D", "B"]
+ "A": (),
+ "B": ("A",),
+ "C": ("B",),
+ "D": ("A",),
+ "E": ("D", "B")
}
- self.assertEquals({"D": ("D'", ["C"]), "E": ("E'", ["D'"])},
+ graph = Graph(DictParentsProvider(parents_map))
+ self.assertEquals({"D": ("D'", ["C"]), "E": ("E'", ("D'",))},
generate_simple_plan(["A", "D", "E"],
"D", None, "C", ["A", "B", "C"],
- parents_map.get, lambda y: y+"'"))
+ graph, lambda y: y+"'"))
def test_plan_with_already_merged_skip_merges(self):
"""We need to use a merge base that makes sense.
@@ -223,16 +224,17 @@
D -> (D', [C])
"""
parents_map = {
- "A": [],
- "B": ["A"],
- "C": ["B"],
- "D": ["A"],
- "E": ["D", "B"]
+ "A": (),
+ "B": ("A",),
+ "C": ("B",),
+ "D": ("A",),
+ "E": ("D", "B")
}
+ graph = Graph(DictParentsProvider(parents_map))
self.assertEquals({"D": ("D'", ["C"])},
generate_simple_plan(["A", "D", "E"],
"D", None, "C", ["A", "B", "C"],
- parents_map.get, lambda y: y+"'", True))
+ graph, lambda y: y+"'", True))
class PlanFileTests(TestCaseWithTransport):
More information about the bazaar-commits
mailing list