chiark / gitweb /
@@ -1,3 +1,9 @@ debian_version_4_0_99_0_18
authorianmdlvl <ianmdlvl>
Tue, 2 Aug 2005 22:49:56 +0000 (22:49 +0000)
committerianmdlvl <ianmdlvl>
Tue, 2 Aug 2005 22:49:56 +0000 (22:49 +0000)
+chiark-utils (4.0.99.0.18) unstable; urgency=low
+
+  * cvs-repomove can move repos from remote sources as well as local ones.
+
+ -- Ian Jackson <ian@davenant.greenend.org.uk>  Tue,  2 Aug 2005 23:49:51 +0100
+
 chiark-utils (4.0.99.0.17) unstable; urgency=low

   * Size for readbuffer/writebuffer may be in k or bytes.

debian/changelog
scripts/cvs-repomove

index 12924c8f9c0d216e614dccd00ae98da4ac3a8dad..1dfb0570c5e68568823563f657d9105e0dbe4913 100644 (file)
@@ -1,3 +1,9 @@
+chiark-utils (4.0.99.0.18) unstable; urgency=low
+
+  * cvs-repomove can move repos from remote sources as well as local ones.
+
+ -- Ian Jackson <ian@davenant.greenend.org.uk>  Tue,  2 Aug 2005 23:49:51 +0100
+
 chiark-utils (4.0.99.0.17) unstable; urgency=low
 
   * Size for readbuffer/writebuffer may be in k or bytes.
