I have filed this as issue #4357, "Pristine text missing - cleanup doesn't 
work", with a reference to this email thread.

I thought of the following possible improvements, which I have noted in the doc 
string of pristine_cleanup_wcroot():

 * TODO: At least check that any zero refcount is really correct, before
 *       using it.
 *
 * TODO: Ideas for possible extra clean-up operations:
 *
 *       * Check and correct all the refcounts.  Identify any rows missing
 *         from the 'pristine' table.  (Create a temporary index for speed
 *         if necessary?)
 *
 *       * Check the checksums.  (Very expensive to check them all, so find
 *         a way to not check them all.)
 *
 *       * Check for pristine files missing from disk but referenced in the
 *         'pristine' table.
 *
 *       * Repair any pristine files missing from disk and/or rows missing
 *         from the 'pristine' table and/or bad checksums.  Generally
 *         requires contacting the server, so requires support at a higher
 *         level than this function.
 *
 *       * Identify any pristine text files on disk that are not referenced
 *         in the DB, and delete them.
 *
 * TODO: Provide feedback about any errors found and any corrections made.

Also, here is the "svn-fetch-pristine-by-sha1.sh" script that I mentioned in my 
initial email but forgot to attach there.

- Julian


Johan Corveleyn wrote:
> On Thu, Apr 18, 2013 at 10:05 PM, Bert Huijben <b...@qqmail.nl> wrote:
>> Johan Corveleyn reported that he heard multiple reports of this being caused
>> by earlier SvnKit versions. I have not got a single bugreport of this type
>> for AnkhSvn via our error reporting infrastructure.
>>
>> I don’t see how anybody using SQLite can cause this as the updating of the
>> reference count is only handled by the triggers...
>>
>> But SvnKit implemented their own clone, which used to have problems in this
>> field...
> 
> Indeed. But those errors have since been fixed (have not seen such
> problems anymore in the last half year or so).
> 
> However ...
> 
> On Thu, Apr 18, 2013 at 9:55 PM, Julian Foad <julianf...@btopenworld.com> 
> wrote:
> ...
>> I think we should do something to improve the situation.  Fortunately it
>> seems to be relatively rare, as not many people have complained about it,
>> but there are over 5000 pages listed by Google with that error message.
> 
> Big +1 from me.
> 
> See my own prodding for improvement in this area.
> 
>http://svn.haxx.se/dev/archive-2012-09/0304.shtml
> http://mail-archives.apache.org/mod_mbox/subversion-dev/201206.mbox/%3CCAB84uBUJeZDHjhKP6Fz2hoU_g1oHUZyUq_wNVNC=ppyju7h...@mail.gmail.com%3E
> http://svn.haxx.se/dev/archive-2011-07/0001.shtml
> 
> FWIW, I don't buy the argument that svn / sqlite can't break. Bugs (or
> rare cosmic ray disturbances or whatever) do happen. Having an 'svn
> repair' / 'svn validate' command or something (like SmartSVN's
> 'validate admin area') would definitely be nice.
#!/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'"'

Reply via email to