quilt-dev
[Top][All Lists]
Advanced

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

[Quilt-dev] [PATCH 27/39] backup-files: Remember the list of files


From: Jean Delvare
Subject: [Quilt-dev] [PATCH 27/39] backup-files: Remember the list of files
Date: Sat, 19 Mar 2011 10:52:57 +0100
User-agent: quilt/0.48-17.1

Remember the results of the find command, to avoid having to run it
again later. We use a temporary file rather than a local variable,
because you can't store binary zeroes in a bash string, and because
the temporary file approach performs better on large file sets.

Signed-off-by: Jean Delvare <address@hidden>
Reviewed-by: Raphael Hertzog <address@hidden>
---
 configure.ac                  |   13 -------------
 quilt/scripts/backup-files.in |   28 ++++++++++++++++++++--------
 quilt/scripts/patchfns.in     |   10 ----------
 quilt/scripts/utilfns         |   10 ++++++++++
 4 files changed, 30 insertions(+), 31 deletions(-)

--- a/quilt/scripts/backup-files.in
+++ b/quilt/scripts/backup-files.in
@@ -142,24 +142,36 @@ restore()
 
 restore_all()
 {
+       local FILELIST
+
        (cd "$OPT_PREFIX" && find . -type d -print0) \
        | xargs -0 mkdir -p
        if [ ${PIPESTATUS[0]} != 0 ]; then
                return 1
        fi
 
-       (cd "$OPT_PREFIX" && find . -type f -print0) \
-       | xargs -0 -r rm -f
+       # Store the list of files to process
+       FILELIST=$(gen_tempfile)
+       trap "rm -f \"$FILELIST\"" EXIT
 
-       find "$OPT_PREFIX" -type f -print \
-       | while read
+       cd "$OPT_PREFIX"
+       find . -type f -print0 > "$FILELIST"
+       cd "$OLDPWD"
+
+       if [ ! -s "$FILELIST" ]; then
+               rm -f "$FILELIST"
+               exit
+       fi
+
+       xargs -0 rm -f < "$FILELIST"
+
+       while read -d $'\0' -r
        do
-               restore_fast "${REPLY#$OPT_PREFIX}"
-       done
+               restore_fast "${REPLY#./}"
+       done < "$FILELIST"
 
        if [ -n "$OPT_TOUCH" ]; then
-               (cd "$OPT_PREFIX" && find . -type f -size +0 -print0) \
-               | xargs -0 -r touch
+               xargs -0 touch -c < "$FILELIST"
        fi
 
        if [ -z "$OPT_KEEP_BACKUP" ]; then
--- a/configure.ac
+++ b/configure.ac
@@ -320,19 +320,6 @@ fi
 
 QUILT_COMPAT_PROG_PATH(XARGS, xargs)
 
-AC_MSG_CHECKING([whether $XARGS -r works])
-if echo | $XARGS -r echo >/dev/null 2>&1; then
-       AC_MSG_RESULT(yes)
-else
-       AC_MSG_RESULT(no)
-       AC_MSG_ERROR([
-Sorry, you have a version of xargs which doesn't understand -r.
-$PACKAGE_NAME needs it.  If you have access to a version of xargs which
-does understand -r, you can supply its path with the
-'--with-xargs=' option.
-])
-fi
-
 AC_MSG_CHECKING([whether $XARGS -0 works])
 if echo | $XARGS -0 echo >/dev/null 2>&1; then
        AC_MSG_RESULT(yes)
--- a/quilt/scripts/patchfns.in
+++ b/quilt/scripts/patchfns.in
@@ -838,16 +838,6 @@ in_array()
        return 1
 }
 
-gen_tempfile()
-{
-       if [ "$1" = -d ]
-       then
-               mktemp -d ${2:-${TMPDIR:-/tmp}/quilt.}XXXXXX
-       else
-               mktemp ${1:-${TMPDIR:-/tmp}/quilt.}XXXXXX
-       fi
-}
-
 first_modified_by()
 {
        local file=$1 patch
--- a/quilt/scripts/utilfns
+++ b/quilt/scripts/utilfns
@@ -42,3 +42,13 @@ dirname()
                fi
        fi
 }
+
+gen_tempfile()
+{
+       if [ "$1" = -d ]
+       then
+               mktemp -d ${2:-${TMPDIR:-/tmp}/quilt.}XXXXXX
+       else
+               mktemp ${1:-${TMPDIR:-/tmp}/quilt.}XXXXXX
+       fi
+}




reply via email to

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