gohg

package module
v0.0.0-...-32d5a06 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2014 License: BSD-2-Clause Imports: 12 Imported by: 12

README

gohg - a Go client library for Mercurial

wercker status Build Status Build Status

What it is

This project provides a Go client library for the Mercurial dvcs, using its Command Server.

The purpose is to make working with Mercurial as transparent and Go-like as possible. So gohg only passes your commands to Mercurial, and does not check them for validity, as that is already done quite well by Mercurial itself. It returns any results - and/or error messages - from Mercurial 'as is'. Well, some results will eventually be wrapped in a more Go-like form, like changeset info for instance.

It is as much an occasion for me to experience working with Go :) .

Features
  • Choice of what hg command/version to use (default = 'hg').
  • Choice of repo to work on (default = '.').
  • First create a new repo on the fly before connecting to it (see the 4th param to Connect()).
  • Commands implemented so far: add, addremove, annotate, archive, branches, clone, commit, diff, export, forget, heads, identify, init, log, manifest, merge, pull, push, remove, serve, showconfig, status, summary, tags, tip, update, verify, version.
  • Options implemented so far: all options for all implemented commands (except global --color and --print0 for status).
  • Obtain the full commandstring that was passed to Mercurial (for showing in the GUI f.i.).
  • Pass any command to Hg, allowing for use of extensions, and future commands when they are not yet implemented by gohg.
  • Commands returning changeset info do that in a Go-like way, using a slice of structs, where each element is a changeset. TODO
  • Ask for 'raw' Hg output (as shown on stdout when issuing a hg command from a terminal). TODO
Compatibility
Mercurial

For Mercurial any version starting from 1.9 should be ok, cause that's the one where the Command Server was introduced. If you send wrong options to it through gohg, or commands or options not yet supported (or obsolete) in your Hg version, you'll simply get back an error from Hg itself, as gohg does not check them. But on the other hand gohg allows issuing new commands, not yet implemented by gohg; see the documentation.

Go

Currently gohg is developed with Go1.2.1. Though I started with the Go1.0 versions, I can't remember having had to change more than one or two minor things when moving to Go1.1.1. Updating to Go1.1.2 required no changes at all. I had an issue though with Go1.2, on Windows only, causing some tests using os.exec.Command to fail. I'll have to look into that further, to find out if I should report a bug.

Platform

I'm developing and testing both on Windows 7 and Ubuntu 12.04/13.04/13.10. But I suppose it should work on any other platform that supports Mercurial and Go.

Dependencies

Only Go and it's standard library. And Mercurial should be installed of course.

Installation

At the commandline type:

go get [-u] bitbucket.org/gohg/gohg
go test [-v] bitbucket.org/gohg/gohg

to have gohg available in your GOPATH.

Example

Run this example program in a terminal from a folder containing a Mercurial repository. Or pass the repo of your choice as the second parameter for Connect(). (You can find the source in the \examples folder as readme-test.go, along with a few others.)

:::go
package main

import (
    hg "bitbucket.org/gohg/gohg"
    "fmt"
    "log"
)

func main() {
    var err error
    hc := hg.NewHgClient()
    if err = hc.Connect("", "", nil); err != nil {
        log.Fatal(err)
    }
    defer hc.Disconnect()

    var summ []byte
    if summ, err = hc.Summary(nil, nil); err != nil {
        fmt.Println(err)
    }
    fmt.Printf("\"summary\" for repo %s:\n%s\n", hc.RepoRoot(), summ)

    var l []byte
    files := []string{}
    if l, err = hc.Log([]hg.Option{hg.Limit(2)}, files); err != nil {
        fmt.Println(err)
    }
    fmt.Printf("\"log -l 2\" for repo %s:\n%s\n", hc.RepoRoot(), l)
}
Documentation

For more details on how to use gohg have a look at the documentation.

Feedback

Please note that this tool is still in it's very early stages. If you have suggestions or requests, or experience any problems, please use the issue tracker. Or you could send a patch or a pull request.

License

Copyright 2012-2014, 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.

Documentation

Overview

Package gohg is a Go client library for using the Mercurial dvcs via it's Command Server.

For Mercurial see: http://mercurial.selenic.com.

For the Hg Command Server see: http://mercurial.selenic.com/wiki/CommandServer.

Compatibility

▪ Mercurial

