* cvs2svn: Use gnu_getopt when available (Python >= 2.3) for more flexible
[cvs2svn.git] / cvs2svn_lib / cvs_file_database.py
blob3b236d3360be2fb17c6f6c04d7aaf50762eecf4b
1 # (Be in -*- python -*- mode.)
3 # ====================================================================
4 # Copyright (c) 2000-2006 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 database facilities used by cvs2svn."""
20 from boolean import *
21 import database
24 class CVSFileDatabase:
25 """A Database to store CVSRevision objects and retrieve them by their
26 unique_key()."""
28 def __init__(self, filename, mode):
29 """Initialize an instance, opening database in MODE (like the MODE
30 argument to Database or anydbm.open())."""
32 self.db = database.PDatabase(filename, mode)
34 def log_file(self, cvs_file):
35 """Add CVS_FILE, a CVSFile instance, to the database."""
37 self.db['%x' % cvs_file.id] = cvs_file
39 def get_file(self, id):
40 """Return the CVSFile with the specified ID."""
42 return self.db['%x' % id]