本文是svn出现类似如下问题的两种解决方案。
svn: E200030: database disk image is malformed
一、最简单的方法,复制其它人的.svn/wc.db替换。
二、类Unix系统(如Mac OS X),会自带sqlite3,windows系统要先下载sqlite3。
操作之前,切记备份.svn/wc.db
在命令行终端cd到.svn文件夹,
cd 项目文件夹/.svn
sqlite3 wc.db "pragma integrity_check"
sqlite3 wc.db "reindex nodes"
sqlite3 wc.db "reindex pristine"
至此,问题一般解决了。还不行,可以使用以下命令排查问题
sqlite3 wc.db "select sql from sqlite_master where name='NODES'"
sqlite3 wc.db "select sql from sqlite_master where name='I_NODES_PARENT'"
创建表NODES_COPY,作为表NODES的复本,sql语句:
sqlite3 wc.db "CREATE TABLE NODES_COPY ( wc_id INTEGER NOT NULL REFERENCES WCROOT (id), local_relpath TEXT NOT NULL, op_depth INTEGER NOT NULL, parent_relpath TEXT, repos_id INTEGER REFERENCES REPOSITORY (id), repos_path TEXT, revision INTEGER, presence TEXT NOT NULL, moved_here INTEGER, moved_to TEXT, kind TEXT NOT NULL, properties BLOB, depth TEXT, checksum TEXT REFERENCES PRISTINE (checksum), symlink_target TEXT, changed_revision INTEGER, changed_date INTEGER, changed_author TEXT, translated_size INTEGER, last_mod_time INTEGER, dav_cache BLOB, file_external TEXT, PRIMARY KEY (wc_id, local_relpath, op_depth) )"
复制表NODES的内容到表NODES_COPY,sql语句:
sqlite3 wc.db "insert into NODES_COPY select * from NODES"
删除NODES,sql语句:
sqlite3 wc.db "drop table NODES"
重新创建表NODES,sql语句:
sqlite3 wc.db "CREATE TABLE NODES ( wc_id INTEGER NOT NULL REFERENCES WCROOT (id), local_relpath TEXT NOT NULL, op_depth INTEGER NOT NULL, parent_relpath TEXT, repos_id INTEGER REFERENCES REPOSITORY (id), repos_path TEXT, revision INTEGER, presence TEXT NOT NULL, moved_here INTEGER, moved_to TEXT, kind TEXT NOT NULL, properties BLOB, depth TEXT, checksum TEXT REFERENCES PRISTINE (checksum), symlink_target TEXT, changed_revision INTEGER, changed_date INTEGER, changed_author TEXT, translated_size INTEGER, last_mod_time INTEGER, dav_cache BLOB, file_external TEXT, PRIMARY KEY (wc_id, local_relpath, op_depth) )"
sqlite3 wc.db "create index I_NODES_PARENT on NODES (wc_id, parent_relpath, op_depth)"
Copy NODES_COPY into NODES:
sqlite3 wc.db "insert into NODES select * from NODES_COPY"
Drop table NODES_COPY:
sqlite3 wc.db "drop table NODES_COPY"
Then you need to do something similar for PRISTINE, although this time
there is no extra index:
sqlite3 wc.db "select sql from sqlite_master where name='PRISTINE'"
Create PRISTINE_COPY
Copy PRISTINE into PRISTINE_COPY
Drop and recreate PRISTINE
Copy PRISTINE_COPY into PRISTINE
Drop PRISTINE_COPY