[PATCH 11 of 15 V5] bash_completion: simplify if-else logic

Sean Farley sean.michael.farley at gmail.com
Tue Nov 26 13:54:50 CST 2013


# HG changeset patch
# User Sean Farley <sean.michael.farley at gmail.com>
# Date 1385495733 21600
#      Tue Nov 26 13:55:33 2013 -0600
# Node ID 1e5decdcde0ac1767b980c212901ca7559a92d99
# Parent  e5eb668a5d0bd5643192f2239d813e2e7a81a39f
bash_completion: simplify if-else logic

There is no change in functionality here but this makes refactoring this later
easier.

diff --git a/contrib/bash_completion b/contrib/bash_completion
--- a/contrib/bash_completion
+++ b/contrib/bash_completion
@@ -238,19 +238,15 @@
         "_hg_cmd_$cmd"
         return 0
     fi
 
     if [ "$cmd" != status ] && [ "$prev" = -r ] || [ "$prev" == --rev ]; then
-        if [ $canonical = 1 ]; then
+        if [[ $canonical = 1 || status != "$cmd"* ]]; then
             _hg_labels
             return 0
-        elif [[ status != "$cmd"* ]]; then
-            _hg_labels
-            return 0
-        else
-            return 1
         fi
+        return 1
     fi
 
     local aliascmd=$(_hg_cmd showconfig alias.$cmd | awk '{print $1}')
     [ -n "$aliascmd" ] && cmd=$aliascmd
 


More information about the Mercurial-devel mailing list