# HG changeset patch # User Jeff Hammel # Date 1376178684 25200 # Node ID 7d6bd51f0323081b627772af23603e4e9989d3b0 # Parent 96859ac4d23fac3809b7821c520d63b076ae2214 python/setup_repo.py diff -r 96859ac4d23f -r 7d6bd51f0323 python/setup_repo.py --- a/python/setup_repo.py Sat Aug 10 16:25:57 2013 -0700 +++ b/python/setup_repo.py Sat Aug 10 16:51:24 2013 -0700 @@ -42,7 +42,7 @@ print >> f, HGRC % { 'host': host, 'repo': repo, 'name': name} -def setup_remote(local_repo, remote_url, push='ssh', remote_path=None): +def setup_remote(local_repo, remote_url, push='ssh', remote_path=None, name=None): """ setup a remote repository for local_repo - remote_url : public (pull) URL for remote repository @@ -52,6 +52,17 @@ # parse remote URL host, netloc, path, query, anchor = urlparse.urlsplit(remote_url) + path = path.rstrip('/') + + # derive name + if name is None: + if '/' in path: + prefix, name = path.rsplit('/', 1) + else: + name = path + assert name + + # get remote path, if specified if remote_path: # split off remote host and path @@ -63,7 +74,7 @@ remote_path = path # setup remote repository - remote_dir = '%s/%s' % (path, name) + remote_dir = '~/%s/%s' % (path.lstrip('/'), name) command = ['ssh', host, "mkdir -p %s && cd %s && hg init" % (remote_dir, remote_dir)] print command # call(command) @@ -105,7 +116,7 @@ if options.remote_url: # setup remote repository - setup_remote(directory, options.remote_url, remote_path=options.remote_path) + setup_remote(directory, options.remote_url, name=name, remote_path=options.remote_path) # push changes call(['hg', 'push', '-R', directory])