Changeset 1002 in tailor


Ignore:
Timestamp:
11/15/05 08:37:22 (8 years ago)
Author:
Brendan Cully <brendan@…>
Hash name:
20051115073722-0ae3a-ef0b1b2d25bea7c8e7c845fce4ec63954b0202f6
Message:

Sanitize CVS tag names

CVS tag names are more restrictive than those of other repositories. This patch
downcodes them where necessary.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vcpx/cvsps.py

    r973 r1002  
    574574        """ 
    575575 
     576        # Sanitize tagnames for CVS: start with [a-zA-z], only include letters, 
     577        # numbers, '-' and '_'. 
     578        # str.isalpha et al are locale-dependent 
     579        def iscvsalpha(chr): 
     580            return (chr >= 'a' and chr <= 'z') or (chr >= 'A' and chr <= 'Z') 
     581        def iscvsdigit(chr): 
     582            return chr >= '0' and chr <= '9' 
     583        def iscvschar(chr): 
     584            return iscvsalpha(chr) or iscvsdigit(chr) or chr == '-' or chr == '_' 
     585        def cvstagify(chr): 
     586            if iscvschar(chr): 
     587                return chr 
     588            else: 
     589                return '_' 
     590 
     591        tagname = ''.join([cvstagify(chr) for chr in tagname]) 
     592        if not iscvsalpha(tagname[0]): 
     593            tagname = 'tag-' + tagname 
     594 
    576595        cmd = self.repository.command("tag") 
    577596        c = ExternalCommand(cwd=self.basedir, command=cmd) 
Note: See TracChangeset for help on using the changeset viewer.