For Mercurial any version starting from 1.9 should be ok, cause that's the one where the Command Server was introduced. If you send wrong options to it through gohg, or commands or options not yet supported (or obsolete) in your Hg version, you'll simply get back an error from Hg itself, as gohg does not check them. But on the other hand gohg allows issuing new commands, not yet implemented by gohg; see further.

▪ Go

Currently gohg is currently developed with Go1.2.1. Though I started with the Go1.0 versions, I can't remember having had to change one or two minor things when moving to Go1.1.1. Updating to Go1.1.2 required no changes at all. I had an issue though with Go1.2, on Windows only, causing some tests using os.exec.Command to fail. I'll have to look into that further, to find out if I should report a bug.

▪ Platform

I'm developing and testing both on Windows 7 and Ubuntu 12.04/13.04/13.10. But I suppose it should work on any other platform that supports Hg and Go.

Dependencies

Only Go and it's standard library. And Mercurial should be installed of course.

Installation

At the commandline type:

go get [-u] bitbucket.org/gohg/gohg
go test [-v] bitbucket.org/gohg/gohg

to have gohg available in your GOPATH.

Import the package

Start with importing the gohg package. Examples:

import gohg "bitbucket.org/gohg/gohg"

or

import hg "bitbucket.org/gohg/gohg"

Connecting the Mercurial Command Server

All interaction with the Mercurial Command Server (Hg CS from now on) happens through the HgClient type, of which you have to create an instance:

hgcl :=  NewHgClient()

Then you can connect the Hg CS as follows:

err := hgcl.Connect("hg", "~/myrepo", nil, false)
 5                   1        2        3     4

1. The Hg executable:

The first parameter is the Mercurial command to use (which 'hg'). You can leave it blanc to let the gohg tool use the default Mercurial command on the system. Having a parameter for the Hg command allows for using a different Hg version, for testing purposes for instance.

2. The repository path:

The second parameter is the path to the repository you want to work on. You can leave it blanc to have gohg use the repository it can find for the current path you are running the program in (searching upward in the folder tree eventually).

3. The config for the session:

The third parameter allows to provide extra configuration for the session. Though this is currently not implemented yet.

4. Should gohg create a new repo before connecting?

This fourth parameter allows you to indicate that you want gohg to first create a new Mercurial repo if it does not already exist in the path given by the second parameter. See the documentation for more detailed info.

5. The returnvalue:

The HgClient.Connect() method eventually returns an error, so you can check if the connection succeeded, and if it is safe to go on.

Once the work is done, you can disconnect the Hg CS using a typical Go idiom:

err := hgcl.Connect("hg", "~/myrepo", nil)
if err != nil {
    log.Fatal(err)
}
defer hgcl.Disconnect()
// do the real work here

Config

The gohg tool sets some environment variables for the Hg CS session, to ensure it's good working:

// ensure Hg works in english
HGPLAIN=True
// Use only the .hg/hgrc from the repo itself.
HGRCPATH=''
HGENCODING=UTF-8

Commands

Once we have a connection to a Hg CS we can do some work with the repository. This is done with commands, and gohg offers 3 ways to use them.

1. The command methods of the HgClient type.

2. The HgCmd type.

3. The ExecCmd() method of the HgClient type.

Each of which has its own reason of existence.

Commands return a byte slice containing the resulting data, and eventually an error. But there are a few exceptions (see api docs).

log, err := hgcl.Log(nil, nil)       // log is a byte slice
err := hgcl.Init(nil, "~/mynewrepo") // only returns an error eventually
vers, err:= hgcl.Version()           // vers is a string of the form '2.4'

If a command fails, the returned error contains 5 elements: 1) the name of the internal routine where the error was trapped, 2) the name of the HgClient command that was run, 3) the returncode by Mercurial, 4) the full command that was passed to the Hg CS, and 5) the eventual error message returned by Mercurial.

So the command

idinfo, err := hgcl.Identify([]hg.HgOption{hg.Verbose(true)}, []string{"C:\\DEV\\myrepo"})

could return something like the following in the err variable when it fails:

runcommand: Identify(): returncode=-1
cmd: identify -v C:\DEV\myrepo
hgerr:

The command aliases (like 'id' for 'identify') are not implemented. But there are examples in identify.go and showconfig.go of how you can easily implement them yourself.

Commands - HgClient command methods

This is the easiest way, a kind of convenience. And the most readable too. A con is that as a user you cannot know the exact command that was passed to Hg, without some extra mechanics.

Each command has the same name as the corresponding Hg command, except it starts with a capital letter of course.

