Add eviewcvs utility for generating viewcvs URLs
authoragriffis <agriffis@gentoo.org>
Sat, 12 Mar 2005 23:03:50 +0000 (23:03 -0000)
committeragriffis <agriffis@gentoo.org>
Sat, 12 Mar 2005 23:03:50 +0000 (23:03 -0000)
svn path=/; revision=194

trunk/src/eviewcvs/AUTHORS [new file with mode: 0644]
trunk/src/eviewcvs/Makefile [new file with mode: 0644]
trunk/src/eviewcvs/README [new file with mode: 0644]
trunk/src/eviewcvs/eviewcvs [new file with mode: 0755]
trunk/src/eviewcvs/eviewcvs.1 [new file with mode: 0644]
trunk/src/eviewcvs/eviewcvs.pod [new file with mode: 0644]

diff --git a/trunk/src/eviewcvs/AUTHORS b/trunk/src/eviewcvs/AUTHORS
new file mode 100644 (file)
index 0000000..36d5bfd
--- /dev/null
@@ -0,0 +1 @@
+Aron Griffis <agriffis@gentoo.org>
diff --git a/trunk/src/eviewcvs/Makefile b/trunk/src/eviewcvs/Makefile
new file mode 100644 (file)
index 0000000..ee4208f
--- /dev/null
@@ -0,0 +1,22 @@
+# Copyright 2005 Gentoo Technologies, Inc.
+# Distributed under the terms of the GNU General Public License v2
+#
+# $Header$
+
+include ../../makedefs.mak
+
+%.1 : %.pod
+       pod2man $< > $@
+
+.PHONY: all
+all: eviewcvs.1
+
+dist: eviewcvs.1
+       mkdir -p ../../$(distdir)/src/eviewcvs/
+       cp Makefile AUTHORS README eviewcvs eviewcvs.pod eviewcvs.1 ../../$(distdir)/src/eviewcvs/
+
+install: all
+       install -m 0755 eviewcvs $(bindir)/
+       install -d $(docdir)/eviewcvs   
+       install -m 0644 AUTHORS README $(docdir)/eviewcvs/
+       install -m 0644 eviewcvs.1 $(mandir)/
diff --git a/trunk/src/eviewcvs/README b/trunk/src/eviewcvs/README
new file mode 100644 (file)
index 0000000..c7258d7
--- /dev/null
@@ -0,0 +1,11 @@
+Most of the documentation is contained in the man-page, which you can
+read directly (using GNU man) by doing
+
+       man ./eviewcvs.1
+
+To rebuild the man-page from pod source, do
+
+       pod2man --name=eviewcvs --center='Gentoolkit' \
+               eviewcvs.pod eviewcvs.1
+
+03 Nov 2004 agriffis
diff --git a/trunk/src/eviewcvs/eviewcvs b/trunk/src/eviewcvs/eviewcvs
new file mode 100755 (executable)
index 0000000..888a564
--- /dev/null
@@ -0,0 +1,106 @@
+#!/bin/bash
+# $Header$
+#
+# Copyright 2005, Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# Written by Aron Griffis <agriffis@gentoo.org>
+#
+# eviewcvs - generate viewcvs urls for some files
+#
+
+if [[ -t 1 ]]; then
+       blue="\e[34;01m"
+       cyan="\e[36;01m"
+       green="\e[32;01m"
+       red="\e[31;01m"
+       off="\e[0m"
+else
+       unset blue cyan green red off
+fi
+
+startdir="$PWD"
+url="http://www.gentoo.org/cgi-bin/viewcvs.cgi"
+unset diffs
+
+chdir() {
+       cd "$1" || return
+
+       # Figure out where we are, hopefully
+       unset cwd root
+       if [[ -f CVS/Repository ]]; then
+               cwd=$(<CVS/Repository)
+               root=${cwd%%/*}
+               cwd=${cwd#*/}
+       elif [[ $PWD == */portage/* || $PWD == */gentoo-x86/* ]]; then
+               cwd=${PWD#*/portage}
+               cwd=${PWD#*/gentoo-x86}
+       fi
+}
+
+# Default to all files in directory
+[[ -n $* ]] || set -- *
+
+for f in "$@"; do
+       if [[ ! -f $f ]]; then
+               echo "$f is not a file" >&2
+               continue
+       fi
+
+       # Determine the directory settings
+       if [[ $f == */* ]]; then
+               chdir ${f%/*}
+               f=${f##*/}
+       else
+               chdir ${startdir}
+       fi
+
+       # Default to the directory settings
+       froot=$root
+       fwd=$cwd
+
+       # Get the header for this file, from which we can extract the root,
+       # directory and revision
+       header=$(egrep -m1 -o '\$(Header|Id):[^$]*\$' "$f")
+       frev=$(cut -d' ' -f3 <<<"$header")
+       case ${header} in
+               ?Header:\ /var/cvsroot/*/*/*) 
+                       fwd=$(cut -d' ' -f2 <<<"$header")       # /var/cvsroot/gentoo-src/keychain/keychain.sh,v
+                       f=${fwd##*/}                                            # keychain.sh,v
+                       f=${f%,v}                                                       # keychain.sh
+                       froot=${fwd#/var/cvsroot/}          # gentoo-src/keychain/keychain.sh,v
+                       froot=${froot%%/*}                                      # gentoo-src
+                       fwd=${fwd#/var/cvsroot/*/}          # gentoo-src/keychain/keychain.sh,v
+                       fwd=${fwd%/*}                                           # keychain
+                       ;;
+               ?Header:\ /var/cvsroot/*/*) 
+                       f=$(cut -d' ' -f2 <<<"$header")     # /var/cvsroot/gentoo-x86/skel.ebuild,v
+                       froot=${f%/*}                                           # /var/cvsroot/gentoo-x86
+                       froot=${froot##*/}                                      # gentoo-x86
+                       f=${f##*/}                                                      # skel.ebuild,v
+                       f=${f%,v}                                                       # skel.ebuild
+                       ;;
+               '')
+                       [[ -d CVS ]] && frev=$(cvs log "$f" 2>/dev/null | awk '/^head:/{print $2}')
+                       ;;
+       esac
+       [[ -n ${frev} ]] || continue
+
+       # gentoo-x86 is the default root
+       [[ -n ${froot} ]] || continue
+       [[ ${froot} == gentoo-x86 ]] && unset froot
+
+       # Here is the simple URL to view it
+       echo "${url}/${fwd:+$fwd/}${green}${f}${off}?rev=${frev}${froot:+&root=$froot}&content-type=text/vnd.viewcvs-markup"
+
+       # Also supply a diff URL if possible
+       if [[ ${frev##*.} -gt 1 ]]; then
+               orev=($(sed 's/\(.*\)\.\(.*\)/\1 \2/g' <<<"$frev"))
+               (( orev[1]-- ))
+               diffs="${diffs:+$diffs
+}${url}/${fwd:+$fwd/}${blue}${f}${off}?r1=${orev[0]}.${orev[1]}&r2=${frev}${froot:+&root=$froot}"
+       fi
+done
+
+if [[ -n ${diffs} ]]; then
+       echo "${diffs}"
+fi
diff --git a/trunk/src/eviewcvs/eviewcvs.1 b/trunk/src/eviewcvs/eviewcvs.1
new file mode 100644 (file)
index 0000000..b05c489
--- /dev/null
@@ -0,0 +1,178 @@
+.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.14
+.\"
+.\" Standard preamble:
+.\" ========================================================================
+.de Sh \" Subsection heading
+.br
+.if t .Sp
+.ne 5
+.PP
+\fB\\$1\fR
+.PP
+..
+.de Sp \" Vertical space (when we can't use .PP)
+.if t .sp .5v
+.if n .sp
+..
+.de Vb \" Begin verbatim text
+.ft CW
+.nf
+.ne \\$1
+..
+.de Ve \" End verbatim text
+.ft R
+.fi
+..
+.\" Set up some character translations and predefined strings.  \*(-- will
+.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
+.\" double quote, and \*(R" will give a right double quote.  | will give a
+.\" real vertical bar.  \*(C+ will give a nicer C++.  Capital omega is used to
+.\" do unbreakable dashes and therefore won't be available.  \*(C` and \*(C'
+.\" expand to `' in nroff, nothing in troff, for use with C<>.
+.tr \(*W-|\(bv\*(Tr
+.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
+.ie n \{\
+.    ds -- \(*W-
+.    ds PI pi
+.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
+.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
+.    ds L" ""
+.    ds R" ""
+.    ds C` ""
+.    ds C' ""
+'br\}
+.el\{\
+.    ds -- \|\(em\|
+.    ds PI \(*p
+.    ds L" ``
+.    ds R" ''
+'br\}
+.\"
+.\" If the F register is turned on, we'll generate index entries on stderr for
+.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
+.\" entries marked with X<> in POD.  Of course, you'll have to process the
+.\" output yourself in some meaningful fashion.
+.if \nF \{\
+.    de IX
+.    tm Index:\\$1\t\\n%\t"\\$2"
+..
+.    nr % 0
+.    rr F
+.\}
+.\"
+.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
+.\" way too many mistakes in technical documents.
+.hy 0
+.if n .na
+.\"
+.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
+.\" Fear.  Run.  Save yourself.  No user-serviceable parts.
+.    \" fudge factors for nroff and troff
+.if n \{\
+.    ds #H 0
+.    ds #V .8m
+.    ds #F .3m
+.    ds #[ \f1
+.    ds #] \fP
+.\}
+.if t \{\
+.    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
+.    ds #V .6m
+.    ds #F 0
+.    ds #[ \&
+.    ds #] \&
+.\}
+.    \" simple accents for nroff and troff
+.if n \{\
+.    ds ' \&
+.    ds ` \&
+.    ds ^ \&
+.    ds , \&
+.    ds ~ ~
+.    ds /
+.\}
+.if t \{\
+.    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
+.    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
+.    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
+.    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
+.    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
+.    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
+.\}
+.    \" troff and (daisy-wheel) nroff accents
+.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
+.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
+.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
+.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
+.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
+.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
+.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
+.ds ae a\h'-(\w'a'u*4/10)'e
+.ds Ae A\h'-(\w'A'u*4/10)'E
+.    \" corrections for vroff
+.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
+.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
+.    \" for low resolution devices (crt and lpr)
+.if \n(.H>23 .if \n(.V>19 \
+\{\
+.    ds : e
+.    ds 8 ss
+.    ds o a
+.    ds d- d\h'-1'\(ga
+.    ds D- D\h'-1'\(hy
+.    ds th \o'bp'
+.    ds Th \o'LP'
+.    ds ae ae
+.    ds Ae AE
+.\}
+.rm #[ #] #H #V #F C
+.\" ========================================================================
+.\"
+.IX Title "EVIEWCVS 1"
+.TH EVIEWCVS 1 "2005-03-12" "perl v5.8.6" "User Contributed Perl Documentation"
+.SH "NAME"
+eviewcvs \- Gentoo: generate viewcvs URLs
+.SH "SYNOPSIS"
+.IX Header "SYNOPSIS"
+eviewcvs [ \fIfiles...\fR ]
+.SH "DESCRIPTION"
+.IX Header "DESCRIPTION"
+This tool generates a list of viewcvs URLs based on the files listed, or all the
+files in the current directory if the file list is omitted.  The first part of
+the output, hilighted in green, is the simple URLs to view the files.  The
+second part of the output, hilighted in blue, is the URLs to view the diffs
+against the previous revision.
+.SH "OPTIONS"
+.IX Header "OPTIONS"
+Presently eviewcvs is simple enough that it supplies no options.
+Probably I'll add \fB\-\-help\fR and \fB\-\-version\fR in the future, but for
+now it's enough to track the gentoolkit version.
+.SH "EXAMPLES"
+.IX Header "EXAMPLES"
+To generate viewcvs URLs for a given file:
+.PP
+.Vb 3
+\&  $ eviewcvs package.mask
+\&  http://www.gentoo.org/cgi-bin/viewcvs.cgi/profiles/package.mask?rev=1.3716&content-type=text/vnd.viewcvs-markup
+\&  http://www.gentoo.org/cgi-bin/viewcvs.cgi/profiles/package.mask?r1=1.3715&r2=1.3716
+.Ve
+.PP
+To generate viewcvs URLs for all files in a directory:
+.PP
+.Vb 11
+\&  $ cd portage/net-misc/keychain
+\&  $ eviewcvs
+\&  http://www.gentoo.org/cgi-bin/viewcvs.cgi/net-misc/keychain/ChangeLog?rev=1.41&content-type=text/vnd.viewcvs-markup
+\&  http://www.gentoo.org/cgi-bin/viewcvs.cgi/net-misc/keychain/Manifest?rev=1.54&content-type=text/vnd.viewcvs-markup
+\&  http://www.gentoo.org/cgi-bin/viewcvs.cgi/net-misc/keychain/keychain-2.5.1.ebuild?rev=1.3&content-type=text/vnd.viewcvs-markup
+\&  http://www.gentoo.org/cgi-bin/viewcvs.cgi/net-misc/keychain/keychain-2.5.3.1.ebuild?rev=1.1&content-type=text/vnd.viewcvs-markup
+\&  http://www.gentoo.org/cgi-bin/viewcvs.cgi/net-misc/keychain/metadata.xml?rev=1.2&content-type=text/vnd.viewcvs-markup
+\&  http://www.gentoo.org/cgi-bin/viewcvs.cgi/net-misc/keychain/ChangeLog?r1=1.40&r2=1.41
+\&  http://www.gentoo.org/cgi-bin/viewcvs.cgi/net-misc/keychain/Manifest?r1=1.53&r2=1.54
+\&  http://www.gentoo.org/cgi-bin/viewcvs.cgi/net-misc/keychain/keychain-2.5.1.ebuild?r1=1.2&r2=1.3
+\&  http://www.gentoo.org/cgi-bin/viewcvs.cgi/net-misc/keychain/metadata.xml?r1=1.1&r2=1.2
+.Ve
+.SH "AUTHOR"
+.IX Header "AUTHOR"
+This tool was written by Aron Griffis <agriffis@gentoo.org>.  Bugs
+found should be filed against me at http://bugs.gentoo.org/
diff --git a/trunk/src/eviewcvs/eviewcvs.pod b/trunk/src/eviewcvs/eviewcvs.pod
new file mode 100644 (file)
index 0000000..308af9c
--- /dev/null
@@ -0,0 +1,48 @@
+=head1 NAME
+
+eviewcvs - Gentoo: generate viewcvs URLs
+
+=head1 SYNOPSIS
+
+eviewcvs [ I<files...> ]
+
+=head1 DESCRIPTION
+
+This tool generates a list of viewcvs URLs based on the files listed, or all the
+files in the current directory if the file list is omitted.  The first part of
+the output, hilighted in green, is the simple URLs to view the files.  The
+second part of the output, hilighted in blue, is the URLs to view the diffs
+against the previous revision.
+
+=head1 OPTIONS
+
+Presently eviewcvs is simple enough that it supplies no options.
+Probably I'll add B<--help> and B<--version> in the future, but for
+now it's enough to track the gentoolkit version.
+
+=head1 EXAMPLES
+
+To generate viewcvs URLs for a given file:
+
+  $ eviewcvs package.mask
+  http://www.gentoo.org/cgi-bin/viewcvs.cgi/profiles/package.mask?rev=1.3716&content-type=text/vnd.viewcvs-markup
+  http://www.gentoo.org/cgi-bin/viewcvs.cgi/profiles/package.mask?r1=1.3715&r2=1.3716
+
+To generate viewcvs URLs for all files in a directory:
+
+  $ cd portage/net-misc/keychain
+  $ eviewcvs
+  http://www.gentoo.org/cgi-bin/viewcvs.cgi/net-misc/keychain/ChangeLog?rev=1.41&content-type=text/vnd.viewcvs-markup
+  http://www.gentoo.org/cgi-bin/viewcvs.cgi/net-misc/keychain/Manifest?rev=1.54&content-type=text/vnd.viewcvs-markup
+  http://www.gentoo.org/cgi-bin/viewcvs.cgi/net-misc/keychain/keychain-2.5.1.ebuild?rev=1.3&content-type=text/vnd.viewcvs-markup
+  http://www.gentoo.org/cgi-bin/viewcvs.cgi/net-misc/keychain/keychain-2.5.3.1.ebuild?rev=1.1&content-type=text/vnd.viewcvs-markup
+  http://www.gentoo.org/cgi-bin/viewcvs.cgi/net-misc/keychain/metadata.xml?rev=1.2&content-type=text/vnd.viewcvs-markup
+  http://www.gentoo.org/cgi-bin/viewcvs.cgi/net-misc/keychain/ChangeLog?r1=1.40&r2=1.41
+  http://www.gentoo.org/cgi-bin/viewcvs.cgi/net-misc/keychain/Manifest?r1=1.53&r2=1.54
+  http://www.gentoo.org/cgi-bin/viewcvs.cgi/net-misc/keychain/keychain-2.5.1.ebuild?r1=1.2&r2=1.3
+  http://www.gentoo.org/cgi-bin/viewcvs.cgi/net-misc/keychain/metadata.xml?r1=1.1&r2=1.2
+
+=head1 AUTHOR
+
+This tool was written by Aron Griffis <agriffis@gentoo.org>.  Bugs
+found should be filed against me at http://bugs.gentoo.org/