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

Function main

gitless/cli/gl_fuse.py:50–103  ·  view source on GitHub ↗
(args, repo)

Source from the content-addressed store, hash-verified

48
49
50def main(args, repo):
51 current_b = repo.current_branch
52 if args.abort:
53 current_b.abort_fuse(op_cb=pprint.OP_CB)
54 pprint.ok('Fuse aborted successfully')
55 return True
56
57 src_branch = helpers.get_branch_or_use_upstream(args.src, 'src', repo)
58
59 mb = repo.merge_base(current_b, src_branch)
60 if mb == src_branch.target: # the current branch is ahead or both branches are equal
61 pprint.err('No commits to fuse')
62 return False
63
64 if (not args.insertion_point or args.insertion_point == 'dp' or
65 args.insertion_point == 'divergent-point'):
66 insertion_point = mb
67 else:
68 insertion_point = repo.revparse_single(args.insertion_point).id
69
70 def valid_input(inp):
71 walker = src_branch.history()
72 walker.hide(insertion_point)
73 divergent_ids = frozenset(ci.id for ci in walker)
74
75 errors_found = False
76 for ci in inp - divergent_ids:
77 pprint.err(
78 'Commit with id {0} is not among the divergent commits of branch '
79 '{1}'.format(ci, src_branch))
80 errors_found = True
81 return not errors_found
82
83 only = None
84 exclude = None
85 if args.only:
86 only = frozenset(args.only)
87 if not valid_input(only):
88 return False
89 elif args.exclude:
90 exclude = frozenset(args.exclude)
91 if not valid_input(exclude):
92 return False
93
94
95 try:
96 current_b.fuse(
97 src_branch, insertion_point, only=only, exclude=exclude,
98 op_cb=pprint.OP_CB)
99 pprint.ok('Fuse succeeded')
100 except core.ApplyFailedError as e:
101 pprint.ok('Fuse succeeded')
102 raise e
103 return True

Callers

nothing calls this directly

Calls 5

valid_inputFunction · 0.85
abort_fuseMethod · 0.80
merge_baseMethod · 0.80
revparse_singleMethod · 0.80
fuseMethod · 0.80

Tested by

no test coverage detected