<commit_before>"""RCS interface module.

Defines the class RCS, which represents a directory with rcs version
files and (possibly) corresponding work files.

"""


import fnmatch
import os
import regsub
import string
import tempfile


class RCS:

    """RCS interface class (local filesystem version).

    An instance of this class represents a directory with rcs version
    files and (possible) corresponding work files.

    Methods provide access to most rcs operations such as
    checkin/checkout, access to the rcs metadata (revisions, logs,
    branches etc.) as well as some filesystem operations such as
    listing all rcs version files.

    XXX BUGS / PROBLEMS

    - The instance always represents the current directory so it's not
    very useful to have more than one instance around simultaneously

    """

    # Characters allowed in work file names
    okchars = string.letters + string.digits + '-_=+.'

    def __init__(self):
	"""Constructor."""
	pass

    def __del__(self):
	"""Destructor."""
	pass

    # --- Informational methods about a single file/revision ---

    def log(self, name_rev, otherflags = ''):
	"""Print the full log text for NAME_REV on stdout.

	Optional OTHERFLAGS are passed to rlog.

	"""
	name, rev = self.checkfile(name_rev)
	cmd = "rlog -r%s %s %s" % (rev, name, otherflags)
	return self._system(cmd)

    def head(self, name_rev):
	"""Return the head revision for NAME_REV"""
	dict = self.info(name_rev)
	return dict['head']

    def info(self, name_rev):
	"""Return a dictionary of info (from rlog -h) for NAME_REV

	The dictionary's keys are the keywords that rlog prints
	(e.g. 'head' and its values are the corresponding data
	(e.g. '1.3').

	XXX symbolic names and locks are not returned

	"""
	f = self._open(name_rev, 'rlog -h')
	dict = {}
	while 1:
	    line = f.readline()
	    if not line: break
	    if line[0] == '\t':<commit_msg>change log() to return the string instead of printing it<commit_after>"""RCS interface module.

Defines the class RCS, which represents a directory with rcs version
files and (possibly) corresponding work files.

"""


import fnmatch
import os
import regsub
import string
import tempfile


class RCS:

    """RCS interface class (local filesystem version).

    An instance of this class represents a directory with rcs version
    files and (possible) corresponding work files.

    Methods provide access to most rcs operations such as
    checkin/checkout, access to the rcs metadata (revisions, logs,
    branches etc.) as well as some filesystem operations such as
    listing all rcs version files.

    XXX BUGS / PROBLEMS

    - The instance always represents the current directory so it's not
    very useful to have more than one instance around simultaneously

    """

    # Characters allowed in work file names
    okchars = string.letters + string.digits + '-_=+.'

    def __init__(self):
	"""Constructor."""
	pass

    def __del__(self):
	"""Destructor."""
	pass

    # --- Informational methods about a single file/revision ---

    def log(self, name_rev, otherflags = ''):
	"""Return the full log text for NAME_REV as a string.

	Optional OTHERFLAGS are passed to rlog.

	"""
	f = self._open(name_rev, 'rlog ' + otherflags)
	data = f.read()
	self._closepipe(f)
	return data

    def head(self, name_rev):
	"""Return the head revision for NAME_REV"""
	dict = self.info(name_rev)
	return dict['head']

    def info(self, name_rev):
	"""Return a dictionary of info (from rlog -h) for NAME_REV

	The dictionary's keys are the keywords that rlog prints
	(e.g. 'head' and its values are the corresponding data
	(e.g. '1.3').

	XXX symbolic names and locks are not returned

	"""
	f = self._open(name_rev, 'rlog -h')
	dict = {}
	while 1:
	    line = f.readline()
	    if not line: break
	    if line[0] == '\t':
{'fraction_non_alphanumeric': 0.09557475778999738, 'fraction_numerical': 0.002094789211835559, 'mean_word_length': 3.3458475540386803, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6137226', 'n_tokens_mistral': 1195, 'n_tokens_neox': 1120, 'n_words': 475}