Patchwork [12,of,15,V5] bash_completion: change --rev if-else block into a case

login
register
mail settings
Submitter Sean Farley
Date Nov. 26, 2013, 7:54 p.m.
Message ID <58efbd280c39addee05f.1385499291@laptop.local>
Download mbox | patch
Permalink /patch/3166/
State Accepted
Commit f6c33fc59dbd72344040ac1da254ef6e262f0273
Headers show

Comments

Sean Farley - Nov. 26, 2013, 7:54 p.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1385496252 21600
#      Tue Nov 26 14:04:12 2013 -0600
# Node ID 58efbd280c39addee05fe06175989da96823efd0
# Parent  1e5decdcde0ac1767b980c212901ca7559a92d99
bash_completion: change --rev if-else block into a case

Again, this doesn't change behavior but does make it easy to add cases in the
next patch.

Patch

diff --git a/contrib/bash_completion b/contrib/bash_completion
--- a/contrib/bash_completion
+++ b/contrib/bash_completion
@@ -237,16 +237,20 @@ 
     if [ "$(type -t "_hg_cmd_$cmd")" = function ]; then
         "_hg_cmd_$cmd"
         return 0
     fi
 
-    if [ "$cmd" != status ] && [ "$prev" = -r ] || [ "$prev" == --rev ]; then
-        if [[ $canonical = 1 || status != "$cmd"* ]]; then
-            _hg_labels
-            return 0
-        fi
-        return 1
+    if [ "$cmd" != status ]; then
+        case "$prev" in
+            -r|--rev)
+                if [[ $canonical = 1 || status != "$cmd"* ]]; then
+                    _hg_labels
+                    return 0
+                fi
+                return 1
+            ;;
+        esac
     fi
 
     local aliascmd=$(_hg_cmd showconfig alias.$cmd | awk '{print $1}')
     [ -n "$aliascmd" ] && cmd=$aliascmd