diff --git a/autoconf_share/rub b/autoconf_share/rub
index 034c230481dcd4df154241a7b2eea534ebada90d..d3fb75846e4833c8b257eb014e889099fc5834aa 100755
--- a/autoconf_share/rub
+++ b/autoconf_share/rub
@@ -676,7 +676,21 @@ do
       # Use the switch command to do this.
       part="trunk"
       if [ "$vers" != "" ]; then
-        part="branches/$vers"
+        # $vers can be either in tags or in branches; try both
+        for dir in tags branches
+        do
+          part="$dir/$vers"
+          # if list command succeeds, we've got the correct value for $part
+          if $command list $svnurl/$part/$pkg > /dev/null 2>&1; then
+            break
+          else
+            part=
+          fi
+        done
+        if [ "$part" = "" ]; then
+          echo "Error: version $vers of $pkg not found"
+          exit 1
+        fi
       fi
       echo "(cd $pkg  &&  $command switch $svnurl/$part/$pkg)" >> rub.log 2>&1
       (cd $pkg  &&  $command switch $svnurl/$part/$pkg) >> rub.log 2>&1
diff --git a/autoconf_share/rub1 b/autoconf_share/rub1
index 0c7c02f14bdb605abf83a4515f73b5a1dab5a9cc..42a97724c4f1be0dabc2ea90c59e12522bff31cc 100755
--- a/autoconf_share/rub1
+++ b/autoconf_share/rub1
@@ -125,7 +125,7 @@ if [ "$pkgline" = "" ]; then
       # Remove the part '-release-branch' leaving the CVS tag name.
       getvers=`cvs log $pkgname/configure.in 2>&1 | grep release-branch | head -1 | sed -e 's/[ \t]*\(.*\)-release-branch.*/\1/'`
     else
-      getvers=`svn list $svnurl/branches 2>&1 | grep $pkgnmvers | grep release-root | tail -1 | sed -e 's/[ \t]*\(.*\)-release-root.*/\1/'`
+      getvers=`svn list $svnurl/branches 2>&1 | grep $pkgnmvers | grep release-branch | tail -1 | sed -e 's/[ \t]*\(.*\)-release-branch.*/\1/'`
     fi
   fi
 
@@ -211,7 +211,21 @@ if [ "$pkgline" = ""  -o  "$getvers" != "$curvers" ]; then
         # in version is also handled.
         part="trunk"
         if [ "$getvers" != "" ]; then
-          part="branches/$getvers"
+          # $getvers can be either in tags or in branches; try both
+          for dir in tags branches
+          do
+            part="$dir/$getvers"
+            # if list command succeeds, we've got the correct value for $part
+            if $command list $svnurl/$part/$pkgname > /dev/null 2>&1; then
+              break
+            else
+              part=
+            fi
+          done
+          if [ "$part" = "" ]; then
+            echo "Error: version $getvers of $pkgname not found"
+            exit 1
+          fi
         fi
         echo "(cd $pkgname  &&  $command switch $svnurl/$part/$pkgname)" >> rub.log 2>&1
         (cd $pkgname  &&  $command switch $svnurl/$part/$pkgname) >> rub.log 2>&1
@@ -253,7 +267,21 @@ if [ "$pkgline" = ""  -o  "$getvers" != "$curvers" ]; then
         # Check out the leaf.
         part=trunk
         if [ "$getvers" != "" ]; then
-          part="branches/$getvers"
+          # $getvers can be either in tags or in branches; try both
+          for dir in tags branches
+          do
+            part="$dir/$getvers"
+            # if list command succeeds, we've got the correct value for $part
+            if $command list $svnurl/$part/$pkgname > /dev/null 2>&1; then
+              break
+            else
+              part=
+            fi
+          done
+          if [ "$part" = "" ]; then
+            echo "Error: version $getvers of $pkgname not found"
+            exit 1
+          fi
         fi
         # Find out if it is a leaf package or super package by testing
 	# if it has a configure.in file.