monotone-commits-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Monotone-commits-diffs] net.venge.monotone: 61e96ce2363fe7ee3e7e4b6adf


From: code
Subject: [Monotone-commits-diffs] net.venge.monotone: 61e96ce2363fe7ee3e7e4b6adfe9fbde874e67bc
Date: Wed, 9 Mar 2011 17:50:10 +0100 (CET)

revision:            61e96ce2363fe7ee3e7e4b6adfe9fbde874e67bc
date:                2011-03-09T16:43:27
author:              Richard Levitte <address@hidden>
branch:              net.venge.monotone
changelog:
* extra/shell/monotone.bash_completion.in (_monotone_databases): Don't
  return any file, just those ending with .mtn.
  (_monotone_command_words): It's perfectly acceptable to have a one
  letter option directly followed by an argument.
  (_monotone): Deal with -d directly followed by a database.  Also,
  because bash handles completion of things with colons in them (it
  normally treats : as a word delimiter, a little like if does with
  paths), add code that deals with this.
  Last of all, don't treat the arguments as file names per se, we do it
  ourselves anyway.
* extra/shell/monotone_gen_bash_completion_table.pl: Some singulars were
  corrected to plurals.

manifest:
format_version "1"

new_manifest [5de2e419f0de21ebe60272ee37fe6915bf68a7e7]

old_revision [5d8b9d46a8717039091ef619e2c1c00d25837063]

patch "extra/shell/monotone.bash_completion.in"
 from [073ee99c02184196639fb088fe427df20264e64d]
   to [df7a7d5b8f27d5dfdf4bd09f953f0b4e26518775]

patch "extra/shell/monotone_gen_bash_completion_table.pl"
 from [724f810ba4f531c872f33f966d1ff04c5adb03c7]
   to [5f1118ffe699209097070259bcd67eca59e3d5ed]
