-
Notifications
You must be signed in to change notification settings - Fork 0
/
example3.go
36 lines (30 loc) · 840 Bytes
/
example3.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
// Copyright 2012, The gohg Authors. All rights reserved.
// Use of this source code is governed by a BSD style license
// that can be found in the LICENSE.md file.
// This program is an example of how you can use the gohg library.
package main
import (
hg "bitbucket.org/gohg/gohg"
"fmt"
"log"
)
func main() {
// Set var hgexe to whatever is appropriate for your situation.
// You can also change it to test with different versions of Mercurial.
hgexe := "hg"
repo := "."
var cfg []string
hgcl := hg.NewHgClient()
if err := hgcl.Connect(hgexe, repo, cfg, false); err != nil {
log.Fatal(err)
}
defer hgcl.Disconnect()
cmd := make([]string, 4)
cmd[0] = "log"
cmd[1] = "--limit"
cmd[2] = "2"
cmd[3] = "-v"
res, _ := hgcl.ExecCmd(cmd)
fmt.Printf("%s\n", hgcl.ShowLastCmd())
fmt.Printf("result:\n%s", string(res))
}