quilt-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Quilt-dev] [patch] Quilt support for committing patches to CVS.


From: Joe Green
Subject: Re: [Quilt-dev] [patch] Quilt support for committing patches to CVS.
Date: Fri, 13 Aug 2004 14:35:59 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113

Joe Green wrote:
I'll try to restructure my patch into "generic" hooks and post it as a strawman.

I've replaced my integrated CVS support with generic hooks "scm_modify_patch" and "scm_modify_series". (See first attachment.) Overridable dummy versions of these are provided. Dean, perhaps a similar "scm_modify_file" hook could be used to implement the support you need?

The hooks can be overridden from .quiltrc. The second attachment shows a set of .quiltrc functions that support CVS operations in the same way as my previous integrated patch.

This doesn't address the "commit" question.

This also doesn't specifically address using different source control systems for different trees, but the CVS implementation dynamically detects whether patches and series file are in CVS source-controlled directories.

Thoughts?

--
Joe Green <address@hidden>
MontaVista Software, Inc.
Source: MontaVista Software, Inc. (address@hidden)
Type: Enhancement
Disposition: merge to http://savannah.nongnu.org/projects/quilt
Description:
    Add generic hooks for Sofware Configuration Management systems.

Index: quilt-0.35/quilt/import.in
===================================================================
--- quilt-0.35.orig/quilt/import.in
+++ quilt-0.35/quilt/import.in
@@ -103,10 +103,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%/*}"
@@ -116,6 +119,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.35/scripts/patchfns.in
===================================================================
--- quilt-0.35.orig/scripts/patchfns.in
+++ quilt-0.35/scripts/patchfns.in
@@ -64,6 +64,32 @@ dirname()
        echo "${path:-.}"
 }
 
+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
+               #               may also delete the file or move to patch_file~
+               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
+
 patch_file_name()
 {
        echo "$QUILT_PATCHES/$1"
@@ -134,6 +160,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
@@ -159,6 +190,7 @@ insert_in_series()
 {
        local patch=$1 patch_args=$2
        local top=$(top_patch) tmpfile
+       local new_series=no
 
        if [ -n "$patch_args" ]
        then
@@ -187,8 +219,24 @@ insert_in_series()
                        cat $SERIES >> $tmpfile
                fi
        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()
@@ -200,7 +248,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
@@ -221,7 +269,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.35/quilt/delete.in
===================================================================
--- quilt-0.35.orig/quilt/delete.in
+++ quilt-0.35/quilt/delete.in
@@ -90,7 +90,16 @@ fi
 if ! remove_from_series $patch
 then
        printf $"Failed to remove patch %s\n" "$patch" >&2
+       exit 1
 fi
+
+patch_file=$(patch_file_name "$patch")
+if [ -e "$patch_file" ]
+then
+       scm_modify_patch "delete" "$patch_file" || exit 1
+fi
+
+exit 0
 ### Local Variables:
 ### mode: shell-script
 ### End:
Index: quilt-0.35/quilt/fork.in
===================================================================
--- quilt-0.35.orig/quilt/fork.in
+++ quilt-0.35/quilt/fork.in
@@ -110,6 +110,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.35/quilt/refresh.in
===================================================================
--- quilt-0.35.orig/quilt/refresh.in
+++ quilt-0.35/quilt/refresh.in
@@ -250,6 +250,14 @@ then
        exit 0
 fi
 
+if [ -e "$patch_file" ]
+then
+       scm_modify_patch "edit" "$patch_file" || die 1
+       newpatch=no
+else
+       newpatch=yes
+fi
+
 if ( [ -n "$QUILT_BACKUP" -a -e $patch_file ] && \
      ! cp $patch_file $patch_file~ ) || \
    ! cat_to_file $patch_file < $tmp_result
@@ -261,6 +269,12 @@ touch $QUILT_PC/$patch/.timestamp
 
 rm -f $QUILT_PC/$patch~refresh
 printf $"Refreshed patch %s\n" "$(print_patch $patch)"
+
+if [ "$newpatch" = "yes" ]
+then
+       scm_modify_patch "add" "$patch_file" || die 1
+fi
+
 if ! change_db_strip_level -p$opt_strip_level $patch
 then
        die 1
# If input file names a symbolic link, print path to real file.
# If non-existent or not a link, print the input path.
realfile() {
        local path=$(find "$1" -printf "%l" 2> /dev/null)
        if [ "$path" ] ; then
                if [ "${path:0:1}" != "/" ] ; then
                        path=$(dirname "$1")"/$path"
                fi
        else
                path="$1"
        fi
        echo "$path"
}

do_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 "$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 ! mv "$dir/$name" "$dir/$name~"
                        then
                                printf $"Cannot remove file \"%s\".\n" \
                                        "$dir/$name"
                                return 1
                        fi
                        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
}

# 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
        #               may also delete the file or move to patch_file~
        do_cvs_operation "$1" "$2"
}

# 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
        do_cvs_operation "$1" "$(realfile $2)"
}

reply via email to

[Prev in Thread] Current Thread [Next in Thread]