This file is indexed.

/usr/lib/python2.7/dist-packages/cvs2svn_lib/cvs_path_database.py is in cvs2svn 2.4.0-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# (Be in -*- python -*- mode.)
#
# ====================================================================
# Copyright (c) 2000-2009 CollabNet.  All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution.  The terms
# are also available at http://subversion.tigris.org/license-1.html.
# If newer versions of this license are posted there, you may use a
# newer version instead, at your option.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://cvs2svn.tigris.org/.
# ====================================================================

"""This module contains database facilities used by cvs2svn."""


import cPickle

from cvs2svn_lib import config
from cvs2svn_lib.common import DB_OPEN_READ
from cvs2svn_lib.common import DB_OPEN_NEW
from cvs2svn_lib.artifact_manager import artifact_manager
from cvs2svn_lib.cvs_path import CVSPath


class CVSPathDatabase:
  """A database to store CVSPath objects and retrieve them by their id.

  All RCS files within every CVS project repository are recorded here
  as CVSFile instances, and all directories within every CVS project
  repository (including empty directories) are recorded here as
  CVSDirectory instances."""

  def __init__(self, mode):
    """Initialize an instance, opening database in MODE (where MODE is
    either DB_OPEN_NEW or DB_OPEN_READ)."""

    self.mode = mode

    # A map { id : CVSPath }
    self._cvs_paths = {}

    if self.mode == DB_OPEN_NEW:
      pass
    elif self.mode == DB_OPEN_READ:
      f = open(artifact_manager.get_temp_file(config.CVS_PATHS_DB), 'rb')
      cvs_paths = cPickle.load(f)
      for cvs_path in cvs_paths:
        self._cvs_paths[cvs_path.id] = cvs_path
    else:
      raise RuntimeError('Invalid mode %r' % self.mode)

  def set_cvs_path_ordinals(self):
    cvs_files = sorted(self.itervalues(), key=CVSPath.sort_key)
    for (i, cvs_file) in enumerate(cvs_files):
      cvs_file.ordinal = i

  def log_path(self, cvs_path):
    """Add CVS_PATH, a CVSPath instance, to the database."""

    if self.mode == DB_OPEN_READ:
      raise RuntimeError('Cannot write items in mode %r' % self.mode)

    self._cvs_paths[cvs_path.id] = cvs_path

  def itervalues(self):
    return self._cvs_paths.itervalues()

  def get_path(self, id):
    """Return the CVSPath with the specified ID."""

    return self._cvs_paths[id]

  def close(self):
    if self.mode == DB_OPEN_NEW:
      self.set_cvs_path_ordinals()
      f = open(artifact_manager.get_temp_file(config.CVS_PATHS_DB), 'wb')
      cPickle.dump(self._cvs_paths.values(), f, -1)
      f.close()

    self._cvs_paths = None