def __update_top_ref(self, ref):
git.set_ref(self.__top_ref, ref)
+ self._set_field('top', ref)
+ self._set_field('bottom', git.get_commit(ref).get_parent())
def __update_log_ref(self, ref):
git.set_ref(self.__log_ref, ref)
def set_top(self, value, backup = False):
if backup:
- curr = self.get_top()
- self._set_field('top.old', curr)
+ curr_top = self.get_top()
+ self._set_field('top.old', curr_top)
+ self._set_field('bottom.old', git.get_commit(curr_top).get_parent())
self.__update_top_ref(value)
def restore_old_boundaries(self):
config.remove_section('branch.%s.stgit' % self.get_name())
def refresh_patch(self, files = None, message = None, edit = False,
+ empty = False,
show_patch = False,
cache_update = True,
author_name = None, author_email = None,
if not bottom:
bottom = patch.get_bottom()
+ if empty:
+ tree_id = git.get_commit(bottom).get_tree()
+ else:
+ tree_id = None
+
commit_id = git.commit(files = files,
message = descr, parents = [bottom],
cache_update = cache_update,
+ tree_id = tree_id,
+ set_head = True,
allowempty = True,
author_name = author_name,
author_email = author_email,
# merge can fail but the patch needs to be pushed
try:
- git.merge(bottom, head, top, recursive = True)
+ git.merge_recursive(bottom, head, top)
+ except git.GitConflictException, ex:
+ ex.list()
except git.GitException, ex:
out.error('The merge failed during "push".',
- 'Use "refresh" after fixing the conflicts or'
- ' revert the operation with "push --undo".')
+ 'Revert the operation with "push --undo".')
append_string(self.__applied_file, name)
log = 'push'
self.refresh_patch(bottom = head, cache_update = False, log = log)
else:
- # we store the correctly merged files only for
- # tracking the conflict history. Note that the
- # git.merge() operations should always leave the index
- # in a valid state (i.e. only stage 0 files)
+ # we make the patch empty, with the merged state in the
+ # working tree.
self.refresh_patch(bottom = head, cache_update = False,
- log = 'push(c)')
+ empty = True, log = 'push(c)')
raise StackException, str(ex)
return modified