|
From: | Joe Green |
Subject: | [Quilt-dev] CVS / source control support |
Date: | Wed, 24 Aug 2005 18:46:31 -0700 |
User-agent: | Mozilla Thunderbird 1.0.2 (X11/20050317) |
Hi, Josh Boyer asked me to post the CVS support patches I have a few weeks ago. It took me a while to get rev'ed up to 0.42 (sorry Josh!), but here they are. This is implemented as a set of "generic" stubs in the quilt code that are overriden with versions which support CVS from a user's quiltrc file. I say "generic" because I'm sure in practice additional hooks might be needed for some other source control systems (e.g. to do some operation before adding a file, rather than after). This implementation does source control operations for changes to the patches in the QUILT_PATCHES directory or to the series file, not for files in the working tree. It dynamically determines if the affected file is in a CVS controlled directory, and does nothing if it is not. We place the patches and the series file in the QUILT_PATCHES directory, which is symlinked from the working tree to a CVS controlled directory. The implementation doesn't assume this structure--it just looks to see if the files are in a CVS directory--but this is the only structure I've tested with. The patches--in the order I apply them--are: quilt-really_delete.patchFinally, there is quiltrc.cvs: This is not a patch, but shows the functions that can be added to a user's quiltrc file to override the default hooks and add support for CVS. -- Joe Green <address@hidden> MontaVista Software, Inc. |
Source: MontaVista Software, Inc. <address@hidden> Type: Enhancement Disposition: submitted to http://savannah.nongnu.org/projects/quilt Add options to the delete command that will remove the deleted patch from the QUILT_PATCHES directory and optionally create a backup file. Index: quilt-0.42/quilt/delete.in =================================================================== --- quilt-0.42.orig/quilt/delete.in +++ quilt-0.42/quilt/delete.in @@ -19,7 +19,7 @@ fi usage() { - printf $"Usage: quilt delete [patch | -n]\n" + printf $"Usage: quilt delete [-r] [--backup] [patch | -n]\n" if [ x$1 = x-h ] then printf $" @@ -29,6 +29,12 @@ topmost patch can be removed right now.) -n Delete the next patch after topmost, rather than the specified or topmost patch. + +-r Remove the deleted patch file from the patches directory as well. + +--backup + Rename the patch file to patch~ rather than deleting it. + Ignored if not used with \"-r\". " exit 0 @@ -37,7 +43,7 @@ topmost patch can be removed right now.) fi } -options=`getopt -o nh -- "$@"` +options=`getopt -o nrh --long backup -- "$@"` if [ $? -ne 0 ] then @@ -52,8 +58,14 @@ do -n) opt_next=1 shift ;; + -r) + opt_remove=1 + shift ;; -h) usage -h ;; + --backup) + QUILT_BACKUP=1 + shift ;; --) shift break ;; @@ -113,6 +125,28 @@ then printf $"Removed patch %s\n" "$(print_patch "$patch")" else printf $"Failed to remove patch %s\n" "$(print_patch "$patch")" >&2 + exit 1 +fi + +patch_file=$(patch_file_name "$patch") +if [ "$opt_remove" -a -e "$patch_file" ] +then + if [ "$QUILT_BACKUP" ] + then + if ! mv -f "$patch_file" "$patch_file~" + then + printf $"Failed to backup patch file \"%s\"\n" \ + "$patch_file" >&2 + exit 1 + fi + else + if ! rm -f "$patch_file" + then + printf $"Failed to remove patch file \"%s\"\n" \ + "$patch_file" >&2 + exit 1 + fi + fi fi ### Local Variables: ### mode: shell-script Index: quilt-0.42/bash_completion =================================================================== --- quilt-0.42.orig/bash_completion +++ quilt-0.42/bash_completion @@ -139,7 +139,7 @@ _quilt_completion() COMPREPLY=( $( compgen -W "-h $(quilt applied)" -- $cur ) ) ;; delete) - COMPREPLY=( $( compgen -W "-n -h $(quilt series)" -- $cur ) ) + COMPREPLY=( $( compgen -W "-n -r -h --backup $(quilt series)" -- $cur ) ) ;; diff) case $prev in
Source: MontaVista Software, Inc. <address@hidden> Type: Enhancement Disposition: submit to http://savannah.nongnu.org/projects/quilt Add "readlink" and "realpath" functions for following symlinks. Index: quilt-0.42/scripts/patchfns.in =================================================================== --- quilt-0.42.orig/scripts/patchfns.in +++ quilt-0.42/scripts/patchfns.in @@ -125,6 +125,29 @@ dirname() echo "${path:-.}" } +if ! type readlink &> /dev/null ; then +readlink() +{ + expr "$(/bin/ls -ld $1)" : ".*-> \(.*\)$" +} +fi + +# If input file names a symbolic link, print path to real file. +# If non-existent or not a link, print the input path. +realpath() +{ + local path="$1" + while [ -L "$path" ] ; do + local link=$(readlink "$path") + if [ "${link#/}" = "$link" ] ; then + path=$(dirname "$path")"/$link" + else + path="$link" + fi + done + echo "$path" +} + patch_file_name() { echo "$QUILT_PATCHES/$1"
Source: MontaVista Software, Inc. (address@hidden) Type: Enhancement Disposition: submit to http://savannah.nongnu.org/projects/quilt Add hooks for Sofware Configuration Management systems. These have been tested with CVS hooks. Index: quilt-0.42/quilt/import.in =================================================================== --- quilt-0.42.orig/quilt/import.in +++ quilt-0.42/quilt/import.in @@ -104,10 +104,13 @@ do fi printf $"Replacing patch %s with new version\n" \ "$(print_patch $patch)" >&2 + scm_modify_patch "edit" "$QUILT_PATCHES/$patch" || exit 1 + newpatch=no else printf $"Importing patch %s (stored as %s)\n" \ "$(print_patch $patch_file)" \ "$(print_patch $patch)" + newpatch=yes fi dest=$QUILT_PATCHES/$patch mkdir -p "${dest%/*}" @@ -117,6 +120,11 @@ do status=1 fi + if [ "$newpatch" = "yes" ] + then + scm_modify_patch "add" "$QUILT_PATCHES/$patch" || exit 1 + fi + if ! patch_in_series $patch && ! insert_in_series $patch "$patch_args" then Index: quilt-0.42/scripts/patchfns.in =================================================================== --- quilt-0.42.orig/scripts/patchfns.in +++ quilt-0.42/scripts/patchfns.in @@ -40,6 +40,35 @@ fi # ======================================================== +if [ "$(type -t scm_modify_patch)" != function ] +then + # Overridable hook to enable source control for patch files. + scm_modify_patch() + { + # local op="$1" patch_file="$2" + # op is one of: + # "add" add patch_file to source control + # "edit" enable modification to existing patch_file + # "delete" remove patch_file from source control + return 0 + } +fi + +if [ "$(type -t scm_modify_series)" != function ] +then + # Overridable hook to enable source control for series file. + scm_modify_series() + { + # local op="$1" series_file="$2" + # op is one of: + # "add" add series_file to source control + # "edit" enable modification to existing series_file + return 0 + } +fi + +# ======================================================== + #declare -a exit_handlers # #add_exit_handler() { @@ -167,6 +196,11 @@ change_db_strip_level() ' $SERIES > $tmpfile if ! cmp $SERIES $tmpfile >/dev/null 2>/dev/null then + if ! scm_modify_series "edit" "$SERIES" + then + rm -f $tmpfile + return 1 + fi cat $tmpfile > $SERIES fi rm -f $tmpfile @@ -192,6 +226,7 @@ insert_in_series() { local patch=$1 patch_args=$2 local top=$(top_patch) tmpfile + local new_series=no if [ -n "$patch_args" ] then @@ -227,8 +262,24 @@ insert_in_series() else echo "$patch$patch_args" > $tmpfile fi + + [ -e "$SERIES" ] || new_series=yes + + if [ "$new_series" = "no" ] && ! scm_modify_series "edit" "$SERIES" + then + rm -f $tmpfile + return 1 + fi + cat $tmpfile > $SERIES rm -f $tmpfile + + if [ "$new_series" = "yes" ] + then + scm_modify_series "add" "$SERIES" || return 1 + fi + + return 0 } remove_from_series() @@ -240,7 +291,7 @@ remove_from_series() ! /^'"$(quote_re $patch)"'([ \t]|$)/ \ { print } ' $SERIES > $tmpfile - if [ $? -ne 0 ] + if [ $? -ne 0 ] || ! scm_modify_series "edit" "$SERIES" then rm -f $tmpfile return 1 @@ -261,7 +312,7 @@ rename_in_series() { print } END { exit(! good) } ' $SERIES > $tmpfile - if [ $? -ne 0 ] + if [ $? -ne 0 ] || ! scm_modify_series "edit" "$SERIES" then rm -f $tmpfile return 1 Index: quilt-0.42/quilt/delete.in =================================================================== --- quilt-0.42.orig/quilt/delete.in +++ quilt-0.42/quilt/delete.in @@ -146,6 +146,7 @@ then exit 1 fi fi + scm_modify_patch "delete" "$patch_file" || exit 1 fi ### Local Variables: ### mode: shell-script Index: quilt-0.42/quilt/fork.in =================================================================== --- quilt-0.42.orig/quilt/fork.in +++ quilt-0.42/quilt/fork.in @@ -118,6 +118,13 @@ printf $"Fork of patch %s created as %s\ "$(print_patch $top_patch)" \ "$(print_patch $new_patch)" +patch_file=$(patch_file_name "$new_patch") +if [ -e "$patch_file" ] +then + scm_modify_patch "add" "$patch_file" || exit 1 +fi + +exit 0 ### Local Variables: ### mode: shell-script ### End: Index: quilt-0.42/quilt/refresh.in =================================================================== --- quilt-0.42.orig/quilt/refresh.in +++ quilt-0.42/quilt/refresh.in @@ -290,6 +290,14 @@ fi cat $tmp_patch >> $tmp_result +if [ -e "$patch_file" ] +then + scm_modify_patch "edit" "$patch_file" || die 1 + newpatch=no +else + newpatch=yes +fi + if [ -e $patch_file ] && \ @DIFF@ -q $patch_file $tmp_result > /dev/null then @@ -305,6 +313,11 @@ fi touch $QUILT_PC/$patch/.timestamp +if [ "$newpatch" = "yes" ] +then + scm_modify_patch "add" "$patch_file" || die 1 +fi + rm -f $QUILT_PC/$patch~refresh if ! change_db_strip_level -p$opt_strip_level $patch then Index: quilt-0.42/quilt/header.in =================================================================== --- quilt-0.42.orig/quilt/header.in +++ quilt-0.42/quilt/header.in @@ -186,7 +186,11 @@ then | maybe_strip_trailing_whitespace else patch_file_or_null=/dev/null - [ -e "$patch_file" ] && patch_file_or_null=$patch_file + if [ -e "$patch_file" ] + then + patch_file_or_null=$patch_file + scm_modify_patch "edit" "$patch_file" + fi tmp=$(gen_tempfile) || exit 1 tmp2=$(gen_tempfile) || exit 1 @@ -244,6 +248,11 @@ $"Replaced header of patch %s\n" "$(prin printf \ $"Appended text to header of patch %s\n" "$(print_patch $patch)" fi + + if [ "$patch_file_or_null" = "/dev/null" ] + then + scm_modify_patch "add" "$patch_file" + fi else exit 1 fi Index: quilt-0.42/quilt/rename.in =================================================================== --- quilt-0.42.orig/quilt/rename.in +++ quilt-0.42/quilt/rename.in @@ -40,6 +40,8 @@ move_file() [ -d "$newdir" ] || mkdir -p "$newdir" || return 1 mv "$old" "$new" || return 1 + scm_modify_patch "add" "$new" || return 1 + scm_modify_patch "delete" "$old" || return 1 rmdir -p "$(dirname "$old")" 2> /dev/null return 0
cvs_operation() { local op="$1" dir=$(dirname "$2") name=$(basename "$2") if [ -d "$dir/CVS" ] then case "$op" in add) # Add file to source control if ! (cd "$dir" && cvs -Q add -ko "$name") then printf $"CVS add failed for file \"%s\".\n" \ "$dir/$name" >&2 return 1 fi ;; edit) # Enable modification to existing file if [ ! -w "$dir/$name" ] && ! (cd "$dir" && cvs edit "$name") then printf $"CVS edit failed for file \"%s\".\n" \ "$dir/$name" >&2 return 1 fi ;; delete) # Remove file from source control if ! (cd "$dir" && cvs -Q remove "$name") ; then printf $"CVS remove failed for file \"%s\".\n" \ "$dir/$name" >&2 return 1 fi ;; esac fi return 0 } scm_modify_patch() { cvs_operation "$1" "$2" } scm_modify_series() { cvs_operation "$1" "$(realpath $2)" }
[Prev in Thread] | Current Thread | [Next in Thread] |