annotate svncommand.py @ 94:b5651f53e7ae

svncommand: Fix help to use ui.status() and be a bit smarter about displaying help.
author Augie Fackler <durin42@gmail.com>
date Wed, 19 Nov 2008 10:16:50 -0600
parents f537eb456cf7
children 91ce18fa0375
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1 import os
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
2 import pickle
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
3 import stat
93
f537eb456cf7 svncommand: Check traceback length to stop masking real exceptions.
Augie Fackler <durin42@gmail.com>
parents: 35
diff changeset
4 import sys
f537eb456cf7 svncommand: Check traceback length to stop masking real exceptions.
Augie Fackler <durin42@gmail.com>
parents: 35
diff changeset
5 import traceback
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
6
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
7 from mercurial import hg
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
8 from mercurial import node
6
1a5bb173170b Fixes for win32 compatibility. Changes suggested by Shun-ichi GOTO, with some alterations by me.
Augie Fackler <durin42@gmail.com>
parents: 0
diff changeset
9 from mercurial import util as merc_util
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
10
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
11 import svnwrap
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
12 import hg_delta_editor
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
13 import util
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
14 from util import register_subcommand, svn_subcommands
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
15 # dirty trick to force demandimport to run my decorator anyway.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
16 from utility_commands import print_wc_url
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
17 from fetch_command import fetch_revisions
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
18 from push_cmd import commit_from_rev
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
19 # shut up, pyflakes, we must import those
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
20 __x = [print_wc_url, fetch_revisions, commit_from_rev, ]
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
21
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
22 mode755 = (stat.S_IXUSR | stat.S_IXGRP| stat.S_IXOTH | stat.S_IRUSR |
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
23 stat.S_IRGRP| stat.S_IROTH | stat.S_IWUSR)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
24 mode644 = (stat.S_IRUSR | stat.S_IRGRP| stat.S_IROTH | stat.S_IWUSR)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
25
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
26
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
27 def svncmd(ui, repo, subcommand, *args, **opts):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
28 if subcommand not in svn_subcommands:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
29 candidates = []
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
30 for c in svn_subcommands:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
31 if c.startswith(subcommand):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
32 candidates.append(c)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
33 if len(candidates) == 1:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
34 subcommand = candidates[0]
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
35 path = os.path.dirname(repo.path)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
36 try:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
37 opts['svn_url'] = open(os.path.join(repo.path, 'svn', 'url')).read()
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
38 return svn_subcommands[subcommand](ui, args=args,
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
39 hg_repo_path=path,
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
40 repo=repo,
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
41 **opts)
93
f537eb456cf7 svncommand: Check traceback length to stop masking real exceptions.
Augie Fackler <durin42@gmail.com>
parents: 35
diff changeset
42 except TypeError:
f537eb456cf7 svncommand: Check traceback length to stop masking real exceptions.
Augie Fackler <durin42@gmail.com>
parents: 35
diff changeset
43 tb = traceback.extract_tb(sys.exc_info()[2])
f537eb456cf7 svncommand: Check traceback length to stop masking real exceptions.
Augie Fackler <durin42@gmail.com>
parents: 35
diff changeset
44 if len(tb) == 1:
f537eb456cf7 svncommand: Check traceback length to stop masking real exceptions.
Augie Fackler <durin42@gmail.com>
parents: 35
diff changeset
45 ui.status('Bad arguments for subcommand %s\n' % subcommand)
f537eb456cf7 svncommand: Check traceback length to stop masking real exceptions.
Augie Fackler <durin42@gmail.com>
parents: 35
diff changeset
46 else:
f537eb456cf7 svncommand: Check traceback length to stop masking real exceptions.
Augie Fackler <durin42@gmail.com>
parents: 35
diff changeset
47 raise
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
48 except KeyError, e:
93
f537eb456cf7 svncommand: Check traceback length to stop masking real exceptions.
Augie Fackler <durin42@gmail.com>
parents: 35
diff changeset
49 tb = traceback.extract_tb(sys.exc_info()[2])
f537eb456cf7 svncommand: Check traceback length to stop masking real exceptions.
Augie Fackler <durin42@gmail.com>
parents: 35
diff changeset
50 if len(tb) == 1:
f537eb456cf7 svncommand: Check traceback length to stop masking real exceptions.
Augie Fackler <durin42@gmail.com>
parents: 35
diff changeset
51 ui.status('Unknown subcommand %s\n' % subcommand)
f537eb456cf7 svncommand: Check traceback length to stop masking real exceptions.
Augie Fackler <durin42@gmail.com>
parents: 35
diff changeset
52 else:
f537eb456cf7 svncommand: Check traceback length to stop masking real exceptions.
Augie Fackler <durin42@gmail.com>
parents: 35
diff changeset
53 raise
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
54
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
55 @register_subcommand('help')
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
56 def help_command(ui, args=None, **opts):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
57 """Get help on the subsubcommands.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
58 """
94
b5651f53e7ae svncommand: Fix help to use ui.status() and be a bit smarter about displaying
Augie Fackler <durin42@gmail.com>
parents: 93
diff changeset
59 if args:
b5651f53e7ae svncommand: Fix help to use ui.status() and be a bit smarter about displaying
Augie Fackler <durin42@gmail.com>
parents: 93
diff changeset
60 subcommand = args[0]
b5651f53e7ae svncommand: Fix help to use ui.status() and be a bit smarter about displaying
Augie Fackler <durin42@gmail.com>
parents: 93
diff changeset
61 if subcommand not in svn_subcommands:
b5651f53e7ae svncommand: Fix help to use ui.status() and be a bit smarter about displaying
Augie Fackler <durin42@gmail.com>
parents: 93
diff changeset
62 candidates = []
b5651f53e7ae svncommand: Fix help to use ui.status() and be a bit smarter about displaying
Augie Fackler <durin42@gmail.com>
parents: 93
diff changeset
63 for c in svn_subcommands:
b5651f53e7ae svncommand: Fix help to use ui.status() and be a bit smarter about displaying
Augie Fackler <durin42@gmail.com>
parents: 93
diff changeset
64 if c.startswith(subcommand):
b5651f53e7ae svncommand: Fix help to use ui.status() and be a bit smarter about displaying
Augie Fackler <durin42@gmail.com>
parents: 93
diff changeset
65 candidates.append(c)
b5651f53e7ae svncommand: Fix help to use ui.status() and be a bit smarter about displaying
Augie Fackler <durin42@gmail.com>
parents: 93
diff changeset
66 if len(candidates) == 1:
b5651f53e7ae svncommand: Fix help to use ui.status() and be a bit smarter about displaying
Augie Fackler <durin42@gmail.com>
parents: 93
diff changeset
67 subcommand = candidates[0]
b5651f53e7ae svncommand: Fix help to use ui.status() and be a bit smarter about displaying
Augie Fackler <durin42@gmail.com>
parents: 93
diff changeset
68 elif len(candidates) > 1:
b5651f53e7ae svncommand: Fix help to use ui.status() and be a bit smarter about displaying
Augie Fackler <durin42@gmail.com>
parents: 93
diff changeset
69 ui.status('Ambiguous command. Could have been:\n%s\n' %
b5651f53e7ae svncommand: Fix help to use ui.status() and be a bit smarter about displaying
Augie Fackler <durin42@gmail.com>
parents: 93
diff changeset
70 ' '.join(candidates))
b5651f53e7ae svncommand: Fix help to use ui.status() and be a bit smarter about displaying
Augie Fackler <durin42@gmail.com>
parents: 93
diff changeset
71 return
b5651f53e7ae svncommand: Fix help to use ui.status() and be a bit smarter about displaying
Augie Fackler <durin42@gmail.com>
parents: 93
diff changeset
72 doc = svn_subcommands[subcommand].__doc__
b5651f53e7ae svncommand: Fix help to use ui.status() and be a bit smarter about displaying
Augie Fackler <durin42@gmail.com>
parents: 93
diff changeset
73 if doc is None:
b5651f53e7ae svncommand: Fix help to use ui.status() and be a bit smarter about displaying
Augie Fackler <durin42@gmail.com>
parents: 93
diff changeset
74 doc = "No documentation available for %s." % subcommand
b5651f53e7ae svncommand: Fix help to use ui.status() and be a bit smarter about displaying
Augie Fackler <durin42@gmail.com>
parents: 93
diff changeset
75 ui.status(doc.strip(), '\n')
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
76 return
94
b5651f53e7ae svncommand: Fix help to use ui.status() and be a bit smarter about displaying
Augie Fackler <durin42@gmail.com>
parents: 93
diff changeset
77 ui.status('Valid commands: ', ' '.join(sorted(svn_subcommands.keys())),
b5651f53e7ae svncommand: Fix help to use ui.status() and be a bit smarter about displaying
Augie Fackler <durin42@gmail.com>
parents: 93
diff changeset
78 '\n')
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
79
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
80 @register_subcommand('gentags')
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
81 def generate_hg_tags(ui, hg_repo_path, **opts):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
82 """Save tags to .hg/localtags
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
83 """
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
84 hg_editor = hg_delta_editor.HgChangeReceiver(hg_repo_path, ui_=ui)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
85 f = open(hg_editor.tag_info_file)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
86 tag_info = pickle.load(f)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
87 f = open(os.path.join(hg_repo_path, '.hg', 'localtags'), 'w')
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
88 for tag, source in tag_info.iteritems():
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
89 source_ha = hg_editor.get_parent_revision(source[1]+1, source[0])
28
9c481cae0428 Change the format of generated tags so they are tag/$tag instead of tag:$tag so that you can use them as revision args in diff.
Augie Fackler <durin42@gmail.com>
parents: 6
diff changeset
90 f.write('%s tag/%s\n' % (node.hex(source_ha), tag))
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
91
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
92 @register_subcommand('up')
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
93 def update(ui, args, repo, clean=False, **opts):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
94 """Update to a specified Subversion revision number.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
95 """
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
96 assert len(args) == 1
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
97 rev = int(args[0])
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
98 path = os.path.join(repo.path, 'svn', 'rev_map')
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
99 answers = []
34
50d55c3e0d85 Some refactors of the previous change, including transparent upgrade of old-style pickled dictionaries.
Augie Fackler <durin42@gmail.com>
parents: 33
diff changeset
100 for k,v in util.parse_revmap(path).iteritems():
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
101 if k[0] == rev:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
102 answers.append((v, k[1]))
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
103 if len(answers) == 1:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
104 if clean:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
105 return hg.clean(repo, answers[0][0])
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
106 return hg.update(repo, answers[0][0])
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
107 elif len(answers) == 0:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
108 ui.status('Revision %s did not produce an hg revision.\n' % rev)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
109 return 1
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
110 else:
35
ef5d7a7aabb0 I meant ambiguous.
Augie Fackler <durin42@gmail.com>
parents: 34
diff changeset
111 ui.status('Ambiguous revision!\n')
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
112 ui.status('\n'.join(['%s on %s' % (node.hex(a[0]), a[1]) for a in
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
113 answers]+['']))
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
114 return 1
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
115
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
116
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
117 @register_subcommand('verify_revision')
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
118 def verify_revision(ui, args, repo, force=False, **opts):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
119 """Verify a single converted revision.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
120 Note: This wipes your working copy and then exports the corresponding
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
121 Subversion into your working copy to verify. Use with caution.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
122 """
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
123 assert len(args) == 1
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
124 if not force:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
125 assert repo.status(ignored=True,
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
126 unknown=True) == ([], [], [], [], [], [], [])
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
127 rev = int(args[0])
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
128 wc_path = os.path.dirname(repo.path)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
129 svn_url = open(os.path.join(repo.path, 'svn', 'url')).read()
6
1a5bb173170b Fixes for win32 compatibility. Changes suggested by Shun-ichi GOTO, with some alterations by me.
Augie Fackler <durin42@gmail.com>
parents: 0
diff changeset
130 svn = svnwrap.SubversionRepo(svn_url, username=merc_util.getuser())
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
131 util.wipe_all_files(wc_path)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
132 if update(ui, args, repo, clean=True) == 0:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
133 util.wipe_all_files(wc_path)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
134 br = repo.dirstate.branch()
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
135 if br == 'default':
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
136 br = None
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
137 if br:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
138 diff_path = 'branches/%s' % br
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
139 else:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
140 diff_path = 'trunk'
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
141 svn.fetch_all_files_to_dir(diff_path, rev, wc_path)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
142 stat = repo.status(unknown=True)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
143 ignored = [s for s in stat[4]
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
144 if '/.svn/' not in s and not s.startswith('.svn/')]
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
145 stat = stat[0:4]
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
146 if stat != ([], [], [], [],) or ignored != []:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
147 ui.status('Something is wrong with this revision.\n')
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
148 return 2
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
149 else:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
150 ui.status('OK.\n')
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
151 return 0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
152 return 1
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
153
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
154 @register_subcommand('verify_all_revisions')
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
155 def verify_all_revisions(ui, args, repo, **opts):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
156 """Verify all the converted revisions, optionally starting at a revision.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
157
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
158 Note: This is *extremely* abusive of the Subversion server. It exports every
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
159 revision of the code one revision at a time.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
160 """
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
161 assert repo.status(ignored=True,
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
162 unknown=True) == ([], [], [], [], [], [], [])
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
163 start_rev = 0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
164 args = list(args)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
165 if args:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
166 start_rev = int(args.pop(0))
34
50d55c3e0d85 Some refactors of the previous change, including transparent upgrade of old-style pickled dictionaries.
Augie Fackler <durin42@gmail.com>
parents: 33
diff changeset
167 revmap = util.parse_revmap(os.path.join(repo.path, 'svn', 'rev_map'))
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
168 revs = sorted(revmap.keys())
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
169 for revnum, br in revs:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
170 if revnum < start_rev:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
171 continue
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
172 res = verify_revision(ui, [revnum], repo, force=True)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
173 if res == 0:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
174 print revnum, 'verfied'
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
175 elif res == 1:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
176 print revnum, 'skipped'
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
177 else:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
178 print revnum, 'failed'
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
179 return 1
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
180 return 0