/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/remotebranch.py

  • Committer: Martin Pool
  • Date: 2005-06-28 03:02:31 UTC
  • Revision ID: mbp@sourcefrog.net-20050628030231-d311e4ebcd467ef4
Merge John's import-speedup branch:

                                                                                         
  777 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 22:20:32 -0500
      revision-id: john@arbash-meinel.com-20050627032031-e82a50db3863b18e
      bzr selftest was not using the correct bzr

  776 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 22:20:22 -0500
      revision-id: john@arbash-meinel.com-20050627032021-c9f21fde989ddaee
      Add was using an old mutter

  775 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 22:02:33 -0500
      revision-id: john@arbash-meinel.com-20050627030233-9165cfe98fc63298
      Cleaned up to be less different

  774 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 21:54:53 -0500
      revision-id: john@arbash-meinel.com-20050627025452-4260d0e744edef43
      Allow BZR_PLUGIN_PATH='' to negate plugin loading.

  773 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 21:49:34 -0500
      revision-id: john@arbash-meinel.com-20050627024933-b7158f67b7b9eae5
      Finished the previous cleanup (allowing load_plugins to be called twice)

  772 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 21:45:08 -0500
      revision-id: john@arbash-meinel.com-20050627024508-723b1df510d196fc
      Work on making the tests pass. versioning.py is calling run_cmd directly, but plugins have been loaded.

  771 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 21:32:29 -0500
      revision-id: john@arbash-meinel.com-20050627023228-79972744d7c53e15
      Got it down a little bit more by removing import of tree and inventory.

  770 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 21:26:05 -0500
      revision-id: john@arbash-meinel.com-20050627022604-350b9773ef622f95
      Reducing the number of import from bzrlib/__init__.py and bzrlib/branch.py

  769 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 20:32:25 -0500
      revision-id: john@arbash-meinel.com-20050627013225-32dd044f10d23948
      Updated revision.py and xml.py to include SubElement.

  768 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 20:03:56 -0500
      revision-id: john@arbash-meinel.com-20050627010356-ee66919e1c377faf
      Minor typo

  767 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 20:03:13 -0500
      revision-id: john@arbash-meinel.com-20050627010312-40d024007eb85051
      Caching the import

  766 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 19:51:47 -0500
      revision-id: john@arbash-meinel.com-20050627005147-5281c99e48ed1834
      Created wrapper functions for lazy import of ElementTree

  765 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 19:46:37 -0500
      revision-id: john@arbash-meinel.com-20050627004636-bf432902004a94c5
      Removed all of the test imports of cElementTree

  764 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 19:43:59 -0500
      revision-id: john@arbash-meinel.com-20050627004358-d137fbe9570dd71b
      Trying to make bzr startup faster.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
 
39
39
ENABLE_URLGRABBER = True
40
40
 
41
 
from bzrlib.errors import BzrError
42
 
 
43
 
class GetFailed(BzrError):
44
 
    def __init__(self, url, status):
45
 
        BzrError.__init__(self, "Get %s failed with status %s" % (url, status))
46
 
        self.url = url
47
 
        self.status = status
48
41
 
49
42
if ENABLE_URLGRABBER:
50
43
    import urlgrabber
57
50
                url += '.gz'
58
51
            mutter("grab url %s" % url)
59
52
            url_f = urlgrabber.urlopen(url, keepalive=1, close_connection=0)
60
 
            if url_f.status != 200:
61
 
                raise GetFailed(url, url_f.status)
62
53
            if not compressed:
63
54
                return url_f
64
55
            else:
152
143
        pl = len(self.baseurl)
153
144
        return path[pl:].lstrip('/')
154
145
 
155
 
 
156
146
    def get_revision(self, revision_id):
157
 
        from bzrlib.revision import Revision
158
 
        from bzrlib.xml import unpack_xml
 
147
        from revision import Revision
159
148
        revf = self.revision_store[revision_id]
160
 
        r = unpack_xml(Revision, revf)
 
149
        r = Revision.read_xml(revf)
161
150
        if r.revision_id != revision_id:
162
151
            raise BzrCheckError('revision stored as {%s} actually contains {%s}'
163
152
                                % (revision_id, r.revision_id))
176
165
        
177
166
    def __getitem__(self, fileid):
178
167
        p = self._path(fileid)
179
 
        try:
180
 
            return get_url(p, compressed=True)
181
 
        except:
182
 
            raise KeyError(fileid)
 
168
        return get_url(p, compressed=True)
183
169
    
184
170
 
 
171
def simple_walk():
 
172
    """For experimental purposes, traverse many parts of a remote branch"""
 
173
    from revision import Revision
 
174
    from branch import Branch
 
175
    from inventory import Inventory
 
176
 
 
177
    got_invs = {}
 
178
    got_texts = {}
 
179
 
 
180
    print 'read history'
 
181
    history = get_url('/.bzr/revision-history').readlines()
 
182
    num_revs = len(history)
 
183
    for i, rev_id in enumerate(history):
 
184
        rev_id = rev_id.rstrip()
 
185
        print 'read revision %d/%d' % (i, num_revs)
 
186
 
 
187
        # python gzip needs a seekable file (!!) but the HTTP response
 
188
        # isn't, so we need to buffer it
 
189
 
 
190
        rev_f = get_url('/.bzr/revision-store/%s' % rev_id,
 
191
                        compressed=True)
 
192
 
 
193
        rev = Revision.read_xml(rev_f)
 
194
        print rev.message
 
195
        inv_id = rev.inventory_id
 
196
        if inv_id not in got_invs:
 
197
            print 'get inventory %s' % inv_id
 
198
            inv_f = get_url('/.bzr/inventory-store/%s' % inv_id,
 
199
                            compressed=True)
 
200
            inv = Inventory.read_xml(inv_f)
 
201
            print '%4d inventory entries' % len(inv)
 
202
 
 
203
            for path, ie in inv.iter_entries():
 
204
                text_id = ie.text_id
 
205
                if text_id == None:
 
206
                    continue
 
207
                if text_id in got_texts:
 
208
                    continue
 
209
                print '  fetch %s text {%s}' % (path, text_id)
 
210
                text_f = get_url('/.bzr/text-store/%s' % text_id,
 
211
                                 compressed=True)
 
212
                got_texts[text_id] = True
 
213
 
 
214
            got_invs.add[inv_id] = True
 
215
 
 
216
        print '----'
 
217
 
 
218
 
 
219
def try_me():
 
220
    BASE_URL = 'http://bazaar-ng.org/bzr/bzr.dev/'
 
221
    b = RemoteBranch(BASE_URL)
 
222
    ## print '\n'.join(b.revision_history())
 
223
    from log import show_log
 
224
    show_log(b)
 
225
 
 
226
 
 
227
if __name__ == '__main__':
 
228
    try_me()
185
229