An example (also see examples/example1.go):

log, err := hgcl.Log([]hg.HgOption{hg.Limit(2)}, []string("my-file"))
if err != nil {
    fmt.Printf(err)
    ...
}
fmt.Printf("%s", log)

Note that these methods all use the HgCmd type internally. As such they are convenience wrappers around that type. You could also consider them as a kind of syntactic sugar. If you just want to simply issue a command, nothing more, they are the way to go.

The only way to obtain the commandstring sent to Hg when using these command methods, is by calling the HgClient.ShowLastCmd() method afterwards before issuing any other commands:

log, err := hgcl.Log([]hg.HgOption{hg.Limit(2)}, []string("my-file"))
fmt.Printf("%s", hgcl.ShowLastCmd()) // prints: log --limit 2 my-file

Commands - the HgCmd type

Using the HgCmd type is kind of the standard way. It is a struct that you can instantiate for any command, and for which you can set elements Name, Options and Params (see the api docs for more details). It allows for building the command step by step, and also to query the exact command that will be sent to the Hg CS.

A pro of this method is that it allows you to obtain the exact command string that will be passed to Mercurial before it is performed, by calling the CmdLine() method of HgCmd. This could be handy for logging, or for showing feedback to the user in a GUI program. (You could even call CmdLine() several times, and show the building of the command step by step.)

An example (also see examples/example2.go):

opts := make([]hg.HgOption, 2)
var lim Limit = 2
opts[0] = lim
var verb Verbose = true
opts[1] = verb
cmd, _ := hg.NewHgCmd("log", opts, nil, new(hg.logOpts))
cmd.SetOptions(opts)
cmdline, _ := cmd.CmdLine(hgcl)
fmt.Printf("%s\n", cmdline) // output: log --limit 2 -v
cmd.Exec(hgcl)

As you can see, this way requires some more coding.

The source code will also show you that the HgCmd type is indeed used as the underlying type for the convenience HgClient commands, in all the New<hg-command>Cmd() constructors.

Commands - ExecCmd

The HgClient type has an extra method ExecCmd(), allowing you to pass a fully custom built command to Hg. It accepts a string slice that is supposed to contain all the elements of the complete command, as you would type it at the command line.

It could be a convenient way for performing commands that are not yet implemented in gohg, or to make use of extensions to Hg (for which gohg offers no support (yet?)).

An example (also see examples/example3.go):

hgcmd := []string{"log", "--limit", "2"}
result, err := hgcl.ExecCmd(hgcmd)

Options and Parameters

Just like on the commandline, options come before parameters.

opts := []hg.HgOption{hg.Verbose(true), hg.Limit(2)}
params := []string{"mytool.go"}
log, err := hgcl.Log(opts, params)

Options to commands use the same name as the long form of the Mercurial option they represent, but start with the necessary capital letter. An options value can be of type bool, int or string. You just pass the value as the parameter to the option (= type conversion of the value to the option type). You can pass any number of options, as the elements of a slice. Options can occur more than once if appropriate (see the ones marked with '[+]' in the Mercurial help).

log, err := hgcl.Log([]hg.HgOption{hg.Verbose(true)}, nil)                 // bool
log, err := hgcl.Log([]hg.HgOption{hg.Limit(2)}, nil)                      // int
log, err := hgcl.Log([]hg.HgOption{hg.User("John Doe"), hg.User("me")}, nil)  // string, repeated option

Parameters are used to provide any arguments for a command that are not options. They are passed in as a string or a slice of strings, depending on the command. These parameters typically contain revisions, paths or filenames and so.

log, err := hgcl.Log(nil, []string{"myfile"})
heads, err := hgcl.Heads(nil, []string{"foobranch"})

The gohg tool only checks if the options the caller gives are valid for that command. It does not check if the values are valid for the combination of that command and that option, as that is done by Mercurial. No need to implement that again. If an option is not valid for a command, it is silently ignored, so it is not passed to the Hg CS.

A few options are not implemented, as they seemed not relevant for use with this tool (for instance: the global --color option, or the --print0 option for status).

Error handling

The gohg tool only returns errors, with an as clear as possible message, and never uses log.Fatal() nor panics, even if those may seem appropriate. It leaves it up to the caller to do that eventually. It's not up to this library to decide whether to do a retry or to abort the complete application.

Limitations

▪ The following config settings are fixated in the code (at least for now):

