+
+ def log_patch(self, patch, message, notes = None):
+ """Generate a log commit for a patch
+ """
+ top = git.get_commit(patch.get_top())
+ old_log = patch.get_log()
+
+ if message is None:
+ # replace the current log entry
+ if not old_log:
+ raise StackException, \
+ 'No log entry to annotate for patch "%s"' \
+ % patch.get_name()
+ replace = True
+ log_commit = git.get_commit(old_log)
+ msg = log_commit.get_log().split('\n')[0]
+ log_parent = log_commit.get_parent()
+ if log_parent:
+ parents = [log_parent]
+ else:
+ parents = []
+ else:
+ # generate a new log entry
+ replace = False
+ msg = '%s\t%s' % (message, top.get_id_hash())
+ if old_log:
+ parents = [old_log]
+ else:
+ parents = []
+
+ if notes:
+ msg += '\n\n' + notes
+
+ log = git.commit(message = msg, parents = parents,
+ cache_update = False, tree_id = top.get_tree(),
+ allowempty = True)
+ patch.set_log(log)
+
+ def hide_patch(self, name):
+ """Add the patch to the hidden list.
+ """
+ unapplied = self.get_unapplied()
+ if name not in unapplied:
+ # keep the checking order for backward compatibility with
+ # the old hidden patches functionality
+ if self.patch_applied(name):
+ raise StackException, 'Cannot hide applied patch "%s"' % name
+ elif self.patch_hidden(name):
+ raise StackException, 'Patch "%s" already hidden' % name
+ else:
+ raise StackException, 'Unknown patch "%s"' % name
+
+ if not self.patch_hidden(name):
+ # check needed for backward compatibility with the old
+ # hidden patches functionality
+ append_string(self.__hidden_file, name)
+
+ unapplied.remove(name)
+ write_strings(self.__unapplied_file, unapplied)
+
+ def unhide_patch(self, name):
+ """Remove the patch from the hidden list.
+ """
+ hidden = self.get_hidden()
+ if not name in hidden:
+ if self.patch_applied(name) or self.patch_unapplied(name):
+ raise StackException, 'Patch "%s" not hidden' % name
+ else:
+ raise StackException, 'Unknown patch "%s"' % name
+
+ hidden.remove(name)
+ write_strings(self.__hidden_file, hidden)
+
+ if not self.patch_applied(name) and not self.patch_unapplied(name):
+ # check needed for backward compatibility with the old
+ # hidden patches functionality
+ append_string(self.__unapplied_file, name)