shelve: changes getting opts values by get method
authorliscju <piotr.listkiewicz@gmail.com>
Wed, 09 Mar 2016 08:21:57 +0100
changeset 28401 2565fe39a76c
parent 28400 a84fc98a8af5
child 28402 7f77e71e5d7e
shelve: changes getting opts values by get method When shelve is used by another extension that doesn't provide all necessary values in opts shelve raises KeyError exception. This patch fixes this by getting values from opts dictionary with get method.
hgext/shelve.py
--- a/hgext/shelve.py	Sat Feb 27 21:15:16 2016 -0800
+++ b/hgext/shelve.py	Wed Mar 09 08:21:57 2016 +0100
@@ -290,10 +290,10 @@
     else:
         desc = '(changes in empty repository)'
 
-    if not opts['message']:
+    if not opts.get('message'):
         opts['message'] = desc
 
-    name = opts['name']
+    name = opts.get('name')
 
     lock = tr = None
     try:
@@ -540,7 +540,7 @@
 
 def unshelvecleanup(ui, repo, name, opts):
     """remove related files after an unshelve"""
-    if not opts['keep']:
+    if not opts.get('keep'):
         for filetype in 'hg patch'.split():
             shelvedfile(repo, name, filetype).movetobackup()
         cleanupoldbackups(repo)
@@ -630,8 +630,8 @@
         return _dounshelve(ui, repo, *shelved, **opts)
 
 def _dounshelve(ui, repo, *shelved, **opts):
-    abortf = opts['abort']
-    continuef = opts['continue']
+    abortf = opts.get('abort')
+    continuef = opts.get('continue')
     if not abortf and not continuef:
         cmdutil.checkunfinished(repo)
 
@@ -850,7 +850,7 @@
         ('stat', set(['stat', 'list'])),
     ]
     def checkopt(opt):
-        if opts[opt]:
+        if opts.get(opt):
             for i, allowable in allowables:
                 if opts[i] and opt not in allowable:
                     raise error.Abort(_("options '--%s' and '--%s' may not be "