[REVIEW][0.8.1] Patch to fix assertion bugs in various get_ancestry calls

Olaf Conradi olaf at conradi.org
Sat May 13 12:37:55 BST 2006


Hi

Fixes agains bzr 0.8 for ancestry.

Fixes Bug #44443:
Don't put critical functionality inside assert statements

This puts the same check in pending merges and removes the None revision
from the bzr ancestry command.

I can merge this inside my integration branch for 0.8 along with the
other fixes if you want.

For bzr.dev I'll add a location argument to bzr ancestry.

Cheers
 -Olaf

-------------- next part --------------
=== modified file 'NEWS'
--- NEWS	
+++ NEWS	
@@ -7,6 +7,14 @@
 
     * Nicer messages from 'commit' in the case of renames, and correct
       messages when a merge has occured. (Robert Collins, Martin Pool)
+
+    * Separate functionality from assert statements as they are skipped in
+      optimized mode of python. Add the same check to pending merges.
+      (#44443, Olaf Conradi)
+
+  CHANGES:
+
+    * Do not show the None revision in output of bzr ancestry. (Olaf Conradi)
 
   INTERNALS:
 

=== modified file 'bzrlib/builtins.py'
--- bzrlib/builtins.py	
+++ bzrlib/builtins.py	
@@ -883,7 +883,10 @@
         tree = WorkingTree.open_containing(u'.')[0]
         b = tree.branch
         # FIXME. should be tree.last_revision
-        for revision_id in b.repository.get_ancestry(b.last_revision()):
+        revision_ids = b.repository.get_ancestry(b.last_revision())
+        assert revision_ids[0] == None
+        revision_ids.pop(0)
+        for revision_id in revision_ids:
             print revision_id
 
 

=== modified file 'bzrlib/repository.py'
--- bzrlib/repository.py	
+++ bzrlib/repository.py	
@@ -1463,7 +1463,8 @@
         target_ids = set(self.target.all_revision_ids())
         if revision_id is not None:
             source_ids = self.source.get_ancestry(revision_id)
-            assert source_ids.pop(0) == None
+            assert source_ids[0] == None
+            source_ids.pop(0)
         else:
             source_ids = self.source.all_revision_ids()
         result_set = set(source_ids).difference(target_ids)
@@ -1572,7 +1573,8 @@
         # - RBC 20060209
         if revision_id is not None:
             source_ids = self.source.get_ancestry(revision_id)
-            assert source_ids.pop(0) == None
+            assert source_ids[0] == None
+            source_ids.pop(0)
         else:
             source_ids = self.source._all_possible_ids()
         source_ids_set = set(source_ids)
@@ -1634,7 +1636,8 @@
         """See InterRepository.missing_revision_ids()."""
         if revision_id is not None:
             source_ids = self.source.get_ancestry(revision_id)
-            assert source_ids.pop(0) == None
+            assert source_ids[0] == None
+            source_ids.pop(0)
         else:
             source_ids = self.source._all_possible_ids()
         source_ids_set = set(source_ids)

=== modified file 'bzrlib/status.py'
--- bzrlib/status.py	
+++ bzrlib/status.py	
@@ -171,6 +171,8 @@
             m_revision = branch.repository.get_revision(merge)
             print >> to_file, ' ', line_log(m_revision, 77)
             inner_merges = branch.repository.get_ancestry(merge)
+            assert inner_merges[0] == None
+            inner_merges.pop(0)
             inner_merges.reverse()
             for mmerge in inner_merges:
                 if mmerge in ignore:

=== modified file 'bzrlib/tests/blackbox/test_ancestry.py'
--- bzrlib/tests/blackbox/test_ancestry.py	
+++ bzrlib/tests/blackbox/test_ancestry.py	
@@ -37,4 +37,13 @@
         a_wt.commit('modified A/foo',rev_id='A2')
         merge(['B',-1],['B',1],this_dir='A')
         a_wt.commit('merged B into A',rev_id='A3')
-        self.run_bzr('ancestry')
+        os.chdir('A')
+        out, err = self.run_bzr('ancestry')
+        self.assertEquals(err, '')
+        self.assertEqualDiff(out,
+"""A1
+B1
+A2
+A3
+""")
+



More information about the bazaar mailing list