Fix stg repair for hidden patches
[stgit] / stgit / stack.py
index 74c2c10..f166aea 100644 (file)
@@ -438,6 +438,9 @@ class Series(PatchSet):
             return []
         return read_strings(self.__hidden_file)
 
+    def set_hidden(self, hidden):
+        write_strings(self.__hidden_file, hidden)
+
     def get_base(self):
         # Return the parent of the bottommost patch, if there is one.
         if os.path.isfile(self.__applied_file):
@@ -624,7 +627,8 @@ class Series(PatchSet):
         """Deletes an stgit series
         """
         if self.is_initialised():
-            patches = self.get_unapplied() + self.get_applied()
+            patches = self.get_unapplied() + self.get_applied() + \
+                    self.get_hidden();
             if not force and patches:
                 raise StackException, \
                       'Cannot delete: the series still contains patches'
@@ -740,26 +744,6 @@ class Series(PatchSet):
 
         return commit_id
 
-    def undo_refresh(self):
-        """Undo the patch boundaries changes caused by 'refresh'
-        """
-        name = self.get_current()
-        assert(name)
-
-        patch = self.get_patch(name)
-        old_bottom = patch.get_old_bottom()
-        old_top = patch.get_old_top()
-
-        # the bottom of the patch is not changed by refresh. If the
-        # old_bottom is different, there wasn't any previous 'refresh'
-        # command (probably only a 'push')
-        if old_bottom != patch.get_bottom() or old_top == patch.get_top():
-            raise StackException, 'No undo information available'
-
-        git.reset(tree_id = old_top, check_out = False)
-        if patch.restore_old_boundaries():
-            self.log_patch(patch, 'undo')
-
     def new_patch(self, name, message = None, can_edit = True,
                   unapplied = False, show_patch = False,
                   top = None, bottom = None, commit = True,
@@ -1019,7 +1003,7 @@ class Series(PatchSet):
                 git.merge_recursive(bottom, head, top)
             except git.GitException, ex:
                 out.error('The merge failed during "push".',
-                          'Revert the operation with "push --undo".')
+                          'Revert the operation with "stg undo".')
 
         append_string(self.__applied_file, name)
 
@@ -1043,29 +1027,6 @@ class Series(PatchSet):
 
         return modified
 
-    def undo_push(self):
-        name = self.get_current()
-        assert(name)
-
-        patch = self.get_patch(name)
-        old_bottom = patch.get_old_bottom()
-        old_top = patch.get_old_top()
-
-        # the top of the patch is changed by a push operation only
-        # together with the bottom (otherwise the top was probably
-        # modified by 'refresh'). If they are both unchanged, there
-        # was a fast forward
-        if old_bottom == patch.get_bottom() and old_top != patch.get_top():
-            raise StackException, 'No undo information available'
-
-        git.reset()
-        self.pop_patch(name)
-        ret = patch.restore_old_boundaries()
-        if ret:
-            self.log_patch(patch, 'undo')
-
-        return ret
-
     def pop_patch(self, name, keep = False):
         """Pops the top patch from the stack
         """