infocalypse

(djk)
2009-05-13: More fixes to make config file upgrading work.

More fixes to make config file upgrading work.

diff --git a/infocalypse/config.py b/infocalypse/config.py
--- a/infocalypse/config.py
+++ b/infocalypse/config.py
@@ -39,7 +39,7 @@ else:
 DEFAULT_CFG_PATH = '~/%s' % CFG_NAME
 
 # hg version that the format last changed in.
-FORMAT_VERSION = 'c5a3f86418b5'
+FORMAT_VERSION = 'd3023b1560fa'
 
 def normalize(usk_or_id):
     """ Returns a USK hash. """
diff --git a/infocalypse/fms.py b/infocalypse/fms.py
--- a/infocalypse/fms.py
+++ b/infocalypse/fms.py
@@ -108,6 +108,8 @@ def recv_msgs(fms_host, fms_port, msg_si
     server = nntplib.NNTP(fms_host, fms_port)
     try:
         for group in groups:
+            if not group or group.strip() == '':
+                raise ValueError("Empty group names are not allowed.")
             result = server.group(group)
             if result[1] == '0':
                 continue
diff --git a/infocalypse/infcmds.py b/infocalypse/infcmds.py
--- a/infocalypse/infcmds.py
+++ b/infocalypse/infcmds.py
@@ -44,6 +44,7 @@ from updatesm import UpdateStateMachine,
      INSERTING_URI, FAILING, REQUESTING_URI_4_COPY, CANCELING, CleaningUp
 
 from config import Config, DEFAULT_CFG_PATH, FORMAT_VERSION, normalize
+from knownrepos import DEFAULT_TRUST, DEFAULT_GROUPS
 
 DEFAULT_PARAMS = {
     # FCP params
@@ -192,6 +193,14 @@ def get_config_info(ui_, opts):
                  (str(cfg.file_name),
                   cfg.defaults['FORMAT_VERSION'],
                   FORMAT_VERSION))
+
+        # Hacks to clean up variables that were set wrong.
+        if not cfg.fmsread_trust_map:
+            ui_.warn('Set default trust map.\n')
+            cfg.fmsread_trust_map = DEFAULT_TRUST.copy()
+        if not cfg.fmsread_groups or cfg.fmsread_groups == ['', ]:
+            ui_.warn('Set default fmsread groups.\n')
+            cfg.fmsread_groups = DEFAULT_GROUPS
         Config.to_file(cfg)
         ui_.warn('Converted OK.\n')