annotate hgsubversion/verify.py @ 1039:3df6ed4e7561

drop support for pre-2.0 versions of Mercurial
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Mon, 05 Aug 2013 20:49:53 +0200
parents ce02baa04e53
children 691078c03ed9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
979
ce02baa04e53 svn verify: print out diffs of bad files in a verbose mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 948
diff changeset
1 import difflib
897
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
2 import posixpath
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
3
899
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
4 from mercurial import util as hgutil
897
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
5 from mercurial import error
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
6
899
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
7 import svnwrap
897
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
8 import svnrepo
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
9 import util
899
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
10 import editor
897
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
11
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
12 def verify(ui, repo, args=None, **opts):
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
13 '''verify current revision against Subversion repository
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
14 '''
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
15
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
16 if repo is None:
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
17 raise error.RepoError("There is no Mercurial repository"
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
18 " here (.hg not found)")
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
19
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
20 ctx = repo[opts.get('rev', '.')]
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
21 if 'close' in ctx.extra():
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
22 ui.write('cannot verify closed branch')
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
23 return 0
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
24 convert_revision = ctx.extra().get('convert_revision')
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
25 if convert_revision is None or not convert_revision.startswith('svn:'):
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
26 raise hgutil.Abort('revision %s not from SVN' % ctx)
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
27
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
28 if args:
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
29 url = repo.ui.expandpath(args[0])
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
30 else:
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
31 url = repo.ui.expandpath('default')
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
32
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
33 svn = svnrepo.svnremoterepo(ui, url).svn
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
34 meta = repo.svnmeta(svn.uuid, svn.subdir)
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
35 srev, branch, branchpath = meta.get_source_rev(ctx=ctx)
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
36
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
37 branchpath = branchpath[len(svn.subdir.lstrip('/')):]
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
38 branchurl = ('%s/%s' % (url, branchpath)).strip('/')
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
39
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
40 ui.write('verifying %s against %s@%i\n' % (ctx, branchurl, srev))
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
41
979
ce02baa04e53 svn verify: print out diffs of bad files in a verbose mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 948
diff changeset
42 def diff_file(path, svndata):
ce02baa04e53 svn verify: print out diffs of bad files in a verbose mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 948
diff changeset
43 fctx = ctx[path]
ce02baa04e53 svn verify: print out diffs of bad files in a verbose mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 948
diff changeset
44
ce02baa04e53 svn verify: print out diffs of bad files in a verbose mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 948
diff changeset
45 if ui.verbose and not fctx.isbinary():
ce02baa04e53 svn verify: print out diffs of bad files in a verbose mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 948
diff changeset
46 svndesc = '%s/%s/%s@%d' % (svn.svn_url, branchpath, path, srev)
ce02baa04e53 svn verify: print out diffs of bad files in a verbose mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 948
diff changeset
47 hgdesc = '%s@%s' % (path, ctx)
ce02baa04e53 svn verify: print out diffs of bad files in a verbose mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 948
diff changeset
48
ce02baa04e53 svn verify: print out diffs of bad files in a verbose mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 948
diff changeset
49 for c in difflib.unified_diff(svndata.splitlines(True),
ce02baa04e53 svn verify: print out diffs of bad files in a verbose mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 948
diff changeset
50 fctx.data().splitlines(True),
ce02baa04e53 svn verify: print out diffs of bad files in a verbose mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 948
diff changeset
51 svndesc, hgdesc):
ce02baa04e53 svn verify: print out diffs of bad files in a verbose mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 948
diff changeset
52 ui.note(c)
ce02baa04e53 svn verify: print out diffs of bad files in a verbose mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 948
diff changeset
53
899
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
54 if opts.get('stupid', ui.configbool('hgsubversion', 'stupid')):
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
55 svnfiles = set()
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
56 result = 0
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
57
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
58 hgfiles = set(ctx) - util.ignoredfiles
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
59
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
60 svndata = svn.list_files(branchpath, srev)
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
61 for i, (fn, type) in enumerate(svndata):
1039
3df6ed4e7561 drop support for pre-2.0 versions of Mercurial
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 979
diff changeset
62 ui.progress('verify', i, total=len(hgfiles))
899
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
63
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
64 if type != 'f':
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
65 continue
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
66 svnfiles.add(fn)
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
67 fp = fn
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
68 if branchpath:
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
69 fp = branchpath + '/' + fn
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
70 data, mode = svn.get_file(posixpath.normpath(fp), srev)
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
71 try:
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
72 fctx = ctx[fn]
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
73 except error.LookupError:
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
74 result = 1
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
75 continue
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
76 if not fctx.data() == data:
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
77 ui.write('difference in: %s\n' % fn)
979
ce02baa04e53 svn verify: print out diffs of bad files in a verbose mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 948
diff changeset
78 diff_file(fn, data)
899
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
79 result = 1
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
80 if not fctx.flags() == mode:
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
81 ui.write('wrong flags for: %s\n' % fn)
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
82 result = 1
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
83
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
84 if hgfiles != svnfiles:
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
85 unexpected = hgfiles - svnfiles
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
86 for f in sorted(unexpected):
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
87 ui.write('unexpected file: %s\n' % f)
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
88 missing = svnfiles - hgfiles
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
89 for f in sorted(missing):
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
90 ui.write('missing file: %s\n' % f)
897
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
91 result = 1
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
92
1039
3df6ed4e7561 drop support for pre-2.0 versions of Mercurial
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 979
diff changeset
93 ui.progress('verify', None, total=len(hgfiles))
897
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
94
899
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
95 else:
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
96 class VerifyEditor(svnwrap.Editor):
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
97 """editor that verifies a repository against the given context."""
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
98 def __init__(self, ui, ctx):
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
99 self.ui = ui
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
100 self.ctx = ctx
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
101 self.unexpected = set(ctx) - util.ignoredfiles
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
102 self.missing = set()
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
103 self.failed = False
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
104
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
105 self.total = len(self.unexpected)
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
106 self.seen = 0
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
107
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
108 def open_root(self, base_revnum, pool=None):
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
109 pass
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
110
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
111 def add_directory(self, path, parent_baton, copyfrom_path,
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
112 copyfrom_revision, pool=None):
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
113 self.file = None
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
114 self.props = None
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
115
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
116 def open_directory(self, path, parent_baton, base_revision, pool=None):
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
117 self.file = None
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
118 self.props = None
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
119
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
120 def add_file(self, path, parent_baton=None, copyfrom_path=None,
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
121 copyfrom_revision=None, file_pool=None):
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
122
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
123 if path in self.unexpected:
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
124 self.unexpected.remove(path)
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
125 self.file = path
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
126 self.props = {}
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
127 else:
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
128 self.total += 1
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
129 self.missing.add(path)
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
130 self.failed = True
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
131 self.file = None
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
132 self.props = None
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
133
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
134 self.seen += 1
1039
3df6ed4e7561 drop support for pre-2.0 versions of Mercurial
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 979
diff changeset
135 self.ui.progress('verify', self.seen, total=self.total)
899
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
136
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
137 def open_file(self, path, base_revnum):
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
138 raise NotImplementedError()
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
139
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
140 def apply_textdelta(self, file_baton, base_checksum, pool=None):
948
e2090fabc1a9 editor: use SimpleStringIO in apply_text()
Patrick Mezard <patrick@mezard.eu>
parents: 939
diff changeset
141 stream = svnwrap.SimpleStringIO(closing=False)
899
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
142 handler = svnwrap.apply_txdelta('', stream)
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
143 if not callable(handler):
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
144 raise hgutil.Abort('Error in Subversion bindings: '
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
145 'cannot call handler!')
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
146 def txdelt_window(window):
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
147 handler(window)
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
148 # window being None means we're done
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
149 if window:
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
150 return
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
151
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
152 fctx = self.ctx[self.file]
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
153 hgdata = fctx.data()
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
154 svndata = stream.getvalue()
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
155
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
156 if 'svn:executable' in self.props:
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
157 if fctx.flags() != 'x':
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
158 self.ui.warn('wrong flags for: %s\n' % self.file)
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
159 self.failed = True
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
160 elif 'svn:special' in self.props:
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
161 hgdata = 'link ' + hgdata
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
162 if fctx.flags() != 'l':
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
163 self.ui.warn('wrong flags for: %s\n' % self.file)
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
164 self.failed = True
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
165 elif fctx.flags():
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
166 self.ui.warn('wrong flags for: %s\n' % self.file)
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
167 self.failed = True
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
168
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
169 if hgdata != svndata:
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
170 self.ui.warn('difference in: %s\n' % self.file)
979
ce02baa04e53 svn verify: print out diffs of bad files in a verbose mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 948
diff changeset
171 diff_file(self.file, svndata)
899
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
172 self.failed = True
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
173
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
174 if self.file is not None:
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
175 return txdelt_window
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
176
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
177 def change_dir_prop(self, dir_baton, name, value, pool=None):
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
178 pass
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
179
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
180 def change_file_prop(self, file_baton, name, value, pool=None):
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
181 if self.props is not None:
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
182 self.props[name] = value
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
183
939
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 899
diff changeset
184 def close_file(self, file_baton, checksum, pool=None):
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 899
diff changeset
185 pass
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 899
diff changeset
186
899
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
187 def close_directory(self, dir_baton, pool=None):
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
188 pass
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
189
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
190 def delete_entry(self, path, revnum, pool=None):
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
191 raise NotImplementedError()
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
192
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
193 def check(self):
1039
3df6ed4e7561 drop support for pre-2.0 versions of Mercurial
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 979
diff changeset
194 self.ui.progress('verify', None, total=self.total)
899
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
195
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
196 for f in self.unexpected:
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
197 self.ui.warn('unexpected file: %s\n' % f)
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
198 self.failed = True
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
199 for f in self.missing:
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
200 self.ui.warn('missing file: %s\n' % f)
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
201 self.failed = True
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
202 return not self.failed
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
203
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
204 v = VerifyEditor(ui, ctx)
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
205 svnrepo.svnremoterepo(ui, branchurl).svn.get_revision(srev, v)
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
206 if v.check():
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
207 result = 0
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
208 else:
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
209 result = 1
897
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
210
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
211 return result