<s> """<STR_LIT>""" <EOL> import sys <EOL> from qisys import ui <EOL> import qisys . parsers <EOL> import qisys . worktree <EOL> import qisys . interact <EOL> import qisrc . git <EOL> import qisrc . snapshot <EOL> import qisrc . status <EOL> import qisrc . parsers <EOL> import qisrc . reset <EOL> def configure_parser ( parser ) : <EOL> """<STR_LIT>""" <EOL> qisys . parsers . worktree_parser ( parser ) <EOL> qisys . parsers . project_parser ( parser ) <EOL> parser . add_argument ( "<STR_LIT>" , "<STR_LIT>" , action = "<STR_LIT:store_true>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( "<STR_LIT>" , help = "<STR_LIT>" ) <EOL> parser . add_argument ( "<STR_LIT>" , help = "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_argument ( "<STR_LIT>" , dest = "<STR_LIT>" , action = "<STR_LIT:store_true>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . set_defaults ( ignore_groups = False ) <EOL> def do ( args ) : <EOL> """<STR_LIT>""" <EOL> git_worktree = qisrc . parsers . get_git_worktree ( args ) <EOL> snapshot = None <EOL> if args . snapshot : <EOL> snapshot = qisrc . snapshot . Snapshot ( ) <EOL> snapshot . load ( args . snapshot ) <EOL> if snapshot and snapshot . format_version and snapshot . format_version >= <NUM_LIT:1> : <EOL> reset_manifest ( git_worktree , snapshot , <EOL> ignore_groups = args . ignore_groups ) <EOL> git_projects = qisrc . parsers . get_git_projects ( git_worktree , args , <EOL> default_all = True , <EOL> use_build_deps = True ) <EOL> errors = list ( ) <EOL> for i , git_project in enumerate ( git_projects ) : <EOL> ui . info_count ( i , len ( git_projects ) , "<STR_LIT>" , git_project . src ) <EOL> src = git_project . src <EOL> git = qisrc . git . Git ( git_project . path ) <EOL> ok , message = git . require_clean_worktree ( ) <EOL> if not ok and not args . force : <EOL> ui . warning ( message ) <EOL> errors . append ( src ) <EOL> continue <EOL> if not git_project . default_branch : <EOL> if git_project . fixed_ref : <EOL> ok , mess = qisrc . reset . clever_reset_ref ( <EOL> git_project , git_project . fixed_ref , raises = False ) <EOL> if not ok : <EOL> errors . append ( src ) <EOL> ui . error ( mess ) <EOL> continue <EOL> else : <EOL> ui . warning ( git_project . src , "<STR_LIT>" ) <EOL> continue <EOL> branch = git_project . default_branch . name <EOL> remote = git_project . default_remote . name <EOL> git . safe_checkout ( branch , remote , force = True ) <EOL> to_reset = None <EOL> if args . snapshot : <EOL> to_reset = snapshot . refs . get ( src ) <EOL> if not to_reset : <EOL> ui . warning ( src , "<STR_LIT>" ) <EOL> continue <EOL> elif args . tag : <EOL> to_reset = args . tag <EOL> else : <EOL> to_reset = "<STR_LIT>" % ( remote , branch ) <EOL> try : <EOL> qisrc . reset . clever_reset_ref ( git_project , to_reset ) <EOL> except : <EOL> errors . append ( src ) <EOL> if not errors : <EOL> return <EOL> ui . error ( "<STR_LIT>" ) <EOL> for error in errors : <EOL> ui . info ( ui . red , "<STR_LIT>" , error ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> def reset_manifest ( git_worktree , snapshot , ignore_groups = False ) : <EOL> manifest = snapshot . manifest <EOL> if ignore_groups : <EOL> groups = git_worktree . manifest . groups <EOL> else : <EOL> groups = manifest . groups <EOL> if not manifest . branch : <EOL> ui . fatal ( "<STR_LIT>" ) <EOL> ok = git_worktree . configure_manifest ( manifest . url , groups = groups , <EOL> branch = manifest . branch , ref = manifest . ref ) <EOL> if not ok : <EOL> sys . exit ( <NUM_LIT:1> ) </s>
