annotate hgsubversion/verify.py @ 1558:ae572c9be4e6

cleanup: remove lots of dead imports and code found by pyflakes
author Augie Fackler <raf@durin42.com>
date Sat, 24 Mar 2018 17:04:19 -0400
parents cff81f35b31e
children 6f5b296c01dd
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
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
4 from mercurial import error
1096
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
5 from mercurial import worker
897
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
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
10
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
11 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
12 '''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
13 '''
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 if repo is None:
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
16 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
17 " here (.hg not found)")
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
18
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
19 ctx = repo[opts.get('rev', '.')]
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
20 if 'close' in ctx.extra():
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
21 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
22 return 0
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
23 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
24 if convert_revision is None or not convert_revision.startswith('svn:'):
1555
cff81f35b31e cleanup: reference Abort from mercurial.error instead of mercurial.util
Augie Fackler <raf@durin42.com>
parents: 1096
diff changeset
25 raise error.Abort('revision %s not from SVN' % ctx)
897
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
26
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
27 if args:
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
28 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
29 else:
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
30 url = repo.ui.expandpath('default')
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
31
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
32 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
33 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
34 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
35
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
36 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
37 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
38
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
39 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
40
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
41 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
42 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
43
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 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
45 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
46 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
47
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 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
49 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
50 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
51 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
52
899
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
53 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
54 svnfiles = set()
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
55 result = 0
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
56
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
57 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
58
1096
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
59 def verifydata(svndata):
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
60 svnworker = svnrepo.svnremoterepo(ui, url).svn
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
61
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
62 i = 0
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
63 res = True
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
64 for fn, type in svndata:
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
65 i += 1
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
66 if type != 'f':
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
67 continue
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
68
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
69 fp = fn
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
70 if branchpath:
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
71 fp = branchpath + '/' + fn
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
72 data, mode = svnworker.get_file(posixpath.normpath(fp), srev)
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
73 try:
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
74 fctx = ctx[fn]
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
75 except error.LookupError:
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
76 yield i, "%s\0%r" % (fn, res)
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
77 continue
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
78
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
79 if not fctx.data() == data:
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
80 ui.write('difference in: %s\n' % fn)
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
81 diff_file(fn, data)
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
82 res = False
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
83 if not fctx.flags() == mode:
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
84 ui.write('wrong flags for: %s\n' % fn)
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
85 res = False
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
86 yield i, "%s\0%r" % (fn, res)
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
87
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
88 if url.startswith('file://'):
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
89 perarg = 0.00001
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
90 else:
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
91 perarg = 0.000001
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
92
899
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
93 svndata = svn.list_files(branchpath, srev)
1096
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
94 w = worker.worker(repo.ui, perarg, verifydata, (), tuple(svndata))
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
95 i = 0
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
96 for _, t in w:
1039
3df6ed4e7561 drop support for pre-2.0 versions of Mercurial
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 979
diff changeset
97 ui.progress('verify', i, total=len(hgfiles))
1096
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
98 i += 1
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
99 fn, ok = t.split('\0', 2)
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
100 if not bool(ok):
899
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
101 result = 1
1096
691078c03ed9 verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents: 1039
diff changeset
102 svnfiles.add(fn)
899
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
103
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
104 if hgfiles != svnfiles:
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
105 unexpected = hgfiles - svnfiles
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
106 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
107 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
108 missing = svnfiles - hgfiles
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
109 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
110 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
111 result = 1
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
112
1039
3df6ed4e7561 drop support for pre-2.0 versions of Mercurial
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 979
diff changeset
113 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
114
899
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
115 else:
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
116 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
117 """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
118 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
119 self.ui = ui
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
120 self.ctx = ctx
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
121 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
122 self.missing = set()
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
123 self.failed = False
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
124
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
125 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
126 self.seen = 0
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
127
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
128 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
129 pass
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
130
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
131 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
132 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
133 self.file = None
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
134 self.props = None
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
135
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
136 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
137 self.file = None
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
138 self.props = None
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 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
141 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
142
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
143 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
144 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
145 self.file = path
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
146 self.props = {}
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
147 else:
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
148 self.total += 1
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
149 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
150 self.failed = True
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
151 self.file = None
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
152 self.props = None
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
153
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
154 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
155 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
156
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
157 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
158 raise NotImplementedError()
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
159
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
160 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
161 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
162 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
163 if not callable(handler):
1555
cff81f35b31e cleanup: reference Abort from mercurial.error instead of mercurial.util
Augie Fackler <raf@durin42.com>
parents: 1096
diff changeset
164 raise error.Abort('Error in Subversion bindings: '
cff81f35b31e cleanup: reference Abort from mercurial.error instead of mercurial.util
Augie Fackler <raf@durin42.com>
parents: 1096
diff changeset
165 'cannot call handler!')
899
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
166 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
167 handler(window)
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
168 # 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
169 if window:
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
170 return
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
171
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
172 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
173 hgdata = fctx.data()
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
174 svndata = stream.getvalue()
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
175
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
176 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
177 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
178 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
179 self.failed = True
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
180 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
181 hgdata = 'link ' + hgdata
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
182 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
183 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
184 self.failed = True
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
185 elif fctx.flags():
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
186 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
187 self.failed = True
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
188
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
189 if hgdata != svndata:
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
190 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
191 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
192 self.failed = True
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
193
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
194 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
195 return txdelt_window
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
196
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
197 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
198 pass
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
199
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
200 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
201 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
202 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
203
939
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 899
diff changeset
204 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
205 pass
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 899
diff changeset
206
899
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
207 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
208 pass
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
209
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
210 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
211 raise NotImplementedError()
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
212
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
213 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
214 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
215
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
216 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
217 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
218 self.failed = True
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
219 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
220 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
221 self.failed = True
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
222 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
223
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
224 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
225 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
226 if v.check():
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
227 result = 0
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
228 else:
7f90bb48c9de svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 898
diff changeset
229 result = 1
897
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
230
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
231 return result