annotate hgsubversion/__init__.py @ 687:d424bd1ac647

templatekw: restore compatibility with hg < 1.5 The templatekw module was new in 1.5 - it looks nontrivial to extend the templater in 1.4.x and earlier, so just disable this feature on those versions.
author Augie Fackler <durin42@gmail.com>
date Mon, 06 Sep 2010 17:08:11 -0500
parents 8687c5aa4f35
children 03dca55abec9
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
332
56d877e6ccbb __init__: rewrite extension docstring to be slightly less hostile.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 331
diff changeset
3 hgsubversion is an extension for Mercurial that allows it to act as a Subversion
56d877e6ccbb __init__: rewrite extension docstring to be slightly less hostile.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 331
diff changeset
4 client, offering fast, incremental and bidirectional synchronisation.
185
57355b0e7bd1 Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 179
diff changeset
5
524
30e885106dab __init__: update docstring to reflect recent change to README
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 507
diff changeset
6 At this point, hgsubversion is usable by users reasonably familiar with
30e885106dab __init__: update docstring to reflect recent change to README
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 507
diff changeset
7 Mercurial as a VCS. It's not recommended to dive into hgsubversion as an
30e885106dab __init__: update docstring to reflect recent change to README
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 507
diff changeset
8 introduction to Mercurial, since hgsubversion "bends the rules" a little
30e885106dab __init__: update docstring to reflect recent change to README
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 507
diff changeset
9 and violates some of the typical assumptions of early Mercurial users.
185
57355b0e7bd1 Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 179
diff changeset
10
332
56d877e6ccbb __init__: rewrite extension docstring to be slightly less hostile.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 331
diff changeset
11 Before using hgsubversion, we *strongly* encourage running the
428
96b4ae475941 Fix syntax highlighting in emacs.
Augie Fackler <durin42@gmail.com>
parents: 404
diff changeset
12 automated tests. See 'README' in the hgsubversion directory for
185
57355b0e7bd1 Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 179
diff changeset
13 details.
332
56d877e6ccbb __init__: rewrite extension docstring to be slightly less hostile.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 331
diff changeset
14
660
67b54cb38843 __init__: activate & advertise the new help topic.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 651
diff changeset
15 For more information and instructions, see :hg:`help subversion`.
185
57355b0e7bd1 Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 179
diff changeset
16 '''
57355b0e7bd1 Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 179
diff changeset
17
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 import os
251
23b02f892d9b Fix up imports in __init__.py.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 248
diff changeset
19 import sys
23b02f892d9b Fix up imports in __init__.py.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 248
diff changeset
20 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
21
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
22 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
23 from mercurial import extensions
660
67b54cb38843 __init__: activate & advertise the new help topic.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 651
diff changeset
24 from mercurial import help
326
33736e2e25f0 alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 304
diff changeset
25 from mercurial import hg
248
a9134fa28d15 Move svncommand code into __init__.py.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
26 from mercurial import util as hgutil
429
a5a475dced59 blacklist svn for demandimport.
Augie Fackler <durin42@gmail.com>
parents: 428
diff changeset
27 from mercurial import demandimport
471
893e40e97f6c Bypass demandimport for all svn submodules
Patrick Mezard <pmezard@gmail.com>
parents: 469
diff changeset
28 demandimport.ignore.extend([
893e40e97f6c Bypass demandimport for all svn submodules
Patrick Mezard <pmezard@gmail.com>
parents: 469
diff changeset
29 'svn',
893e40e97f6c Bypass demandimport for all svn submodules
Patrick Mezard <pmezard@gmail.com>
parents: 469
diff changeset
30 'svn.client',
893e40e97f6c Bypass demandimport for all svn submodules
Patrick Mezard <pmezard@gmail.com>
parents: 469
diff changeset
31 'svn.core',
893e40e97f6c Bypass demandimport for all svn submodules
Patrick Mezard <pmezard@gmail.com>
parents: 469
diff changeset
32 'svn.delta',
893e40e97f6c Bypass demandimport for all svn submodules
Patrick Mezard <pmezard@gmail.com>
parents: 469
diff changeset
33 'svn.ra',
893e40e97f6c Bypass demandimport for all svn submodules
Patrick Mezard <pmezard@gmail.com>
parents: 469
diff changeset
34 ])
209
d06572495c5e Better error message when we encounter an unknown SSL cert.
Augie Fackler <durin42@gmail.com>
parents: 199
diff changeset
35
687
d424bd1ac647 templatekw: restore compatibility with hg < 1.5
Augie Fackler <durin42@gmail.com>
parents: 684
diff changeset
36 try:
d424bd1ac647 templatekw: restore compatibility with hg < 1.5
Augie Fackler <durin42@gmail.com>
parents: 684
diff changeset
37 from mercurial import templatekw
d424bd1ac647 templatekw: restore compatibility with hg < 1.5
Augie Fackler <durin42@gmail.com>
parents: 684
diff changeset
38 # force demandimport to load templatekw
d424bd1ac647 templatekw: restore compatibility with hg < 1.5
Augie Fackler <durin42@gmail.com>
parents: 684
diff changeset
39 templatekw.keywords
d424bd1ac647 templatekw: restore compatibility with hg < 1.5
Augie Fackler <durin42@gmail.com>
parents: 684
diff changeset
40 except ImportError:
d424bd1ac647 templatekw: restore compatibility with hg < 1.5
Augie Fackler <durin42@gmail.com>
parents: 684
diff changeset
41 templatekw = None
d424bd1ac647 templatekw: restore compatibility with hg < 1.5
Augie Fackler <durin42@gmail.com>
parents: 684
diff changeset
42
241
4950b18cf949 Move fetch_command.fetch_revisions() to svncommands.pull().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 234
diff changeset
43 import svncommands
440
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 429
diff changeset
44 import util
328
48ec2d62dc29 Rename tag_repo.py to svnrepo.py and get rid of the 'fake' tags.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 326
diff changeset
45 import svnrepo
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents: 256
diff changeset
46 import wrappers
331
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 329
diff changeset
47
403
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
48 svnopts = [
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
49 ('', 'stupid', None,
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
50 'use slower, but more compatible, protocol for Subversion'),
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
51 ]
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
52
506
b5f24dd948af __init__: document wrapping commands more clearly
Augie Fackler <durin42@gmail.com>
parents: 505
diff changeset
53 # generic means it picks up all options from svnopts
b5f24dd948af __init__: document wrapping commands more clearly
Augie Fackler <durin42@gmail.com>
parents: 505
diff changeset
54 # fixdoc means update the docstring
b5f24dd948af __init__: document wrapping commands more clearly
Augie Fackler <durin42@gmail.com>
parents: 505
diff changeset
55 # TODO: fixdoc hoses l18n
403
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
56 wrapcmds = { # cmd: generic, target, fixdoc, ppopts, opts
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
57 'parents': (False, None, False, False, [
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
58 ('', 'svn', None, 'show parent svn revision instead'),
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
59 ]),
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
60 'diff': (False, None, False, False, [
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
61 ('', 'svn', None, 'show svn diffs against svn parent'),
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
62 ]),
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
63 'pull': (True, 'sources', True, True, []),
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
64 'push': (True, 'destinations', True, True, []),
404
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
65 'incoming': (False, 'sources', True, True, []),
507
4ce09bf4d382 wrappers: wrap version with a --svn flag
Augie Fackler <durin42@gmail.com>
parents: 506
diff changeset
66 'version': (False, None, False, False, [
4ce09bf4d382 wrappers: wrap version with a --svn flag
Augie Fackler <durin42@gmail.com>
parents: 506
diff changeset
67 ('', 'svn', None, 'print hgsubversion information as well')]),
403
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
68 'clone': (False, 'sources', True, True, [
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
69 ('T', 'tagpaths', '',
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
70 'list of paths to search for tags in Subversion repositories'),
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
71 ('A', 'authors', '',
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
72 'file mapping Subversion usernames to Mercurial authors'),
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
73 ('', 'filemap', '',
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
74 'file containing rules for remapping Subversion repository paths'),
499
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 471
diff changeset
75 ('', 'layout', 'auto', ('import standard layout or single '
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 471
diff changeset
76 'directory? Can be standard, single, or auto.')),
574
8e025a6f0db4 add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
77 ('', 'branchmap', '', 'file containing rules for branch conversion'),
651
827547493112 clone: allow specifying a start revision.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 618
diff changeset
78 ('', 'startrev', '', ('convert Subversion revisions starting at the one '
827547493112 clone: allow specifying a start revision.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 618
diff changeset
79 'specified, either an integer revision or HEAD; '
827547493112 clone: allow specifying a start revision.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 618
diff changeset
80 'HEAD causes only the latest revision to be '
827547493112 clone: allow specifying a start revision.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 618
diff changeset
81 'pulled')),
403
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
82 ]),
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
83 }
342
76c833526fbc Use fallbacks in the wrappers for Subversion support, instead of prefixes.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 340
diff changeset
84
618
82bfc96a1311 svnrepo: support new discovery module introduced in 3d0591a66118
Augie Fackler <durin42@gmail.com>
parents: 599
diff changeset
85
82bfc96a1311 svnrepo: support new discovery module introduced in 3d0591a66118
Augie Fackler <durin42@gmail.com>
parents: 599
diff changeset
86 # only need the discovery variant of this code when we drop hg < 1.6
82bfc96a1311 svnrepo: support new discovery module introduced in 3d0591a66118
Augie Fackler <durin42@gmail.com>
parents: 599
diff changeset
87 try:
82bfc96a1311 svnrepo: support new discovery module introduced in 3d0591a66118
Augie Fackler <durin42@gmail.com>
parents: 599
diff changeset
88 from mercurial import discovery
82bfc96a1311 svnrepo: support new discovery module introduced in 3d0591a66118
Augie Fackler <durin42@gmail.com>
parents: 599
diff changeset
89 def findoutgoing(orig, *args, **opts):
82bfc96a1311 svnrepo: support new discovery module introduced in 3d0591a66118
Augie Fackler <durin42@gmail.com>
parents: 599
diff changeset
90 capable = getattr(args[1], 'capable', lambda x: False)
82bfc96a1311 svnrepo: support new discovery module introduced in 3d0591a66118
Augie Fackler <durin42@gmail.com>
parents: 599
diff changeset
91 if capable('subversion'):
82bfc96a1311 svnrepo: support new discovery module introduced in 3d0591a66118
Augie Fackler <durin42@gmail.com>
parents: 599
diff changeset
92 return wrappers.outgoing(*args, **opts)
82bfc96a1311 svnrepo: support new discovery module introduced in 3d0591a66118
Augie Fackler <durin42@gmail.com>
parents: 599
diff changeset
93 else:
82bfc96a1311 svnrepo: support new discovery module introduced in 3d0591a66118
Augie Fackler <durin42@gmail.com>
parents: 599
diff changeset
94 return orig(*args, **opts)
82bfc96a1311 svnrepo: support new discovery module introduced in 3d0591a66118
Augie Fackler <durin42@gmail.com>
parents: 599
diff changeset
95 extensions.wrapfunction(discovery, 'findoutgoing', findoutgoing)
82bfc96a1311 svnrepo: support new discovery module introduced in 3d0591a66118
Augie Fackler <durin42@gmail.com>
parents: 599
diff changeset
96 except ImportError:
82bfc96a1311 svnrepo: support new discovery module introduced in 3d0591a66118
Augie Fackler <durin42@gmail.com>
parents: 599
diff changeset
97 pass
82bfc96a1311 svnrepo: support new discovery module introduced in 3d0591a66118
Augie Fackler <durin42@gmail.com>
parents: 599
diff changeset
98
256
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
99 def uisetup(ui):
403
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
100 """insert command wrappers for a bunch of commands"""
402
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 384
diff changeset
101 docvals = {'extension': 'hgsubversion'}
403
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
102 for cmd, (generic, target, fixdoc, ppopts, opts) in wrapcmds.iteritems():
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
103
504
bc117ea4c95a do not assume that doc-strings are present.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 503
diff changeset
104 if fixdoc and wrappers.generic.__doc__:
403
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
105 docvals['command'] = cmd
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
106 docvals['Command'] = cmd.capitalize()
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
107 docvals['target'] = target
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
108 doc = wrappers.generic.__doc__.strip() % docvals
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
109 fn = getattr(commands, cmd)
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
110 fn.__doc__ = fn.__doc__.rstrip() + '\n\n ' + doc
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
111
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
112 wrapped = generic and wrappers.generic or getattr(wrappers, cmd)
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
113 entry = extensions.wrapcommand(commands.table, cmd, wrapped)
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
114 if ppopts:
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
115 entry[1].extend(svnopts)
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
116 if opts:
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
117 entry[1].extend(opts)
337
46e69be8e2c8 Reorganize to have a more conventional module structure.
Augie Fackler <durin42@gmail.com>
parents: 332
diff changeset
118
264
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 257
diff changeset
119 try:
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 257
diff changeset
120 rebase = extensions.find('rebase')
403
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
121 if not rebase:
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
122 return
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
123 entry = extensions.wrapcommand(rebase.cmdtable, 'rebase', wrappers.rebase)
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
124 entry[1].append(('', 'svn', None, 'automatic svn rebase'))
264
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 257
diff changeset
125 except:
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 257
diff changeset
126 pass
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 257
diff changeset
127
660
67b54cb38843 __init__: activate & advertise the new help topic.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 651
diff changeset
128 helpdir = os.path.join(os.path.dirname(__file__), 'help')
115
ed42f6e5705a Clean up help text, document subcommands.
Luke Opperman <luke@loppear.com>
parents: 52
diff changeset
129
660
67b54cb38843 __init__: activate & advertise the new help topic.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 651
diff changeset
130 entries = (
67b54cb38843 __init__: activate & advertise the new help topic.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 651
diff changeset
131 (['subversion'],
67b54cb38843 __init__: activate & advertise the new help topic.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 651
diff changeset
132 "Working with Subversion Repositories",
67b54cb38843 __init__: activate & advertise the new help topic.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 651
diff changeset
133 lambda: open(os.path.join(helpdir, 'subversion.rst')).read()),
67b54cb38843 __init__: activate & advertise the new help topic.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 651
diff changeset
134 )
67b54cb38843 __init__: activate & advertise the new help topic.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 651
diff changeset
135
67b54cb38843 __init__: activate & advertise the new help topic.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 651
diff changeset
136 # in 1.6 and earler the help table is a tuple
67b54cb38843 __init__: activate & advertise the new help topic.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 651
diff changeset
137 if getattr(help.helptable, 'extend', None):
67b54cb38843 __init__: activate & advertise the new help topic.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 651
diff changeset
138 help.helptable.extend(entries)
67b54cb38843 __init__: activate & advertise the new help topic.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 651
diff changeset
139 else:
67b54cb38843 __init__: activate & advertise the new help topic.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 651
diff changeset
140 help.helptable = help.helptable + entries
185
57355b0e7bd1 Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 179
diff changeset
141
684
8687c5aa4f35 Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents: 660
diff changeset
142
8687c5aa4f35 Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents: 660
diff changeset
143 def _get_svnmeta(ctx):
8687c5aa4f35 Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents: 660
diff changeset
144 """Returns a dictionary with parsed convert_revision or None."""
8687c5aa4f35 Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents: 660
diff changeset
145 unparsed = ctx.extra().get('convert_revision', '')
8687c5aa4f35 Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents: 660
diff changeset
146 if unparsed.startswith('svn:'):
8687c5aa4f35 Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents: 660
diff changeset
147 unparsed = unparsed[4:] # remove "svn:"
8687c5aa4f35 Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents: 660
diff changeset
148 return {'svnuuid': unparsed[:36],
8687c5aa4f35 Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents: 660
diff changeset
149 'svnpath': unparsed[36:].rsplit('@', 1)[0],
8687c5aa4f35 Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents: 660
diff changeset
150 'svnrev': unparsed[36:].rsplit('@', 1)[-1]}
8687c5aa4f35 Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents: 660
diff changeset
151 return None
8687c5aa4f35 Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents: 660
diff changeset
152
8687c5aa4f35 Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents: 660
diff changeset
153
8687c5aa4f35 Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents: 660
diff changeset
154 def _show_tpl_kw(ctx, kw):
8687c5aa4f35 Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents: 660
diff changeset
155 convinfo = _get_svnmeta(ctx)
8687c5aa4f35 Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents: 660
diff changeset
156 if convinfo is None:
8687c5aa4f35 Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents: 660
diff changeset
157 return ''
8687c5aa4f35 Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents: 660
diff changeset
158 return convinfo.get(kw, '')
8687c5aa4f35 Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents: 660
diff changeset
159
8687c5aa4f35 Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents: 660
diff changeset
160
687
d424bd1ac647 templatekw: restore compatibility with hg < 1.5
Augie Fackler <durin42@gmail.com>
parents: 684
diff changeset
161 if templatekw:
d424bd1ac647 templatekw: restore compatibility with hg < 1.5
Augie Fackler <durin42@gmail.com>
parents: 684
diff changeset
162 templatekw.keywords.update({
d424bd1ac647 templatekw: restore compatibility with hg < 1.5
Augie Fackler <durin42@gmail.com>
parents: 684
diff changeset
163 'svnrev': lambda repo, ctx, templ, **a: _show_tpl_kw(ctx, 'svnrev'),
d424bd1ac647 templatekw: restore compatibility with hg < 1.5
Augie Fackler <durin42@gmail.com>
parents: 684
diff changeset
164 'svnpath': lambda repo, ctx, templ, **a: _show_tpl_kw(ctx, 'svnpath'),
d424bd1ac647 templatekw: restore compatibility with hg < 1.5
Augie Fackler <durin42@gmail.com>
parents: 684
diff changeset
165 'svnuuid': lambda repo, ctx, templ, **a: _show_tpl_kw(ctx, 'svnuuid'),
d424bd1ac647 templatekw: restore compatibility with hg < 1.5
Augie Fackler <durin42@gmail.com>
parents: 684
diff changeset
166 })
684
8687c5aa4f35 Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents: 660
diff changeset
167
8687c5aa4f35 Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents: 660
diff changeset
168
326
33736e2e25f0 alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 304
diff changeset
169 def reposetup(ui, repo):
33736e2e25f0 alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 304
diff changeset
170 if repo.local():
328
48ec2d62dc29 Rename tag_repo.py to svnrepo.py and get rid of the 'fake' tags.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 326
diff changeset
171 svnrepo.generate_repo_class(ui, repo)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
172
505
e508a718779c fallback to the previous scheme for file repositories.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 504
diff changeset
173 _old_local = hg.schemes['file']
342
76c833526fbc Use fallbacks in the wrappers for Subversion support, instead of prefixes.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 340
diff changeset
174 def _lookup(url):
440
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 429
diff changeset
175 if util.islocalrepo(url):
342
76c833526fbc Use fallbacks in the wrappers for Subversion support, instead of prefixes.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 340
diff changeset
176 return svnrepo
76c833526fbc Use fallbacks in the wrappers for Subversion support, instead of prefixes.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 340
diff changeset
177 else:
505
e508a718779c fallback to the previous scheme for file repositories.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 504
diff changeset
178 return _old_local(url)
342
76c833526fbc Use fallbacks in the wrappers for Subversion support, instead of prefixes.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 340
diff changeset
179
76c833526fbc Use fallbacks in the wrappers for Subversion support, instead of prefixes.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 340
diff changeset
180 # install scheme handlers
76c833526fbc Use fallbacks in the wrappers for Subversion support, instead of prefixes.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 340
diff changeset
181 hg.schemes.update({ 'file': _lookup, 'http': svnrepo, 'https': svnrepo,
469
5567af673f83 Revive svn+http(s) URLs support (issue94)
Patrick Mezard <pmezard@gmail.com>
parents: 463
diff changeset
182 'svn': svnrepo, 'svn+ssh': svnrepo, 'svn+http': svnrepo,
5567af673f83 Revive svn+http(s) URLs support (issue94)
Patrick Mezard <pmezard@gmail.com>
parents: 463
diff changeset
183 'svn+https': svnrepo})
142
42958d9de864 documentation update
Alexander Solovyov <piranha@piranha.org.ua>
parents: 140
diff changeset
184
573
00393e9abff8 svncommands: make repo optional (useful for things like listauthors)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 524
diff changeset
185 commands.optionalrepo += ' svn'
00393e9abff8 svncommands: make repo optional (useful for things like listauthors)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 524
diff changeset
186
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
187 cmdtable = {
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
188 "svn":
599
408869906fbf Move the 'svn' metacommand into the 'svncommands' module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 598
diff changeset
189 (svncommands.svn,
185
57355b0e7bd1 Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 179
diff changeset
190 [('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
191 ('', '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
192 ('A', 'authors', '', 'username mapping filename'),
185
57355b0e7bd1 Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 179
diff changeset
193 ('', 'filemap', '',
57355b0e7bd1 Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 179
diff changeset
194 '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
195 ('', '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
196 ('', 'username', '', 'username for authentication'),
33e885f5f86a Add --username and --password options to all commands
Daniel Tang <dytang@cs.purdue.edu>
parents: 224
diff changeset
197 ('', 'password', '', 'password for authentication'),
503
00ecb2bc005c Add a -r option to hg svn. Use with hg svn info to change the mercurial rev.
Jason Ostrander <jason@sentilla.com>
parents: 499
diff changeset
198 ('r', 'rev', '', 'Mercurial revision'),
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
199 ],
598
e432b61c6d74 Use Mercurial-provided infrastructure for `svn' metacommand help.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 580
diff changeset
200 'hg svn <subcommand> ...',
115
ed42f6e5705a Clean up help text, document subcommands.
Luke Opperman <luke@loppear.com>
parents: 52
diff changeset
201 ),
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
202 }
342
76c833526fbc Use fallbacks in the wrappers for Subversion support, instead of prefixes.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 340
diff changeset
203
76c833526fbc Use fallbacks in the wrappers for Subversion support, instead of prefixes.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 340
diff changeset
204 # only these methods are public
76c833526fbc Use fallbacks in the wrappers for Subversion support, instead of prefixes.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 340
diff changeset
205 __all__ = ('cmdtable', 'reposetup', 'uisetup')