Skip to content

Instantly share code, notes, and snippets.

@DMinsky
Last active April 2, 2019 02:41
Show Gist options
  • Save DMinsky/f7c55dd8d38634cb91e12d50e23f52c9 to your computer and use it in GitHub Desktop.
Save DMinsky/f7c55dd8d38634cb91e12d50e23f52c9 to your computer and use it in GitHub Desktop.

Revisions

  1. Dmitry Minsky revised this gist Oct 5, 2017. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions svn-fetch-pristine-by-sha1.sh
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,8 @@
    # referenced from the NODES table, download it into the pristine store and
    # insert a PRISTINE table row.

    # by Julian Foad from "Pristine text missing - cleanup doesn't work" org.apache.subversion.dev thread

    SHA1="$1"

    set -e
  2. Dmitry Minsky created this gist Oct 5, 2017.
    32 changes: 32 additions & 0 deletions svn-fetch-pristine-by-sha1.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    #!/bin/bash
    # Given a pristine file's SHA1, which is missing from the PRISTINE table but
    # referenced from the NODES table, download it into the pristine store and
    # insert a PRISTINE table row.

    SHA1="$1"

    set -e

    PRISTINE=.svn/pristine/${SHA1:0:2}/$SHA1.svn-base
    echo "In NODES table:"
    svnsqlite3 'select * from nodes where checksum="$sha1$'$SHA1'"'
    RRP=$(svnsqlite3 'select repos_path from nodes where checksum="$sha1$'$SHA1'"')
    REV=$(svnsqlite3 'select revision from nodes where checksum="$sha1$'$SHA1'"')
    echo "In PRISTINE table:"
    svnsqlite3 'select * from pristine where checksum="$sha1$'$SHA1'"'
    if [ -e "$PRISTINE" ]; then
    echo >&2 "Pristine file already exists: $PRISTINE"
    exit 1
    fi
    echo "Downloading '^/$RRP@$REV'..."
    svn cat "^/$RRP@$REV" > $PRISTINE
    V=$(sha1sum "$PRISTINE"); V=${V:0:40}
    echo "SHA1: $V"
    V=$(md5sum "$PRISTINE"); MD5=${V:0:32}
    echo "MD5: $MD5"
    LEN=$(stat --printf=%s "$PRISTINE")
    echo "Len: $LEN"
    echo "Inserting PRISTINE table row..."
    #echo svnsqlite3 'insert into pristine values ("$sha1$'$SHA1'", null, '$LEN', 1, "$md5 $'$MD5'")'
    svnsqlite3 'insert into pristine values ("$sha1$'$SHA1'", null, '$LEN', 1, "$md5 $'$MD5'")'
    svnsqlite3 'select * from pristine where checksum="$sha1$'$SHA1'"'