Mercurial > hgsubversion
comparison __init__.py @ 331:75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
The 'hg svn url' command has been killed; the replacement is
'.hg/hgrc'. More stuff related to its disappearance has been stripped,
including two tests.
HgChangeReceiver now takes a UUID argument, which it uses to ensure
that remote repositories remain unchanged. This is a temporary
solution, and I'm not entirely satisfied with how it's done either.
Access to the UUID file has been isolated in a HgChangeReceiver
property.
Some more tests have been updated to use ui.pushbuffer()/popbuffer(),
and to pass through the Mercurial API.
Moved the arguments to wrappers.pull() to the UI configuration.
Also, remove HgChangeReceiver.opts in favour of a 'usebranchnames'
instance & configuration variable. The name is taken from the
ConvertExtension.
| author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
|---|---|
| date | Fri, 15 May 2009 19:18:43 +0200 |
| parents | 235022089da6 |
| children | 56d877e6ccbb |
comparison
equal
deleted
inserted
replaced
| 330:5f8f2fd4fd54 | 331:75f082b5897e |
|---|---|
| 9 | 9 |
| 10 Before using hgsubversion, it is *strongly* encouraged to run the | 10 Before using hgsubversion, it is *strongly* encouraged to run the |
| 11 automated tests. See `README' in the hgsubversion directory for | 11 automated tests. See `README' in the hgsubversion directory for |
| 12 details. | 12 details. |
| 13 ''' | 13 ''' |
| 14 # TODO: The docstring should be slightly more helpful, and at least mention all | |
| 15 # configuration settings we support | |
| 14 | 16 |
| 15 import os | 17 import os |
| 16 import sys | 18 import sys |
| 17 import traceback | 19 import traceback |
| 18 | 20 |
| 27 import svnrepo | 29 import svnrepo |
| 28 import util | 30 import util |
| 29 import wrappers | 31 import wrappers |
| 30 import svnexternals | 32 import svnexternals |
| 31 | 33 |
| 34 schemes = ('svn', 'svn+ssh', 'svn+http', 'svn+file') | |
| 35 | |
| 36 optionmap = { | |
| 37 'tagpaths': ('hgsubversion', 'tagpaths'), | |
| 38 'authors': ('hgsubversion', 'authormap'), | |
| 39 'filemap': ('hgsubversion', 'filemap'), | |
| 40 'stupid': ('hgsubversion', 'stupid'), | |
| 41 'defaulthost': ('hgsubversion', 'defaulthost'), | |
| 42 'defaultauthors': ('hgsubversion', 'defaultauthors'), | |
| 43 'usebranchnames': ('hgsubversion', 'usebranchnames'), | |
| 44 } | |
| 45 | |
| 46 def wrapper(orig, ui, repo, *args, **opts): | |
| 47 """ | |
| 48 Subversion repositories are also supported for this command. See | |
| 49 `hg help %(extension)s` for details. | |
| 50 """ | |
| 51 for opt, (section, name) in optionmap.iteritems(): | |
| 52 if opt in opts: | |
| 53 if isinstance(repo, str): | |
| 54 ui.setconfig(section, name, opts.pop(opt)) | |
| 55 else: | |
| 56 repo.ui.setconfig(section, name, opts.pop(opt)) | |
| 57 | |
| 58 return orig(ui, repo, *args, **opts) | |
| 59 | |
| 32 def uisetup(ui): | 60 def uisetup(ui): |
| 33 """Do our UI setup. | 61 """Do our UI setup. |
| 34 | 62 |
| 35 Does the following wrappings: | 63 Does the following wrappings: |
| 36 * parent -> utility_commands.parent | 64 * parent -> utility_commands.parent |
| 44 entry[1].append(('', 'svn', None, "show revisions outgoing to subversion")) | 72 entry[1].append(('', 'svn', None, "show revisions outgoing to subversion")) |
| 45 entry = extensions.wrapcommand(commands.table, 'diff', | 73 entry = extensions.wrapcommand(commands.table, 'diff', |
| 46 wrappers.diff) | 74 wrappers.diff) |
| 47 entry[1].append(('', 'svn', None, | 75 entry[1].append(('', 'svn', None, |
| 48 "show svn-style diffs, default against svn parent")) | 76 "show svn-style diffs, default against svn parent")) |
| 49 entry = extensions.wrapcommand(commands.table, 'push', | |
| 50 wrappers.push) | |
| 51 entry[1].append(('', 'svn', None, "push to subversion")) | |
| 52 entry[1].append(('', 'svn-stupid', None, "use stupid replay during push to svn")) | |
| 53 | 77 |
| 78 newflags = (('A', 'authors', '', 'path to file containing username ' | |
| 79 'mappings for Subversion sources'), | |
| 80 ('', 'filemap', '', 'path to file containing rules for file ' | |
| 81 'name mapping used for sources)'), | |
| 82 ('T', 'tagpaths', ['tags'], 'list of paths to search for tags ' | |
| 83 'in Subversion repositories.')) | |
| 84 extname = __package__.split('_')[-1] | |
| 85 | |
| 86 for command in ['clone']: | |
| 87 doc = wrapper.__doc__.strip() % { 'extension': extname } | |
| 88 getattr(commands, command).__doc__ += doc | |
| 89 entry = extensions.wrapcommand(commands.table, command, wrapper) | |
| 90 entry[1].extend(newflags) | |
| 91 | |
| 54 try: | 92 try: |
| 55 rebase = extensions.find('rebase') | 93 rebase = extensions.find('rebase') |
| 56 if rebase: | 94 if rebase: |
| 57 entry = extensions.wrapcommand(rebase.cmdtable, 'rebase', wrappers.rebase) | 95 entry = extensions.wrapcommand(rebase.cmdtable, 'rebase', wrappers.rebase) |
| 58 entry[1].append(('', 'svn', None, 'automatic svn rebase', )) | 96 entry[1].append(('', 'svn', None, 'automatic svn rebase', )) |
| 98 | 136 |
| 99 def reposetup(ui, repo): | 137 def reposetup(ui, repo): |
| 100 if repo.local(): | 138 if repo.local(): |
| 101 svnrepo.generate_repo_class(ui, repo) | 139 svnrepo.generate_repo_class(ui, repo) |
| 102 | 140 |
| 103 for scheme in ('svn', 'svn+ssh', 'svn+http', 'svn+file'): | 141 for scheme in schemes: |
| 104 hg.schemes[scheme] = svnrepo | 142 hg.schemes[scheme] = svnrepo |
| 105 | 143 |
| 106 cmdtable = { | 144 cmdtable = { |
| 107 "svn": | 145 "svn": |
| 108 (svn, | 146 (svn, |
