[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Quilt-dev] [patch 4/6] select/merge documentation on import
From: |
jayvdb |
Subject: |
[Quilt-dev] [patch 4/6] select/merge documentation on import |
Date: |
Tue, 27 Sep 2005 19:19:26 +1000 |
User-agent: |
quilt/0.42-1 |
Several error conditions are now caught.
Patches floating around the QUILT_PATCHES directory can be imported.
A minor fix in the output.
scripts/patchfns.in | 22 ++++++++++++++++++++++
quilt/import.in | 24 +++++++++++++++++++-----
test/import.test | 27 ++++++---------------------
3 files changed, 47 insertions(+), 26 deletions(-)
--- quilt-files.orig/scripts/patchfns.in
+++ quilt-files/scripts/patchfns.in
@@ -566,6 +566,28 @@ find_pending_patch ()
echo "$patch"
}
+find_patch_file()
+{
+ local name="$1"
+
+ if [ -r "$name" ]
+ then
+ echo "$name"
+ return
+ fi
+
+ local patch file
+
+ patch=$(find_series_patch "$name" 2>/dev/null)
+ if [ -z "$patch" ]
+ then
+ printf $"Patch %s does not exist\n" "$name" >&2
+ return 1
+ fi
+
+ echo $(patch_file_name "$patch")
+}
+
file_in_patch()
{
local file=$1 patch=$2
--- quilt-files.orig/quilt/import.in
+++ quilt-files/quilt/import.in
@@ -87,14 +87,23 @@ do
patch=${patch_file##*/}
fi
+ patch_file=$(find_patch_file $patch_file) || exit 1
+
if is_applied $patch
then
printf $"Patch %s is applied\n" "$patch" >&2
exit 1
fi
- if [ -e "$QUILT_PATCHES/$patch" ]
+ dest=$(patch_file_name $patch)
+ if patch_in_series "$patch"
then
+ if [ "$patch_file" = "$dest" ]
+ then
+ printf $"Patch %s already exists in series.\n" \
+ "$(print_patch $patch)" >&2
+ exit 1
+ fi
if [ -z "$opt_force" ]
then
printf $"Patch %s exists. Replace with -f.\n" \
@@ -103,14 +112,19 @@ do
fi
printf $"Replacing patch %s with new version\n" \
"$(print_patch $patch)" >&2
+ elif [ -e "$dest" ]
+ then
+ printf $"Importing patch %s\n" \
+ "$(print_patch $patch)"
else
printf $"Importing patch %s (stored as %s)\n" \
- "$(print_patch $patch_file)" \
+ "$patch_file" \
"$(print_patch $patch)"
+
+ mkdir -p "${dest%/*}"
fi
- dest=$QUILT_PATCHES/$patch
- mkdir -p "${dest%/*}"
- if ! cp "$patch_file" "$dest"
+
+ if [ "$patch_file" != "$dest" ] && ! cp "$patch_file" "$dest"
then
printf $"Failed to import patch %s\n" "$(print_patch $patch)"
>&2
exit 1
--- quilt-files.orig/test/import.test
+++ quilt-files/test/import.test
@@ -27,7 +27,7 @@
$ rm -rf patches/ .pc/
$ mkdir patches
$ quilt import t/patch1.diff
- > Importing patch patches/t/patch1.diff (stored as patches/patch1.diff)
+ > Importing patch t/patch1.diff (stored as patches/patch1.diff)
$ quilt push
> Applying patch patches/patch1.diff
@@ -71,28 +71,13 @@
# test a few error cases
$ quilt import missing.diff
- > Importing patch patches/missing.diff (stored as patches/missing.diff)
- > cp: cannot stat `missing.diff': No such file or directory
- > Failed to import patch patches/missing.diff
+ > Patch missing.diff does not exist
$ quilt import patches/patch1.diff
- > Patch patches/patch1.diff exists. Replace with -f.
-
- $ quilt import -f patches/patch1.diff
- > Replacing patch patches/patch1.diff with new version
- > cp: `patches/patch1.diff' and `patches/patch1.diff' are the same file
- > Failed to import patch patches/patch1.diff
-
- # no real damage has been done
+ > Importing patch patches/patch1.diff
- $ cat patches/patch1.diff
- > original description
- > Index: d/f
- > ===================================================================
- > --- /dev/null
- > +++ d/f
- > @@ -0,0 +1 @@
- > +f
+ $ quilt import patches/patch2.diff
+ > Patch patches/patch2.diff already exists in series.
# a simple use of import
@@ -119,7 +104,7 @@
$ cp patches/patch1.diff t/patch1.patch
$ quilt import t/patch1.patch
- > Importing patch patches/t/patch1.patch (stored as
patches/patch1.patch)
+ > Importing patch t/patch1.patch (stored as patches/patch1.patch)
$ ls patches/
> patch1.diff
--
John
- [Quilt-dev] [patch 0/6] select/merge documentation on import, jayvdb, 2005/09/26
- [Quilt-dev] [patch 6/6] select/merge documentation on import, jayvdb, 2005/09/26
- [Quilt-dev] [patch 1/6] select/merge documentation on import, jayvdb, 2005/09/26
- [Quilt-dev] [patch 4/6] select/merge documentation on import,
jayvdb <=
- [Quilt-dev] [patch 5/6] select/merge documentation on import, jayvdb, 2005/09/26
- [Quilt-dev] [patch 3/6] select/merge documentation on import, jayvdb, 2005/09/26
- [Quilt-dev] [patch 2/6] select/merge documentation on import, jayvdb, 2005/09/26