Detail: Mercurial Gedit External Tools 2 (bash)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/sh
# [Gedit Tool]
# Name=Mercurial
# Shortcut=<Control><Alt>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

[raw] - Pasted by: r0sk on bash on Sept. 22, 2011