· KLDP.org · KLDP.net · KLDP Wiki · KLDP BBS ·
CVS Log Message Encoding

CVS 로그 메시지 인코딩을 cp949에서 utf-8로 바꿔주는 방법

동일한 CVS 저장소를 윈도우와 리눅스에서 사용할 경우에 로그 메시지의 인코딩이 달라서 문제가 되는 경우가 있습니다. (물론 어떤 경우에도 인코딩이 다르면 문제겠지만; ) 그럴 때 다음과 같은 스크립트를 쓰면 모든 로그 메시지를 utf-8로 바꿔줍니다.
#!/usr/bin/python # -*- coding: UTF-8 -*- """ file do_something_about_encoding.py Title: 인코딩 어쩌구저쩌구. Desc: 파일의 인코딩에 대해 뭔갈 하는 프로그램. Author: Son, Kyeong-uk(hey_calm) $Log: CVSLogMessageEncoding,v $ Revision 1.1 2004/11/13 11:14:26 kss 211.104.178.25;;WkPark;; Revision 1.2 2004/07/30 04:37:13 kss 211.63.103.71;;hey;; Revision 1.1 2004/07/29 09:56:04 kss 211.213.198.101;;pyrasis;; Revision 1.6 2004/07/29 09:02:22 hey_calm 로그 메시지 변경 확인. Revision 1.5 2004/07/29 08:59:55 hey_calm 로그 메시지를 euc-kr -> utf-8 -> cp949 순서대로 간주하고 인코딩 추측함. Revision 1.4 2004/07/29 08:15:31 hey_calm Revision 1.3 2004/07/29 07:58:32 hey_calm iconv가 실패해도 에러 메시지 찍지 않게 바꿈. Revision 1.2 2004/07/27 06:05:24 hey_calm 탭을 스페이스로 바꿈. Revision 1.1 2004/07/27 05:39:57 hey_calm 로그 메시지의 인코딩을 utf-8로 바꿔주는 기능 넣음. """ import os, sys filename = "" if __name__ == '__main__': if 1 < len(sys.argv): filename = sys.argv[1] file = open(filename, 'r') source = file.read() try: content = unicode(source, "euc-kr").encode("utf-8") except UnicodeError: try: unicode(source, "utf-8").encode("utf-8") content = None except UnicodeError: try: content = unicode(source, "cp949").encode("utf-8") except UnicodeError: content = None if content is not None: file = open(filename, "w") file.write(content) file.close()
pynoos님이 만드신 cvsnotify 등의 프로그램을 써보셨다면 CVSROOT를 체크아웃해보셨을 겁니다. 먼저 해당 저장소의 CVSROOT를 체크아웃하세요. 그리고 로그 정보를 검증할 때 이 스크립트가 불리도록 verifymsg에 다음과 같이
... 생략 # # One thing that should be noted is the the ALL keyword is not # supported. There can be only one entry that matches a given # repository. DEFAULT $CVSROOT/CVSROOT/do_something_about_encoding.py
마지막에 한 줄을 넣으세요. 이 새로 만든 스크립트는 CVSROOT에 자동으로 체크아웃되어야 하므로 checkoutlist 파일의 마지막에
... 생략 # File format: # # [<whitespace>]<filename>[<whitespace><error message>]<end-of-line> # # comment lines begin with '#' do_something_about_encoding.py 로그 메시지 인코딩을 어떻게 좀 하는 프로그램
이렇게 넣어 주세요. 자 이제, utf-8과 cp949를 기본으로 사용하는 각각의 컴퓨터에서 커밋을 해봅시다. :]

ID
Password
Join
You will be married within a year.


sponsored by andamiro
sponsored by cdnetworks
sponsored by HP

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2004-11-13 20:14:26
Processing time 0.0040 sec