changeset 353:ee8ab3de9c7f

f-ing print
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 27 Jun 2013 02:41:53 -0700
parents eeff298cc922
children 912aec4ab59b
files python/hgrc.py
diffstat 1 files changed, 19 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/python/hgrc.py	Thu Jun 27 02:13:40 2013 -0700
+++ b/python/hgrc.py	Thu Jun 27 02:41:53 2013 -0700
@@ -17,18 +17,20 @@
     # command line parser
     usage = '%prog [options] repository <repository> <...>'
     parser = optparse.OptionParser(usage=usage, description=__doc__)
-    parser.add_option('-p', '--print', dest='print',
+    parser.add_option('-p', '--print', dest='print_hgrc',
                       action='store_true', default=False,
                       help="print full path to hgrc files and exit")
     parser.add_option('--ssh', dest='default_push_ssh',
                       action='store_true', default=False,
                       help="use `default` entries for `default-push`")
+    parser.add_option('--push', '--default-push', dest='default_push',
+                      help="set [paths] default-push location")
     options, args = options.parse_args(args)
     if not args:
         parser.print_usage()
         parser.exit()
 
-    # find all .hgrc files
+    # find all hgrc files
     hgrc = []
     missing = []
     not_hg = []
@@ -57,15 +59,26 @@
             assert os.path.isfile(path), "%s is not a file, exiting" % path
         hgrc.append(path)
 
+    # raise errors if encountered
+    if sum(errors.values()):
+        for key, value in errors.items():
+            if value:
+                print '%s: %s' % (key, ', '.join(value))
+        parser.exit(1)
+
     # construct ConfigParser objects and
     # ensure that all the files are parseable
     config = {}
     for path in hgrc:
-        config['path'] = ConfigParser()
+        config[path] = ConfigParser()
         if isinstance(path, basestring):
-            config['path'].read(path)
-        
-    if options.print:
+            if os.path.exists(path):
+                config[path].read(path)
+        else:
+            # XXX this code path is untenable
+            config[path].
+
+    if options.print_hgrc:
         # print the chosen hgrc paths and you're done
         print '\n'.join(hgrc)
         parser.exit()