MCPcopy
hub / github.com/gitless-vcs/gitless / main

Function main

gitless/cli/gl_checkout.py:30–66  ·  view source on GitHub ↗
(args, repo)

Source from the content-addressed store, hash-verified

28
29
30def 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

Callers

nothing calls this directly

Calls 4

status_fileMethod · 0.80
checkout_fileMethod · 0.80
revparse_singleMethod · 0.80
get_pathsMethod · 0.80

Tested by

no test coverage detected