[Pkg-bazaar-commits] ./bzr/unstable r697: - write out parent list for new revisions
Martin Pool
mbp at sourcefrog.net
Fri Apr 10 08:20:45 UTC 2009
------------------------------------------------------------
revno: 697
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Fri 2005-06-17 20:10:09 +1000
message:
- write out parent list for new revisions
- don't assign to the Revision.precursor property in commit but rather
store parents
This is done in a way that should support old clients; the precursor
property is still present
modified:
bzrlib/commit.py
bzrlib/revision.py
-------------- next part --------------
=== modified file 'bzrlib/commit.py'
--- a/bzrlib/commit.py 2005-06-11 01:39:37 +0000
+++ b/bzrlib/commit.py 2005-06-17 10:10:09 +0000
@@ -55,12 +55,11 @@
import time, tempfile
- from osutils import local_time_offset, username
-
- from branch import gen_file_id
- from errors import BzrError
- from revision import Revision
- from trace import mutter, note
+ from bzrlib.osutils import local_time_offset, username
+ from bzrlib.branch import gen_file_id
+ from bzrlib.errors import BzrError
+ from bzrlib.revision import Revision, RevisionReference
+ from bzrlib.trace import mutter, note
branch.lock_write()
@@ -119,11 +118,12 @@
# ever actually does anything special
inv_sha1 = branch.get_inventory_sha1(inv_id)
- precursor = branch.last_patch()
- if precursor:
- precursor_sha1 = branch.get_revision_sha1(precursor)
+ precursor_id = branch.last_patch()
+ if precursor_id:
+ precursor_sha1 = branch.get_revision_sha1(precursor_id)
else:
precursor_sha1 = None
+ parent = RevisionReference(precursor_id, precursor_sha1)
branch._write_inventory(work_inv)
@@ -140,12 +140,11 @@
rev = Revision(timestamp=timestamp,
timezone=timezone,
committer=committer,
- precursor = precursor,
- precursor_sha1 = precursor_sha1,
message = message,
inventory_id=inv_id,
inventory_sha1=inv_sha1,
revision_id=rev_id)
+ rev.parents = [parent]
rev_tmp = tempfile.TemporaryFile()
rev.write_xml(rev_tmp)
=== modified file 'bzrlib/revision.py'
--- a/bzrlib/revision.py 2005-06-17 09:36:41 +0000
+++ b/bzrlib/revision.py 2005-06-17 10:10:09 +0000
@@ -58,7 +58,10 @@
written out. This is not stored because you cannot write the hash
into the file it describes.
- TODO: Perhaps make precursor be a child element, not an attribute?
+ 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;
@@ -92,8 +95,14 @@
else:
return None
- precursor = property(_get_precursor)
- precursor_sha1 = property(_get_precursor_sha1)
+
+ 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):
@@ -120,6 +129,15 @@
msg.text = self.message
msg.tail = '\n'
+ if self.parents:
+ pelts = SubElement(root, 'parents')
+ for rr in self.parents:
+ assert isinstance(rr, RevisionReference)
+ p = SubElement(pelts, 'revision_ref')
+ p.set('revision_id', rr.revision_id)
+ if rr.revision_sha1:
+ p.set('revision_sha1', rr.revision_sha1)
+
return root
@@ -155,7 +173,7 @@
rev.parents.append(rev_ref)
elif pelts:
for p in pelts:
- assert p.tag == 'revisionref', \
+ assert p.tag == 'revision_ref', \
"bad parent node tag %r" % p.tag
rev_ref = RevisionReference(p.get('revision_id'),
p.get('revision_sha1'))
More information about the Pkg-bazaar-commits
mailing list