<s> from . utils import do , do_ex , trace <EOL> from . version import meta <EOL> from os . path import abspath , realpath <EOL> FILES_COMMAND = '<STR_LIT>' <EOL> DEFAULT_DESCRIBE = '<STR_LIT>' <EOL> def parse ( root , describe_command = DEFAULT_DESCRIBE ) : <EOL> real_root , _ , ret = do_ex ( '<STR_LIT>' , root ) <EOL> if ret : <EOL> return <EOL> trace ( '<STR_LIT>' , real_root ) <EOL> if abspath ( realpath ( real_root ) ) != abspath ( realpath ( root ) ) : <EOL> return <EOL> rev_node , _ , ret = do_ex ( '<STR_LIT>' , root ) <EOL> if ret : <EOL> return meta ( '<STR_LIT>' ) <EOL> rev_node = rev_node [ : <NUM_LIT:7> ] <EOL> out , err , ret = do_ex ( describe_command , root ) <EOL> if '<STR_LIT:->' not in out and '<STR_LIT:.>' not in out : <EOL> revs = do ( '<STR_LIT>' , root ) <EOL> count = revs . count ( '<STR_LIT:\n>' ) <EOL> if ret : <EOL> out = rev_node <EOL> return meta ( '<STR_LIT>' , distance = count + <NUM_LIT:1> , node = out ) <EOL> if ret : <EOL> return <EOL> dirty = out . endswith ( '<STR_LIT>' ) <EOL> if dirty : <EOL> out = out . rsplit ( '<STR_LIT:->' , <NUM_LIT:1> ) [ <NUM_LIT:0> ] <EOL> tag , number , node = out . rsplit ( '<STR_LIT:->' , <NUM_LIT:2> ) <EOL> number = int ( number ) <EOL> if number : <EOL> return meta ( tag , distance = number , node = node , dirty = dirty ) <EOL> else : <EOL> return meta ( tag , dirty = dirty , node = node ) </s>
