Rev 4238: Stop-gap fix for Repository.get_revision_xml in http://bazaar.launchpad.net/~vila/bzr/integration/

Vincent Ladeuil v.ladeuil+lp at free.fr
Thu Apr 2 14:57:04 BST 2009


At http://bazaar.launchpad.net/~vila/bzr/integration/

------------------------------------------------------------
revno: 4238 [merge]
revision-id: v.ladeuil+lp at free.fr-20090402135702-z4o6v81p439b0ey8
parent: pqm at pqm.ubuntu.com-20090402093220-mqwls6dsncdfegbq
parent: v.ladeuil+lp at free.fr-20090402102108-g0xrarrluckwgxvs
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: trunk
timestamp: Thu 2009-04-02 15:57:02 +0200
message:
  Stop-gap fix for Repository.get_revision_xml
modified:
  bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
------------------------------------------------------------
Use --levels 0 (or -n0) to see merged revisions.
-------------- next part --------------
=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py	2009-04-01 15:14:38 +0000
+++ b/bzrlib/repository.py	2009-04-02 10:21:08 +0000
@@ -16,6 +16,7 @@
 
 from bzrlib.lazy_import import lazy_import
 lazy_import(globals(), """
+import cStringIO
 import re
 import time
 
@@ -1635,13 +1636,20 @@
 
     @needs_read_lock
     def get_revision_xml(self, revision_id):
-        """Return the XML representation of a revision.
-
-        :param revision_id: Revision for which to return the XML.
-        :return: XML string
-        """
-        return self._serializer.write_revision_to_string(
-            self.get_revision(revision_id))
+        # TODO: jam 20070210 This shouldn't be necessary since get_revision
+        #       would have already do it.
+        # TODO: jam 20070210 Just use _serializer.write_revision_to_string()
+        # TODO: this can't just be replaced by:
+        # return self._serializer.write_revision_to_string(
+        #     self.get_revision(revision_id))
+        # as cStringIO preservers the encoding unlike write_revision_to_string
+        # or some other call down the path.
+        rev = self.get_revision(revision_id)
+        rev_tmp = cStringIO.StringIO()
+        # the current serializer..
+        self._serializer.write_revision(rev, rev_tmp)
+        rev_tmp.seek(0)
+        return rev_tmp.getvalue()
 
     def get_deltas_for_revisions(self, revisions, specific_fileids=None):
         """Produce a generator of revision deltas.



More information about the bazaar-commits mailing list