func UpdateRevision(rev *Revision) error {
	_, err := x.Id(rev.ID).Update(rev)
	return err
}
UpdateRevision updates revision information.
package models
import (
	"errors"
	"os"
	"path"
	"strings"
	"time"
	"github.com/Unknwon/com"
	"github.com/gpmgo/switch/pkg/archive"
	"github.com/gpmgo/switch/pkg/log"
	"github.com/gpmgo/switch/pkg/setting"
)
var (
	ErrRevisionIsLocal  = errors.New("revision archive is in local")
	ErrPackageNotExist  = errors.New("package does not exist")
	ErrRevisionNotExist = errors.New("revision does not exist")
)
type Storage int
const (
	LOCAL Storage = iota
)
type Revision struct {
	ID       int64    `xorm:"pk autoincr"`
	PkgID    int64    `xorm:"UNIQUE(s)"`
	Pkg      *Package `xorm:"-"`
	Revision string   `xorm:"UNIQUE(s)"`
	Storage
	Size    int64
	Updated time.Time `xorm:"UPDATED"`
}
func (r *Revision) GetPackage() (err error) {
	if r.Pkg != nil {
		return nil
	}
	r.Pkg, err = GetPakcageByID(r.PkgID)
	return err
}
func (r *Revision) KeyName() (string, error) {
	if r.Storage == LOCAL {
		return "", ErrRevisionIsLocal
	}
	if err := r.GetPackage(); err != nil {
		return "", err
	}
	return r.Pkg.ImportPath + "-" + r.Revision + archive.GetExtension(r.Pkg.ImportPath), nil
}
func GetRevision(pkgID int64, rev string) (*Revision, error) {
	r := &Revision{
		PkgID:    pkgID,
		Revision: rev,
	}
	has, err := x.Get(r)
	if err != nil {
		return nil, err
	} else if !has {
		return nil, ErrRevisionNotExist
	}
	return r, nil
}