diff svncommands.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 1d48d9a34c19
children
line wrap: on
line diff
--- a/svncommands.py
+++ b/svncommands.py
@@ -30,16 +30,10 @@ def incoming(ui, svn_url, hg_repo_path, 
                                                  author_host=author_host,
                                                  tag_locations=tag_locations,
                                                  authors=authors,
-                                                 filemap=filemap)
-    if os.path.exists(hg_editor.uuid_file):
-        uuid = open(hg_editor.uuid_file).read()
-        assert uuid == svn.uuid
-        start = hg_editor.last_known_revision()
-    else:
-        open(hg_editor.uuid_file, 'w').write(svn.uuid)
-        open(hg_editor.svn_url_file, 'w').write(svn_url)
-        initializing_repo = True
-        start = skipto_rev
+                                                 filemap=filemap,
+                                                 uuid=svn.uuid)
+    start = max(hg_editor.last_known_revision(), skipto_rev)
+    initializing_repo = (hg_editor.last_known_revision() <= 0)
 
     if initializing_repo and start > 0:
         raise hgutil.Abort('Revision skipping at repository initialization '
@@ -65,9 +59,13 @@ def rebuildmeta(ui, repo, hg_repo_path, 
     """rebuild hgsubversion metadata using values stored in revisions
     """
     if len(args) != 1:
-        raise hgutil.Abort('You must pass the svn URI used to create this repo.')
+        url = repo.ui.expandpath(dest or 'default-push', dest or 'default')
+    else:
+        url = args[0]
+    if not (url.startswith('svn+') or url.startswith('svn:')):
+        raise hgutil.Abort('No valid Subversion URI found; please specify one.')
     uuid = None
-    url = args[0].rstrip('/')
+    url = util.normalize_url(url.rstrip('/'))
     user, passwd = util.getuserpass(opts)
     svn = svnwrap.SubversionRepo(url, user, passwd)
     subdir = svn.subdir
@@ -95,9 +93,6 @@ def rebuildmeta(ui, repo, hg_repo_path, 
             if uuid is None:
                 uuid = convinfo[4:40]
                 assert uuid == svn.uuid, 'UUIDs did not match!'
-                urlfile = open(os.path.join(svnmetadir, 'url'), 'w')
-                urlfile.write(url)
-                urlfile.close()
                 uuidfile = open(os.path.join(svnmetadir, 'uuid'), 'w')
                 uuidfile.write(uuid)
                 uuidfile.close()