def revert_page(page, sha1, sha2 = nil, commit = {})
      if sha2.is_a?(Hash)
        commit = sha2
        sha2   = nil
      end

      patch     = full_reverse_diff_for(page, sha1, sha2)
      committer = Committer.new(self, commit)
      parent    = committer.parents[0]
      committer.options[:tree] = @repo.git.apply_patch(parent.sha, patch)
      return false unless committer.options[:tree]
      committer.after_commit do |index, _sha|
        @access.refresh

        files = []
        if page
          files << [page.path, page.filename_stripped, page.format]
        else
          # Grit::Diff can't parse reverse diffs.... yet
          patch.each_line do |line|
            if line =~ %r(^diff --git b/.+? a/(.+)$)
              path = Regexp.last_match[1]
              ext  = ::File.extname(path)
              name = ::File.basename(path, ext)
              if (format = ::Gollum::Page.format_for(ext))
                files << [path, name, format]
              end
            end
          end
        end

        files.each do |(path, name, format)|
          dir = ::File.dirname(path)
          dir = '' if dir == '.'
          index.update_working_dir(dir, name, format)
        end
      end

      committer.commit
    end
def revert_page(page, sha1, sha2 = nil, commit = {})
      if sha2.is_a?(Hash)
        commit = sha2
        sha2   = nil
      end

      patch     = full_reverse_diff_for(page, sha1, sha2)
      committer = Committer.new(self, commit)
      parent    = committer.parents[0]
      committer.options[:tree] = @repo.git.apply_patch(parent.sha, patch)
      return false unless committer.options[:tree]
      committer.after_commit do |index, _sha|
        @access.refresh

        files = []
        if page
          files << [page.path, page.filename_stripped, page.format]
        else
          # Grit::Diff can't parse reverse diffs.... yet
          patch.each_line do |line|
            if line =~ %r(^diff --git b/.+? a/(.+)$)
              path = Regexp.last_match[1]
              ext  = ::File.extname(path)
              name = ::File.basename(path, ext)
              if (format = ::Gollum::Page.format_for(ext))
                files << [path, name, format]
              end
            end
          end
        end

        files.each do |(path, name, format)|
          dir = ::File.dirname(path)
          dir = '' if dir == '.'
          index.update_working_dir(dir, name, format)
        end
      end

      committer.commit
    end
Public: Applies a reverse diff for a given page.  If only 1 SHA is given,
 the reverse diff will be taken from its parent (^SHA...SHA).  If two SHAs
 are given, the reverse diff is taken from SHA1...SHA2.

 page   - The Gollum::Page to delete.
 sha1   - String SHA1 of the earlier parent if two SHAs are given,
          or the child.
 sha2   - Optional String SHA1 of the child.
 commit - The commit Hash details:
          :message - The String commit message.
          :name    - The String author full name.
          :email   - The String email address.
          :parent  - Optional Gollum::Git::Commit parent to this update.

 Returns a String SHA1 of the new commit, or nil if the reverse diff does
 not apply.