58
61
raise BzrError("remote fetch failed: %r: %s" % (url, e))
65
history = get_url('/.bzr/revision-history').readlines()
66
num_revs = len(history)
67
for i, rev_id in enumerate(history):
68
rev_id = rev_id.rstrip()
69
print 'read revision %d/%d' % (i, num_revs)
71
# python gzip needs a seekable file (!!) but the HTTP response
72
# isn't, so we need to buffer it
64
class RemoteBranch(Branch):
65
def __init__(self, baseurl):
66
"""Create new proxy for a remote branch."""
67
self.baseurl = baseurl
71
def controlfile(self, filename, mode):
72
if mode not in ('rb', 'rt', 'r'):
73
raise BzrError("file mode %r not supported for remote branches" % mode)
74
return get_url(self.baseurl + '/.bzr/' + filename, False)
76
def _need_readlock(self):
77
# remote branch always safe for read
80
def _need_writelock(self):
81
raise BzrError("cannot get write lock on HTTP remote branch")
74
rev_f = get_url('/.bzr/revision-store/%s' % rev_id,
77
rev = Revision.read_xml(rev_f)
79
inv_id = rev.inventory_id
80
if inv_id not in got_invs:
81
print 'get inventory %s' % inv_id
82
inv_f = get_url('/.bzr/inventory-store/%s' % inv_id,
90
history = get_url('/.bzr/revision-history').readlines()
91
num_revs = len(history)
92
for i, rev_id in enumerate(history):
93
rev_id = rev_id.rstrip()
94
print 'read revision %d/%d' % (i, num_revs)
96
# python gzip needs a seekable file (!!) but the HTTP response
97
# isn't, so we need to buffer it
99
rev_f = get_url('/.bzr/revision-store/%s' % rev_id,
84
inv = Inventory.read_xml(inv_f)
85
print '%4d inventory entries' % len(inv)
87
for path, ie in inv.iter_entries():
91
if text_id in got_texts:
93
print ' fetch %s text {%s}' % (path, text_id)
94
text_f = get_url('/.bzr/text-store/%s' % text_id,
96
got_texts.add(text_id)
102
rev = Revision.read_xml(rev_f)
104
inv_id = rev.inventory_id
105
if inv_id not in got_invs:
106
print 'get inventory %s' % inv_id
107
inv_f = get_url('/.bzr/inventory-store/%s' % inv_id,
109
inv = Inventory.read_xml(inv_f)
110
print '%4d inventory entries' % len(inv)
112
for path, ie in inv.iter_entries():
116
if text_id in got_texts:
118
print ' fetch %s text {%s}' % (path, text_id)
119
text_f = get_url('/.bzr/text-store/%s' % text_id,
121
got_texts.add(text_id)
129
b = RemoteBranch(BASE_URL)
130
print '\n'.join(b.revision_history())
133
if __name__ == '__main__':