quilt-dev
[Top][All Lists]
Advanced

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

[Quilt-dev] altering the series


From: John Vandenberg
Subject: [Quilt-dev] altering the series
Date: Sat, 3 Sep 2005 22:13:04 +1000

Hi,

Presently, I find that it is often necessary to edit the series file. 
There are two problems with this:
1.  It could be anywhere
2.  Manually reordering or deleting applied patches from the series
can result in a fragged working tree.

I propose that in the short term, we introduce an option to series to
safely allow the user to edit the series files.  Currently, I have a
solution, below, that permits:
- altering comments anywhere
- editing the unapplied patches section

It prohibits:
- editing the set of applied and current patches or their ordering

In order to assist the user avoid making undesirable changes, the
patch prefixes the appropriate parts of the series with APPLIED> and
CURRENT> ; this is only a visual guide, and is not part of the logic.

AFIACS there is no need to permit direct editing of the applied
section of the series, as delete should be used for this purpose, or
in the worst case, the user can pop any necessary patches off in order
to safely make the changes.

In the less immediate term, it would be nice to allow the user to
reorder the series without needing to pop.  Using pop & push when
re-arranging patches is especially annoying when a C header is
involved, as it can cause an entire project to rebuild unnecessarily.

To this end, I propose the dependency-graph script is used to
determine whether requested changes to the applied patches can be
safely achieved without calling pop & push.

At this stage, I cant find a unified CLI interface for re-ordering
patches.  A new "reorder" command would need to know the intended
order, which would require a complicated syntax, and would be hard to
type out; instead, we would resort back to editing the series file.

The best approach I can think of is to allow the user to alter the
applied portion of the series using an editor, and then check the
requested order does not break dependencies.

Another approach is to introduce commands to match typical reasons we
edit the series file.  From my limited person experience, the first
candidate would be "raise", that attempts to pull the specified patch
to the top, with an option to have the patch raised as high as
possible.

For example, if a user was at patch7, and wanted to work on patch3,
but patch7 depends on patch3, the following sequence could show
typical usage

$ quilt raise patch3
Patch patch7 depends on patch3
$ quilt raise -f patch3
Patch patch3 is now before patch7

Another way to reduce the amount of series editing, is to introduce a
"working set".  Within a series, there may be a number of contiguous
patches that are logically dependent in the series order, but the
order amoungst them is not a literal dependancy.  It would be nice to
move around this working set freely, as there is no need to use push &
pop to navigate between then.  This does not remove the need to
reorder the series, but it would mean the series order does not need
to be locked in stone until submission.   One very obvious problem
with this, is that it is difficult to introduce a working set
conceptually into quilt, which is currently assumed to be a stack of
patches.

Comments, objections, flames, etc; all will be appreciated.

Index: quilt/quilt/series.in
===================================================================
--- quilt.orig/quilt/series.in  2005-06-11 08:17:04.000000000 +1000
+++ quilt/quilt/series.in       2005-09-03 19:45:36.608411386 +1000
@@ -17,16 +17,19 @@
        . @SCRIPTS@/patchfns
 fi
 
+: ${EDITOR:=vi}
+
 usage()
 {
        printf $"Usage: quilt series [-v]\n"
        if [ x$1 = x-h ]
        then
                printf $"
-Print the names of all patches in the series file.
+Print or change the names of all patches in the series file.
 
+-e     edit the series in \$EDITOR (%s)
 -v     Verbose, more user friendly output.
-"
+" "$EDITOR"
                exit 0
        else
                exit 1
@@ -45,7 +48,56 @@
        done
 }
 
-options=`getopt -o vh -- "$@"`
+editable_series()
+{
+       local tmp_series=$1
+       local top_patch=$(top_patch)
+
+       [ -e $SERIES ] || exit 1
+
+       if [ -z "$top_patch" ]
+       then
+               cp $SERIES $tmp_series
+       else
+               @AWK@ '
+               found                   { print $0; next }
+               $0 == "'"$top_patch"'"  { found=1; print "CURRENT> "$0; next }
+               !found                  { print "APPLIED> "$0 }
+               ' $SERIES > $tmp_series
+       fi
+}
+
+# Checks that $1 contains the same ordered list of patches as those applied
+check_applied()
+{
+       local new_series=$1 applied=$(gen_tempfile)
+
+       applied_patches > "$applied"
+
+       if SERIES="$new_series" cat_series | grep -f "$applied" \
+               | diff -q "$applied" -
+       then
+               return 0
+       else
+               return 1
+       fi
+}
+
+update_series()
+{
+       local edited_series=$1 new_series=$(gen_tempfile)
+
+       @SED@ -e 's/^CURRENT> //g;s/APPLIED> //g;' $edited_series > $new_series
+
+       if check_applied $new_series
+       then
+               mv $new_series $SERIES
+       else
+               return 1
+       fi
+}
+
+options=`getopt -o vhe -- "$@"`
 
 if [ $? -ne 0 ]
 then
@@ -57,6 +109,9 @@
 while true
 do
        case "$1" in
+       -e)
+               opt_edit=1
+               shift ;;
        -v)
                opt_verbose=1
                shift ;;
@@ -73,6 +128,20 @@
        usage
 fi
 
+if [ -n "$opt_edit" ]
+then
+       tmp=$(gen_tempfile) || exit 1
+       editable_series $tmp
+       $EDITOR $tmp || exit 1
+       if ! update_series $tmp
+       then
+               printf $"Failed to update series\n"
+               exit 1
+       fi
+       printf $"Committed new series\n"
+       exit 0
+fi
+
 if [ -n "$opt_verbose" ]
 then
        top=$(top_patch)

--
John




reply via email to

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