72
def from_objects(klass, repository, revision_id, submit_location,
73
patch_type='bundle', local_submit_location=None,
74
public_location=None):
75
if patch_type == 'bundle':
76
patch = klass._generate_bundle(repository, revision_id,
78
elif patch_type == 'diff':
79
patch = klass._generate_diff(repository, revision_id,
76
def from_objects(klass, repository, revision_id, time, timezone,
77
submit_location, patch_type='bundle',
78
local_submit_location=None, public_branch=None):
79
if public_branch is not None:
80
public_location = public_branch.base
81
if not public_branch.repository.has_revision(revision_id):
82
raise errors.PublicBranchOutOfDate(public_location,
85
public_location = None
86
t = testament.StrictTestament3.from_revision(repository, revision_id)
87
if patch_type is None:
83
return MergeDirective(revision_id, submit_location, patch, patch_type,
90
submit_branch = _mod_branch.Branch.open(submit_location)
91
submit_revision_id = submit_branch.last_revision()
92
repository.fetch(submit_branch.repository, submit_revision_id)
93
ancestor_id = _mod_revision.common_ancestor(revision_id,
96
if patch_type == 'bundle':
98
bundle_serializer.write_bundle(repository, revision_id,
101
elif patch_type == 'diff':
102
patch = klass._generate_diff(repository, revision_id,
104
return MergeDirective(revision_id, t.as_sha1(), time, timezone,
105
submit_location, patch, patch_type,
109
def _generate_diff(repository, revision_id, ancestor_id):
110
tree_1 = repository.revision_tree(ancestor_id)
111
tree_2 = repository.revision_tree(revision_id)
113
diff.show_diff_trees(tree_1, tree_2, s)