changeset 213:b1d2ea765516

tools: refactor stuff into common.sh, make verify-all-heads not revert.
author Augie Fackler <durin42@gmail.com>
date Fri, 20 Mar 2009 10:18:34 -0500
parents a421aca2b0f5
children 1416429584b2
files tools/bisect-find-bad.sh tools/common.sh tools/verify-all-heads.sh
diffstat 3 files changed, 32 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/tools/bisect-find-bad.sh
+++ b/tools/bisect-find-bad.sh
@@ -1,10 +1,4 @@
 #!/bin/bash
-/bin/rm -rf *
-svn export `hg svn info 2> /dev/null | grep '^URL: ' | sed 's/URL: //'` -`hg svn parent | sed 's/.*: //;s/ .*//'` . --force
-if [ `hg st | wc -l` = 0 ] ; then
-    exit 0
-else
-    hg revert --all
-    hg purge
-    exit 1
-fi
+. $(dirname $0)/common.sh
+verify_current_revision $1
+exit $?
new file mode 100644
--- /dev/null
+++ b/tools/common.sh
@@ -0,0 +1,26 @@
+function verify_current_revision()
+{
+    /bin/rm -rf *
+    exportcmd="svn export `hg svn info 2> /dev/null | grep '^URL: ' | sed 's/URL: //'` -`hg svn parent | sed 's/.*: //;s/ .*//'` . --force"
+    `echo $exportcmd` > /dev/null
+    x=$?
+    if [[ "$x" != "0" ]] ; then
+        echo $exportcmd
+        echo 'export failed!'
+        return 255
+    fi
+    if [[ "`hg st | wc -l`" == "0" ]] ; then
+        return 0
+    else
+        if [[ $1 != "keep" ]] ; then
+            revert_all_files
+        fi
+        return 1
+    fi
+}
+
+function revert_all_files()
+{
+    hg revert --all
+    hg purge
+}
--- a/tools/verify-all-heads.sh
+++ b/tools/verify-all-heads.sh
@@ -1,7 +1,9 @@
 #!/bin/sh
+. $(dirname $0)/common.sh
+
 for b in `hg branches | cut -f 1 -d ' '` ; do
     hg co $b || break
     echo Verifying $b
-    $(dirname $0)/bisect-find-bad.sh > /dev/null || break
+    verify_current_revision keep > /dev/null || break
     echo $b Verified.
 done