encoding=utf-8
ui.interactive=False
extensions.color=!

▪ As mentioned earlier, passing config info is not implemented yet.

▪ Currently the only support for extensions to Mercurial is through the ExecCmd method.

▪ If multiple Hg CSs are used against the same repo, it is up to Mercurial to handle this correctly.

▪ Mercurial is always run in english. Internationalization is not necessary here, as the conversation with Hg is internal to the application.

Feedback

Please note that this tool is still in it's very early stages. If you have suggestions or requests, or experience any problems, please use the issue tracker at https://bitbucket.org/gohg/gohg/issues?status=new&status=open. Or you could send a patch or a pull request.

License

Copyright 2012-2014, 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.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessLog

type AccessLog string // -A --accesslog FILE

type Active

type Active bool // -a --active

type AddRemove

type AddRemove bool // -A  --addremove

type Added

type Added bool // -a --added

type Address

type Address string // -a --address ADDR

type After

type After bool // -A --after

type All

type All bool //    --all

type AllTasks

type AllTasks bool //    --all-tasks

type Amend

type Amend bool //    --ammend

type Bookmark

type Bookmark string // -B --bookmark BOOKMARK [+]

type Bookmarks

type Bookmarks bool // -B --bookmarks

type Branch

type Branch bool // -b --branch BRANCH [+]

type Certificate

type Certificate string //    --certificate FILE

type Change

type Change bool // [-c] --change REV

type Changeset

type Changeset bool // -c --changeset

type Check

type Check bool // -c --check

type Clean

type Clean bool // -c --clean // -C --clean (update)

type CloseBranch

type CloseBranch bool //    --close-branch

type Closed

type Closed bool // -c --closed

type CmdServer

type CmdServer string //    --cmdserver MODE

type CompletedTasks

type CompletedTasks bool //    --completed-tasks

type Config

type Config string //    --config

type Copies

type Copies bool // -C --copies

type Cset

type Cset struct {
	Rev    int
	Node   string
	Tags   []string
	Branch string
	Author string
	Time   time.Time // always as UTC
	Desc   string
	Patch  []string
}

Cset: Should be moved into a separate sourcefile, together with any other Mercurial related stuff.

type Cwd

type Cwd string //    --cwd

type Daemon

type Daemon bool // -d --daemon

type DaemonPipefds

type DaemonPipefds int //    --daemon-pipefds NUM

type Date

type Date string // -d --date

type Debug

type Debug bool //    --debug

type Deleted

type Deleted bool // -d --deleted

type DryRun

type DryRun bool // -n --dry-run

type ErrorLog

type ErrorLog string // -E --errorlog FILE

type Exclude

type Exclude string // -X --exclude PATTERN [+]

type File

type File bool // -f --file

type Follow

type Follow bool // -f --follow

type Force

type Force bool // -f --force

type Git

type Git bool // -g --git

type Graph

type Graph bool // -G --graph

type HgClient

type HgClient struct {
	// contains filtered or unexported fields
}

Type HgClient acts as the entrypoint through which all interaction with the Mercurial Command Server takes place. If you want to keep a pool of connections to multiple repos, you can create multiple HgClient instances, each connecting to its own Hg CS.

func NewHgClient

func NewHgClient() *HgClient

NewHgClient creates a new instance of the client type for working with the Hg Command Server.

func (*HgClient) Add

func (hgcl *HgClient) Add(opts []HgOption, files []string) ([]byte, error)

func (*HgClient) AddRemove

func (hgcl *HgClient) AddRemove(opts []HgOption, files []string) ([]byte, error)

func (*HgClient) Annotate

func (hgcl *HgClient) Annotate(opts []HgOption, files []string) ([]byte, error)

func (*HgClient) Archive

func (hgcl *HgClient) Archive(opts []HgOption, dest []string) ([]byte, error)

func (*HgClient) Branches

func (hgcl *HgClient) Branches(opts []HgOption, params []string) ([]byte, error)

func (*HgClient) Capabilities

func (hgcl *HgClient) Capabilities() []string

Capabilities returns the capabilities of the connected Hg CS.

func (*HgClient) Clone

func (hgcl *HgClient) Clone(opts []HgOption, fromto []string) error

func (*HgClient) Commit

func (hgcl *HgClient) Commit(opts []HgOption, files []string) error

func (*HgClient) Connect

func (hgcl *HgClient) Connect(hgexe string, reponame string, config []string, initrepo bool) error

