forked from Masterminds/vcs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bzr_upd.go
53 lines (49 loc) · 1.73 KB
/
bzr_upd.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package vcs
// BzrUpdater implements the Repo interface for the Bzr source control.
type BzrUpdater struct {
Description
Results
mirror bool
rebase RebaseVal
refs map[string]RefOp
}
// NewBzrUpdater creates a new instance of BzrUpdater. The remote and localPath
// directories need to be passed in. Params:
// remote (string): URL of remote repo
// remoteName (string): If there is a name for the remote repo (SVN: use "", not used)
// localPath (string): Directory for the local repo/clone/workspace to update
// mirror (bool): if a full mirroring of all content is desired
// rebase (RebaseVal): if rebase wanted or not, what type
// refs (map[string]RefOp): list of refs to act on w/given operation (or nil)
// Currently ignores mirror, rebase and refs.
func NewBzrUpdater(remote, remoteName, localPath string, mirror bool, rebase RebaseVal, refs map[string]RefOp) (Updater, error) {
ltype, err := DetectVcsFromFS(localPath)
// Found a VCS other than Bzr. Need to report an error.
if err == nil && ltype != Bzr {
return nil, ErrWrongVCS
}
u := &BzrUpdater{}
u.mirror = mirror
u.rebase = rebase
if refs != nil { // if refs given, then set up refs to act on w/ops
u.refs = make(map[string]RefOp)
u.refs = refs
}
u.setDescription(remote, remoteName, localPath, defaultBzrSchemes, Bzr)
if err == nil { // Have a localPath FS repo, try to improve the remote..
remote, _, err = BzrCheckRemote(u, remote)
if err != nil {
return nil, err
}
u.setRemote(remote)
}
return u, nil
}
// Update support for bzr updater
func (u *BzrUpdater) Update(rev ...Rev) (Resulter, error) {
return BzrUpdate(u, rev...)
}
// Exists support for bzr updater
func (u *BzrUpdater) Exists(l Location) (string, Resulter, error) {
return BzrExists(u, l)
}