Ticket #5874: hgdumpchangesets.sh

File hgdumpchangesets.sh, 897 bytes (added by mmadia, 14 years ago)

script for individual patches of creating commit message + changest from Mercurial repository

Line 
1#!/bin/bash
2# TODO Add support for command line arguments
3#usage:
4# hgdumpchangesets [<int> [<int>]]
5
6# defaults
7rev=0
8tip=`hg tip`
9max=`echo ${tip} | awk '{ print $2 }' | sed -e 's/:.*//g'`
10
11# parse command line options, if specified
12if [ "$1" != "" ] ; then
13 if [ $1 -gt 0 ] ; then
14 rev=$1
15 fi
16 if [ "$2" != "" ] ; then
17 if [ $2 -gt $1 ] ; then
18 max=$2
19 fi
20 fi
21fi
22
23if [ $rev -gt $max ] ; then
24 echo 'A revision greater than the working repository was specified. Exiting ...'
25 exit 1
26fi
27
28output='dumped_changesets'
29if [ -d ${output} ] ; then
30 # be happy.
31 echo ''
32else
33 mkdir ${output}
34fi
35while [ $rev -le $max ] ; do
36 echo "Creating a logged patch for ${rev} ..."
37 patchfile="${output}/hg-${rev}.patch"
38 #echo "hg -v log -r ${rev} > ${patchfile}"
39 #echo "hg diff -r ${rev} >> ${patchfile}"
40 hg -v log -r ${rev} > ${patchfile}
41 hg diff -c ${rev} >> ${patchfile}
42 rev=`expr ${rev} + 1`
43done