============================================================
--- extra/shell/monotone.bash_completion.in	073ee99c02184196639fb088fe427df20264e64d
+++ extra/shell/monotone.bash_completion.in	df7a7d5b8f27d5dfdf4bd09f953f0b4e26518775
@@ -69,7 +69,7 @@ _monotone_databases() {
 }
 
 _monotone_databases() {
-    _filedir
+    _filedir mtn
     COMPREPLY=(
 	"address@hidden"
 	$(compgen -W "$(LANG=POSIX \
@@ -160,6 +160,16 @@ _monotone_command_words() {
 	    fi
 	    pw="${w%%?(\\)=*}"
 	    w="${w#*=}"
+	# if the current word is '-oval', split it up into '-o' and 'val'
+	elif [[ "$w" == -[a-z]?* ]]; then
+	    if [[ "$pw" == -* \
+		&& " ${_monotone_options_noarg[*]} " != *\ $pw\ * ]]; then
+		# Current word is an argument to an earlier option,
+		# so we skip past it
+		continue
+	    fi
+	    pw="${w:0:2}"
+	    w="${w:2}"
 	elif [[ "$w" == -* ]]; then
 	    continue
 	fi
@@ -203,28 +213,45 @@ _monotone() {
     local i cmdi argi
     local x
 
+    local debug
+    debug=${DEBUG_MONOTONE_BASH_COMPLETIONS:-false}
+
     if [[ $- == *v* ]]; then
 	original_v_value="-v"
     else
 	original_v_value="+v"
     fi
-    #set -v
     if [[ $- == *x* ]]; then
 	original_x_value="-x"
     else
 	original_x_value="+x"
     fi
-    #set -x
 
+    if $debug; then
+	echo "COMP_WORDS:" "address@hidden"
+	echo "COMP_CWORD:" "$COMP_CWORD"
+    fi
 
     COMPREPLY=()
     _get_comp_words_by_ref -n := cur prev words cword
     _split_longopt
     _monotone_command_words
+    if [[ "$cur" == -[a-z]?* ]]; then
+	if ! [[ "$prev" == -* \
+	    && " ${_monotone_options_noarg[*]} " != *\ $prev\ * ]]; then
+	    prev="${cur:0:2}"
+	    cur="${cur:2}"
+	fi
+    fi
 
+    if $debug; then
+	echo "words:" "address@hidden"
+	echo "cword:" "$cword"
+    fi
+
     mtn=${words[0]}
     for w in address@hidden ; do
-	if [[ "$w" == --db=* ]] ; then
+	if [[ "$w" == --db=* || "$w" == -d?* ]] ; then
 	    mono_db="$w" ; break
 	fi
     done
@@ -238,6 +265,16 @@ _monotone() {
 	done
     fi
 
+    if $debug; then
+	echo "db: $mono_db"
+	echo "prev: $prev"
+	echo "cur: $cur"
+    fi
+
+    if $debug; then
+	set -x
+	set -v
+    fi
     case $cur in
 	*/a:!(*/[[:alpha:]]:*) | *=a:!(*/[[:alpha:]]:*) | a:!(*/[[:alpha:]]:*) )
             cur="${cur##*a:}"
@@ -300,13 +337,13 @@ _monotone() {
 		    fi
 		    case $argtype in
 			*PATH | PATHS | *FILENAME | *FILE | SRC | SRC[0-9] | FILE[0-9] )
-			    _filedir
+			    _monotone_files
 			    ;;
 			*REVISION | REV* | NEW_REV* | OLD_REV* | *REVID | FROM | TO )
 			    _monotone_revisions
 			    ;;
 			DIR* | *ROOT | DEST_DIR | WORKSPACE_PATH )
-			    _filedir -d
+			    _monotone_dirs
 			    ;;
 			KEY* )
 			    _monotone_public_keys
@@ -332,13 +369,30 @@ _monotone() {
 		fi
 	    fi
     esac
-
     set $original_v_value
     unset original_v_value
     set $original_x_value
     unset original_x_value
 
+    # I copied this code from http://willcode4beer.com/tips.jsp?set=tabMaven
+    # -- Richard Levitte
+    ############################################################
+    # Work-around bash_completion issue where bash interprets a colon
+    # as a separator.
+    # Work-around borrowed from the darcs work-around for the same
+    # issue.
+    colonprefixes=${cur%"${cur##*:}"}
+    local i=${#COMPREPLY[*]}
+    while [ $((--i)) -ge 0 ]; do
+	COMPREPLY[$i]=${COMPREPLY[$i]#"$colonprefixes"}
+    done
+    ############################################################
+
+    if $debug; then
+	echo "COMPREPLY: address@hidden"
+    fi
+
     return 0
 }
 
-complete -F _monotone -o filenames mtn
+complete -F _monotone mtn
============================================================
--- extra/shell/monotone_gen_bash_completion_table.pl	724f810ba4f531c872f33f966d1ff04c5adb03c7
+++ extra/shell/monotone_gen_bash_completion_table.pl	5f1118ffe699209097070259bcd67eca59e3d5ed
@@ -107,14 +107,14 @@ print "    [--branches-file]=_monotone_f
 print "    [--bind]=_monotone_address_port\n";
 print "    [--branch]=_monotone_branches [-b]=_monotone_branches\n";
 print "    [--branches-file]=_monotone_files\n";
-print "    [--confdir]=_monotone_dir\n";
+print "    [--confdir]=_monotone_dirs\n";
 print "    [--conflicts-file]=_monotone_files\n";
 print "    [--db]=_monotone_databases [-d]=_monotone_databases\n";
 print "    [--dump]=_monotone_files\n";
 print "    [--export-marks]=_monotone_files\n";
-print "    [--from]=_monotone_revision\n";
+print "    [--from]=_monotone_revisions\n";
 print "    [--import-marks]=_monotone_files\n";
-print "    [--keydir]=_monotone_dir\n";
+print "    [--keydir]=_monotone_dirs\n";
 print "    [--key]=_monotone_key [-k]=_monotone_public_key\n";
 print "    [--key-to-push]=_monotone_public_key\n";
 print "    [--log]=_monotone_files\n";
@@ -124,8 +124,8 @@ print "    [--resolve-conflicts-file]=_m
 print "    [--refs]=_monotone_refs\n";
 print "    [--remote-stdio-host]=_monotone_address_port\n";
 print "    [--resolve-conflicts-file]=_monotone_files\n";
-print "    [--revision]=_monotone_revision [-r]=_monotone_revision\n";
-print "    [--root]=_monotone_dir\n";
+print "    [--revision]=_monotone_revisions [-r]=_monotone_revisions\n";
+print "    [--root]=_monotone_dirs\n";
 print "    [--ssh-sign]=_monotone_ssh_sign\n";
 print "    [--ticker]=_monotone_ticker\n";
 print "    [--xargs]=_monotone_files\n";

reply via email to

[Prev in Thread] Current Thread [Next in Thread]