~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/pack_repo.py

  • Committer: Patch Queue Manager
  • Date: 2011-12-12 15:12:07 UTC
  • mfrom: (6225.2.10 314314-obsolete-packs)
  • Revision ID: pqm@pqm.ubuntu.com-20111212151207-xiz0tu02z1hxrq76
(jelmer) Deal with the obsolete_packs directory being removed from under us.
 (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1221
1221
        """
1222
1222
        for pack in packs:
1223
1223
            try:
1224
 
                pack.pack_transport.move(pack.file_name(),
1225
 
                    '../obsolete_packs/' + pack.file_name())
 
1224
                try:
 
1225
                    pack.pack_transport.move(pack.file_name(),
 
1226
                        '../obsolete_packs/' + pack.file_name())
 
1227
                except errors.NoSuchFile:
 
1228
                    # perhaps obsolete_packs was removed? Let's create it and
 
1229
                    # try again
 
1230
                    try:
 
1231
                        pack.pack_transport.mkdir('../obsolete_packs/')
 
1232
                    except errors.FileExists:
 
1233
                        pass
 
1234
                    pack.pack_transport.move(pack.file_name(),
 
1235
                        '../obsolete_packs/' + pack.file_name())
1226
1236
            except (errors.PathError, errors.TransportError), e:
1227
1237
                # TODO: Should these be warnings or mutters?
1228
1238
                mutter("couldn't rename obsolete pack, skipping it:\n%s"
1494
1504
        obsolete_pack_transport = self.transport.clone('obsolete_packs')
1495
1505
        if preserve is None:
1496
1506
            preserve = set()
1497
 
        for filename in obsolete_pack_transport.list_dir('.'):
 
1507
        try:
 
1508
            obsolete_pack_files = obsolete_pack_transport.list_dir('.')
 
1509
        except errors.NoSuchFile:
 
1510
            return found
 
1511
        for filename in obsolete_pack_files:
1498
1512
            name, ext = osutils.splitext(filename)
1499
1513
            if ext == '.pack':
1500
1514
                found.append(name)