diff __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
line wrap: on
line diff
--- a/__init__.py
+++ b/__init__.py
@@ -11,6 +11,8 @@ Before using hgsubversion, it is *strong
 automated tests. See `README' in the hgsubversion directory for
 details.
 '''
+# TODO: The docstring should be slightly more helpful, and at least mention all
+#       configuration settings we support
 
 import os
 import sys
@@ -29,6 +31,32 @@ import util
 import wrappers
 import svnexternals
 
+schemes = ('svn', 'svn+ssh', 'svn+http', 'svn+file')
+
+optionmap = {
+    'tagpaths': ('hgsubversion', 'tagpaths'),
+    'authors': ('hgsubversion', 'authormap'),
+    'filemap': ('hgsubversion', 'filemap'),
+    'stupid': ('hgsubversion', 'stupid'),
+    'defaulthost': ('hgsubversion', 'defaulthost'),
+    'defaultauthors': ('hgsubversion', 'defaultauthors'),
+    'usebranchnames': ('hgsubversion', 'usebranchnames'),
+}
+
+def wrapper(orig, ui, repo, *args, **opts):
+    """
+    Subversion repositories are also supported for this command. See
+    `hg help %(extension)s` for details.
+    """
+    for opt, (section, name) in optionmap.iteritems():
+        if opt in opts:
+            if isinstance(repo, str):
+                ui.setconfig(section, name, opts.pop(opt))
+            else:
+                repo.ui.setconfig(section, name, opts.pop(opt))
+
+    return orig(ui, repo, *args, **opts)
+
 def uisetup(ui):
     """Do our UI setup.
 
@@ -46,11 +74,21 @@ def uisetup(ui):
                                    wrappers.diff)
     entry[1].append(('', 'svn', None,
                      "show svn-style diffs, default against svn parent"))
-    entry = extensions.wrapcommand(commands.table, 'push',
-                                   wrappers.push)
-    entry[1].append(('', 'svn', None, "push to subversion"))
-    entry[1].append(('', 'svn-stupid', None, "use stupid replay during push to svn"))
 
+    newflags = (('A', 'authors', '', 'path to file containing username '
+                 'mappings for Subversion sources'),
+                ('', 'filemap', '', 'path to file containing rules for file '
+                 'name mapping used for sources)'),
+                ('T', 'tagpaths', ['tags'], 'list of paths to search for tags '
+                 'in Subversion repositories.'))
+    extname = __package__.split('_')[-1]
+
+    for command in ['clone']:
+        doc = wrapper.__doc__.strip() % { 'extension': extname }
+        getattr(commands, command).__doc__ += doc
+        entry = extensions.wrapcommand(commands.table, command, wrapper)
+        entry[1].extend(newflags)
+        
     try:
         rebase = extensions.find('rebase')
         if rebase:
@@ -100,7 +138,7 @@ def reposetup(ui, repo):
     if repo.local():
        svnrepo.generate_repo_class(ui, repo)
 
-for scheme in ('svn', 'svn+ssh', 'svn+http', 'svn+file'):
+for scheme in schemes:
     hg.schemes[scheme] = svnrepo
 
 cmdtable = {