quilt-dev
[Top][All Lists]
Advanced

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

[Quilt-dev] restoring moved file


From: John Vandenberg
Subject: [Quilt-dev] restoring moved file
Date: Tue, 9 Aug 2005 00:06:49 +1000

Hi,

I have run into a minor anoyance when restoring a file that is moved
when the old filename becomes used as a generated file.  To
illustrate, a file Makefile is moved to Makefile.in in a distinct
patch; subsequent patches alter Makefile.in and when the generated
Makefile becomes different from the original, pop -a halts.

  2> Patch x.diff does not remove cleanly (refresh it or enforce with -f)

The message can be misleading, because the patch x.diff is in fine; it
is local files that cause the error.  Personally, I would prefer that
pop would overwrite the stale file, but there may be other
circumstances where restoring the file could cause irreparable
dataloss.  The following patch reports why it cant be removed cleanly,
so the user knows its probably safe to enforce.  How do others think
quilt should handle this scenario?
--
John

Report when files to be restored conflict with local files.

Without this, pop will fail with this message:
Patch x.diff does not remove cleanly (refresh it or enforce with -f)

Index: quilt/quilt/pop.in
===================================================================
--- quilt.orig/quilt/pop.in     2005-08-08 22:20:28.%N +1000
+++ quilt/quilt/pop.in  2005-08-09 00:44:50.%N +1000
@@ -143,19 +143,32 @@
                fi
        fi
 
-       local file failed
+       local file failed overwrite
        for file2 in $(files_in_patch $patch)
        do
                file=$workdir/$file2
                [ -e $file  ] || file=/dev/null
                [ -e $file2 ] || file2=/dev/null
-               @DIFF@ -q $file $file2 > /dev/null || failed=1
+               @DIFF@ -q $file $file2 > /dev/null ||
+               if [ $file = '/dev/null' -a $file2 != '/dev/null' ]
+               then
+                       overwrite=1
+                       [ -z "$opt_quiet" ] &&
+                               printf $"File $file2 can not be
restored: file exists\n" >&2
+               else
+                       failed=1
+               fi
        done
 
-       if [ -n "$failed" ]
+       if [ -n "$failed" -o -n "$overwrite" ]
        then
-               printf $"Patch %s does not remove cleanly (refresh it
or enforce with -f)\n" \
-                      "$(print_patch $patch)" >&2
+               recommend='refresh it or enforce with -f'
+               if [ -z "$failed" ]; then
+                       recommend='overwrite with -f'
+               fi
+               printf $"Patch %s does not remove cleanly (%s)\n" \
+                      "$(print_patch $patch)" \
+                      "$recommend" >&2
                status=1
        fi
        rm -rf $workdir
Index: quilt/test/move.test
===================================================================
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
+++ quilt/test/move.test        2005-08-09 00:45:33.%N +1000
@@ -0,0 +1,43 @@
+Test moving a file and restoring it, even when the original filename is later
+used for another purpose.  Most often, this will occur when a file is renamed
+to become a generated file.  e.g. Makefile -> Makefile.in
+
+       $ rm -rf d
+       $ mkdir d
+       $ cd d
+
+       $ echo test > old
+       $ quilt new move.patch
+       > Patch patches/move.patch is now on top
+
+       $ quilt add old new
+       > File old added to patch patches/move.patch
+       > File new added to patch patches/move.patch
+
+       $ mv old new
+       $ quilt refresh
+       > Refreshed patch patches/move.patch
+
+       $ quilt new ontop.patch
+       > Patch patches/ontop.patch is now on top
+
+       $ quilt add f
+       > File f added to patch patches/ontop.patch
+
+       $ echo foo > f
+       $ quilt refresh
+       > Refreshed patch patches/ontop.patch
+
+       $ echo break > old
+       $ quilt pop
+       > Removing patch patches/ontop.patch
+       > Removing f
+       >
+       > Now at patch patches/move.patch
+
+       $ quilt pop
+       > File old can not be restored: file exists
+       > Patch patches/move.patch does not remove cleanly (overwrite with -f)
+
+       $ cd ..
+       $? rm -rf d




reply via email to

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