[Pkg-bazaar-commits] ./bzr/unstable r816: - don't write precursor field in new revision xml

Martin Pool mbp at sourcefrog.net
Fri Apr 10 08:21:06 UTC 2009


------------------------------------------------------------
revno: 816
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Mon 2005-07-04 21:57:18 +1000
message:
  - don't write precursor field in new revision xml
  - make parents more primary; remove more precursor code
  - test commit of revision with parents
modified:
  bzrlib/commit.py
  bzrlib/revision.py
  bzrlib/selftest/whitebox.py
-------------- next part --------------
=== modified file 'bzrlib/commit.py'
--- a/bzrlib/commit.py	2005-07-04 08:06:51 +0000
+++ b/bzrlib/commit.py	2005-07-04 11:57:18 +0000
@@ -143,10 +143,13 @@
                        inventory_sha1=inv_sha1,
                        revision_id=rev_id)
 
+        rev.parents = []
         precursor_id = branch.last_patch()
         if precursor_id:
             precursor_sha1 = branch.get_revision_sha1(precursor_id)
-            rev.parents = [RevisionReference(precursor_id, precursor_sha1)]
+            rev.parents.append(RevisionReference(precursor_id, precursor_sha1))
+        for merge_rev in pending_merges:
+            rev.parents.append(RevisionReference(merge_rev))            
 
         rev_tmp = tempfile.TemporaryFile()
         pack_xml(rev, rev_tmp)

=== modified file 'bzrlib/revision.py'
--- a/bzrlib/revision.py	2005-07-04 07:41:50 +0000
+++ b/bzrlib/revision.py	2005-07-04 11:57:18 +0000
@@ -25,7 +25,7 @@
     """
     revision_id = None
     revision_sha1 = None
-    def __init__(self, revision_id, revision_sha1):
+    def __init__(self, revision_id, revision_sha1=None):
         if revision_id == None \
            or isinstance(revision_id, basestring):
             self.revision_id = revision_id
@@ -49,9 +49,6 @@
     into the file it describes.
 
     After bzr 0.0.5 revisions are allowed to have multiple parents.
-    To support old clients this is written out in a slightly redundant
-    form: the first parent as the predecessor.  This will eventually
-    be dropped.
 
     parents
         List of parent revisions, each is a RevisionReference.
@@ -68,32 +65,6 @@
         self.__dict__.update(args)
         self.parents = []
 
-    def _get_precursor(self):
-        from warnings import warn
-        warn("Revision.precursor is deprecated", stacklevel=2)
-        if self.parents:
-            return self.parents[0].revision_id
-        else:
-            return None
-
-
-    def _get_precursor_sha1(self):
-        from warnings import warn
-        warn("Revision.precursor_sha1 is deprecated", stacklevel=2)
-        if self.parents:
-            return self.parents[0].revision_sha1
-        else:
-            return None    
-
-
-    def _fail(self):
-        raise Exception("can't assign to precursor anymore")
-
-
-    precursor = property(_get_precursor, _fail, _fail)
-    precursor_sha1 = property(_get_precursor_sha1, _fail, _fail)
-
-
 
     def __repr__(self):
         return "<Revision id %s>" % self.revision_id
@@ -118,15 +89,6 @@
         msg.tail = '\n'
 
         if self.parents:
-            # first parent stored as precursor for compatability with 0.0.5 and
-            # earlier
-            pr = self.parents[0]
-            assert pr.revision_id
-            root.set('precursor', pr.revision_id)
-            if pr.revision_sha1:
-                root.set('precursor_sha1', pr.revision_sha1)
-                
-        if self.parents:
             pelts = SubElement(root, 'parents')
             pelts.tail = pelts.text = '\n'
             for rr in self.parents:
@@ -168,12 +130,7 @@
 
     pelts = elt.find('parents')
 
-    if precursor:
-        # revisions written prior to 0.0.5 have a single precursor
-        # give as an attribute
-        rev_ref = RevisionReference(precursor, precursor_sha1)
-        rev.parents.append(rev_ref)
-    elif pelts:
+    if pelts:
         for p in pelts:
             assert p.tag == 'revision_ref', \
                    "bad parent node tag %r" % p.tag
@@ -181,6 +138,16 @@
                                         p.get('revision_sha1'))
             rev.parents.append(rev_ref)
 
+        if precursor:
+            # must be consistent
+            prec_parent = rev.parents[0].revision_id
+            assert prec_parent == precursor
+    elif precursor:
+        # revisions written prior to 0.0.5 have a single precursor
+        # give as an attribute
+        rev_ref = RevisionReference(precursor, precursor_sha1)
+        rev.parents.append(rev_ref)
+
     v = elt.get('timezone')
     rev.timezone = v and int(v)
 

=== modified file 'bzrlib/selftest/whitebox.py'
--- a/bzrlib/selftest/whitebox.py	2005-07-04 08:06:51 +0000
+++ b/bzrlib/selftest/whitebox.py	2005-07-04 11:57:18 +0000
@@ -64,6 +64,16 @@
         self.assertEquals(b.pending_merges(),
                           ['foo at azkhazan-123123-abcabc',
                            'wibble at fofof--20050401--1928390812'])
+
+        b.commit("commit from base with two merges")
+
+        rev = b.get_revision(b.revision_history()[0])
+        self.assertEquals(len(rev.parents), 2)
+        self.assertEquals(rev.parents[0].revision_id,
+                          'foo at azkhazan-123123-abcabc')
+        self.assertEquals(rev.parents[1].revision_id,
+                           'wibble at fofof--20050401--1928390812')
+        
         
 
 class Revert(InTempDir):



More information about the Pkg-bazaar-commits mailing list