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