[Pkg-bazaar-commits] ./bzr/unstable r192: - exercise the network more towards doing a remote clone

mbp at sourcefrog.net mbp at sourcefrog.net
Fri Apr 10 07:44:03 UTC 2009


------------------------------------------------------------
revno: 192
committer: mbp at sourcefrog.net
timestamp: Thu 2005-04-07 17:08:53 +1000
message:
  - exercise the network more towards doing a remote clone
modified:
  bzrlib/remotebranch.py
-------------- next part --------------
=== modified file 'bzrlib/remotebranch.py'
--- a/bzrlib/remotebranch.py	2005-04-07 05:47:05 +0000
+++ b/bzrlib/remotebranch.py	2005-04-07 07:08:53 +0000
@@ -22,41 +22,71 @@
 
 
 import urllib2, gzip, zlib
+from sets import Set
+from cStringIO import StringIO
 
 from errors import BzrError
 from revision import Revision
-from cStringIO import StringIO
+from inventory import Inventory
 
 # h = HTTPConnection('localhost:8000')
 # h = HTTPConnection('bazaar-ng.org')
 
 
-prefix = 'http://bazaar-ng.org/bzr/main'
+# prefix = 'http://localhost:8000'
+prefix = 'http://bazaar-ng.org/bzr/main/'
 
-def get_url(path):
+def get_url(path, compressed=False):
     try:
         url = prefix + path
-        return urllib2.urlopen(url)
+        if compressed:
+            url += '.gz'
+        url_f = urllib2.urlopen(url)
+        if not compressed:
+            return url_f
+        else:
+            return gzip.GzipFile(fileobj=StringIO(url_f.read()))
     except urllib2.URLError, e:
         raise BzrError("remote fetch failed: %r: %s" % (url, e))
 
+
+got_invs = Set()
+got_texts = Set()
+
 print 'read history'
-history = get_url('/.bzr/revision-history').read().split('\n')
+history = get_url('/.bzr/revision-history').readlines()
+num_revs = len(history)
 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()
+    rev_id = rev_id.rstrip()
+    print 'read revision %d/%d' % (i, num_revs)
 
     # 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_f = get_url('/.bzr/revision-store/%s' % rev_id,
+                    compressed=True)
 
-    rev = Revision.read_xml(uncomp_f)
+    rev = Revision.read_xml(rev_f)
     print rev.message
+    inv_id = rev.inventory_id
+    if inv_id not in got_invs:
+        print 'get inventory %s' % inv_id
+        inv_f = get_url('/.bzr/inventory-store/%s' % inv_id,
+                        compressed=True)
+        inv = Inventory.read_xml(inv_f)
+        print '%4d inventory entries' % len(inv)
+
+        for path, ie in inv.iter_entries():
+            text_id = ie.text_id
+            if text_id == None:
+                continue
+            if text_id in got_texts:
+                continue
+            print '  fetch %s text {%s}' % (path, text_id)
+            text_f = get_url('/.bzr/text-store/%s' % text_id,
+                             compressed=True)
+            got_texts.add(text_id)
+            
+        got_invs.add(inv_id)
+
     print '----'
-    
-    
-    
-
-



More information about the Pkg-bazaar-commits mailing list