Merge from mh-e; up to 2012-01-03T19:41:14Z!larsi@gnus.org.
[bpt/emacs.git] / admin / update_autogen
index 154c184..b951196 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/bash
 ### update_autogen - update some auto-generated files in the Emacs tree
 
-## Copyright (C) 2011-2013 Free Software Foundation, Inc.
+## Copyright (C) 2011-2014 Free Software Foundation, Inc.
 
 ## Author: Glenn Morris <rgm@gnu.org>
 
@@ -140,24 +140,36 @@ OPTIND=1
 [ "$quiet" ] && exec 1> /dev/null
 
 
-echo "Running bzr status..."
+## Run status on inputs, list modified files on stdout.
+status ()
+{
+    bzr status -S "$@" >| $tempfile || die "bzr status error for $@"
 
-bzr status -S ${autogendir:+$sources} ${ldefs_flag:+lisp} \
-    ${info_flag:+doc} >| $tempfile || \
-    die "bzr status error for input files"
+    local stat file modified
 
-## The lisp portion could be more permissive, eg only care about .el files.
-while read stat file; do
+    while read stat file; do
 
-    case $stat in
-        M)
-            echo "Locally modified: $file"
-            [ "$force" ] || die "There are local modifications"
-            ;;
+        [ "$stat" != "M" ] && \
+            die "Unexpected status ($stat) for generated $file"
+        modified="$modified $file"
 
-        *) die "Unexpected status ($stat) for $file" ;;
-    esac
-done < $tempfile
+    done < $tempfile
+
+    echo "$modified"
+
+    return 0
+}                               # function status
+
+
+echo "Checking input file status..."
+
+## The lisp portion could be more permissive, eg only care about .el files.
+modified=$(status ${autogendir:+$sources} ${ldefs_flag:+lisp} ${info_flag:+doc}) || die
+
+[ "$modified" ] && {
+    echo "Locally modified: $modified"
+    [ "$force" ] || die "There are local modifications"
+}
 
 
 ## Probably this is overkill, and there's no need to "bootstrap" just
@@ -259,21 +271,11 @@ EOF
         done
     done
 
-    bzr status -S $outfile >| $tempfile || \
-        die "bzr status error for generated $outfile"
-
     local modified
 
-    while read stat file; do
+    modified=$(status $outfile) || die
 
-        [ "$stat" != "M" ] && \
-            die "Unexpected status ($stat) for generated $file"
-
-        modified="$modified $file"
-
-    done < $tempfile
-
-    commit "info/dir" $modified || die "bzr commit error"
+    commit "info/dir" $modified || die "commit error"
 }                               # function info_dir
 
 
@@ -287,23 +289,11 @@ EOF
 
     echo "Checking status of generated files..."
 
-    bzr status -S $basegen >| $tempfile || \
-        die "bzr status error for generated files"
-
-    modified=
-
-    while read stat file; do
-
-        [ "$stat" != "M" ] && \
-            die "Unexpected status ($stat) for generated $file"
-
-        modified="$modified $file"
-
-    done < $tempfile
+    modified=$(status $basegen) || die
 
     cd $oldpwd
 
-    commit "generated" $modified || die "bzr commit error"
+    commit "generated" $modified || die "commit error"
 
     exit 0
 }                               # $autogendir
@@ -317,8 +307,9 @@ EOF
 
 echo "Finding loaddef targets..."
 
-sed -n -e '/^AUTOGEN_VCS/,/^$/ s/\\//p' lisp/Makefile.in | \
-    sed '/AUTOGEN_VCS/d' >| $tempfile || die "sed error"
+sed -n -e '/^AUTOGEN_VCS/,/^$/p' lisp/Makefile.in | \
+    sed -e '/AUTOGEN_VCS/d' -e '/^$/d' -e 's/\\//' \
+    >| $tempfile || die "sed error"
 
 genfiles=
 
@@ -370,24 +361,13 @@ echo "Checking status of loaddef files..."
 ## It probably would be fine to just check+commit lisp/, since
 ## making autoloads should not effect any other files.  But better
 ## safe than sorry.
-bzr status -S $genfiles ${ldefs_out#lisp/} >| $tempfile || \
-    die "bzr status error for generated files"
-
-
-modified=
-
-while read stat file; do
-
-    [ "$stat" != "M" ] && die "Unexpected status ($stat) for generated $file"
-    modified="$modified $file"
-
-done < $tempfile
+modified=$(status $genfiles ${ldefs_out#lisp/}) || die
 
 
 cd ../
 
 
-commit "loaddefs" $modified || die "bzr commit error"
+commit "loaddefs" $modified || die "commit error"
 
 
 exit 0