Rev 2684: (robertc) Remove the new FileNames class as it is redundant with a trivial no-refs, no-value index. (Robert Collins) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed Aug 8 06:55:18 BST 2007


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 2684
revision-id: pqm at pqm.ubuntu.com-20070808055516-ml9ucjsb4idmpmww
parent: pqm at pqm.ubuntu.com-20070808033251-yml3s60hget1rj2b
parent: robertc at robertcollins.net-20070808050416-1c2u8miy1v7ij028
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2007-08-08 06:55:16 +0100
message:
  (robertc) Remove the new FileNames class as it is redundant with a trivial no-refs, no-value index. (Robert Collins)
removed:
  bzrlib/file_names.py           file_collection.py-20070714100753-j2zz4ahtk331k5zm-1
  bzrlib/tests/test_file_names.py test_file_collection-20070714093417-5gc9d821to85zo4t-1
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
    ------------------------------------------------------------
    revno: 2683.1.1
    merged: robertc at robertcollins.net-20070808050416-1c2u8miy1v7ij028
    parent: pqm at pqm.ubuntu.com-20070808033251-yml3s60hget1rj2b
    committer: Robert Collins <robertc at robertcollins.net>
    branch nick: integration
    timestamp: Wed 2007-08-08 15:04:16 +1000
    message:
      (robertc) Remove the new FileNames class as it is redundant with a trivial no-refs, no-value index. (Robert Collins)
=== removed file 'bzrlib/file_names.py'
--- a/bzrlib/file_names.py	2007-07-20 00:57:43 +0000
+++ b/bzrlib/file_names.py	1970-01-01 00:00:00 +0000
@@ -1,81 +0,0 @@
-# Copyright (C) 2007 Canonical Ltd
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-"""A collection of file names which is persisted on a transport."""
-
-from bzrlib.lazy_import import lazy_import
-lazy_import(globals(), """
-from bzrlib import (
-        errors,
-        )
-""")
-
-
-class FileNames(object):
-    """A collection of file names.
-
-    The file names are persisted to a file on a transport, and cand be
-    added, removed and initialised.
-
-    The set of names are stored in a flat file, one name per line.
-    New names are allocated sequentially.
-    Initialisation creates an empty file.
-
-    This is intended to support management of modest numbers of files in 
-    write-locked environments which may be read from unlistable transports.
-    
-    The save method must be called to cause the state to be saved to the
-    transport.
-
-    Finally, load is used to obtain a previously saved set.
-    """
-
-    def __init__(self, transport, index_name):
-        """Create a collection on transport called index_name."""
-        self._transport = transport
-        self._index_name = index_name
-        self._names = None
-        self._cap = 10000
-
-    def allocate(self):
-        for number in xrange(self._cap):
-            if str(number) not in self._names:
-                self._names.add(str(number))
-                return str(number)
-        raise errors.BzrError('too many files')
-
-    def initialise(self):
-        """Initialise the collection."""
-        self._names = set()
-
-    def load(self):
-        """Load the names from the transport."""
-        self._names = set(self._transport.get_bytes(
-            self._index_name).split('\n'))
-        self._names.discard('')
-
-    def names(self):
-        """What are the names in this collection?"""
-        return frozenset(self._names)
-
-    def remove(self, name):
-        """Remove name from the collection."""
-        self._names.remove(name)
-
-    def save(self):
-        """Save the set of names."""
-        self._transport.put_bytes(self._index_name, '\n'.join(self._names))
-

=== removed file 'bzrlib/tests/test_file_names.py'
--- a/bzrlib/tests/test_file_names.py	2007-07-19 03:37:17 +0000
+++ b/bzrlib/tests/test_file_names.py	1970-01-01 00:00:00 +0000
@@ -1,103 +0,0 @@
-# Copyright (C) 2007 Canonical Ltd
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-"""Tests for the FileNames class."""
-
-from bzrlib import errors
-from bzrlib.file_names import FileNames
-from bzrlib.tests import TestCaseWithMemoryTransport
-from bzrlib.transport import get_transport
-
-
-class TestFileNames(TestCaseWithMemoryTransport):
-
-    def test_initialise(self):
-        t = self.get_transport()
-        for name in ('index', '00index'):
-            names = FileNames(t, name)
-            names.initialise()
-            self.assertFalse(t.has(name))
-            names.save()
-            self.assertEqual('', t.get_bytes(name))
-        
-    def test_allocate_trivial(self):
-        t = self.get_transport()
-        names = FileNames(t, 'index')
-        names.initialise()
-        name = names.allocate()
-        self.assertEqual('0', name)
-        self.assertFalse(t.has('index'))
-        name = names.allocate()
-        self.assertEqual('1', name)
-        self.assertFalse(t.has('index'))
-
-    def test_allocate_overrun(self):
-        t = self.get_transport()
-        names = FileNames(t, 'index')
-        names.initialise()
-        names._cap = 5
-        for number in xrange(5):
-            name = names.allocate()
-        self.assertRaises(errors.BzrError, names.allocate)
-
-    def test_load(self):
-        t = self.get_transport()
-        names = FileNames(t, 'index')
-        names.initialise()
-        names.allocate()
-        names.allocate()
-        names.save()
-        names = FileNames(t, 'index')
-        names.load()
-        self.assertEqual(set(['0', '1']), names.names())
-
-    def test_load_empty(self):
-        t = self.get_transport()
-        names = FileNames(t, 'index')
-        names.initialise()
-        names.save()
-        names = FileNames(t, 'index')
-        names.load()
-        self.assertEqual(set(), names.names())
-
-    def test_names(self):
-        t = self.get_transport()
-        names = FileNames(t, 'index')
-        names.initialise()
-        names.allocate()
-        names.allocate()
-        self.assertEqual(set(['0', '1']), names.names())
-
-    def test_names_on_unlistable_works(self):
-        t = self.get_transport()
-        names = FileNames(t, 'index')
-        names.initialise()
-        names.allocate()
-        names.allocate()
-        names.save()
-        names = FileNames(
-            get_transport('unlistable+' + self.get_url()), 'index')
-        names.load()
-        self.assertEqual(set(['0', '1']), names.names())
-
-    def test_remove(self):
-        t = self.get_transport()
-        names = FileNames(t, 'index')
-        names.initialise()
-        name1 = names.allocate()
-        name2 = names.allocate()
-        names.remove(name1)
-        self.assertEqual(set([name2]), names.names())

=== modified file 'NEWS'
--- a/NEWS	2007-08-08 02:38:39 +0000
+++ b/NEWS	2007-08-08 05:04:16 +0000
@@ -176,9 +176,6 @@
     * New transport decorator 'unlistable+' which disables the list_dir
       functionality for testing.
 
-    * New ``file_names.FileNames`` support class which mananges names
-      for unlistable transport situations. (Robert Collins)
-
     * Deprecated ``change_entry`` in transform.py. (Ian Clatworthy)
 
     * RevisionTree.get_weave is now deprecated.  Tree.plan_merge is now used

=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py	2007-08-01 15:38:37 +0000
+++ b/bzrlib/tests/__init__.py	2007-08-08 05:04:16 +0000
@@ -2288,7 +2288,6 @@
                    'bzrlib.tests.test_escaped_store',
                    'bzrlib.tests.test_extract',
                    'bzrlib.tests.test_fetch',
-                   'bzrlib.tests.test_file_names',
                    'bzrlib.tests.test_ftp_transport',
                    'bzrlib.tests.test_generate_docs',
                    'bzrlib.tests.test_generate_ids',




More information about the bazaar-commits mailing list