Changeset 781 in tailor


Ignore:
Timestamp:
09/07/05 19:02:24 (8 years ago)
Author:
lele@…
Hash name:
20050907170224-7a6fb-949b72e3c6d9df658a5013ce0c33131759050a04
Message:

Make the cvs log parser unicode aware
Now the parser accepts an unicode stream, and returns properly decoded
informations eventually using the new 'encoding' option if specified,
otherwise using the system default.

Location:
vcpx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • vcpx/cvs.py

    r777 r781  
    299299        from os.path import join, exists 
    300300        from datetime import timedelta 
     301 
     302        from codecs import getreader 
    301303 
    302304        branch = '' 
     
    349351                "%s returned status %d" % (str(cvslog), cvslog.exit_status)) 
    350352 
     353        reader = getreader(self.repository.encoding) 
     354        log = reader(log) 
    351355        return changesets_from_cvslog(log, self.repository.module) 
    352356 
  • vcpx/tests/cvs.py

    r721 r781  
    4444    """Ensure the cvs log parser does its job.""" 
    4545 
    46     SIMPLE_TEST = """\ 
     46    SIMPLE_TEST = u"""\ 
    4747cvs rlog: Logging docutils 
    4848 
     
    9494        self.assertEqual(entry.action_kind, entry.UPDATED) 
    9595 
    96     DOUBLE_TEST = """\ 
     96    DOUBLE_TEST = u"""\ 
    9797cvs rlog: Logging docutils/docutils 
    9898 
     
    188188        self.assertEqual(cset.date, datetime(2004, 6, 20, 16, 3, 17)) 
    189189 
    190     DELETED_TEST = """\ 
     190    DELETED_TEST = u"""\ 
    191191cvs rlog: Logging docutils 
    192192 
     
    228228        self.assertEqual(entry.action_kind, entry.DELETED) 
    229229 
    230     COLLAPSE_TEST = """\ 
     230    COLLAPSE_TEST = u"""\ 
    231231cvs rlog: Logging PyObjC/Doc 
    232232 
     
    312312        self.assertEqual(cset.date, datetime(1996, 10, 18, 13, 48, 45)) 
    313313 
    314     BRANCHES_TEST = """\ 
     314    BRANCHES_TEST = u"""\ 
    315315cvs rlog: Logging Archetypes/tests 
    316316 
     
    350350        self.assertEqual(cset.log,"Fixed deepcopy problem in validations") 
    351351 
    352     REPOSPATH_TEST = """\ 
     352    REPOSPATH_TEST = u"""\ 
    353353cvs rlog: Logging Zope/spurious/dummy/dir 
    354354cvs rlog: Logging Zope/lib/python/DateTime 
     
    384384        self.assertEqual(entry.name, 'lib/python/DateTime/DateTime.py') 
    385385 
    386     LONGLOG_TEST = """\ 
     386    LONGLOG_TEST = u"""\ 
    387387cvs rlog: Logging ATContentTypes 
    388388 
     
    680680        self.assertEqual(entry.action_kind, entry.UPDATED) 
    681681 
    682     SILLY_TEST = """\ 
     682    SILLY_TEST = u"""\ 
    683683RCS file: /cvsroot/docutils/docutils/THANKS.txt,v 
    684684head: 1.2 
     
    692692                          changesets_from_cvslog, log, 'docutils') 
    693693 
    694     CREATED_IN_BRANCH_TEST = """\ 
     694    CREATED_IN_BRANCH_TEST = u"""\ 
    695695cvs rlog: Logging dsssl-utils/bigdiesel/src 
    696696 
     
    723723        self.assertEqual(len(csets), 1) 
    724724 
    725     DESCRIPTION_TEST = """\ 
     725    DESCRIPTION_TEST = u"""\ 
    726726cvs rlog: Logging Zope 
    727727 
     
    756756        csets = changesets_from_cvslog(log, 'zope') 
    757757 
    758     ADD_DEL_ADD_AGAIN_TEST = """\ 
     758    ADD_DEL_ADD_AGAIN_TEST = u"""\ 
    759759cvs rlog: Logging test 
    760760 
     
    820820        self.assertEqual(entry.action_kind, entry.ADDED) 
    821821 
    822     MULTI_MODULE_TEST = """\ 
     822    MULTI_MODULE_TEST = u"""\ 
    823823cvs rlog: Logging apache-1.3/src/test/vhtest/logs 
    824824 
     
    867867        csets = changesets_from_cvslog(log, 'apache-1.3') 
    868868 
    869     ENTRY_NAMES_TEST = """ 
     869    ENTRY_NAMES_TEST = u""" 
    870870cvs rlog: Logging Products/PluggableAuthService 
    871871 
     
    894894        entry = cset.entries[0] 
    895895        self.assertEqual(entry.name, 'COPYRIGHT.txt') 
     896 
     897    ENCODING_TEST = u""" 
     898cvs rlog: Logging pxlib/src 
     899 
     900RCS file: /cvsroot/pxlib/pxlib/src/px_head.h,v 
     901head: 1.8 
     902branch: 
     903locks: strict 
     904access list: 
     905keyword substitution: kv 
     906total revisions: 9;     selected revisions: 2 
     907description: 
     908---------------------------- 
     909revision 1.8 
     910date: 2005/08/17 16:07:40;  author: steinm;  state: Exp;  lines: +1 -0 
     911- added prototype for px_delete_data_from_block() 
     912---------------------------- 
     913revision 1.7 
     914date: 2005/08/17 05:16:24;  author: steinm;  state: Exp;  lines: +1 -1 
     915­ new prototype for px_add_data_to_block() 
     916============================================================================= 
     917""" 
     918    def testUnicode(self): 
     919        """Verify cvs parser returns unicode strings""" 
     920 
     921        log = StringIO(self.ENCODING_TEST) 
     922        csets = changesets_from_cvslog(log, 'pxlib') 
     923 
     924        self.assertEqual(len(csets), 2) 
     925 
     926        log = csets[0].log 
     927        self.assertEqual(type(log), type(u'€')) 
     928        self.assertEqual(len(log), 42) 
     929        self.assertRaises(UnicodeEncodeError, log.encode, 'ascii') 
     930        self.assertEqual(len(log.encode('ascii', 'ignore')), 41) 
  • vcpx/tests/tailor.py

    r768 r781  
    101101repository = :pserver:anonymous@cvs.sf.net:/cvsroot/pxlib 
    102102module = pxlib 
     103encoding = iso-8859-1 
    103104 
    104105[cvs2hg] 
Note: See TracChangeset for help on using the changeset viewer.