#NEWLINE# def _normalize_filenames( self ) : #NEWLINE# #INDENT# ' sanitize filenames, normalizing paths, i.e.:\n        1. strip a/ and b/ prefixes from GIT and HG style patches\n        2. remove all references to parent directories (with warning)\n        3. translate any absolute paths to relative (with warning)\n\n        [x] always use forward slashes to be crossplatform\n            (diff/patch were born as a unix utility after all)\n        \n        return None\n    ' #NEWLINE# if debugmode : #NEWLINE# #INDENT# debug ( 'normalize filenames' ) #NEWLINE# #UNINDENT# for ( i , p ) in enumerate ( self . items ) : #NEWLINE# #INDENT# if debugmode : #NEWLINE# #INDENT# debug ( ( '    patch type = ' + p . type ) ) #NEWLINE# debug ( ( '    source = ' + p . source ) ) #NEWLINE# debug ( ( '    target = ' + p . target ) ) #NEWLINE# #UNINDENT# if ( p . type in ( HG , GIT ) ) : #NEWLINE# #INDENT# debug ( 'stripping a/ and b/ prefixes' ) #NEWLINE# if ( p . source != '/dev/null' ) : #NEWLINE# #INDENT# if ( not p . source . startswith ( b'a/' ) ) : #NEWLINE# #INDENT# warning ( 'invalid source filename' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# p . source = p . source [ 2 : ] #NEWLINE# #UNINDENT# #UNINDENT# if ( p . target != '/dev/null' ) : #NEWLINE# #INDENT# if ( not p . target . startswith ( b'b/' ) ) : #NEWLINE# #INDENT# warning ( 'invalid target filename' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# p . target = p . target [ 2 : ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# p . source = xnormpath ( p . source ) #NEWLINE# p . target = xnormpath ( p . target ) #NEWLINE# sep = b'/' #NEWLINE# if p . source . startswith ( ( b'..' + sep ) ) : #NEWLINE# #INDENT# warning ( ( 'error: stripping parent path for source file patch no.%d' % ( i + 1 ) ) ) #NEWLINE# self . warnings += 1 #NEWLINE# while p . source . startswith ( ( b'..' + sep ) ) : #NEWLINE# #INDENT# p . source = p . source . partition ( sep ) [ 2 ] #NEWLINE# #UNINDENT# #UNINDENT# if p . target . startswith ( ( b'..' + sep ) ) : #NEWLINE# #INDENT# warning ( ( 'error: stripping parent path for target file patch no.%d' % ( i + 1 ) ) ) #NEWLINE# self . warnings += 1 #NEWLINE# while p . target . startswith ( ( b'..' + sep ) ) : #NEWLINE# #INDENT# p . target = p . target . partition ( sep ) [ 2 ] #NEWLINE# #UNINDENT# #UNINDENT# if ( xisabs ( p . source ) or xisabs ( p . target ) ) : #NEWLINE# #INDENT# warning ( ( 'error: absolute paths are not allowed - file no.%d' % ( i + 1 ) ) ) #NEWLINE# self . warnings += 1 #NEWLINE# if xisabs ( p . source ) : #NEWLINE# #INDENT# warning ( ( "stripping absolute path from source name '%s'" % p . source ) ) #NEWLINE# p . source = xstrip ( p . source ) #NEWLINE# #UNINDENT# if xisabs ( p . target ) : #NEWLINE# #INDENT# warning ( ( "stripping absolute path from target name '%s'" % p . target ) ) #NEWLINE# p . target = xstrip ( p . target ) #NEWLINE# #UNINDENT# #UNINDENT# self . items [ i ] . source = p . source #NEWLINE# self . items [ i ] . target = p . target