From 1f7ea22511561228672d7e691af31ffc465655a5 Mon Sep 17 00:00:00 2001 From: jpaint Date: Fri, 21 Apr 2000 22:20:26 +0000 Subject: [PATCH] okay, I've fixed the file/attic/",v" problem; now RLogData's filename is always set with the idealized path name for the RCS file: this means no ",v" and no "Attic" directory. There needs to be a flag set in RLogData to show it is an Attic file, but it's not there yet git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@63 8cb11bc2-c004-0410-86c3-e597b4017df7 --- lib/cvsdbapi.py | 8 +------ lib/rlog.py | 59 ++++++++++++++++++++++++++++++++----------------- 2 files changed, 40 insertions(+), 27 deletions(-) diff --git a/lib/cvsdbapi.py b/lib/cvsdbapi.py index e3cda0c0..4f0bea7e 100644 --- a/lib/cvsdbapi.py +++ b/lib/cvsdbapi.py @@ -86,16 +86,10 @@ def RLogDataToCommitList(repository, rlog_data): commit_list = [] ## the filename in rlog_data contains the entire path of the - ## repository, and the ,v at the end of the RCS file; - ## we strip those out here + ## repository; we strip that out here temp = rlog_data.filename[len(repository):] - while temp[0] == os.sep: - temp = temp[1:] directory, file = os.path.split(temp) - if file[-2:] == ",v": - file = file[:-2] - for rlog_entry in rlog_data.rlog_entry_list: commit = CreateCommit() commit.SetRepository(repository) diff --git a/lib/rlog.py b/lib/rlog.py index ee95a14c..266106ad 100644 --- a/lib/rlog.py +++ b/lib/rlog.py @@ -96,7 +96,8 @@ class RLog: "Provides a alternative file-like interface for running 'rlog'." def __init__(self, filename, revision, date): - self.filename = filename + self.filename = self.fix_filename(filename) + self.checkout_filename = self.create_checkout_filename(self.filename) self.revision = revision self.date = date @@ -106,19 +107,39 @@ class RLog: if self.date: arg_list.append('-d%s' % (self.date)) - ## modify path if in Attic - if self.filename[-2:] != ",v": - self.filename = "%s,v" % (self.filename) - - if not os.path.isfile(self.filename): - path, basename = os.path.split(self.filename) - self.filename = os.path.join(path, "Attic", basename) - if not os.path.isfile(self.filename): - raise error, "file not found" - self.cmd = 'rlog %s "%s"' % (string.join(arg_list), self.filename) self.rlog = os.popen(self.cmd, 'r') + def fix_filename(self, filename): + ## all RCS files have the ",v" ending + if filename[-2:] != ",v": + filename = "%s,v" % (filename) + + if os.path.isfile(filename): + return filename + + ## check the Attic for the RCS file + path, basename = os.path.split(filename) + filename = os.path.join(path, "Attic", basename) + + if os.path.isfile(filename): + return filename + + raise error, "file not found" + + def create_checkout_filename(self, filename): + ## cut off the ",v" + checkout_filename = filename[:-2] + + ## check if the file is in the Attic + path, basename = os.path.split(checkout_filename) + if path[-6:] != '/Attic': + return checkout_filename + + ## remove the "Attic" part of the path + checkout_filename = os.path.join(path[:-6], basename) + return checkout_filename + def readline(self): if not self.rlog: raise error, 'rlog terminated' @@ -155,14 +176,12 @@ _re_data_line_add = re.compile( "state:\s+([^;]+);$") class RLogOutputParser: + + def __init__(self, rlog): + self.rlog = rlog + self.rlog_data = RLogData(rlog.checkout_filename) - def __init__(self, filename, revision, date): - self.rlog_data = RLogData(filename) - self.revision = revision - self.date = date - - def Run(self): - self.rlog = RLog(self.rlog_data.filename, self.revision, self.date) + ## run the parser self.parse_to_symbolic_names() self.parse_symbolic_names() self.parse_to_description() @@ -297,6 +316,6 @@ class RLogOutputParser: ## entrypoints def GetRLogData(path, revision = '', date = ''): - rlog_parser = RLogOutputParser(path, revision, date) - rlog_parser.Run() + rlog = RLog(path, revision, date) + rlog_parser = RLogOutputParser(rlog) return rlog_parser.rlog_data