[Pkg-bazaar-commits] ./bzr/unstable r191: more XML performance tests
mbp at sourcefrog.net
mbp at sourcefrog.net
Fri Apr 10 07:44:03 UTC 2009
------------------------------------------------------------
revno: 191
committer: mbp at sourcefrog.net
timestamp: Thu 2005-04-07 16:16:02 +1000
message:
more XML performance tests
modified:
bzrlib/commands.py
bzrlib/newinventory.py
-------------- next part --------------
=== modified file 'bzrlib/commands.py'
--- a/bzrlib/commands.py 2005-04-06 14:06:32 +0000
+++ b/bzrlib/commands.py 2005-04-07 06:16:02 +0000
@@ -454,6 +454,9 @@
Branch('.').basis_tree().inventory
+def cmd_dump_inventory():
+ Branch('.').read_working_inventory().write_xml(sys.stdout)
+
def cmd_dump_new_inventory():
import bzrlib.newinventory
=== modified file 'bzrlib/newinventory.py'
--- a/bzrlib/newinventory.py 2005-04-07 05:56:55 +0000
+++ b/bzrlib/newinventory.py 2005-04-07 06:16:02 +0000
@@ -62,12 +62,22 @@
f.write('\n')
+
+def escape_attr(text):
+ return text.replace("&", "&") \
+ .replace("'", "'") \
+ .replace('"', """) \
+ .replace("<", "<") \
+ .replace(">", ">")
+
+
# This writes out an inventory without building an XML tree first,
# just to see if it's faster. Not currently used.
def write_slacker_inventory(inv, f):
def descend(ie):
kind = ie.kind
- f.write('<%s name="%s" id="%s" ' % (kind, ie.name, ie.file_id))
+ f.write('<%s name="%s" id="%s" ' % (kind, escape_attr(ie.name),
+ escape_attr(ie.file_id)))
if kind == 'file':
if ie.text_id:
@@ -90,7 +100,7 @@
bailout('unknown InventoryEntry kind %r' % kind)
f.write('<inventory>\n')
- f.write('<root_directory id="bogus-root-id">\n')
+ f.write('<root_directory id="%s">\n' % escape_attr(inv.root.file_id))
l = inv.root.children.items()
l.sort()
More information about the Pkg-bazaar-commits
mailing list