grim/hgkeeper
Clone
Summary
Browse
Changes
Graph
access.yml is no longer used for out authentication, also not sure how this ended up here...
2019-09-11, Gary Kramlich
2664db87766e
access.yml is no longer used for out authentication, also not sure how this ended up here...
package
hg
import
(
"os"
"os/exec"
log
"github.com/sirupsen/logrus"
)
type
Command
struct
{
cmd
*
exec
.
Cmd
tmpHgrc
string
writeable
bool
}
func
(
c
*
Command
)
Setup
()
error
{
hgrc
,
err
:=
createHgrc
(
c
.
writeable
)
if
err
!=
nil
{
return
err
}
c
.
tmpHgrc
=
hgrc
c
.
cmd
.
Env
=
append
(
os
.
Environ
(),
"HGRCPATH="
+
c
.
tmpHgrc
)
return
nil
}
func
(
c
*
Command
)
Teardown
()
{
if
c
.
tmpHgrc
!=
""
{
if
err
:=
os
.
Remove
(
c
.
tmpHgrc
);
err
!=
nil
{
log
.
Warnf
(
"failed to remove %q: %v"
,
c
.
tmpHgrc
,
err
)
}
c
.
tmpHgrc
=
""
}
}
func
(
c
*
Command
)
Cmd
()
*
exec
.
Cmd
{
return
c
.
cmd
}
func
Init
(
path
string
)
*
Command
{
return
&
Command
{
cmd
:
exec
.
Command
(
"hg"
,
"init"
,
path
),
}
}
func
Serve
(
path
string
,
writeable
bool
)
*
Command
{
return
&
Command
{
cmd
:
exec
.
Command
(
"hg"
,
"-R"
,
path
,
"serve"
,
"--stdio"
),
writeable
:
writeable
,
}
}
func
Add
(
path
string
,
files
...
string
)
*
Command
{
args
:=
append
([]
string
{
"add"
,
"--cwd"
,
path
},
files
...
)
return
&
Command
{
cmd
:
exec
.
Command
(
"hg"
,
args
...
),
}
}
func
Commit
(
path
,
username
,
message
string
)
*
Command
{
args
:=
[]
string
{
"commit"
,
"--cwd"
,
path
,
"--config"
,
"ui.username="
+
username
,
"-m"
,
message
,
}
return
&
Command
{
cmd
:
exec
.
Command
(
"hg"
,
args
...
),
}
}