Rev 43: Add stop_revid argumen to generate_simple_plan. in file:///data/jelmer/bzr-rebase/trunk/

Jelmer Vernooij jelmer at samba.org
Thu Aug 2 19:15:02 BST 2007


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

------------------------------------------------------------
revno: 43
revision-id: jelmer at samba.org-20070802181500-0ooc82u2xaz1nquu
parent: jelmer at samba.org-20070802121510-ybt147lrfpcyuq8n
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Thu 2007-08-02 19:15:00 +0100
message:
  Add stop_revid argumen to generate_simple_plan.
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	2007-08-02 10:49:41 +0000
+++ b/__init__.py	2007-08-02 18:15:00 +0000
@@ -84,6 +84,7 @@
         wt.lock_write()
         if upstream_location is None:
             upstream_location = wt.branch.get_parent()
+            info("Rebasing on %s" % upstream_location)
         upstream = Branch.open(upstream_location)
         upstream_repository = upstream.repository
         upstream_revision = upstream.last_revision()
@@ -118,10 +119,11 @@
 
             start_revid = wt.branch.get_rev_id(
                     wt.branch.revision_id_to_revno(common_revid)+1)
+            stop_revid = wt.branch.last_revision()
 
             # Create plan
             replace_map = generate_simple_plan(
-                    wt.branch.revision_history(), start_revid, onto,
+                    wt.branch.revision_history(), start_revid, stop_revid, onto,
                     wt.branch.repository.get_ancestry(onto),
                     wt.branch.repository.revision_parents,
                     lambda revid: regenerate_default_revid(wt.branch.repository, revid)

=== modified file 'rebase.py'
--- a/rebase.py	2007-08-02 12:15:10 +0000
+++ b/rebase.py	2007-08-02 18:15:00 +0000
@@ -118,13 +118,14 @@
     return gen_revision_id(rev.committer, rev.timestamp)
 
 
-def generate_simple_plan(history, start_revid, onto_revid, 
+def generate_simple_plan(history, start_revid, stop_revid, onto_revid, 
                          onto_ancestry, get_parents, generate_revid):
     """Create a simple rebase plan that replays history based 
     on one revision being replayed on top of another.
 
     :param history: Revision history
     :param start_revid: Id of revision at which to start replaying
+    :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
@@ -134,9 +135,16 @@
     """
     assert start_revid in history
     replace_map = {}
-    i = history.index(start_revid)
+    if start_revid is not None:
+        start_revno = history.index(start_revid)
+    else:
+        start_revno = None
+    if stop_revid is not None:
+        stop_revno = history.index(stop_revid)+1
+    else:
+        stop_revno = None
     new_parent = onto_revid
-    for oldrevid in history[i:]: 
+    for oldrevid in history[start_revno:stop_revno]: 
         parents = get_parents(oldrevid)
         assert len(parents) == 0 or \
                 parents[0] == history[history.index(oldrevid)-1]

=== modified file 'test_rebase.py'
--- a/test_rebase.py	2007-08-02 12:15:10 +0000
+++ b/test_rebase.py	2007-08-02 18:15:00 +0000
@@ -95,7 +95,8 @@
         wt.commit(message='change hello', rev_id="bla2")
 
         self.assertEquals({'bla2': ('newbla2', ["bloe"])}, 
-                generate_simple_plan(b.revision_history(), "bla2", "bloe", 
+                generate_simple_plan(b.revision_history(), "bla2", None, 
+                    "bloe", 
                     ["bloe", "bla"],
                     b.repository.revision_parents, 
                     lambda y: "new"+y))
@@ -116,7 +117,7 @@
         wt.commit(message='change hello again', rev_id="bla3")
 
         self.assertEquals({'bla2': ('newbla2', ["bloe"]), 'bla3': ('newbla3', ['newbla2'])}, 
-                generate_simple_plan(b.revision_history(), "bla2", "bloe", 
+                generate_simple_plan(b.revision_history(), "bla2", None, "bloe", 
                     ["bloe", "bla"],
                     b.repository.revision_parents,
                     lambda y: "new"+y))
@@ -190,7 +191,7 @@
         }
         self.assertEquals({"D": ("D'", ["C"]), "E": ("E'", ["D'"])}, 
                 generate_simple_plan(["A", "D", "E"], 
-                                     "D", "C", ["A", "B", "C"], 
+                                     "D", None, "C", ["A", "B", "C"], 
                     parents_map.get, lambda y: y+"'"))
  
 




More information about the bazaar-commits mailing list