Rev 89: Use tuples for parents. in file:///data/jelmer/bzr-rebase/trunk/

Jelmer Vernooij jelmer at samba.org
Thu May 29 15:23:15 BST 2008


At file:///data/jelmer/bzr-rebase/trunk/

------------------------------------------------------------
revno: 89
revision-id: jelmer at samba.org-20080529142315-w6cpjsiz2287414h
parent: jelmer at samba.org-20080529140718-ddrlmqyf0rfplub6
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Thu 2008-05-29 16:23:15 +0200
message:
  Use tuples for parents.
modified:
  rebase.py                      rebase.py-20070626221123-ellanmf93nw8z9r1-1
  test_rebase.py                 test_rebase.py-20070626221123-ellanmf93nw8z9r1-2
=== modified file 'rebase.py'
--- a/rebase.py	2008-05-29 14:07:18 +0000
+++ b/rebase.py	2008-05-29 14:23:15 +0000
@@ -218,15 +218,15 @@
                 if c in renames:
                     continue
                 if replace_map.has_key(c):
-                    parents = list(replace_map[c][1])
+                    parents = replace_map[c][1]
                 else:
-                    parents = list(parent_map[c])
-                assert isinstance(parents, list), \
-                        "Expected list of parents, got: %r" % parents
+                    parents = parent_map[c]
+                assert isinstance(parents, tuple), \
+                        "Expected tuple of parents, got: %r" % parents
                 # replace r in parents with replace_map[r][0]
                 if not replace_map[r][0] in parents:
-                    parents[parents.index(r)] = replace_map[r][0]
-                replace_map[c] = (generate_revid(c), parents)
+                    parents[list(parents).index(r)] = replace_map[r][0]
+                replace_map[c] = (generate_revid(c), tuple(parents))
                 assert replace_map[c][0] != c
             processed.add(r)
             # Add them to todo[]
@@ -311,7 +311,7 @@
     :param new_parents: Revision ids of the new parent revisions.
     :param revid_renames: Revision id renames for texts.
     """
-    assert isinstance(new_parents, list)
+    assert isinstance(new_parents, tuple)
     mutter('creating copy %r of %r with new parents %r' % 
                                (newrevid, oldrevid, new_parents))
     oldrev = repository.get_revision(oldrevid)

=== modified file 'test_rebase.py'
--- a/test_rebase.py	2008-05-29 14:07:18 +0000
+++ b/test_rebase.py	2008-05-29 14:23:15 +0000
@@ -75,7 +75,7 @@
 
         wt.branch.repository.lock_write()
         newrev = replay_snapshot(wt.branch.repository, "bla2", "bla4", 
-                ["bloe"], {"bla": "bloe"})
+                ("bloe",), {"bla": "bloe"})
         self.assertEqual("bla4", newrev)
         self.assertTrue(wt.branch.repository.has_revision(newrev))
         self.assertEqual(("bloe",), 
@@ -172,7 +172,7 @@
         b.repository.unlock()
 
     def test_generate_transpose_plan_one(self):
-        graph = Graph(DictParentsProvider({"bla": ["bloe"], "bloe": [], "lala": []}))
+        graph = Graph(DictParentsProvider({"bla": ("bloe",), "bloe": (), "lala": ()}))
         self.assertEquals({"bla": ("newbla", ["lala"])},
                 generate_transpose_plan(graph.iter_ancestry(["bla", "bloe"]),
                     {"bloe": "lala"}, graph, lambda y: "new"+y))
@@ -353,7 +353,7 @@
         wt.add(["afile"])
         wt.commit("bla", rev_id="oldcommit")
         wt.branch.repository.lock_write()
-        replay_snapshot(wt.branch.repository, "oldcommit", "newcommit", [],
+        replay_snapshot(wt.branch.repository, "oldcommit", "newcommit", (),
                         {})
         wt.branch.repository.unlock()
         oldrev = wt.branch.repository.get_revision("oldcommit")
@@ -383,7 +383,7 @@
         self.assertRaises(
                 ReplayParentsInconsistent, replay_snapshot, 
                 wt.branch.repository, "oldcommit", "newcommit", 
-                ["base"], {"oldparent": "base"})
+                ("base",), {"oldparent": "base"})
         wt.branch.repository.unlock()
 
     def test_two_revisions(self):
@@ -401,7 +401,7 @@
         wt.branch.repository.fetch(oldrepos)
         wt.branch.repository.lock_write()
         replay_snapshot(wt.branch.repository, "oldcommit", "newcommit", 
-                ["newparent"], {"oldparent": "newparent"})
+                ("newparent",), {"oldparent": "newparent"})
         wt.branch.repository.unlock()
         oldrev = wt.branch.repository.get_revision("oldcommit")
         newrev = wt.branch.repository.get_revision("newcommit")
@@ -431,7 +431,7 @@
         self.assertRaises(ReplayParentsInconsistent, 
                           replay_snapshot, wt.branch.repository, 
                           "oldcommit", "newcommit", 
-                        ["newparent"], revid_renames={})
+                        ("newparent",), revid_renames={})
         wt.branch.repository.unlock()
 
     def test_multi_revisions(self):
@@ -455,7 +455,7 @@
         wt.branch.repository.fetch(oldrepos)
         wt.branch.repository.lock_write()
         replay_snapshot(wt.branch.repository, "oldcommit", "newcommit", 
-                ["newparent"], {"oldgrandparent": "newgrandparent", 
+                ("newparent",), {"oldgrandparent": "newgrandparent", 
                                 "oldparent": "newparent"})
         wt.branch.repository.unlock()
         oldrev = wt.branch.repository.get_revision("oldcommit")
@@ -486,7 +486,7 @@
         wt.branch.repository.fetch(oldrepos)
         wt.branch.repository.lock_write()
         replay_snapshot(wt.branch.repository, "oldcommit", "newcommit", 
-                ["newparent"], {"oldparent": "newparent"})
+                ("newparent",), {"oldparent": "newparent"})
         wt.branch.repository.unlock()
         oldrev = wt.branch.repository.get_revision("oldcommit")
         newrev = wt.branch.repository.get_revision("newcommit")




More information about the bazaar-commits mailing list