summaryrefslogtreecommitdiff
path: root/hgsubversion/svncommands.py
diff options
context:
space:
mode:
Diffstat (limited to 'hgsubversion/svncommands.py')
-rw-r--r--hgsubversion/svncommands.py46
1 files changed, 20 insertions, 26 deletions
diff --git a/hgsubversion/svncommands.py b/hgsubversion/svncommands.py
index abd93c7..ba3cb22 100644
--- a/hgsubversion/svncommands.py
+++ b/hgsubversion/svncommands.py
@@ -64,8 +64,12 @@ def _buildmeta(ui, repo, args, partial=False, skipuuid=False):
youngest = 0
startrev = 0
- sofar = []
branchinfo = {}
+
+ if not partial:
+ hgutil.unlinkpath(meta.revmap_file, ignoremissing=True)
+
+ revmap = meta.revmap
if partial:
try:
# we can't use meta.lastpulled here because we are bootstraping the
@@ -75,9 +79,8 @@ def _buildmeta(ui, repo, args, partial=False, skipuuid=False):
youngestpath = os.path.join(meta.metapath, 'lastpulled')
if os.path.exists(youngestpath):
youngest = util.load(youngestpath)
- sofar = list(maps.RevMap.readmapfile(meta.revmap_file))
- if sofar and len(sofar[-1].split(' ', 2)) > 1:
- lasthash = sofar[-1].split(' ', 2)[1]
+ lasthash = revmap.lasthash
+ if len(revmap) > 0 and lasthash:
startrev = repo[lasthash].rev() + 1
branchinfo = util.load(meta.branch_info_file)
foundpartialinfo = True
@@ -91,9 +94,9 @@ def _buildmeta(ui, repo, args, partial=False, skipuuid=False):
except AttributeError:
ui.status('no metadata available -- doing a full rebuild\n')
- revmap = open(meta.revmap_file, 'w')
- revmap.write('%d\n' % maps.RevMap.VERSION)
- revmap.writelines(sofar)
+ if not partial:
+ revmap.clear()
+
last_rev = -1
if not partial and os.path.exists(meta.tagfile):
os.unlink(meta.tagfile)
@@ -107,13 +110,8 @@ def _buildmeta(ui, repo, args, partial=False, skipuuid=False):
# 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
# changesets that close a branch, and store their first parent
- for rev in xrange(startrev, len(repo)):
- ui.progress('prepare', rev - startrev, total=numrevs)
- try:
- ctx = repo[rev]
- except error.RepoError:
- # this revision is hidden
- continue
+ for ctx in util.get_contexts(repo, startrev):
+ ui.progress('prepare', ctx.rev() - startrev, total=numrevs)
convinfo = util.getsvnrev(ctx, None)
if not convinfo:
@@ -137,16 +135,11 @@ def _buildmeta(ui, repo, args, partial=False, skipuuid=False):
else:
closed.add(parentctx.rev())
- meta.lastpulled = youngest
ui.progress('prepare', None, total=numrevs)
- for rev in xrange(startrev, len(repo)):
- ui.progress('rebuild', rev-startrev, total=numrevs)
- try:
- ctx = repo[rev]
- except error.RepoError:
- # this revision is hidden
- continue
+ revmapbuf = []
+ for ctx in util.get_contexts(repo, startrev):
+ ui.progress('rebuild', ctx.rev() - startrev, total=numrevs)
convinfo = util.getsvnrev(ctx, None)
if not convinfo:
@@ -226,7 +219,7 @@ def _buildmeta(ui, repo, args, partial=False, skipuuid=False):
continue
branch = meta.layoutobj.localname(commitpath)
- revmap.write('%s %s %s\n' % (revision, ctx.hex(), branch or ''))
+ revmapbuf.append((revision, branch, ctx.node()))
revision = int(revision)
if revision > last_rev:
@@ -254,7 +247,7 @@ def _buildmeta(ui, repo, args, partial=False, skipuuid=False):
branch = meta.layoutobj.localname(parentpath)
break
- if rev in closed:
+ if ctx.rev() in closed:
# a direct child of this changeset closes the branch; drop it
branchinfo.pop(branch, None)
elif ctx.extra().get('close'):
@@ -276,6 +269,7 @@ def _buildmeta(ui, repo, args, partial=False, skipuuid=False):
int(parentrev),
revision)
+ revmap.batchset(revmapbuf, youngest)
ui.progress('rebuild', None, total=numrevs)
# save off branch info
@@ -347,7 +341,7 @@ def genignore(ui, repo, force=False, **opts):
raise error.RepoError("There is no Mercurial repository"
" here (.hg not found)")
- ignpath = repo.wjoin('.hgignore')
+ ignpath = repo.wvfs.join('.hgignore')
if not force and os.path.exists(ignpath):
raise hgutil.Abort('not overwriting existing .hgignore, try --force?')
svn = svnrepo.svnremoterepo(repo.ui).svn
@@ -369,7 +363,7 @@ def genignore(ui, repo, force=False, **opts):
lines = props['svn:ignore'].strip().split('\n')
ignorelines += [dir and (dir + '/' + prop) or prop for prop in lines if prop.strip()]
- repo.wopener('.hgignore', 'w').write('\n'.join(ignorelines) + '\n')
+ repo.wvfs('.hgignore', 'w').write('\n'.join(ignorelines) + '\n')
def info(ui, repo, **opts):