(args, repo)
| 28 | |
| 29 | |
| 30 | def main(args, repo): |
| 31 | errors_found = False |
| 32 | |
| 33 | curr_b = repo.current_branch |
| 34 | cp = args.cp |
| 35 | |
| 36 | for fp in args.files: |
| 37 | conf_msg = ( |
| 38 | 'You have uncomitted changes in "{0}" that could be overwritten by ' |
| 39 | 'checkout'.format(fp)) |
| 40 | try: |
| 41 | f = curr_b.status_file(fp) |
| 42 | if f.type == core.GL_STATUS_TRACKED and f.modified and ( |
| 43 | not pprint.conf_dialog(conf_msg)): |
| 44 | pprint.err('Checkout aborted') |
| 45 | continue |
| 46 | except KeyError: |
| 47 | pass |
| 48 | |
| 49 | try: |
| 50 | curr_b.checkout_file(fp, repo.revparse_single(cp)) |
| 51 | pprint.ok( |
| 52 | 'File {0} checked out successfully to its state at {1}'.format( |
| 53 | fp, cp)) |
| 54 | except core.PathIsDirectoryError: |
| 55 | commit = repo.revparse_single(cp) |
| 56 | for fp in curr_b.get_paths(fp, commit): |
| 57 | curr_b.checkout_file(fp, commit) |
| 58 | pprint.ok( |
| 59 | 'File {0} checked out successfully to its state at {1}'.format( |
| 60 | fp, cp)) |
| 61 | except KeyError: |
| 62 | pprint.err('Checkout aborted') |
| 63 | pprint.err('There\'s no file {0} at {1}'.format(fp, cp)) |
| 64 | errors_found = True |
| 65 | |
| 66 | return not errors_found |
nothing calls this directly
no test coverage detected