annotate __init__.py @ 258:4ab27ddbae51

Updated readme a little bit for the new UI.
author Augie Fackler <durin42@gmail.com>
date Fri, 10 Apr 2009 22:41:33 -0500
parents ffccf0080e54
children 112d57bb736e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
185
57355b0e7bd1 Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 179
diff changeset
1 '''integration with Subversion repositories
57355b0e7bd1 Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 179
diff changeset
2
57355b0e7bd1 Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 179
diff changeset
3 This extension allows Mercurial to act as a Subversion client, for
57355b0e7bd1 Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 179
diff changeset
4 fast incremental, bidirectional updates.
57355b0e7bd1 Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 179
diff changeset
5
57355b0e7bd1 Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 179
diff changeset
6 It is *not* ready yet for production use. You should only be using
57355b0e7bd1 Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 179
diff changeset
7 this if you're ready to hack on it, and go diving into the internals
57355b0e7bd1 Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 179
diff changeset
8 of Mercurial and/or Subversion.
57355b0e7bd1 Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 179
diff changeset
9
57355b0e7bd1 Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 179
diff changeset
10 Before using hgsubversion, it is *strongly* encouraged to run the
57355b0e7bd1 Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 179
diff changeset
11 automated tests. See `README' in the hgsubversion directory for
57355b0e7bd1 Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 179
diff changeset
12 details.
57355b0e7bd1 Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 179
diff changeset
13 '''
57355b0e7bd1 Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 179
diff changeset
14
52
fb1d911bb0be svnclone now updates to the tip revision if it is the initial clone.
Augie Fackler <durin42@gmail.com>
parents: 0
diff changeset
15 import os
251
23b02f892d9b Fix up imports in __init__.py.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 248
diff changeset
16 import sys
23b02f892d9b Fix up imports in __init__.py.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 248
diff changeset
17 import traceback
52
fb1d911bb0be svnclone now updates to the tip revision if it is the initial clone.
Augie Fackler <durin42@gmail.com>
parents: 0
diff changeset
18
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
19 from mercurial import commands
256
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
20 from mercurial import extensions
248
a9134fa28d15 Move svncommand code into __init__.py.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
21 from mercurial import util as hgutil
209
d06572495c5e Better error message when we encounter an unknown SSL cert.
Augie Fackler <durin42@gmail.com>
parents: 199
diff changeset
22
d06572495c5e Better error message when we encounter an unknown SSL cert.
Augie Fackler <durin42@gmail.com>
parents: 199
diff changeset
23 from svn import core
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
24
241
4950b18cf949 Move fetch_command.fetch_revisions() to svncommands.pull().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 234
diff changeset
25 import svncommands
124
291925677a9f tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
Luke Opperman <luke@loppear.com>
parents: 115
diff changeset
26 import tag_repo
291925677a9f tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
Luke Opperman <luke@loppear.com>
parents: 115
diff changeset
27 import util
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents: 256
diff changeset
28 import wrappers
124
291925677a9f tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
Luke Opperman <luke@loppear.com>
parents: 115
diff changeset
29
291925677a9f tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
Luke Opperman <luke@loppear.com>
parents: 115
diff changeset
30 def reposetup(ui, repo):
291925677a9f tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
Luke Opperman <luke@loppear.com>
parents: 115
diff changeset
31 if not util.is_svn_repo(repo):
291925677a9f tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
Luke Opperman <luke@loppear.com>
parents: 115
diff changeset
32 return
291925677a9f tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
Luke Opperman <luke@loppear.com>
parents: 115
diff changeset
33
291925677a9f tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
Luke Opperman <luke@loppear.com>
parents: 115
diff changeset
34 repo.__class__ = tag_repo.generate_repo_class(ui, repo)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
35
256
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
36 def uisetup(ui):
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
37 """Do our UI setup.
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
38
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
39 Does the following wrappings:
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
40 * parent -> utility_commands.parent
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
41 * outgoing -> utility_commands.outgoing
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
42 """
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
43 entry = extensions.wrapcommand(commands.table, 'parents',
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents: 256
diff changeset
44 wrappers.parent)
256
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
45 entry[1].append(('', 'svn', None, "show parent svn revision instead"))
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
46 entry = extensions.wrapcommand(commands.table, 'outgoing',
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents: 256
diff changeset
47 wrappers.outgoing)
256
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
48 entry[1].append(('', 'svn', None, "show revisions outgoing to subversion"))
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
49 entry = extensions.wrapcommand(commands.table, 'diff',
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents: 256
diff changeset
50 wrappers.diff)
256
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
51 entry[1].append(('', 'svn', None,
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
52 "show svn-style diffs, default against svn parent"))
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
53 entry = extensions.wrapcommand(commands.table, 'push',
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents: 256
diff changeset
54 wrappers.push)
256
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
55 entry[1].append(('', 'svn', None, "push to subversion"))
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
56 entry[1].append(('', 'svn-stupid', None, "use stupid replay during push to svn"))
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
57 entry = extensions.wrapcommand(commands.table, 'pull',
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents: 256
diff changeset
58 wrappers.pull)
256
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
59 entry[1].append(('', 'svn', None, "pull from subversion"))
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
60 entry[1].append(('', 'svn-stupid', None, "use stupid replay during pull from svn"))
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
61
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
62 entry = extensions.wrapcommand(commands.table, 'clone',
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents: 256
diff changeset
63 wrappers.clone)
256
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
64 entry[1].extend([#('', 'skipto-rev', '0', 'skip commits before this revision.'),
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
65 ('', 'svn-stupid', False, 'be stupid and use diffy replay.'),
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
66 ('', 'svn-tag-locations', 'tags', 'Relative path to Subversion tags.'),
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
67 ('', 'svn-authors', '', 'username mapping filename'),
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
68 ('', 'svn-filemap', '',
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
69 'remap file to exclude paths or include only certain paths'),
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
70 ])
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
71
115
ed42f6e5705a Clean up help text, document subcommands.
Luke Opperman <luke@loppear.com>
parents: 52
diff changeset
72
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
73 def svn(ui, repo, subcommand, *args, **opts):
185
57355b0e7bd1 Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 179
diff changeset
74 '''see detailed help for list of subcommands'''
248
a9134fa28d15 Move svncommand code into __init__.py.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
75
a9134fa28d15 Move svncommand code into __init__.py.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
76 # guess command if prefix
253
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 251
diff changeset
77 if subcommand not in svncommands.table:
248
a9134fa28d15 Move svncommand code into __init__.py.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
78 candidates = []
253
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 251
diff changeset
79 for c in svncommands.table:
248
a9134fa28d15 Move svncommand code into __init__.py.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
80 if c.startswith(subcommand):
a9134fa28d15 Move svncommand code into __init__.py.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
81 candidates.append(c)
a9134fa28d15 Move svncommand code into __init__.py.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
82 if len(candidates) == 1:
a9134fa28d15 Move svncommand code into __init__.py.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
83 subcommand = candidates[0]
a9134fa28d15 Move svncommand code into __init__.py.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
84
a9134fa28d15 Move svncommand code into __init__.py.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
85 path = os.path.dirname(repo.path)
209
d06572495c5e Better error message when we encounter an unknown SSL cert.
Augie Fackler <durin42@gmail.com>
parents: 199
diff changeset
86 try:
253
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 251
diff changeset
87 commandfunc = svncommands.table[subcommand]
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 251
diff changeset
88 if commandfunc not in svncommands.nourl:
248
a9134fa28d15 Move svncommand code into __init__.py.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
89 opts['svn_url'] = open(os.path.join(repo.path, 'svn', 'url')).read()
a9134fa28d15 Move svncommand code into __init__.py.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
90 return commandfunc(ui, args=args, hg_repo_path=path, repo=repo, **opts)
209
d06572495c5e Better error message when we encounter an unknown SSL cert.
Augie Fackler <durin42@gmail.com>
parents: 199
diff changeset
91 except core.SubversionException, e:
224
2165461d2dd8 Exception clean-ups; use symbolic names & avoid Python 2.6 deprecations.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 209
diff changeset
92 if e.apr_err == core.SVN_ERR_RA_SERF_SSL_CERT_UNTRUSTED:
248
a9134fa28d15 Move svncommand code into __init__.py.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
93 raise hgutil.Abort('It appears svn does not trust the ssl cert for this site.\n'
209
d06572495c5e Better error message when we encounter an unknown SSL cert.
Augie Fackler <durin42@gmail.com>
parents: 199
diff changeset
94 'Please try running svn ls on that url first.')
d06572495c5e Better error message when we encounter an unknown SSL cert.
Augie Fackler <durin42@gmail.com>
parents: 199
diff changeset
95 raise
248
a9134fa28d15 Move svncommand code into __init__.py.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
96 except TypeError:
a9134fa28d15 Move svncommand code into __init__.py.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
97 tb = traceback.extract_tb(sys.exc_info()[2])
a9134fa28d15 Move svncommand code into __init__.py.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
98 if len(tb) == 1:
a9134fa28d15 Move svncommand code into __init__.py.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
99 ui.status('Bad arguments for subcommand %s\n' % subcommand)
a9134fa28d15 Move svncommand code into __init__.py.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
100 else:
a9134fa28d15 Move svncommand code into __init__.py.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
101 raise
a9134fa28d15 Move svncommand code into __init__.py.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
102 except KeyError, e:
a9134fa28d15 Move svncommand code into __init__.py.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
103 tb = traceback.extract_tb(sys.exc_info()[2])
a9134fa28d15 Move svncommand code into __init__.py.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
104 if len(tb) == 1:
a9134fa28d15 Move svncommand code into __init__.py.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
105 ui.status('Unknown subcommand %s\n' % subcommand)
a9134fa28d15 Move svncommand code into __init__.py.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
106 else:
a9134fa28d15 Move svncommand code into __init__.py.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
107 raise
185
57355b0e7bd1 Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 179
diff changeset
108
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
109
142
42958d9de864 documentation update
Alexander Solovyov <piranha@piranha.org.ua>
parents: 140
diff changeset
110
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
111 cmdtable = {
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
112 "svn":
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
113 (svn,
185
57355b0e7bd1 Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 179
diff changeset
114 [('u', 'svn-url', '', 'path to the Subversion server.'),
57355b0e7bd1 Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 179
diff changeset
115 ('', 'stupid', False, 'be stupid and use diffy replay.'),
167
3cd6a7354207 fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents: 143
diff changeset
116 ('A', 'authors', '', 'username mapping filename'),
185
57355b0e7bd1 Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 179
diff changeset
117 ('', 'filemap', '',
57355b0e7bd1 Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 179
diff changeset
118 'remap file to exclude paths or include only certain paths'),
199
91db8fc049b0 Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents: 185
diff changeset
119 ('', 'force', False, 'force an operation to happen'),
234
33e885f5f86a Add --username and --password options to all commands
Daniel Tang <dytang@cs.purdue.edu>
parents: 224
diff changeset
120 ('', 'username', '', 'username for authentication'),
33e885f5f86a Add --username and --password options to all commands
Daniel Tang <dytang@cs.purdue.edu>
parents: 224
diff changeset
121 ('', 'password', '', 'password for authentication'),
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
122 ],
253
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 251
diff changeset
123 svncommands._helpgen(),
115
ed42f6e5705a Clean up help text, document subcommands.
Luke Opperman <luke@loppear.com>
parents: 52
diff changeset
124 ),
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
125 }