63
def build_snapshot(self, parent_ids, revision_id, actions):
63
def _move_branch_pointer(self, new_revision_id):
64
"""Point self._branch to a different revision id."""
65
self._branch.lock_write()
67
# We don't seem to have a simple set_last_revision(), so we
69
cur_revno, cur_revision_id = self._branch.last_revision_info()
70
g = self._branch.repository.get_graph()
71
new_revno = g.find_distance_to_null(new_revision_id,
72
[(cur_revision_id, cur_revno)])
73
self._branch.set_last_revision_info(new_revno, new_revision_id)
77
def build_snapshot(self, revision_id, parent_ids, actions):
78
"""Build a commit, shaped in a specific way.
80
:param revision_id: The handle for the new commit, could be none, as it
81
will be returned, though it is put in the commit message.
82
:param parent_ids: A list of parent_ids to use for the commit.
83
It can be None, which indicates to use the last commit.
84
:param actions: A list of actions to perform. Supported actions are:
85
('add', ('path', 'file-id', 'kind', 'content' or None))
86
('modify', ('file-id', 'new-content'))
87
('unversion', 'file-id')
88
# not supported yet: ('rename', ('orig-path', 'new-path'))
89
;return: The revision_id of the new commit
64
91
if parent_ids is not None:
65
self._branch.lock_write()
67
base_id = parent_ids[0]
68
# Unfortunately, this is the only real way to get the revno
69
cur_revno, cur_revision_id = self._branch.last_revision_info()
70
g = self._branch.repository.get_graph()
71
new_revno = g.find_distance_to_null(base_id,
72
[(cur_revision_id, cur_revno)])
73
self._branch.set_last_revision_info(new_revno, base_id)
92
base_id = parent_ids[0]
93
if base_id != self._branch.last_revision():
94
self._move_branch_pointer(base_id)
76
96
tree = memorytree.MemoryTree.create_on_branch(self._branch)