Re-update to rcsparse r2495 to get all the goodness of the new update script.
[cvs2svn.git] / cvs2svn_lib / key_generator.py
blobd580d6b1090b27101391d967a49556d8a6a18b86
1 # (Be in -*- python -*- mode.)
3 # ====================================================================
4 # Copyright (c) 2000-2008 CollabNet. All rights reserved.
6 # This software is licensed as described in the file COPYING, which
7 # you should have received as part of this distribution. The terms
8 # are also available at http://subversion.tigris.org/license-1.html.
9 # If newer versions of this license are posted there, you may use a
10 # newer version instead, at your option.
12 # This software consists of voluntary contributions made by many
13 # individuals. For exact contribution history, see the revision
14 # history and logs, available at http://cvs2svn.tigris.org/.
15 # ====================================================================
17 """This module contains the KeyGenerator class."""
20 class KeyGenerator:
21 """Generate a series of unique keys."""
23 def __init__(self, first_id=1):
24 """Initialize a KeyGenerator with the specified FIRST_ID.
26 FIRST_ID should be an int or long, and the generated keys will be
27 of the same type."""
29 self._key_base = first_id
30 self._last_id = None
32 def gen_id(self):
33 """Generate and return a previously-unused key, as an integer."""
35 self._last_id = self._key_base
36 self._key_base += 1
38 return self._last_id
40 def get_last_id(self):
41 """Return the last id that was generated, as an integer."""
43 return self._last_id