Mercurial > hgsubversion
annotate hgsubversion/verify.py @ 1601:5d8603f080c5
compathacks: add compat code for ui.makeprogress() deprecation
ui.makeprogress() is deprecated and will be dropped in 5.1. This patch adds
compat code for that. The compat code is plain copy of compat code available in
evolve extension.
author | Pulkit Goyal <pulkit@yandex-team.ru> |
---|---|
date | Mon, 04 Feb 2019 20:56:39 +0300 |
parents | 6f5b296c01dd |
children |
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 |
1601
5d8603f080c5
compathacks: add compat code for ui.makeprogress() deprecation
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
1600
diff
changeset
|
7 import compathacks |
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 |
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:'): |
1555
cff81f35b31e
cleanup: reference Abort from mercurial.error instead of mercurial.util
Augie Fackler <raf@durin42.com>
parents:
1096
diff
changeset
|
26 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
|
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 |
1096
691078c03ed9
verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents:
1039
diff
changeset
|
60 def verifydata(svndata): |
691078c03ed9
verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents:
1039
diff
changeset
|
61 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
|
62 |
691078c03ed9
verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents:
1039
diff
changeset
|
63 i = 0 |
691078c03ed9
verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents:
1039
diff
changeset
|
64 res = True |
691078c03ed9
verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents:
1039
diff
changeset
|
65 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
|
66 i += 1 |
691078c03ed9
verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents:
1039
diff
changeset
|
67 if type != 'f': |
691078c03ed9
verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents:
1039
diff
changeset
|
68 continue |
691078c03ed9
verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents:
1039
diff
changeset
|
69 |
691078c03ed9
verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents:
1039
diff
changeset
|
70 fp = fn |
691078c03ed9
verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents:
1039
diff
changeset
|
71 if branchpath: |
691078c03ed9
verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents:
1039
diff
changeset
|
72 fp = branchpath + '/' + fn |
691078c03ed9
verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents:
1039
diff
changeset
|
73 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
|
74 try: |
691078c03ed9
verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents:
1039
diff
changeset
|
75 fctx = ctx[fn] |
691078c03ed9
verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents:
1039
diff
changeset
|
76 except error.LookupError: |
691078c03ed9
verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents:
1039
diff
changeset
|
77 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
|
78 continue |
691078c03ed9
verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents:
1039
diff
changeset
|
79 |
691078c03ed9
verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents:
1039
diff
changeset
|
80 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
|
81 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
|
82 diff_file(fn, data) |
691078c03ed9
verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents:
1039
diff
changeset
|
83 res = False |
691078c03ed9
verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents:
1039
diff
changeset
|
84 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
|
85 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
|
86 res = False |
691078c03ed9
verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents:
1039
diff
changeset
|
87 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
|
88 |
691078c03ed9
verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents:
1039
diff
changeset
|
89 if url.startswith('file://'): |
691078c03ed9
verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents:
1039
diff
changeset
|
90 perarg = 0.00001 |
691078c03ed9
verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents:
1039
diff
changeset
|
91 else: |
691078c03ed9
verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents:
1039
diff
changeset
|
92 perarg = 0.000001 |
691078c03ed9
verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents:
1039
diff
changeset
|
93 |
899
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
94 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
|
95 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
|
96 i = 0 |
691078c03ed9
verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents:
1039
diff
changeset
|
97 for _, t in w: |
1601
5d8603f080c5
compathacks: add compat code for ui.makeprogress() deprecation
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
1600
diff
changeset
|
98 compathacks.progress(ui, '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
|
99 i += 1 |
691078c03ed9
verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents:
1039
diff
changeset
|
100 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
|
101 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
|
102 result = 1 |
1096
691078c03ed9
verify: use mercurials worker API to speedup stupid verify
David Soria Parra <dsp@experimentalworks.net>
parents:
1039
diff
changeset
|
103 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
|
104 |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
105 if hgfiles != svnfiles: |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
106 unexpected = hgfiles - svnfiles |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
107 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
|
108 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
|
109 missing = svnfiles - hgfiles |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
110 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
|
111 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
|
112 result = 1 |
6bc8046e3d0a
move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
113 |
1601
5d8603f080c5
compathacks: add compat code for ui.makeprogress() deprecation
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
1600
diff
changeset
|
114 compathacks.progress(ui, '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
|
115 |
899
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
116 else: |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
117 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
|
118 """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
|
119 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
|
120 self.ui = ui |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
121 self.ctx = ctx |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
122 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
|
123 self.missing = set() |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
124 self.failed = False |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
125 |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
126 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
|
127 self.seen = 0 |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
128 |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
129 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
|
130 pass |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
131 |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
132 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
|
133 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
|
134 self.file = None |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
135 self.props = None |
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_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
|
138 self.file = None |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
139 self.props = None |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
140 |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
141 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
|
142 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
|
143 |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
144 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
|
145 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
|
146 self.file = path |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
147 self.props = {} |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
148 else: |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
149 self.total += 1 |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
150 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
|
151 self.failed = True |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
152 self.file = None |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
153 self.props = None |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
154 |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
155 self.seen += 1 |
1601
5d8603f080c5
compathacks: add compat code for ui.makeprogress() deprecation
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
1600
diff
changeset
|
156 compathacks.progress(self.ui, '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
|
157 |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
158 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
|
159 raise NotImplementedError() |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
160 |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
161 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
|
162 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
|
163 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
|
164 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
|
165 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
|
166 '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
|
167 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
|
168 handler(window) |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
169 # 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
|
170 if window: |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
171 return |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
172 |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
173 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
|
174 hgdata = fctx.data() |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
175 svndata = stream.getvalue() |
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 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
|
178 if fctx.flags() != 'x': |
1600
6f5b296c01dd
verify: use ui.write() instead of ui.warn()
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
1558
diff
changeset
|
179 self.ui.write('wrong flags for: %s\n' % self.file) |
899
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
180 self.failed = True |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
181 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
|
182 hgdata = 'link ' + hgdata |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
183 if fctx.flags() != 'l': |
1600
6f5b296c01dd
verify: use ui.write() instead of ui.warn()
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
1558
diff
changeset
|
184 self.ui.write('wrong flags for: %s\n' % self.file) |
899
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
185 self.failed = True |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
186 elif fctx.flags(): |
1600
6f5b296c01dd
verify: use ui.write() instead of ui.warn()
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
1558
diff
changeset
|
187 self.ui.write('wrong flags for: %s\n' % self.file) |
899
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
188 self.failed = True |
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 if hgdata != svndata: |
1600
6f5b296c01dd
verify: use ui.write() instead of ui.warn()
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
1558
diff
changeset
|
191 self.ui.write('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
|
192 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
|
193 self.failed = True |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
194 |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
195 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
|
196 return txdelt_window |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
197 |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
198 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
|
199 pass |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
200 |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
201 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
|
202 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
|
203 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
|
204 |
939
997de286ba0c
editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents:
899
diff
changeset
|
205 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
|
206 pass |
997de286ba0c
editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents:
899
diff
changeset
|
207 |
899
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
208 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
|
209 pass |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
210 |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
211 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
|
212 raise NotImplementedError() |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
213 |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
214 def check(self): |
1601
5d8603f080c5
compathacks: add compat code for ui.makeprogress() deprecation
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
1600
diff
changeset
|
215 compathacks.progress(self.ui, '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
|
216 |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
217 for f in self.unexpected: |
1600
6f5b296c01dd
verify: use ui.write() instead of ui.warn()
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
1558
diff
changeset
|
218 self.ui.write('unexpected file: %s\n' % f) |
899
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
219 self.failed = True |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
220 for f in self.missing: |
1600
6f5b296c01dd
verify: use ui.write() instead of ui.warn()
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
1558
diff
changeset
|
221 self.ui.write('missing file: %s\n' % f) |
899
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
222 self.failed = True |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
223 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
|
224 |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
225 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
|
226 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
|
227 if v.check(): |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
228 result = 0 |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
229 else: |
7f90bb48c9de
svn verify: use a custom editor and get_revision()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
898
diff
changeset
|
230 result = 1 |
897
6bc8046e3d0a
move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
231 |
6bc8046e3d0a
move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
232 return result |