]> git.neil.brown.name Git - wiggle.git/commitdiff
Add rebase function to 'p'
authorNeil Brown <neilb@suse.de>
Tue, 13 Jun 2006 12:57:10 +0000 (22:57 +1000)
committerNeil Brown <neilb@suse.de>
Tue, 13 Jun 2006 12:57:10 +0000 (22:57 +1000)
This moves all 'applied' patches to 'included'
and makes the current files 'current'  and 'orig'.

Signed-off-by: Neil Brown <neilb@suse.de>
p

diff --git a/p b/p
index 5220c815529fa824780bfbe20989532a35fb30cd..923bc478e0df354a87b479a98ca1fe4ee5d030a0 100755 (executable)
--- a/p
+++ b/p
@@ -141,6 +141,15 @@ forget_one()
        fi
 }
 
+rebase_one()
+{
+    f="/$1"
+    mkdir -p .patches/orig${f%/*}
+    mkdir -p .patches/current${f%/*}
+    rm -f .patches/orig$f .patches/current$f
+    cp -p $1 .patches/orig$f
+    cp -p $1 .patches/current$f
+}
 
 snap_one()
 {
@@ -287,7 +296,7 @@ find_prefix()
            prefix=`expr $prefix + 1`
        done
        if [ -z "$file" ]
-       then echo "Cannot find $orig" >&2 
+       then echo "Cannot find $orig" >&2
           if [ $n -gt 4 ]
           then exit 2;
           else find_prefix "$1" $[n+1]
@@ -847,6 +856,23 @@ case $cmd in
        while [ -s "$pfile" ]  &&
             $0 open last && $0 discard ; do : ; done
        ;;
+
+  rebase )
+       # move all applied patches to included, and
+       # copy current to orig and current
+       make_diff
+       if [ -s .patches/patch ]
+       then
+           echo >&2 Patch already open - please commit; eixt 1;
+       fi
+       for p in `ls .patches/applied`
+       do
+         name=${p##[0-9][0-9][0-9]}
+         mv .patches/applied/$p .patches/patch
+         save_patch included $name
+       done
+       all_files rebase_one
+       ;;
   snapshot )
        all_files snap_one
        ;;