p4_access_checked = False
-re_ko_keywords = re.compile(r'\$(Id|Header)(:[^$\n]+)?\$')
-re_k_keywords = re.compile(r'\$(Id|Header|Author|Date|DateTime|Change|File|Revision)(:[^$\n]+)?\$')
+re_ko_keywords = re.compile(br'\$(Id|Header)(:[^$\n]+)?\$')
+re_k_keywords = re.compile(br'\$(Id|Header|Author|Date|DateTime|Change|File|Revision)(:[^$\n]+)?\$')
def p4_build_cmd(cmd):
"""Build a suitable p4 command line.
# Attempt to zap the RCS keywords in a p4 controlled file matching the given regex
(handle, outFileName) = tempfile.mkstemp(dir='.')
try:
- with os.fdopen(handle, "w") as outFile, open(file, "r") as inFile:
+ with os.fdopen(handle, "wb") as outFile, open(file, "rb") as inFile:
for line in inFile.readlines():
- outFile.write(regexp.sub(r'$\1$', line))
+ outFile.write(regexp.sub(br'$\1$', line))
# Forcibly overwrite the original file
os.unlink(file)
shutil.move(outFileName, file)
regexp = p4_keywords_regexp_for_file(file)
if regexp:
# this file is a possibility...look for RCS keywords.
- for line in read_pipe_lines(["git", "diff", "%s^..%s" % (id, id), file]):
+ for line in read_pipe_lines(
+ ["git", "diff", "%s^..%s" % (id, id), file],
+ raw=True):
if regexp.search(line):
if verbose:
print("got keyword match on %s in %s in %s" % (regex.pattern, line, file))
# even though in theory somebody may want that.
regexp = p4_keywords_regexp_for_type(type_base, type_mods)
if regexp:
- contents = [encode_text_stream(regexp.sub(
- r'$\1$', ''.join(decode_text_stream(c) for c in contents)))]
+ contents = [regexp.sub(br'$\1$', c) for c in contents]
if self.largeFileSystem:
(git_mode, contents) = self.largeFileSystem.processContent(git_mode, relPath, contents)
. ./lib-git-p4.sh
+CP1252="\223\224"
+
test_expect_success 'start p4d' '
start_p4d
'
p4 submit -d "filek" &&
p4 add -t text+ko fileko &&
p4 submit -d "fileko" &&
+ printf "$CP1252" >fileko_cp1252 &&
+ p4 add -t text+ko fileko_cp1252 &&
+ p4 submit -d "fileko_cp1252" &&
p4 add -t text file_text &&
p4 submit -d "file_text"
)
)
'
+test_expect_success 'check cp1252 smart quote are preserved through RCS keyword processing' '
+ test_when_finished cleanup_git &&
+ git p4 clone --dest="$git" //depot &&
+ (
+ cd "$git" &&
+ printf "$CP1252" >expect &&
+ test_cmp_bin expect fileko_cp1252
+ )
+'
+
test_done