diff options
author | Zac Medico <zmedico@gentoo.org> | 2010-05-12 12:55:57 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2010-05-12 12:55:57 -0700 |
commit | 29d14ab1a1667289940c9a162fbb6df8d6c47580 (patch) | |
tree | d84827bb4001968613f37f3c79be0ab48f3e57f5 | |
parent | 76b879a5719a94e0dbb3a9519e75698a75275c2f (diff) | |
download | portage-29d14ab1a1667289940c9a162fbb6df8d6c47580.tar.gz portage-29d14ab1a1667289940c9a162fbb6df8d6c47580.tar.bz2 portage-29d14ab1a1667289940c9a162fbb6df8d6c47580.zip |
When rewritting /Attic/ in cvs headers, use binary mode in order to avoid
potential character encoding issues.
-rwxr-xr-x | bin/repoman | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/bin/repoman b/bin/repoman index aa3a95268..8220a8cc9 100755 --- a/bin/repoman +++ b/bin/repoman @@ -2339,22 +2339,28 @@ else: # When files are removed and re-added, the cvs server will put /Attic/ # inside the $Header path. This code detects the problem and corrects it # so that the Manifest will generate correctly. See bug #169500. - from portage.util import write_atomic - cvs_header = re.compile(r'^#\s*\$Header.*\$$') + cvs_header = r'^#\s*\$Header.*\$$' + attic_str = "/Attic/" + attic_replace = "/" + cvs_header = _unicode_encode(cvs_header) + attic_str = _unicode_encode(attic_str) + attic_replace = _unicode_encode(attic_replace) + cvs_header_re = re.compile(cvs_header) for x in myheaders: - f = codecs.open(_unicode_encode(x, + f = open(_unicode_encode(x, encoding=_encodings['fs'], errors='strict'), - mode='r', encoding=_encodings['repo.content'], errors='strict') + mode='rb') mylines = f.readlines() f.close() modified = False for i, line in enumerate(mylines): - if cvs_header.match(line) and "/Attic/" in line: - mylines[i] = line.replace("/Attic/", "/") + if cvs_header_re.match(line) is not None and \ + attic_str in line: + mylines[i] = line.replace(attic_str, attic_replace) modified = True if modified: - write_atomic(x, "".join(mylines), - encoding=_encodings['repo.content'], errors='strict') + portage.util.write_atomic(x, _unicode_encode("").join(mylines), + mode='wb') manifest_commit_required = True if vcs in ('cvs', 'svn') and (myupdates or myremoved): |