~svn/ubuntu/raring/subversion/ppa

« back to all changes in this revision

Viewing changes to tools/dev/verify-history.py

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-12-05 01:26:14 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051205012614-qom4xfypgtsqc2xq
Tags: 1.2.3dfsg1-3ubuntu1
Merge with the final Debian release of 1.2.3dfsg1-3, bringing in
fixes to the clean target, better documentation of the libdb4.3
upgrade and build fixes to work with swig1.3_1.3.27.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
# This program is used to verify the FS history code.
 
4
#
 
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().
 
13
#
 
14
# A fun way to run this:
 
15
#
 
16
#   #!/bin/sh
 
17
#
 
18
#   export VERIFY=/path/to/verify-history.py
 
19
#   export MYREPOS=/path/to/repos
 
20
#   
 
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}
 
25
#   done
 
26
 
 
27
import sys
 
28
import string
 
29
from svn import core, repos, fs
 
30
 
 
31
class HistoryChecker:
 
32
  def __init__(self, fs_ptr):
 
33
    self.fs_ptr = fs_ptr
 
34
        
 
35
  def _check_history(self, path, revision, pool):
 
36
    root = fs.revision_root(self.fs_ptr, revision, pool)
 
37
    changes = fs.paths_changed(root, pool)
 
38
    while 1:
 
39
      if changes.has_key(path):
 
40
        return 1
 
41
      if path == '/':
 
42
        return 0
 
43
      idx = string.rfind(path, '/')
 
44
      if idx != -1:
 
45
        path = path[:idx]
 
46
      else:
 
47
        return 0
 
48
 
 
49
  def add_history(self, path, revision, pool):
 
50
    if not self._check_history(path, revision, pool):
 
51
      print "**WRONG** %8d %s" % (revision, path)
 
52
    else:
 
53
      print "          %8d %s" % (revision, path)
 
54
 
 
55
 
 
56
def check_history(fs_ptr, path, revision, pool):
 
57
  history = HistoryChecker(fs_ptr)
 
58
  repos.history(fs_ptr, path, history.add_history,
 
59
                1, revision, 1, pool)
 
60
 
 
61
 
 
62
def main():
 
63
  argc = len(sys.argv)
 
64
  if argc < 3 or argc > 4:
 
65
    print "Usage: %s PATH-TO-REPOS PATH-IN-REPOS [REVISION]"
 
66
    sys.exit(1)
 
67
 
 
68
  core.apr_initialize()
 
69
  pool = core.svn_pool_create(None)
 
70
  fs_ptr = repos.fs(repos.open(sys.argv[1], pool))
 
71
  if argc == 3:
 
72
    revision = fs.youngest_rev(fs_ptr, pool)
 
73
  else:
 
74
    revision = int(sys.argv[3])
 
75
  check_history(fs_ptr, sys.argv[2], revision, pool)
 
76
  sys.exit(0)
 
77
 
 
78
 
 
79
if __name__ == '__main__':
 
80
  main()