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: Dean Roehrich
Subject: Re: [Quilt-dev] [patch] Quilt support for committing patches to CVS.
Date: Wed, 11 Aug 2004 11:02:52 -0500

>From:  Andreas Gruenbacher <address@hidden>

>I am not happy about hard-coding CVS specifics into quilt. We could
>provide some sort of hook mechanism to fix this. What's relevant to
>version control is which files have been modified, added, and removed,
>so a simple function in .quiltrc like this would probably do:

My own stuff is pretty generic.  Most of the logic is in .quiltrc, and quilt
just needs to know that the quiltrc functions need to be called.  The
functions in .quiltrc figure out what type of source control management system
(SCM) is being used for this code and calls the appropriate commands.  This
has limitations such as the rename you mentioned and while I'm not conversant
in CVS I suspect it won't handle the "commit" issue; at least, I don't attempt
to handle the commit issue for BK trees and for the SGI-internal SCM I use.

The good news is that quilt itself doesn't need to now about the SCMs, it just
needs to know that before it modifies or creates a file it must call the SCM
function that .quiltrc supplies.  That function in .quiltrc is responsible for
determining what type of SCM is being used and how/if to tell that SCM that we
want to modify a particular file or create a new file.  Then the .quiltrc SCM
function returns a result that tells quilt whether or not it can continue and
patch the file.

For example, in a BK repository you would want to run "bk co -l" on the file
before you allow quilt to apply a patch to it.  BK does not need to be told
about any new files that will be created by the quilt patches.

Another example: For the SGI-internal SCM the .quiltrc SCM function needs to
run a command to tell our SCM that we want to modify a file; our SCM also
needs to be told when new files are going to be created by the quilt patches.

And while I'm not familiar with CVS, it looks like it does not need to be told
about files that quilt patches are going to modify or create.  This puts CVS
on a slightly different model than the two SCMs I mentioned above.

This allows me to handle my day-to-day activities, though, clearly it has
caveats.  I don't attempt to handle renames or deletes--those activities are
infrequent enough in my work that I just haven't been bothered to solve the
problem.

I also don't attempt to handle the SCM "check-in" steps.  I used to have some
minimal support for this hacked into Andrew's original patch management
scripts but it was a mess for the SCMs that I use and I gave it up when I
switched to quilt.

I'll attach the changes that I use in quilt to make it call into the SCM
function offered by my .quiltrc, and the relevant parts of the .quiltrc for
BK.  This, I think, shows a different side of the story from Jason's "commit"
command.

Dean



--------- .quiltrc ------------

QUILT_SCM_MODIFY=my_modify_file

my_set_scm()
{
        SCM=none
        if [ sgi_internal_scm ]
        then
                SCM=sgis-scm
        elif [ -e BitKeeper/log/repo_id ]
        then
                SCM=bk
        fi
}

bk_modify()
{
        BK_FILE=$1
        bk flags $BK_FILE
        if [ $? -ne 0 ]
        then
                # New file
                if [ ! -d $(dirname $BK_FILE) ]
                then
                        mkdir -p $(dirname $BK_FILE)
                fi
                touch $BK_FILE
                chmod u+w $BK_FILE
        else
                bk co -l $BK_FILE
        fi

        if [ ! -f $BK_FILE ]
        then
                return 1 # does not exist
        fi
        if [ ! -w $BK_FILE ]
        then
                return 1 # not writable
        fi

        return 0
}


my_modify_file()
{
        my_set_scm
        ${SCM}_modify $1
        return $?
}

-----------cut------------------




Index: work/quilt/add.in
===================================================================
--- work.orig/quilt/add.in
+++ work/quilt/add.in
@@ -103,6 +103,13 @@ do
                continue
        fi
 
+       if ! scm_modify $SUBDIR$file
+       then
+               echo $"SCM failed to modify file $SUBDIR$file" >&2
+               status=1
+               continue
+       fi
+
        if ! @LIB@/backup-files -b -s -L -B $QUILT_PC/$patch/ $SUBDIR$file
        then
                printf $"Failed to back up file %s\n" "$SUBDIR$file" >&2
Index: work/scripts/apatch.in
===================================================================
--- work.orig/scripts/apatch.in
+++ work/scripts/apatch.in
@@ -55,9 +55,12 @@ apply_patch()
                        --backup --prefix="$QUILT_PC/$patch/" \
                        -E $silent $force_apply 2>&1
        else
-               @PATCH@ $QUILT_PATCH_OPTS $(patch_args $patch) \
-                       --backup --prefix="$QUILT_PC/$patch/" \
-                       -E $silent $force_apply -i $patch_file 2>&1
+               if scm_modify_files_for_patch $patch_file
+               then
+                       @PATCH@ $QUILT_PATCH_OPTS $(patch_args $patch) \
+                               --backup --prefix="$QUILT_PC/$patch/" \
+                               -E $silent $force_apply -i $patch_file 2>&1
+               fi
        fi
 }
 
Index: work/scripts/patchfns.in
===================================================================
--- work.orig/scripts/patchfns.in
+++ work/scripts/patchfns.in
@@ -35,6 +35,29 @@ if [ -n "$QUILT_COMMAND" ]; then
        unset args
 fi
 
+# Tell the underlying SCM that we are going to modify the file.
+scm_modify()
+{
+       if [ -n "$QUILT_SCM_MODIFY" ]
+       then
+               $QUILT_SCM_MODIFY $1
+       fi
+}
+
+scm_modify_files_for_patch()
+{
+       if [ -n "$QUILT_SCM_MODIFY" ]
+       then
+               for i in $(lsdiff --strip=1 $1)
+               do
+                       if ! $QUILT_SCM_MODIFY $i
+                       then
+                               return 1
+                       fi
+               done
+       fi
+}
+
 # Quote a string for use in a basic regular expression.
 quote_bre()
 {




reply via email to

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