# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1465264615 -3600
# Node ID 16242cec256f6e1fffd70e0efd2f2a01c8571689
# Parent  32166f55751810b5475232f8178cbc72ce7a491a
svncommands: unlink revmap file before rebuildmeta

Rebuildmeta should success regardless of what the content of revmap is. The
recent refactor makes it possible that a corrupted revmap file can prevent
"rebuildmeta" from running successfully.

This patch fixes the issue by deleting the revmap file before doing actual
rebuildmeta so that the revmap object can be created successfully.

diff --git a/hgsubversion/svncommands.py b/hgsubversion/svncommands.py
--- a/hgsubversion/svncommands.py
+++ b/hgsubversion/svncommands.py
@@ -65,6 +65,10 @@ def _buildmeta(ui, repo, args, partial=F
     youngest = 0
     startrev = 0
     branchinfo = {}
+
+    if not partial:
+        hgutil.unlinkpath(meta.revmap_file, ignoremissing=True)
+
     revmap = meta.revmap
     if partial:
         try: