Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/cvs/rlog.py
Show First 20 Lines • Show All 254 Lines • ▼ Show 20 Lines | |||||
# | # | ||||
# ^rlog\: (.*)(?:\:\d+)?\: (.*)$ | # ^rlog\: (.*)(?:\:\d+)?\: (.*)$ | ||||
# | # | ||||
# But for some reason the windows version of rlog omits the "rlog: " prefix | # But for some reason the windows version of rlog omits the "rlog: " prefix | ||||
# for the first error message when the standard error stream has been | # for the first error message when the standard error stream has been | ||||
# redirected to a file or pipe. (the prefix is present in subsequent errors | # redirected to a file or pipe. (the prefix is present in subsequent errors | ||||
# and when rlog is run from the console). So the expression below is more | # and when rlog is run from the console). So the expression below is more | ||||
# complicated | # complicated | ||||
_re_log_error = re.compile(b"^(?:rlog\: )*(.*,v)(?:\:\d+)?\: (.*)$") # noqa: W605 | _re_log_error = re.compile(rb"^(?:rlog\: )*(.*,v)(?:\:\d+)?\: (.*)$") | ||||
# CVSNT error messages look like: | # CVSNT error messages look like: | ||||
# cvs rcsfile: `C:/path/to/file,v' does not appear to be a valid rcs file | # cvs rcsfile: `C:/path/to/file,v' does not appear to be a valid rcs file | ||||
# cvs [rcsfile aborted]: C:/path/to/file,v: No such file or directory | # cvs [rcsfile aborted]: C:/path/to/file,v: No such file or directory | ||||
# cvs [rcsfile aborted]: cannot open C:/path/to/file,v: Permission denied | # cvs [rcsfile aborted]: cannot open C:/path/to/file,v: Permission denied | ||||
_re_cvsnt_error = re.compile( | _re_cvsnt_error = re.compile( | ||||
b"^(?:cvs rcsfile\: |cvs \[rcsfile aborted\]: )" # noqa: W605 | rb"^(?:cvs rcsfile\: |cvs \[rcsfile aborted\]: )" | ||||
b"(?:\`(.*,v)' |" # noqa: W605 | rb"(?:\`(.*,v)' |" | ||||
b"cannot open (.*,v)\: |(.*,v)\: |)" # noqa: W605 | rb"cannot open (.*,v)\: |(.*,v)\: |)" | ||||
b"(.*)$" | rb"(.*)$" | ||||
) | ) | ||||
def _parse_log_header(fp): | def _parse_log_header(fp): | ||||
"""Parse and RCS/CVS log header. | """Parse and RCS/CVS log header. | ||||
fp is a file (pipe) opened for reading the log information. | fp is a file (pipe) opened for reading the log information. | ||||
▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | while 1: | ||||
continue | continue | ||||
eof = _EOF_ERROR | eof = _EOF_ERROR | ||||
break | break | ||||
return filename, branch, taginfo, lockinfo, msg, eof | return filename, branch, taginfo, lockinfo, msg, eof | ||||
_re_log_info = re.compile( | _re_log_info = re.compile( | ||||
b"^date:\s+([^;]+);" # noqa: W605 | rb"^date:\s+([^;]+);" | ||||
b"\s+author:\s+([^;]+);" # noqa: W605 | rb"\s+author:\s+([^;]+);" | ||||
b"\s+state:\s+([^;]+);" # noqa: W605 | rb"\s+state:\s+([^;]+);" | ||||
b"(\s+lines:\s+([0-9\s+-]+);?)?" # noqa: W605 | rb"(\s+lines:\s+([0-9\s+-]+);?)?" | ||||
b"(\s+commitid:\s+([a-zA-Z0-9]+);)?\n$" # noqa: W605 | rb"(\s+commitid:\s+([a-zA-Z0-9]+);)?\n$" | ||||
) | ) | ||||
# TODO: _re_rev should be updated to extract the "locked" flag | # TODO: _re_rev should be updated to extract the "locked" flag | ||||
_re_rev = re.compile(b"^revision\s+([0-9.]+).*") # noqa: W605 | _re_rev = re.compile(rb"^revision\s+([0-9.]+).*") | ||||
def cvs_strptime(timestr): | def cvs_strptime(timestr): | ||||
try: | try: | ||||
return time.strptime(timestr, "%Y/%m/%d %H:%M:%S")[:-1] + (0,) | return time.strptime(timestr, "%Y/%m/%d %H:%M:%S")[:-1] + (0,) | ||||
except ValueError: | except ValueError: | ||||
return time.strptime(timestr, "%Y-%m-%d %H:%M:%S %z")[:-1] + (0,) | return time.strptime(timestr, "%Y-%m-%d %H:%M:%S %z")[:-1] + (0,) | ||||
▲ Show 20 Lines • Show All 84 Lines • Show Last 20 Lines |