Connect establishes the connection with the Mercurial Command Server.

Arguments:

hgexe
	The command to run Mercurial. Optional.
	The 'hg' command will be used when not provided.
	This allows to run a specific version of Mercurial.
reponame
	The folder of the Hg repository to work on. Optional.
	When blanc the folder where the program is run is used
	(see function locateRepository()).
config
	Configuration settings that will be added to the necessary
	fixed settings (see composeStartupConfig() for more). Optional.
initrepo
	When a repo exitsts for reponame, then initrepo is ignored.
	When no repo is found for reponame, and initrepo is true,
	  then Connect() will first create the repository before connecting.
	When no repo is found for reponame, and initrepo is false,
	  then Connect() will return an error.

Returns an error if the connection could not be established properly.

Example
hc := NewHgClient()
if err := hc.Connect("hg", ".", []string{""}, false); err != nil {
	log.Fatal(err)
}
defer hc.Disconnect()
// Call some useful methods on hc here.
Output:

func (*HgClient) Diff

func (hgcl *HgClient) Diff(opts []HgOption, files []string) ([]byte, error)

func (*HgClient) Disconnect

func (hgcl *HgClient) Disconnect() error

Disconnect ends the connection with the Mercurial Command Server.

func (*HgClient) Encoding

func (hgcl *HgClient) Encoding() string

Encoding returns the encoding for the connected Hg CS.

func (*HgClient) ExecCmd

func (hgcl *HgClient) ExecCmd(hgcmd []string) ([]byte, error)

ExecCmd allows to pass in a full commandline for the Hg CS by yourself, though in a less Go-like way. No checks are done however; the command is directly passed to the Hg CS as is. See client_test.go for an example. This method could come in handy when you want to use a new Hg command for which the gohg tool is not yet updated. Or for using some extension to Hg. Be sure to add an option and its value separately to hgcmd. (is not ok: ' hgcmd[1] = "--limit 2" ', is ok: ' hgcmd[1] = "--limit"; hgcmd[2] = "2" ')

func (*HgClient) Export

func (hgcl *HgClient) Export(opts []HgOption, params []string) ([]byte, error)

func (*HgClient) Forget

func (hgcl *HgClient) Forget(opts []HgOption, files []string) ([]byte, error)

func (*HgClient) Heads

func (hgcl *HgClient) Heads(opts []HgOption, revs []string) ([]byte, error)

func (*HgClient) HgExe

func (hgcl *HgClient) HgExe() string

HgExe returns the path of the Mercurial executable used in the Hg CS.

func (*HgClient) Identify

func (hgcl *HgClient) Identify(opts []HgOption, source []string) ([]byte, error)

func (*HgClient) Init

func (hgcl *HgClient) Init(opts []HgOption, destpath string) error

Be aware of the fact that Init() cannot be used to initialize the repo you want the (current) Hg CS to work on, as the Hg CS requires an existing repo before you can connect it. But Init() can be used to create any new repo besides the one the Hg CS is running for.

func (*HgClient) IsConnected

func (hgcl *HgClient) IsConnected() bool

IsConnected tells if there is a connection to a Hg CS.

func (*HgClient) Log

func (hgcl *HgClient) Log(opts []HgOption, files []string) ([]byte, error)

func (*HgClient) Manifest

func (hgcl *HgClient) Manifest(opts []HgOption, params []string) ([]byte, error)

func (*HgClient) Merge

func (hgcl *HgClient) Merge(opts []HgOption, rev []string) ([]byte, error)

func (*HgClient) Pull

func (hgcl *HgClient) Pull(opts []HgOption, source []string) ([]byte, error)

func (*HgClient) Push

func (hgcl *HgClient) Push(opts []HgOption, dest []string) ([]byte, error)

func (*HgClient) Remove

func (hgcl *HgClient) Remove(opts []HgOption, files []string) ([]byte, error)

func (*HgClient) RepoRoot

func (hgcl *HgClient) RepoRoot() string

RepoRoot returns the root of the repository the connected Hg CS is working on.

func (*HgClient) Serve

func (hgcl *HgClient) Serve(opts []HgOption, params []string) ([]byte, error)

func (*HgClient) ShowConfig

func (hgcl *HgClient) ShowConfig(opts []HgOption, configitems []string) ([]byte, error)

func (*HgClient) ShowLastCmd

func (hgcl *HgClient) ShowLastCmd() string

