# HG changeset patch # User Jeff Hammel # Date 1376187982 25200 # Node ID 6274107e477e5e3b5c1dede82d9eb48351ad7003 # Parent 9d81ec713f1bdc2f29f26b9d677a7855b302106b python/hgrc.py diff -r 9d81ec713f1b -r 6274107e477e python/hgrc.py --- a/python/hgrc.py Sat Aug 10 19:15:40 2013 -0700 +++ b/python/hgrc.py Sat Aug 10 19:26:22 2013 -0700 @@ -11,9 +11,11 @@ import os import subprocess import sys +import urlparse from ConfigParser import RawConfigParser as ConfigParser #@parser # decorator makes this x-form path -> ConfigParser automagically +#@section('paths') def set_default_push(parser, default_push): """ set [paths]:default_push to `default_push` @@ -22,14 +24,23 @@ def set_default_push_to_ssh(parser): """ - set `[path]:default_push` to that given by `[path]:default` but + set `[paths]:default_push` to that given by `[paths]:default` but turn the protocol to 'ssh' + If `[paths]:default` is not there, do nothing. + Returns True if written, otherwise False """ - import pdb; pdb.set_trace() + # get [paths]:default value + if 'paths' not in parser.sections(): + return False + if not parser.has_option('paths', 'default'): + return False + default = parser.get('paths', 'default') - # get default path - default = '' + # parse URL + scheme, netloc, path, query, anchor = urlparse.urlsplit(default) + ssh_url = urlparse.urlunsplit(('ssh', netloc, path, query, anchor)) + def main(args=sys.argv[1:]):