#NEWLINE# def find_copyfrom( self , path ) : #NEWLINE# #INDENT# '\n        A helper function for handle_renames\n\n        The output of \'svn info\' reports the "Copied From" header when invoked\n        on the exact path that was copied. If the current file was copied as a\n        part of a parent or any further ancestor directory, \'svn info\' will not\n        report the origin. Thus it is needed to ascend from the path until\n        either a copied path is found or there are no more path components to\n        try.\n        ' #NEWLINE# def smart_join( p1 , p2 ) : #NEWLINE# #INDENT# if p2 : #NEWLINE# #INDENT# return os . path . join ( p1 , p2 ) #NEWLINE# #UNINDENT# return p1 #NEWLINE# #UNINDENT# path1 = path #NEWLINE# path2 = None #NEWLINE# while path1 : #NEWLINE# #INDENT# info = ( self . svn_info ( path1 , ignore_errors = True ) or { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# url = info . get ( 'Copied From URL' , None ) #NEWLINE# if url : #NEWLINE# #INDENT# root = info [ 'Repository Root' ] #NEWLINE# from_path1 = unquote ( url [ len ( root ) : ] ) . encode ( 'utf-8' ) #NEWLINE# return smart_join ( from_path1 , path2 ) #NEWLINE# #UNINDENT# if ( info . get ( 'Schedule' , None ) != 'normal' ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# ( path1 , tmp ) = os . path . split ( path1 ) #NEWLINE# if ( ( path1 == b'' ) or ( path1 == b'/' ) ) : #NEWLINE# #INDENT# path1 = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# path2 = smart_join ( from_path1 , path2 ) #NEWLINE# #UNINDENT# #UNINDENT# return None