ShowLastCmd produces the commandline for the last command that was submitted to the Hg CS until then. It is a convenience for if you use the hgcl.Identify() way of issuing commands (so not via a HgCmd.Exec(), or via ExecCmd()), and you want to know the exact commandline that was passed to Hg. This one works after all 3 possibilities to pass commands to Hg.

func (*HgClient) Status

func (hgcl *HgClient) Status(opts []HgOption, files []string) ([]byte, error)

func (*HgClient) Summary

func (hgcl *HgClient) Summary(opts []HgOption, params []string) ([]byte, error)

func (*HgClient) Tags

func (hgcl *HgClient) Tags(opts []HgOption, params []string) ([]byte, error)

func (*HgClient) Tip

func (hgcl *HgClient) Tip(opts []HgOption, params []string) ([]byte, error)

func (*HgClient) Update

func (hgcl *HgClient) Update(opts []HgOption, params []string) ([]byte, error)

func (*HgClient) Verify

func (hgcl *HgClient) Verify(opts []HgOption, params []string) ([]byte, error)

func (*HgClient) Version

func (hgcl *HgClient) Version() (string, error)

Version implements the 'hg version -q' command, and only returns the version number.

type HgCmd

type HgCmd struct {
	Name    string
	Options []HgOption
	Params  []string
	// contains filtered or unexported fields
}

HgCmd is the type through which you can create and execute Mercurial commands.

func NewAddCmd

func NewAddCmd(opts []HgOption, files []string) HgCmd

func NewAddRemoveCmd

func NewAddRemoveCmd(opts []HgOption, files []string) HgCmd

func NewAnnotateCmd

func NewAnnotateCmd(opts []HgOption, files []string) HgCmd

func NewArchiveCmd

func NewArchiveCmd(opts []HgOption, dest []string) HgCmd

func NewBranchesCmd

func NewBranchesCmd(opts []HgOption, files []string) HgCmd

func NewCloneCmd

func NewCloneCmd(opts []HgOption, fromto []string) HgCmd

func NewCommitCmd

func NewCommitCmd(opts []HgOption, files []string) HgCmd

func NewDiffCmd

func NewDiffCmd(opts []HgOption, files []string) HgCmd

func NewExportCmd

func NewExportCmd(opts []HgOption, params []string) HgCmd

func NewForgetCmd

func NewForgetCmd(opts []HgOption, files []string) HgCmd

func NewHeadsCmd

func NewHeadsCmd(opts []HgOption, revs []string) HgCmd

func NewHgCmd

func NewHgCmd(name string, opts []HgOption, params []string, cmdopts interface{}) (*HgCmd, error)

NewHgCmd creates a new HgCmd instance for working with Mercurial commands.

func NewIdentifyCmd

func NewIdentifyCmd(opts []HgOption, source []string) HgCmd

func NewInitCmd

func NewInitCmd(opts []HgOption, destpath []string) HgCmd

func NewLogCmd

func NewLogCmd(opts []HgOption, files []string) HgCmd

func NewManifestCmd

func NewManifestCmd(opts []HgOption, files []string) HgCmd

func NewMergeCmd

func NewMergeCmd(opts []HgOption, rev []string) HgCmd

func NewPullCmd

func NewPullCmd(opts []HgOption, source []string) HgCmd

func NewPushCmd

func NewPushCmd(opts []HgOption, dest []string) HgCmd

func NewRemoveCmd

func NewRemoveCmd(opts []HgOption, files []string) HgCmd

func NewServeCmd

func NewServeCmd(opts []HgOption, params []string) HgCmd

func NewShowConfigCmd

func NewShowConfigCmd(opts []HgOption, configitems []string) HgCmd

func NewStatusCmd

func NewStatusCmd(opts []HgOption, files []string) HgCmd

func NewSummaryCmd

func NewSummaryCmd(opts []HgOption, params []string) HgCmd

func NewTagCmd

func NewTagCmd(opts []HgOption, params []string) HgCmd

func NewTipCmd

func NewTipCmd(opts []HgOption, params []string) HgCmd

func NewUpdateCmd

func NewUpdateCmd(opts []HgOption, files []string) HgCmd

func NewVerifyCmd

func NewVerifyCmd(opts []HgOption, params []string) HgCmd

func (*HgCmd) CmdLine

func (hc *HgCmd) CmdLine(hgcl *HgClient) (string, error)

