[Pkg-bazaar-commits] ./bzr/unstable r188: - experimental remote-branch support
mbp at sourcefrog.net
mbp at sourcefrog.net
Fri Apr 10 07:44:04 UTC 2009
------------------------------------------------------------
revno: 188
committer: mbp at sourcefrog.net
timestamp: Thu 2005-04-07 15:47:05 +1000
message:
- experimental remote-branch support
- fix up newinventory code
added:
bzrlib/remotebranch.py
modified:
bzrlib/newinventory.py
-------------- next part --------------
=== modified file 'bzrlib/newinventory.py'
--- a/bzrlib/newinventory.py 2005-03-30 23:34:24 +0000
+++ b/bzrlib/newinventory.py 2005-04-07 05:47:05 +0000
@@ -20,7 +20,7 @@
def write_inventory(inv, f):
el = Element('inventory', {'version': '2'})
- root = Element('root_directory', {'id': 'bogus-root-id'})
+ root = Element('root_directory', {'id': inv.root.file_id})
el.append(root)
def descend(parent_el, ie):
@@ -59,7 +59,8 @@
f.write('\n')
-
+# 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
=== added file 'bzrlib/remotebranch.py'
--- a/bzrlib/remotebranch.py 1970-01-01 00:00:00 +0000
+++ b/bzrlib/remotebranch.py 2005-04-07 05:47:05 +0000
@@ -0,0 +1,62 @@
+# Copyright (C) 2005 Canonical Ltd
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+## XXX: This is pretty slow on high-latency connections because it
+## doesn't keep the HTTP connection alive. If you have a smart local
+## proxy it may be much better. Eventually I want to switch to
+## urlgrabber which should use HTTP much more efficiently.
+
+
+import urllib2, gzip, zlib
+
+from errors import BzrError
+from revision import Revision
+from cStringIO import StringIO
+
+# h = HTTPConnection('localhost:8000')
+# h = HTTPConnection('bazaar-ng.org')
+
+
+prefix = 'http://bazaar-ng.org/bzr/main'
+
+def get_url(path):
+ try:
+ url = prefix + path
+ return urllib2.urlopen(url)
+ except urllib2.URLError, e:
+ raise BzrError("remote fetch failed: %r: %s" % (url, e))
+
+print 'read history'
+history = get_url('/.bzr/revision-history').read().split('\n')
+for i, rev_id in enumerate(history):
+ print 'read revision %d' % i
+ comp_f = get_url('/.bzr/revision-store/%s.gz' % rev_id)
+ comp_data = comp_f.read()
+
+ # python gzip needs a seekable file (!!) but the HTTP response
+ # isn't, so we need to buffer it
+
+ uncomp_f = gzip.GzipFile(fileobj=StringIO(comp_data))
+
+ rev = Revision.read_xml(uncomp_f)
+ print rev.message
+ print '----'
+
+
+
+
+
More information about the Pkg-bazaar-commits
mailing list