Rev 91: Fix blackbox tests, add comments to assertions. in file:///data/jelmer/bzr-rebase/trunk/
Jelmer Vernooij
jelmer at samba.org
Thu May 29 15:57:15 BST 2008
At file:///data/jelmer/bzr-rebase/trunk/
------------------------------------------------------------
revno: 91
revision-id: jelmer at samba.org-20080529145715-h6l3hone8px6uo0h
parent: jelmer at samba.org-20080529143424-qp3mpdu9sknfugy7
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Thu 2008-05-29 16:57:15 +0200
message:
Fix blackbox tests, add comments to assertions.
modified:
rebase.py rebase.py-20070626221123-ellanmf93nw8z9r1-1
test_blackbox.py test_blackbox.py-20070709202607-dyvt95dfu09tuv6a-1
test_rebase.py test_rebase.py-20070626221123-ellanmf93nw8z9r1-2
=== modified file 'rebase.py'
--- a/rebase.py 2008-05-29 14:34:24 +0000
+++ b/rebase.py 2008-05-29 14:57:15 +0000
@@ -142,8 +142,8 @@
:return: replace map
"""
- assert start_revid is None or start_revid in history
- assert stop_revid is None or stop_revid in history
+ assert start_revid is None or start_revid in history, "invalid start revid"
+ assert stop_revid is None or stop_revid in history, "invalid stop_revid"
replace_map = {}
if start_revid is not None:
start_revno = history.index(start_revid)
@@ -160,15 +160,17 @@
oldparents = parent_map[oldrevid]
assert isinstance(oldparents, tuple), "not tuple: %r" % oldparents
assert oldparents == () or \
- oldparents[0] == history[history.index(oldrevid)-1]
+ oldparents[0] == history[history.index(oldrevid)-1], \
+ "invalid old parents for %r" % oldrevid
if len(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:
- parents = [new_parent]
+ parents = (new_parent,)
newrevid = generate_revid(oldrevid)
- assert newrevid != oldrevid
+ assert newrevid != oldrevid, "old and newrevid equal (%r)" % newrevid
+ assert isinstance(parents, tuple), "parents not tuple: %r" % parents
replace_map[oldrevid] = (newrevid, parents)
new_parent = newrevid
return replace_map
@@ -229,7 +231,7 @@
parents[parents.index(r)] = replace_map[r][0]
parents = tuple(parents)
replace_map[c] = (generate_revid(c), tuple(parents))
- assert replace_map[c][0] != c
+ assert replace_map[c][0] != c, "Invalid value in replace map %r" % c
processed.add(r)
# Add them to todo[]
todo.extend(filter(lambda x: not x in processed, children[r]))
@@ -250,8 +252,9 @@
:param repository: Repository that contains the revisions
:param replace_map: Replace map
"""
- for revid in replace_map:
- if not repository.has_revision(replace_map[revid][0]):
+ for revid, parent_ids in replace_map.items():
+ assert isinstance(parent_ids, tuple), "replace map parents not tuple"
+ if not repository.has_revision(parent_ids[0]):
yield revid
@@ -283,7 +286,7 @@
i += 1
revid = todo.pop()
(newrevid, newparents) = replace_map[revid]
- assert isinstance(newparents, tuple)
+ assert isinstance(newparents, tuple), "Expected tuple for %r" % newparents
if filter(repository.has_revision, newparents) != newparents:
# Not all parents present yet, avoid for now
continue
@@ -313,7 +316,7 @@
:param new_parents: Revision ids of the new parent revisions.
:param revid_renames: Revision id renames for texts.
"""
- assert isinstance(new_parents, tuple)
+ assert isinstance(new_parents, tuple), "replay_snapshot: Expected tuple for %r" % new_parents
mutter('creating copy %r of %r with new parents %r' %
(newrevid, oldrevid, new_parents))
oldrev = repository.get_revision(oldrevid)
@@ -380,7 +383,7 @@
:param wt: Mutable tree with the changes.
:param oldrev: Revision info of new revision to commit.
:param newrevid: New revision id."""
- assert oldrev.revision_id != newrevid
+ assert oldrev.revision_id != newrevid, "Invalid revid %r" % newrevid
revprops = dict(oldrev.properties)
revprops[REVPROP_REBASE_OF] = oldrev.revision_id
committer = wt.branch.get_config().username()
@@ -443,7 +446,7 @@
# Make sure there are no conflicts or pending merges/changes
# in the working tree
complete_revert(wt, [newparents[0]])
- assert not wt.changes_from(wt.basis_tree()).has_changed()
+ assert not wt.changes_from(wt.basis_tree()).has_changed(), "Changes in rev"
oldtree = repository.revision_tree(oldrevid)
write_active_rebase_revid(wt, oldrevid)
@@ -469,7 +472,7 @@
:param map_ids: Whether to try to map between file ids (False for path-based merge)
"""
def replay(repository, oldrevid, newrevid, newparents):
- assert wt.branch.repository == repository
+ assert wt.branch.repository == repository, "Different repository"
return replay_delta_workingtree(wt, oldrevid, newrevid, newparents,
merge_type=merge_type)
return replay
@@ -520,7 +523,7 @@
else:
os.unlink(abs_path)
wt.revert(None, old_tree=newtree, backups=False)
- assert not wt.changes_from(wt.basis_tree()).has_changed()
+ assert not wt.changes_from(wt.basis_tree()).has_changed(), "Rev changed"
wt.set_parent_ids(newparents)
=== modified file 'test_blackbox.py'
--- a/test_blackbox.py 2008-05-18 13:57:53 +0000
+++ b/test_blackbox.py 2008-05-29 14:57:15 +0000
@@ -48,6 +48,7 @@
def test_pending_merges(self):
os.chdir('../main')
self.make_file('hello', '42')
+ self.run_bzr('add')
self.run_bzr('commit -m that')
os.chdir('../feature')
self.make_file('hoi', "my data")
=== modified file 'test_rebase.py'
--- a/test_rebase.py 2008-05-29 14:34:24 +0000
+++ b/test_rebase.py 2008-05-29 14:57:15 +0000
@@ -100,10 +100,10 @@
wt.commit(message='change hello', rev_id="bla2")
b.repository.lock_read()
- self.assertEquals({'bla2': ('newbla2', ["bloe"])},
+ self.assertEquals({'bla2': ('newbla2', ("bloe",))},
generate_simple_plan(b.revision_history(), "bla2", None,
"bloe",
- ["bloe", "bla"],
+ ("bloe", "bla"),
b.repository.get_graph(),
lambda y: "new"+y))
b.repository.unlock()
@@ -124,9 +124,9 @@
wt.commit(message='change hello again', rev_id="bla3")
b.repository.lock_read()
- self.assertEquals({'bla2': ('newbla2', ["bloe"]), 'bla3': ('newbla3', ['newbla2'])},
+ self.assertEquals({'bla2': ('newbla2', ("bloe",)), 'bla3': ('newbla3', ('newbla2',))},
generate_simple_plan(b.revision_history(), "bla2", None, "bloe",
- ["bloe", "bla"],
+ ("bloe", "bla"),
b.repository.get_graph(),
lambda y: "new"+y))
b.repository.unlock()
@@ -203,7 +203,7 @@
"E": ("D", "B")
}
graph = Graph(DictParentsProvider(parents_map))
- self.assertEquals({"D": ("D'", ["C"]), "E": ("E'", ("D'",))},
+ self.assertEquals({"D": ("D'", ("C",)), "E": ("E'", ("D'",))},
generate_simple_plan(["A", "D", "E"],
"D", None, "C", ["A", "B", "C"],
graph, lambda y: y+"'"))
@@ -233,7 +233,7 @@
"E": ("D", "B")
}
graph = Graph(DictParentsProvider(parents_map))
- self.assertEquals({"D": ("D'", ["C"])},
+ self.assertEquals({"D": ("D'", ("C",))},
generate_simple_plan(["A", "D", "E"],
"D", None, "C", ["A", "B", "C"],
graph, lambda y: y+"'", True))
More information about the bazaar-commits
mailing list