Skip to content

Instantly share code, notes, and snippets.

@fudanchii
Created May 9, 2012 07:50
Show Gist options
  • Save fudanchii/2642781 to your computer and use it in GitHub Desktop.
Save fudanchii/2642781 to your computer and use it in GitHub Desktop.
fabric file to manage mercurial repository in remote host
from fabric.api import *
from fabric import contrib
# Put your server address here
env.host_string = "192.168.0.133:2221"
env.user = "hg"
# Put your username here
user="adie"
def create(name):
if contrib.files.exists("%s/%s" % (user, name)):
print("Path given already exists.")
return
run("mkdir -p %s/%s" % (user, name))
with cd("%s/%s" % (user, name)):
run("hg init")
print("Mercurial repository created at ssh://%s@%s/%s/%s" %
(env.user, env.host_string, user, name))
def delete(name):
if contrib.files.exists("%s/%s" % (user, name)):
run("rm -r %s/%s" % (user, name))
print("Repo %s/%s deleted." % (user, name))
def ls():
run("ls %s" % user)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment