func (s *BzrRepo) Current() (string, error) {
	tip, err := s.CommitInfo("-1")
	if err != nil {
		return "", err
	}
	curr, err := s.Version()
	if err != nil {
		return "", err
	}
	if tip.Commit == curr {
		return "-1", nil
	}
	ts, err := s.TagsFromCommit(curr)
	if err != nil {
		return "", err
	}
	if len(ts) > 0 {
		return ts[0], nil
	}
	return curr, nil
}
Current returns the current version-ish. This means:
* -1 if on the tip of the branch (this is the Bzr value for HEAD)
* A tag if on a tag
* Otherwise a revision
package vcs
import (
	"fmt"
	"net/url"
	"os"
	"os/exec"
	"path/filepath"
	"regexp"
	"strings"
	"time"
)
var bzrDetectURL = regexp.MustCompile("parent branch: (?P<foo>.+)\n")
func NewBzrRepo(remote, local string) (*BzrRepo, error) {
	ins := depInstalled("bzr")
	if !ins {
		return nil, NewLocalError("bzr is not installed", nil, "")
	}
	ltype, err := DetectVcsFromFS(local)
	if err == nil && ltype != Bzr {
		return nil, ErrWrongVCS
	}
	r := &BzrRepo{}
	r.setRemote(remote)
	r.setLocalPath(local)
	r.Logger = Logger
	if err == nil && r.CheckLocal() == true && remote == "" {
		c := exec.Command("bzr", "info")
		c.Dir = local
		c.Env = envForDir(c.Dir)
		out, err := c.CombinedOutput()
		if err != nil {
			return nil, NewLocalError("Unable to retrieve local repo information", err, string(out))
		}
		m := bzrDetectURL.FindStringSubmatch(string(out))
		if m[1] != "" {
			r.setRemote(m[1])
		}
	}
	return r, nil
}
type BzrRepo struct {
	base
}
func (s BzrRepo) Vcs() Type {
	return Bzr
}
func (s *BzrRepo) Get() error {
	basePath := filepath.Dir(filepath.FromSlash(s.LocalPath()))
	if _, err := os.Stat(basePath); os.IsNotExist(err) {
		err = os.MkdirAll(basePath, 0755)
		if err != nil {
			return NewLocalError("Unable to create directory", err, "")
		}
	}
	out, err := s.run("bzr", "branch", s.Remote(), s.LocalPath())
	if err != nil {
		return NewRemoteError("Unable to get repository", err, string(out))
	}
	return nil
}
func (s *BzrRepo) Init() error {
	out, err := s.run("bzr", "init", s.LocalPath())
	if err != nil && s.isUnableToCreateDir(err) {
		basePath := filepath.Dir(filepath.FromSlash(s.LocalPath()))
		if _, err := os.Stat(basePath); os.IsNotExist(err) {
			err = os.MkdirAll(basePath, 0755)
			if err != nil {
				return NewLocalError("Unable to initialize repository", err, "")
			}
			out, err = s.run("bzr", "init", s.LocalPath())
			if err != nil {
				return NewLocalError("Unable to initialize repository", err, string(out))
			}
			return nil
		}
	} else if err != nil {
		return NewLocalError("Unable to initialize repository", err, string(out))
	}
	return nil
}
func (s *BzrRepo) Update() error {
	out, err := s.RunFromDir("bzr", "pull")
	if err != nil {
		return NewRemoteError("Unable to update repository", err, string(out))
	}
	out, err = s.RunFromDir("bzr", "update")
	if err != nil {
		return NewRemoteError("Unable to update repository", err, string(out))
	}
	return nil
}
func (s *BzrRepo) UpdateVersion(version string) error {
	out, err := s.RunFromDir("bzr", "update", "-r", version)
	if err != nil {
		return NewLocalError("Unable to update checked out version", err, string(out))
	}
	return nil
}
func (s *BzrRepo) Version() (string, error) {
	out, err := s.RunFromDir("bzr", "revno", "--tree")
	if err != nil {
		return "", NewLocalError("Unable to retrieve checked out version", err, string(out))
	}
	return strings.TrimSpace(string(out)), nil
}