Rev 19: - Add blackbox tests in file:///data/jelmer/bzr-rebase/trunk/

Jelmer Vernooij jelmer at samba.org
Thu Jul 12 09:22:43 BST 2007


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

------------------------------------------------------------
revno: 19
revision-id: jelmer at samba.org-20070709204402-2gnnfvop0j2mgoe2
parent: jelmer at samba.org-20070709201858-0hsbv48mwm09vt16
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Mon 2007-07-09 21:44:02 +0100
message:
  - Add blackbox tests
  - Add verbose option to rebase
  - Support python2.4
added:
  test_blackbox.py               test_blackbox.py-20070709202607-dyvt95dfu09tuv6a-1
modified:
  __init__.py                    __init__.py-20070626215909-fi0s39bkwxn4gcto-1
  rebase.py                      rebase.py-20070626221123-ellanmf93nw8z9r1-1
=== added file 'test_blackbox.py'
--- a/test_blackbox.py	1970-01-01 00:00:00 +0000
+++ b/test_blackbox.py	2007-07-09 20:44:02 +0000
@@ -0,0 +1,53 @@
+# Copyright (C) 2007 by Jelmer Vernooij
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+"""Couple of blackbox tests for the rebase plugin."""
+
+from bzrlib.tests.blackbox import ExternalBase
+
+import os
+
+class TestRebaseSimple(ExternalBase):
+    def make_file(self, name, contents):
+        f = open(name, 'wb')
+        try:
+            f.write(contents)
+        finally:
+            f.close()
+
+    def setUp(self):
+        super(TestRebaseSimple, self).setUp()
+        os.mkdir('main')
+        os.chdir('main')
+        self.run_bzr('init')
+        self.make_file('hello', "hi world")
+        self.run_bzr('add')
+        self.run_bzr('commit -m bla')
+        self.run_bzr('branch . ../feature')
+
+    def test_notneeded(self):
+        os.chdir('../feature')
+        self.run_bzr_error(['bzr: ERROR: Already rebased on .*'], 
+                           'rebase ../main')
+
+    def test_simple_success(self):
+        self.make_file('hello', '42')
+        self.run_bzr('commit -m that')
+        os.chdir('../feature')
+        self.make_file('hoi', "my data")
+        self.run_bzr('add')
+        self.run_bzr('commit -m this')
+        self.check_output('', 'rebase ../main')
+        self.check_output('3\n', 'revno')

=== modified file '__init__.py'
--- a/__init__.py	2007-07-09 16:35:14 +0000
+++ b/__init__.py	2007-07-09 20:44:02 +0000
@@ -24,12 +24,12 @@
 
     """
     takes_args = ['upstream_location?']
-    takes_options = ['revision', 'merge-type', 
+    takes_options = ['revision', 'merge-type', 'verbose',
                      Option('onto', help='Different revision to replay onto')]
     
     @display_command
     def run(self, upstream_location=None, onto=None, revision=None, 
-            merge_type=None):
+            merge_type=None, verbose=False):
         from bzrlib.branch import Branch
         from bzrlib.revisionspec import RevisionSpec
         from bzrlib.workingtree import WorkingTree
@@ -83,6 +83,10 @@
             # Write plan file
             write_rebase_plan(wt, replace_map)
 
+            if verbose:
+                for revid in rebase_todo(wt.branch.repository, replace_map):
+                    info("%s -> %s" % (revid, replace_map[revid][0]))
+
             # Start executing plan
             try:
                 rebase(wt.branch.repository, replace_map, workingtree_replay(wt, merge_type=merge_type))
@@ -193,7 +197,7 @@
 
     loader = TestUtil.TestLoader()
     suite = TestSuite()
-    testmod_names = ['test_rebase', 'test_maptree']
+    testmod_names = ['test_blackbox', 'test_rebase', 'test_maptree']
     suite.addTest(loader.loadTestsFromModuleNames(
                               ["%s.%s" % (__name__, i) for i in testmod_names]))
 

=== modified file 'rebase.py'
--- a/rebase.py	2007-07-09 16:35:14 +0000
+++ b/rebase.py	2007-07-09 20:44:02 +0000
@@ -242,7 +242,7 @@
             i += 1
             revid = todo.pop()
             (newrevid, newparents) = replace_map[revid]
-            if not all(map(repository.has_revision, newparents)):
+            if filter(repository.has_revision, newparents) != newparents:
                 # Not all parents present yet, avoid for now
                 continue
             if repository.has_revision(newrevid):
@@ -257,8 +257,8 @@
     finally:
         pb.finished()
         
-    assert all(map(repository.has_revision, 
-               [replace_map[r][0] for r in replace_map]))
+    #assert all(map(repository.has_revision, 
+    #           [replace_map[r][0] for r in replace_map]))
 
 def replay_snapshot(repository, oldrevid, newrevid, new_parents):
     """Replay a commit by simply commiting the same snapshot with different parents.




More information about the bazaar-commits mailing list