~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Martin Pool
  • Date: 2005-06-28 03:06:39 UTC
  • Revision ID: mbp@sourcefrog.net-20050628030639-27f8ebbea40150de
- remove unneeded imports from bzrlib.xml

Show diffs side-by-side

added added

removed removed

Lines of Context:
291
291
 
292
292
    def _make_control(self):
293
293
        from bzrlib.inventory import Inventory
294
 
        from bzrlib.xml import pack_xml
295
 
        
296
294
        os.mkdir(self.controlfilename([]))
297
295
        self.controlfile('README', 'w').write(
298
296
            "This is a Bazaar-NG control directory.\n"
305
303
                  'branch-lock'):
306
304
            self.controlfile(f, 'w').write('')
307
305
        mutter('created control directory in ' + self.base)
308
 
 
309
 
        pack_xml(Inventory(), self.controlfile('inventory','w'))
 
306
        Inventory().write_xml(self.controlfile('inventory','w'))
310
307
 
311
308
 
312
309
    def _check_format(self):
332
329
    def read_working_inventory(self):
333
330
        """Read the working inventory."""
334
331
        from bzrlib.inventory import Inventory
335
 
        from bzrlib.xml import unpack_xml
336
332
        from time import time
337
333
        before = time()
 
334
        # ElementTree does its own conversion from UTF-8, so open in
 
335
        # binary.
338
336
        self.lock_read()
339
337
        try:
340
 
            # ElementTree does its own conversion from UTF-8, so open in
341
 
            # binary.
342
 
            inv = unpack_xml(Inventory,
343
 
                                  self.controlfile('inventory', 'rb'))
 
338
            inv = Inventory.read_xml(self.controlfile('inventory', 'rb'))
344
339
            mutter("loaded inventory of %d items in %f"
345
340
                   % (len(inv), time() - before))
346
341
            return inv
354
349
        That is to say, the inventory describing changes underway, that
355
350
        will be committed to the next revision.
356
351
        """
357
 
        from bzrlib.atomicfile import AtomicFile
358
 
        from bzrlib.xml import pack_xml
359
 
        
360
352
        self.lock_write()
361
353
        try:
 
354
            from bzrlib.atomicfile import AtomicFile
 
355
 
362
356
            f = AtomicFile(self.controlfilename('inventory'), 'wb')
363
357
            try:
364
 
                pack_xml(inv, f)
 
358
                inv.write_xml(f)
365
359
                f.commit()
366
360
            finally:
367
361
                f.close()
561
555
    def get_revision(self, revision_id):
562
556
        """Return the Revision object for a named revision"""
563
557
        from bzrlib.revision import Revision
564
 
        from bzrlib.xml import unpack_xml
565
 
 
566
 
        self.lock_read()
567
 
        try:
568
 
            if not revision_id or not isinstance(revision_id, basestring):
569
 
                raise ValueError('invalid revision-id: %r' % revision_id)
570
 
            r = unpack_xml(Revision, self.revision_store[revision_id])
571
 
        finally:
572
 
            self.unlock()
573
 
            
 
558
        if not revision_id or not isinstance(revision_id, basestring):
 
559
            raise ValueError('invalid revision-id: %r' % revision_id)
 
560
        r = Revision.read_xml(self.revision_store[revision_id])
574
561
        assert r.revision_id == revision_id
575
562
        return r
576
 
        
577
563
 
578
564
    def get_revision_sha1(self, revision_id):
579
565
        """Hash the stored value of a revision, and return it."""
593
579
               parameter which can be either an integer revno or a
594
580
               string hash."""
595
581
        from bzrlib.inventory import Inventory
596
 
        from bzrlib.xml import unpack_xml
597
 
 
598
 
        return unpack_xml(Inventory, self.inventory_store[inventory_id])
599
 
            
 
582
        i = Inventory.read_xml(self.inventory_store[inventory_id])
 
583
        return i
600
584
 
601
585
    def get_inventory_sha1(self, inventory_id):
602
586
        """Return the sha1 hash of the inventory entry