index d53528db31fdef521c34898bdf0b5ec9233a80bd..e7d2e53b5af2830e7f9f3c7e74f5467d78a1369b 100755 (executable)
@@ -4,6 +4,7 @@ print_usage () { cat <<'END'
 usage:
   to move repository directory, cd to anywhere and
     cvs-repomove --move local-repo module hostname remote-repo
+    cvs-repomove --move src-hostname src-repo module dst-hostname dst-repo
   to adjust CVS/Root afterwards, in each working directory
     cvs-repomove                automatically update **/CVS/Root
 END
@@ -46,7 +47,7 @@ check_module () {
        esac
 }
 
-check_remote_host () {
+check_hostname () {
        case "$1" in
        /*|.*|-*)       fail "bad hostname $dsthost" ;;
        esac
@@ -55,13 +56,15 @@ check_remote_host () {
 check_remote_path () {
        case "$1" in
        *[^0-9a-zA-Z/._+,-]*) fail \
-               "remote pathname may not contain metacharacters, sorry" ;;
+               "pathname may not contain metacharacters, sorry" ;;
        esac
 }
 
 do_move () {
        check_module
-       check_remote_host "$dsthost"
+       check_hostname "$srchost"
+       check_hostname "$dsthost"
+       check_remote_path "$srcrepo/$module"
        check_remote_path "$dstrepo/$module"
 
        case "$dstrepo" in
@@ -69,61 +72,69 @@ do_move () {
        *)      bad_usage "destination repo path must be absolute" ;;
        esac
 
-       printf "moving module %s from %s to %s:%s\n" \
-               "$module" "$srcrepo" "$dsthost" "$dstrepo"
+       printf "moving module %s from %s:%s to %s:%s\n" \
+               "$module" "$srchost" "$srcrepo" "$dsthost" "$dstrepo"
 
        mn "checking existing repository"
-       ls -d -- "$srcrepo/CVSROOT" >/dev/null
+       "$CVS_RSH" "$srchost" bash -ec "'
+ ls -d -- $srcrepo/CVSROOT >/dev/null
+       '"
 
        dstrepotrans="$(printf "%s" "$dstrepo" | tr / :)"
        movingto="moving-to-$dsthost:$dstrepotrans"
-       if test -d "$srcrepo/$module..$movingto"; then
-               echo "    resuming previous attempt at a move"
-               resume=true
-               if test -d "$srcrepo/$module"; then
-                       fail "but $srcrepo/$module exists too"
-               fi
-       else
-               resume=false
-               ls -d -- "$srcrepo/$module" >/dev/null
-       fi
-
-       set +e
-       previously="$(ls -d -- "$srcrepo/$module..moved-to-"* 2>/dev/null)"
-       set -e
-       if [ "x$previously" != x ]; then
-               echo "    btw, module was once before moved away from here"
-               mv -- "$previously" \
- "${previously/..moved-to-/..previously-$(date +%s)-moved-to-}"
-       fi
+       resume="$("$CVS_RSH" "$srchost" bash -ec "'
+ if test -d $srcrepo/$module..$movingto; then
+  echo \"    resuming previous attempt at a move\"
+  resume=true
+  if test -d $srcrepo/$module; then
+   echo >&2 \"but $srcrepo/$module exists too\"
+   exit 1
+  fi
+ else
+  resume=false
+  ls -d -- $srcrepo/$module >/dev/null
+ fi
+ set +e
+ previously=\"$(ls -d -- $srcrepo/$module..moved-to-* 2>/dev/null)\"
+ set -e
+ if [ \"x$previously\" != x ]; then
+  echo \"    btw, module was once before moved away from here\"
+  mv -- \"$previously\" \
+   \"${previously/..moved-to-/..previously-\$(date +%s)-moved-to-}\"
+ fi
+ echo \$resume
+       '")"
 
        mn "checking dst repository"
        "$CVS_RSH" "$dsthost" bash -ec "'
              cd $dstrepo
              ls -d CVSROOT >/dev/null
              if test -d $dstrepo/$module; then
-                       echo >&2 module already exists in destination repo
-                       exit 1
              fi
              for f in $module..*; do
- case \"\$f\" in
*..moved-to-*) echo \"    btw, module was previously at destn repo\" ;;
- *..previously-*) ;;
*..tmp-*) echo \"    nb: possibly-stale temp/partial copy \$f\" ;;
*..\*) ;;
*) echo >&2 \"error: found unexpected subdir \$f\"; exit 8;;
- esac
              done
+ cd $dstrepo
+ ls -d CVSROOT >/dev/null
+ if test -d $dstrepo/$module; then
+  echo >&2 module already exists in destination repo
+  exit 1
+ fi
+ for f in $module..*; do
 case \"\$f\" in
 *..moved-to-*)   echo \"    btw, module was previously at destn repo\" ;;
 *..previously-*) ;;
 *..tmp-*)       echo \"    nb: possibly-stale temp/partial copy \$f\" ;;
 *..\*)          ;;
 *)              echo >&2 \"error: found unexpected subdir \$f\"; exit 8;;
 esac
+ done
        '"
 
        if ! $resume; then
-               mv -- "$srcrepo/$module" "$srcrepo/$module..$movingto"
+               "$CVS_RSH" "$srchost" bash -ec "'
+ mv -- $srcrepo/$module $srcrepo/$module..$movingto
+               '"
        fi
 
        mn "transferring repo data"
        tmpid="tmp-$(uname -n).$(date +%s)"
-       tar -c -C "$srcrepo/$module..$movingto" -f - . | \
-        "$CVS_RSH" "$dsthost" bash -ec "'
+       "$CVS_RSH" "$srchost" bash -ec "'
+ tar -c -C $srcrepo/$module..$movingto -f - .
+       '" | "$CVS_RSH" "$dsthost" bash -ec "'
                cd $dstrepo
                mkdir $module..$tmpid
                cd $module..$tmpid
@@ -137,9 +148,11 @@ do_move () {
                mv $module..$tmpid $module
        '"
 
-       mn "confirming move at local repo"
-       mv -- "$srcrepo/$module..$movingto" \
-               "$srcrepo/$module..moved-to-$dsthost:$dstrepotrans"
+       mn "confirming move at source repo"
+       "$CVS_RSH" "$srchost" bash -ec "'
+ mv -- $srcrepo/$module..$movingto \
+  $srcrepo/$module..moved-to-$dsthost:$dstrepotrans
+       '"
        echo "module moved successfully"
 }
 
@@ -162,7 +175,7 @@ do_furtle () {
                *[0-9a-zA-Z]:/*)
                        remotehost="${goose%%:*}"
                        path="${goose#*:}"
-                       check_remote_host "$remotehost"
+                       check_hostname "$remotehost"
                        check_remote_path "$remotepath/$module"
                        isremote=true
                        compute_fqdn_data "$remotehost"
@@ -220,8 +233,17 @@ do_furtle () {
 }
 
 if $move; then
-       [ "$#" = 4 ] || bad_usage "--move needs hostname and path"
-       srcrepo="$1"; module="$2"; dsthost="$3"; dstrepo="$4"
+       if [ $# = 4 ]; then
+               srchost="$(hostname -f)"; srcrepo="$1"
+               module="$2";
+               dsthost="$3"; dstrepo="$4"
+       elif [ $# = 5 ]; then
+               srchost="$1"; srcrepo="$2"
+               module="$3";
+               dsthost="$4"; dstrepo="$5"
+       else
+               bad_usage "--move needs hostname(s) and paths"
+       fi
        do_move
 else
        [ "$#" = 0 ] || bad_usage "without --move, give no arguments"