#!/bin/sh # [Gedit Tool] # Name=Mercurial # Shortcut=h # Applicability=titled # Output=Panel # Input=Current document # Save-files=Current document # Guarda el documento actual y muestra un menú con opciones de Mercurial # (depende de Mercurial, zenity y poco más) # # Guardar: Documento actual # Entrada: Documento actual # Salida: Panel inferior # # por Mamel Muras (mameyugo@gmail.com) y Óscar Lage (r0sk10@gmail.com) # Función que se encarga de hacer commit si hace falta commit() { if [ `hg st 2> /dev/null | wc -l` -gt 0 ]; then comentario=`zenity --entry --title='Mercurial' --width='500' --height='150' --text='Agregar comentario commit' --entry-text ''` if [ -z $comentario ]; then zenity --warning --title='Mercurial' --text='Commit fallido por falta de comentario' exit 0 fi hg addremove hg commit -m "$comentario" else zenity --warning --title='Mercurial' --text='Nada que commitear' fi } # Comprobamos si existe directorio Mercurial if [ `hg heads 2> /dev/null | wc -l` -gt 0 ]; then # Si existe directorio Mercurial, sacamos selector sel=`echo "1 Status (hg st) 2 Commit (hg commit) 3 Pull (hg pull -u) 4 Push (hg push) 5 Merge (hg merge) 6 Log (hg log -l) 7 Diff (hg diff documento -c changeset) " | zenity --list --title="git" --text="choose action" --column="#" --column="action" --height=320 --width=400` case $sel in 1) hg st ;; 2) hg st commit ;; 3) hg pull -u ;; 4) hg push ;; 5) hg merge ;; 6) nivel=`zenity --entry --title='Mercurial' --width='500' --height='150' --text='Nivel de log' --entry-text '3'` hg log -l $nivel ;; 7) hglog=`hg log $GEDIT_CURRENT_DOCUMENT_NAME | grep "changeset" | cut -d":" -f2 | sed 's/ //'` j=1 for i in $hglog; do zen="$zen $i\n" done; hglogversion=`echo $zen | zenity --list --title="git" --text="choose action" --column="Changset" --height=320 --width=400` echo $hglogversion hg diff $GEDIT_CURRENT_DOCUMENT_NAME -c $hglogversion ;; esac else zenity --error --title='Mercurial' --text='No estamos dentro de ningún repositorio Mercurial' fi