Monday Sep 03, 2007

Nautilus scripts to launch diff viewer and view a particular revision

I have hacked two more nautilus scripts.

  • cvs_diff_revisions - this script prompts for two revisions of a file and shows diffs them in a diff viewer.
  • cvs_view_revision - this script prompts for a revisions of a file and shows it a editor.

Just put the scripts in your

~/gnome2/nautilus-scripts

directory and

> chmod 755 cvs_diff_revisions cvs_view_revision

> nautilus -q

Here are the scripts:

cvs_diff_revisions - this uses the meld diff viewer. You can use any other diff viewer in it's place.


#!/bin/bash
#
# Distributed under the terms of GNU GPL version 2
#
# http://blogs.sun.com/scblog
#

ICONPATH="`dirname $0`/cvs.xpm"

for TARGET in ${NAUTILUS_SCRIPT_SELECTED_FILE_PATHS}
do
TARGETDIR=`dirname "${TARGET}"`
TARGET=`basename "${TARGET}"`

cd "${TARGETDIR}"
REVISIONA=`zenity --list --radiolist --title="cvs diff - Select Revision A" --text="${TARGETDIR}/${TARGET}" \\
--width=500 --height=700 --column "A" --column "Revisions" \\`cvs log "${TARGET}" | grep "\^revision" | mawk '{ print "FALSE", $2 }'\\``
if [ $? -eq 0 ] ; then
if [ ! -z "${REVISIONA}" ] ; then
REVISIONB=`zenity --list --radiolist --title="cvs diff - Select Revision B (A is ${REVISIONA})" \\
--text="${TARGETDIR}/${TARGET}" --width=500 --height=700 --column "B" --column "Revisions" \\`cvs log "${TARGET}" \\
| grep "\^revision" | grep -v ${REVISIONA}| mawk '{ print "FALSE", $2 }'\\``
if [ $? -eq 0 ] ; then
if [ ! -z "${REVISIONB}" ] ; then
cvs update -r "${REVISIONA}" -p "${TARGET}" > "${TARGETDIR}/${TARGET}.~${REVISIONA}~"
cvs update -r "${REVISIONB}" -p "${TARGET}" > "${TARGETDIR}/${TARGET}.~${REVISIONB}~"
meld "${TARGETDIR}/${TARGET}.~${REVISIONA}~" "${TARGETDIR}/${TARGET}.~${REVISIONB}~"
fi
fi
fi
fi
done 

cvs_view_revision


#!/bin/bash
#
# Distributed under the terms of GNU GPL version 2
#
# http://blogs.sun.com/scblog
#

ICONPATH="`dirname $0`/cvs.xpm"

for TARGET in ${NAUTILUS_SCRIPT_SELECTED_FILE_PATHS}
do
TARGETDIR=`dirname "${TARGET}"`
TARGET=`basename "${TARGET}"`

cd "${TARGETDIR}"
REVISION=`zenity --list --radiolist --title="cvs view revision" --text="${TARGETDIR}/${TARGET}" \\
--width=500 --height=700 --column "" --column "Revisions" \\`cvs log "${TARGET}" | grep "\^revision" | mawk '{ print "FALSE", $2 }'\\``
if [ $? -eq 0 -a ! -z "${REVISION}" ] ; then
cvs update -r "${REVISION}" -p "${TARGET}" > "${TARGETDIR}/${TARGET}.~${REVISION}~"
gedit "${TARGETDIR}/${TARGET}.~${REVISION}~"
fi
done

Also save this cvs icon as ~/gnome2/nautilus-scripts/cvs.xpm.

I think it should be possible to build a set of scripts which more or less emulate TortoiseCVS integration with Windows Explorer. 

About

sandipchitale

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
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
   
       
Today