+ def undo_refresh(self):
+ """Undo the patch boundaries changes caused by 'refresh'
+ """
+ name = self.get_current()
+ assert(name)
+
+ patch = Patch(name, self.__patch_dir, self.__refs_dir)
+ 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 refresh undo information available'
+
+ git.reset(tree_id = old_top, check_out = False)
+ if patch.restore_old_boundaries():
+ self.log_patch(patch, 'undo')
+