On Sun, 29 Nov 2009, Raphael Hertzog wrote:
> A contributor submitted us the attached patch, please share your comments
> and consider including it if it's fine.

Really attached this time.

Cheers,
-- 
Raphaƫl Hertzog
Description: remember locations for patches and series file
 Create .pc/.quilt_patches and .pc/.quilt_series files when creating
 the .pc directory containing the path to the patches directory and
 series file used that first time. The paths are made relative when
 they point inside the directory .pc resides in, to allow renaming
 of the top directory, and are left absolute otherwise. This allows to
 be set QUILT_PATCHES only on the first invocation and have it correct
 automatically on subsequent calls.
Bug-Debian: http://bugs.debian.org/557623
Author: Goswin von Brederlow <[email protected]>
Last-Update: 2009-11-28

diff --git a/quilt/scripts/patchfns.in b/quilt/scripts/patchfns.in
index 9ed4fd1..7468349 100644
--- a/quilt/scripts/patchfns.in
+++ b/quilt/scripts/patchfns.in
@@ -20,9 +20,14 @@ export LANG=POSIX
 export QUILT_PATCHES QUILT_PC SUBDIR SERIES DB
 DB_VERSION=2
 
-: ${QUILT_PATCHES:=patches}
 : ${QUILT_PC:=.pc}
 
+if [ -r $QUILT_PC/.quilt_patches ]; then
+	: ${QUILT_PATCHES:="$(< $QUILT_PC/.quilt_patches)"}
+else
+	: ${QUILT_PATCHES:=patches}
+fi
+
 # Support compatibility layer
 if [ -d $QUILT_DIR/compat ]
 then
@@ -943,11 +948,29 @@ next_filename()
         echo "${base%-$num}-$((num+1))${patch#$base}"
 }
 
+relativize_path() {
+	local dir=$1 base=$2
+	if ! [ "${dir:0:1}" = "/" ]
+	then
+		echo "$dir"
+		return
+	fi
+	LEN="${#base}"
+	if [ "${dir:0:$LEN}" = "$base" ]
+	then
+		echo "${dir:$LEN}"
+	else
+		echo "$dir"
+	fi
+}
+
 create_db() {
 	if ! [ -e $QUILT_PC ]
 	then
 		mkdir -p $QUILT_PC
 		echo $DB_VERSION > $QUILT_PC/.version
+		relativize_path "$QUILT_PATCHES" "$(pwd)/" > "$QUILT_PC/.quilt_patches"
+		relativize_path "$QUILT_SERIES" "$(pwd)/" > "$QUILT_PC/.quilt_series"
 	fi
 }
 
@@ -1073,7 +1096,11 @@ then
     unset basedir down
 fi
 
-: ${QUILT_SERIES:=series}
+if [ -r $QUILT_PC/quilt_series ]; then
+	: ${QUILT_SERIES:="$(< $QUILT_PC/.quilt_series)"}
+else
+	: ${QUILT_SERIES:=series}
+fi
 
 if [ "${QUILT_SERIES:0:1}" = / ]
 then
_______________________________________________
Quilt-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/quilt-dev

Reply via email to