3 # This program is used to verify the FS history code.
5 # The basic gist is this: given a repository, a path in that
6 # repository, and a revision at which to begin plowing through history
7 # (towards revision 1), verify that each history object returned by
8 # the svn_fs_history_prev() interface -- indirectly via
9 # svn_repos_history() -- represents a revision in which the node being
10 # tracked actually changed, or where a parent directory of the node
11 # was copied, according to the list of paths changed as reported by
12 # svn_fs_paths_changed().
14 # A fun way to run this:
18 # export VERIFY=/path/to/verify-history.py
19 # export MYREPOS=/path/to/repos
21 # # List the paths in HEAD of the repos (filtering out the directories)
22 # for VCFILE in `svn ls -R file://${MYREPOS} | grep -v '/$'`; do
23 # echo "Checking ${VCFILE}"
24 # ${VERIFY} ${MYREPOS} ${VCFILE}
29 from svn
import core
, repos
, fs
32 def __init__(self
, fs_ptr
):
35 def _check_history(self
, path
, revision
):
36 root
= fs
.revision_root(self
.fs_ptr
, revision
)
37 changes
= fs
.paths_changed(root
)
39 if changes
.has_key(path
):
43 idx
= string
.rfind(path
, '/')
49 def add_history(self
, path
, revision
, pool
=None):
50 if not self
._check
_history
(path
, revision
):
51 print "**WRONG** %8d %s" % (revision
, path
)
53 print " %8d %s" % (revision
, path
)
56 def check_history(fs_ptr
, path
, revision
):
57 history
= HistoryChecker(fs_ptr
)
58 repos
.history(fs_ptr
, path
, history
.add_history
,
64 if argc
< 3 or argc
> 4:
65 print "Usage: %s PATH-TO-REPOS PATH-IN-REPOS [REVISION]" % sys
.argv
[0]
68 fs_ptr
= repos
.fs(repos
.open(sys
.argv
[1]))
70 revision
= fs
.youngest_rev(fs_ptr
)
72 revision
= int(sys
.argv
[3])
73 check_history(fs_ptr
, sys
.argv
[2], revision
)
77 if __name__
== '__main__':