histedit: change string literals to constants in goal naming
authorKostia Balytskyi <ikostia@fb.com>
Mon, 15 Feb 2016 10:48:36 +0000
changeset 28144 ed6d650b7cb7
parent 28143 c754996fd41f
child 28145 cfa0037448f4
histedit: change string literals to constants in goal naming This is a part of bigger effort to refactor histedit with ultimate goal of understanding it.
hgext/histedit.py
--- a/hgext/histedit.py	Sun Feb 07 18:08:59 2016 +0900
+++ b/hgext/histedit.py	Mon Feb 15 10:48:36 2016 +0000
@@ -982,14 +982,19 @@
     finally:
         release(state.lock, state.wlock)
 
+goalcontinue = 'continue'
+goalabort = 'abort'
+goaleditplan = 'edit-plan'
+goalnew = 'new'
+
 def _getgoal(opts):
     if opts.get('continue'):
-        return 'continue'
+        return goalcontinue
     if opts.get('abort'):
-        return 'abort'
+        return goalabort
     if opts.get('edit_plan'):
-        return 'edit-plan'
-    return 'new'
+        return goaleditplan
+    return goalnew
 
 def _validateargs(ui, repo, state, freeargs, opts, goal, rules, revs):
     # TODO only abort if we try to histedit mq patches, not just
@@ -1045,16 +1050,17 @@
     _validateargs(ui, repo, state, freeargs, opts, goal, rules, revs)
 
     # rebuild state
-    if goal == 'continue':
+    if goal == goalcontinue:
         state.read()
         state = bootstrapcontinue(ui, state, opts)
-    elif goal == 'edit-plan':
+    elif goal == goaleditplan:
         _editplanaction(ui, repo, state, rules)
         return
-    elif goal == 'abort':
+    elif goal == goalabort:
         _abortaction(ui, repo, state)
         return
     else:
+        # goal == goalnew
         _newaction(ui, repo, state, revs, freeargs, opts)
 
     _continueaction(ui, repo, state)