- def make_virtual_commit(rev, parents = []):
- """
- Takes a revision and generates a "virtual" commit with
- user-specific variables instantiated for a smooth, easy
- merge.
-
- .. warning::
-
- Changes the state of the working copy.
- """
- shell.call("git", "checkout", "-q", rev, "--")
- self.wc.parametrize(self.prod)
- for file in self.wc.application.parametrized_files:
- try:
- shell.call("git", "add", "--", file)
- except shell.CallError:
- pass
- virtual_tree = shell.eval("git", "write-tree", log=True)
- parent_args = itertools.chain(*(["-p", p] for p in parents))
- virtual_commit = shell.eval("git", "commit-tree", virtual_tree,
- *parent_args, input="", log=True)
- shell.call("git", "reset", "--hard")
- return virtual_commit
- user_tree = shell.eval("git", "rev-parse", "HEAD^{tree}")
- base_virtual_commit = make_virtual_commit(self.wc.app_version.scripts_tag)
- next_virtual_commit = make_virtual_commit(self.version, [base_virtual_commit])
- user_virtual_commit = shell.eval("git", "commit-tree", user_tree,
- "-p", base_virtual_commit, input="", log=True)
- shell.call("git", "checkout", user_virtual_commit, "--")
- self.wc.prepareMerge()
- try:
- shell.call("git", "commit", "--amend", "-a", "-m", "amendment")
- except shell.CallError as e:
- pass