/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/xml6.py

  • Committer: v.ladeuil+lp at free
  • Date: 2006-10-12 14:29:32 UTC
  • mto: (2145.1.1 keepalive)
  • mto: This revision was merged to the branch mainline in revision 2146.
  • Revision ID: v.ladeuil+lp@free.fr-20061012142932-7221fe16d2b48fa3
Shuffle http related test code. Hopefully it ends up at the right place :)

* bzrlib/tests/HttpServer.py: 
New file. bzrlib.tests.ChrootedTestCase use HttpServer. So the
class can't be defined in bzrlib.tests.HTTPUtils because it
creates a circular dependency (bzrlib.tests.HTTPUtils needs to
import bzrlib.tests).

* bzrlib/transport/http/_urllib.py: 
Transfer test server definition to bzrlib.tests.HttpServer. Clean
up imports.

* bzrlib/transport/http/_pycurl.py: 
Transfer test server definition to bzrlib.tests.HttpServer. Clean
up imports.

* bzrlib/transport/http/__init__.py: 
Transfer all test related code to either bzrlib.tests.HttpServer
and bzrlib.tests.HTTPUtils.
Fix all use of TransportNotPossible and InvalidURL by prefixing it
by 'errors.' (this seems to be the preferred way in the rest of
bzr).
Get rid of unused imports.

* bzrlib/tests/test_transport.py:
(ReadonlyDecoratorTransportTest.test_local_parameters,
FakeNFSDecoratorTests.test_http_parameters): Use HttpServer from
bzrlib.tests.HttpServer instead of bzrlib.transport.http.

* bzrlib/tests/test_sftp_transport.py:
(set_test_transport_to_sftp): Use HttpServer from
bzrlib.tests.HttpServer instead of bzrlib.transport.http.

* bzrlib/tests/test_selftest.py:
(TestTestCaseWithTransport.test_get_readonly_url_http): Use
HttpServer from bzrlib.tests.HttpServer instead of
bzrlib.transport.http.

* bzrlib/tests/test_repository.py: 
Does *not* use HttpServer.

* bzrlib/tests/test_http.py: 
Build on top of bzrlib.tests.HttpServer and bzrlib.tests.HTTPUtils
instead of bzrlib.transport.http.

* bzrlib/tests/test_bzrdir.py:
(ChrootedTests.setUp): Use HttpServer from bzrlib.tests.HttpServer
instead of bzrlib.transport.http.

* bzrlib/tests/branch_implementations/test_http.py:
(HTTPBranchTests.setUp): Use HttpServer from bzrlib.tests.HttpServer
instead of bzrlib.transport.http.

* bzrlib/tests/branch_implementations/test_branch.py:
(ChrootedTests.setUp): Use HttpServer from bzrlib.tests.HttpServer
instead of bzrlib.transport.http.

* bzrlib/tests/__init__.py:
(ChrootedTestCase.setUp): Use HttpServer from
bzrlib.tests.HttpServer instead of bzrlib.transport.http.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from bzrlib import cache_utf8, inventory, errors, xml5
 
2
 
 
3
 
 
4
class Serializer_v6(xml5.Serializer_v5):
 
5
 
 
6
    def _append_inventory_root(self, append, inv):
 
7
        """Append the inventory root to output."""
 
8
        append('<inventory')
 
9
        append(' format="6"')
 
10
        if inv.revision_id is not None:
 
11
            append(' revision_id="')
 
12
            append(xml5._encode_and_escape(inv.revision_id))
 
13
        append('>\n')
 
14
        self._append_entry(append, inv.root)
 
15
 
 
16
    def _parent_condition(self, ie):
 
17
        return ie.parent_id is not None
 
18
 
 
19
    def _unpack_inventory(self, elt):
 
20
        """Construct from XML Element"""
 
21
        if elt.tag != 'inventory':
 
22
            raise errors.UnexpectedInventoryFormat('Root tag is %r' % elt.tag)
 
23
        format = elt.get('format')
 
24
        if format != '6':
 
25
            raise errors.UnexpectedInventoryFormat('Invalid format version %r'
 
26
                                                   % format)
 
27
        revision_id = elt.get('revision_id')
 
28
        if revision_id is not None:
 
29
            revision_id = cache_utf8.get_cached_unicode(revision_id)
 
30
        inv = inventory.Inventory(root_id=None, revision_id=revision_id)
 
31
        for e in elt:
 
32
            ie = self._unpack_entry(e, none_parents=True)
 
33
            inv.add(ie)
 
34
        return inv
 
35
 
 
36
 
 
37
serializer_v6 = Serializer_v6()