simplemerge: refactor _picklabels to be more compact
authorPhil Cohen <phillco@fb.com>
Fri, 25 Aug 2017 13:49:17 -0700
changeset 33933 39d253d088a9
parent 33932 3b2a002ef685
child 33934 6cc8f848b4c3
simplemerge: refactor _picklabels to be more compact Use @martinvonz's suggestion from D376. Differential Revision: https://phab.mercurial-scm.org/D521
mercurial/simplemerge.py
--- a/mercurial/simplemerge.py	Fri Aug 25 13:49:16 2017 -0700
+++ b/mercurial/simplemerge.py	Fri Aug 25 13:49:17 2017 -0700
@@ -406,18 +406,12 @@
     return text
 
 def _picklabels(defaults, overrides):
-    name_a, name_b, name_base = defaults
-
-    if len(overrides) > 0:
-        name_a = overrides[0]
-    if len(overrides) > 1:
-        name_b = overrides[1]
-    if len(overrides) > 2:
-        name_base = overrides[2]
     if len(overrides) > 3:
         raise error.Abort(_("can only specify three labels."))
-
-    return [name_a, name_b, name_base]
+    result = defaults[:]
+    for i, override in enumerate(overrides):
+        result[i] = override
+    return result
 
 def simplemerge(ui, localctx, basectx, otherctx, repo=None, **opts):
     """Performs the simplemerge algorithm.