monotone-devel
[Top][All Lists]
Advanced

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

[Monotone-devel] monotone-viz, bash completion and a small bug in 0.14


From: Olivier Andrieu
Subject: [Monotone-devel] monotone-viz, bash completion and a small bug in 0.14
Date: Thu, 05 Aug 2004 19:30:44 +0200 (CEST)

Hi,

I'd like to announce monotone-viz, an embryonic GTK app I wrote to
visualize monotone ancestry graphs. It's not really a GUI because it
won't change the database state, it just displays the manifest graph
and the manifest certs.

http://oandrieu.nerim.net/monotone-viz/

Also, attached is a new version of the bash completion file, updated
for monotone 0.14.

And I found a small bug: the db execute command doesn't work because
there's a check that rejects the SQL argument.

-- 
   Olivier
# -*- shell-script -*-

# bash completion for monotone 0.14

# The function _filedir is defined in /etc/bash_completion.
# This is a weaker version, for those who do not have the 
# bash completion package installed. <http://www.caliban.org/bash/>
if ! type _filedir >& /dev/null ; then
_filedir() {
    local IFS=$'\t\n' arg
    COMPREPLY=( address@hidden:-} $(compgen ${1:--f} -- $cur) )
}
fi

# Call monotone to complete manifest for file IDs
_monotone_complete() {
  if [ -n "$cur" ] ; then
    COMPREPLY=( address@hidden:-} $(monotone $mono_db complete $1 $cur 2> 
/dev/null) )
  fi
}

# Call monotone to complete key ids (private or public)
_monotone_keys() {
  local range
  if [ "$1" == "privkey" ]; then
    range='/\[private/,$'
  else
    range='1,/\[private/'
  fi
  COMPREPLY=( $(compgen -W "$(monotone $mono_db list keys |\
                              sed -n ${range}'{/^[0-9a-f]/s/[0-9a-f]* //p}')" 
-- ${cur#*=} ) )
}

_monotone() {
  local cur=${COMP_WORDS[COMP_CWORD]}
  local prev=${COMP_WORDS[COMP_CWORD-1]}
  local mono_db

  for w in address@hidden ; do
    if [[ "$w" == --db=* ]] ; then
      mono_db="$w" ; break
    fi
  done

  case $cur in
    --db=* | --rcfile=* )
      cur="${cur#*=}"
      _filedir
      ;;
    --branch=* )
      COMPREPLY=( $(compgen -W "$(monotone $mono_db list branches)" -- 
${cur#*=} ) )
      ;;
    --key=* )
      _monotone_keys pubkey
      ;;
    -* )
      COMPREPLY=( $(compgen -W '--debug --quiet --help --nostd --norc\
                                --rcfile= --key= --db= --branch= --version 
--dump=' -- $cur) ) 
      ;;
    * )
      case $prev in
        db )
          COMPREPLY=( $(compgen -W 'init info version dump load migrate 
execute' -- $cur ) )
          ;;
        diff | log | approve | disapprove | comment | tag | testresult | cert )
          _monotone_complete manifest
          ;;
        ls | list )
          COMPREPLY=( $(compgen -W 'certs keys branches unknown ignored 
missing' -- $cur ) )
          ;;
        co | checkout )
          _filedir -d
          _monotone_complete manifest
          ;;
        cvs_import | add | drop | rename | revert )
          _filedir
          ;;
        cat )
          COMPREPLY=( $(compgen -W 'file manifest' -- $cur) )
          ;;
        push | pull | serve | sync )
          COMPREPLY=( $(compgen -A hostname -- $cur) )
          ;;
        pubkey | privkey )
          _monotone_keys $prev
          ;;
        * )
          if (( $COMP_CWORD >= 2 )) ; then
            local prev2=${COMP_WORDS[COMP_CWORD-2]}
            case $prev2 in
              diff | approve | disapprove )
                _monotone_complete manifest
                ;;
              co | checkout )
                _filedir -d
                ;;
              cat )
                _monotone_complete $prev
                ;;
              list )
                if [ $prev == certs ] ; then
                    _monotone_complete manifest 
                    _monotone_complete file
                fi
                ;;
              push | pull | serve | sync )
                COMPREPLY=( $(compgen -W "$(monotone $mono_db list branches)" 
-- $cur) )
                ;;
              * )
                unset prev2
                ;;
            esac
          fi
          if [ -z "$prev2" ] ; then
            COMPREPLY=( $(compgen -W 'approve comment tag testresult \
                                      db agraph \
                                      complete diff list log ls status \
                                      cert genkey vcheck pull push reindex 
serve sync \
                                      fcerts fdata fdelta mcerts mdata mdelta 
privkey pubkey read \
                                      cvs_import rcs_import \
                                      cat checkout co fload fmerge heads merge 
propagate \
                                      add commit drop rename revert update' -- 
$cur) )
          fi
          ;;
      esac
      ;;
  esac
  return 0
}

complete -F _monotone -o default monotone
# Old manifest: 5763b3b683522b81c0adec9b6728267cae7bfcb9
# New manifest: 4a7d3d8ff8b89dd9ae934c5fe3c826eacd5eaf7a
# Summary of changes:
# 
#   patch commands.cc
#    from b6826e3685d333bf97b019084021c864b14e2ce5
#      to 5dbeb38b1b8f7a9ccd5f83002459fe25eef54785
# 
--- commands.cc
+++ commands.cc
@@ -2565,8 +2565,6 @@
 
 CMD(db, "database", "init\ninfo\nversion\ndump\nload\nmigrate\nexecute SQL", 
"manipulate database state")
 {
-  if (args.size() != 1)
-    throw usage(name);
   if (idx(args, 0)() == "init")
     app.db.initialize();
   else if (idx(args, 0)() == "info")

reply via email to

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