CmdLine gives you the exact commandline as it will be passed to Mercurial, generated with the data in the HgCmd instance. Handy for logging or showing in a GUI.

func (*HgCmd) Exec

func (hc *HgCmd) Exec(hgcl *HgClient) ([]byte, error)

Exec builds the commandline with the data in the HgCmd instance, and then passes the command to the Mercurial Command Server for execution, returning the result or an error.

func (*HgCmd) SetOptions

func (hc *HgCmd) SetOptions(opts []HgOption)

func (*HgCmd) SetParams

func (hc *HgCmd) SetParams(params []string)

type HgOption

type HgOption interface {
	// contains filtered or unexported methods
}

HgOption is an interface that allows adding options to a command in a more or less controlled way.

type Hidden

type Hidden bool //    --hidden

type Id

type Id bool // -i --id

type IgnoreAllSpace

type IgnoreAllSpace bool // -w --ignore-all-space

type IgnoreBlankLines

type IgnoreBlankLines bool // -B --ignore-blank-lines

type IgnoreSpaceChange

type IgnoreSpaceChange bool // -b --ignore-space-change

type Ignored

type Ignored bool // -i --ignored

type Include

type Include string // -I --include PATTERN [+]

type Insecure

type Insecure bool //    --insecure

type Ipv6

type Ipv6 bool // -6 --ipv6

type Keyword

type Keyword string // -k --keyword

type Limit

type Limit int // -l --limit

type LineNumber

type LineNumber bool // -l --line-number

type Logfile

type Logfile string // -l --logfile

type Message

type Message string // -m --message

type Modified

type Modified bool // -m --modified

type Name

type Name string // -n --name NAME

type NewBranch

type NewBranch bool //    --new-branch

type NoDates

type NoDates bool //    --nodates

type NoDecode

type NoDecode bool //    --no-decode

type NoFollow

type NoFollow bool //    --no-follow

type NoMerges

type NoMerges bool // -M --no-merges

type NoStatus

type NoStatus bool // -n --no-status

type NoUpdate

type NoUpdate bool // -U --noupdate

type NonInteractive

type NonInteractive bool // -y --noninteractive

type Num

type Num bool // -n --num

type Number

type Number bool // -n --number

type Output

type Output string // -o --output FORMAT

type Patch

type Patch bool // -p --patch

type PidFile

type PidFile string //    --pid-file FILE

type Port

type Port int // -p --port PORT

type Prefix

type Prefix string // [-p] --prefix PREFIX

type Preview

type Preview bool // -P --preview

type Print0

type Print0 bool // -0 --print0

type Profile

type Profile bool //    --profile

type Prune

type Prune bool // -P --prune

type Pull

type Pull bool //    --pull

type Quiet

type Quiet bool // -q --quiet

type Rebase

type Rebase bool //    --rebase

type Remote

type Remote bool //    --remote

type RemoteCmd

type RemoteCmd string //    --remotecmd CMD

type Removed

type Removed bool // (-r) --removed

type Repository

type Repository string // -R --repository

type Rev

type Rev string // -r --rev REV [+] //    --rev REV [+]

type Reverse

type Reverse bool //    --reverse

type ShowFunction

type ShowFunction bool // -p --show-fuction

type Similarity

type Similarity int // -s --similarity SIMILARITY

type Ssh

type Ssh string // -e --ssh CMD

type Stat

type Stat bool //    --stat

type Stdio

type Stdio bool //    --stdio

type Style

type Style string //    --style STYLE

type SubRepos

type SubRepos bool // -S --subrepos

type SwitchParent

type SwitchParent bool //    --switch-parent

type Tags

type Tags bool // -t --tags

type Template

type Template string //    --template

type Templates

type Templates string // -t --templates TEMPLATE

type Text

type Text bool // -a --text

type Time

type Time bool //    --time

type Tool

type Tool string // -t --tool VALUE

type Topo

type Topo bool // -t --topo

type Traceback

type Traceback bool //    --traceback

type Type

type Type string // -t --type TYPE

type Uncompressed

type Uncompressed bool //    --uncompressed

type Unified

type Unified int // -U --unified NUM

type Unknown

type Unknown bool // -u --unknown

type Untrusted

type Untrusted bool // -u --untrusted

type Update

type Update bool // -u --update

type UpdateRev

type UpdateRev string // -u --updaterev

type User

type User string // -u --user

type Verbose

type Verbose bool // -v --verbose

type WebConf

type WebConf string //    --web-conf FILE

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL