~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/file_names.py

  • Committer: Robert Collins
  • Date: 2007-08-06 23:49:18 UTC
  • mto: (2592.3.81 repository)
  • mto: This revision was merged to the branch mainline in revision 2933.
  • Revision ID: robertc@robertcollins.net-20070806234918-xc9w5f86tgjphf9u
Prevent the duplicate additions of names to FileNames collections.

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
        """Allocate name in the names collection.
59
59
 
60
60
        :param name: The name to allocate.
 
61
        :raises: bzrlib.errors.DuplicateKey if the name is already allocated.
61
62
        """
62
63
        if name is not None:
63
64
            if len(self._names) >= self._cap:
64
65
                raise errors.BzrError('too many files')
 
66
            if name in self._names:
 
67
                raise errors.DuplicateKey(name)
65
68
            self._names.add(name)
66
69
            return name
67
70