hgkw/keyword.py
changeset 319 2da9ab0bc400
parent 318 12d26936a315
child 320 83dad6b67ed9
--- a/hgkw/keyword.py	Tue Jan 01 19:16:13 2008 +0100
+++ b/hgkw/keyword.py	Wed Jan 02 16:31:49 2008 +0100
@@ -290,11 +290,11 @@
     ui.note(_('creating temporary repo at %s\n') % tmpdir)
     repo = localrepo.localrepository(ui, path=tmpdir, create=True)
     ui.setconfig('keyword', fn, '')
-    if args or opts['rcfile']:
+    if args or opts.get('rcfile'):
         kwstatus = 'custom'
-    if opts['rcfile']:
-        ui.readconfig(opts['rcfile'])
-    if opts['default']:
+    if opts.get('rcfile'):
+        ui.readconfig(opts.get('rcfile'))
+    if opts.get('default'):
         kwstatus = 'default'
         kwmaps = kwtemplater.templates
         if ui.configitems('keywordmaps'):
@@ -308,7 +308,7 @@
         fp.writelines(rcmaps)
         fp.close()
         ui.readconfig(repo.join('hgrc'))
-    if not opts['default']:
+    if not opts.get('default'):
         kwmaps = dict(ui.configitems('keywordmaps')) or kwtemplater.templates
     reposetup(ui, repo)
     for k, v in ui.configitems('extensions'):
@@ -363,23 +363,21 @@
     '''
     status = _status(ui, repo, *pats, **opts)
     modified, added, removed, deleted, unknown, ignored, clean = status
-    if opts['untracked']:
+    if opts.get('untracked'):
         files = modified + added + unknown + clean
     else:
         files = modified + added + clean
     files.sort()
     kwfiles = [f for f in files if _iskwfile(f, repo._link)]
     cwd = pats and repo.getcwd() or ''
-    allf = opts['all']
-    ignore = opts['ignore']
-    if ignore:
+    if opts.get('ignore'):
         kwfstats = ()
     else:
         kwfstats = (('K', kwfiles),)
-    if allf or ignore:
+    if opts.get('all') or opts.get('ignore'):
         kwfstats += (('I', [f for f in files if f not in kwfiles]),)
     for char, filenames in kwfstats:
-        format = (allf or ui.verbose) and '%s %%s\n' % char or '%s\n'
+        format = (opts.get('all') or ui.verbose) and '%s %%s\n' % char or '%s\n'
         for f in filenames:
             ui.write(format % repo.pathto(f, cwd))