changeset 997:c8cb06e1f323

buildmeta: do not contact svn unless needed We read uuid and subdir information from local metadata if available. Only if they do not exist do we need to construct an svnremoterepo object.
author Bryan O'Sullivan <bryano@fb.com>
date Mon, 04 Feb 2013 17:58:05 -0800
parents 2c87bdc43d3c
children 8045ebda705a 3f45bd7b60cf
files hgsubversion/svncommands.py
diffstat 1 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/svncommands.py
+++ b/hgsubversion/svncommands.py
@@ -67,14 +67,20 @@ def _buildmeta(ui, repo, args, partial=F
         raise hgutil.Abort('rebuildmeta takes 1 or no arguments')
     url = repo.ui.expandpath(dest or repo.ui.config('paths', 'default-push') or
                              repo.ui.config('paths', 'default') or '')
-    svn = svnrepo.svnremoterepo(ui, url).svn
-    subdir = svn.subdir
     svnmetadir = os.path.join(repo.path, 'svn')
     if not os.path.exists(svnmetadir):
         os.makedirs(svnmetadir)
     uuidpath = os.path.join(svnmetadir, 'uuid')
     uuid = read_if_exists(uuidpath)
 
+    subdirpath = os.path.join(svnmetadir, 'subdir')
+    subdir = read_if_exists(subdirpath)
+    svn = None
+    if subdir is None:
+        svn = svnrepo.svnremoterepo(ui, url).svn
+        subdir = svn.subdir
+        open(subdirpath, 'wb').write(subdir.strip('/'))
+
     youngest = 0
     startrev = 0
     sofar = []
@@ -120,8 +126,6 @@ def _buildmeta(ui, repo, args, partial=F
 
     numrevs = len(repo) - startrev
 
-    write_if_needed(os.path.join(svnmetadir, 'subdir'), subdir.strip('/'))
-
     # ctx.children() visits all revisions in the repository after ctx. Calling
     # it would make us use O(revisions^2) time, so we perform an extra traversal
     # of the repository instead. During this traversal, we find all converted
@@ -205,6 +209,8 @@ def _buildmeta(ui, repo, args, partial=F
         if uuid is None:
             uuid = convinfo[4:40]
             if not skipuuid:
+                if svn is None:
+                    svn = svnrepo.svnremoterepo(ui, url).svn
                 if uuid != svn.uuid:
                     raise hgutil.Abort('remote svn repository identifier '
                                        'does not match')