diff --git a/hggit/__init__.py b/hggit/__init__.py
index 006c837f918199d5324e75b727e67d4dd1455a59_aGdnaXQvX19pbml0X18ucHk=..78959c8e5e607a00f23e0991760439923bf30dfb_aGdnaXQvX19pbml0X18ucHk= 100644
--- a/hggit/__init__.py
+++ b/hggit/__init__.py
@@ -270,8 +270,9 @@
         gitsha, hgsha = line.strip().split(' ', 1)
         if hgsha in repo:
             new_map.append('%s %s\n' % (gitsha, hgsha))
-    f = repo.vfs(GitHandler.map_file, 'wb')
-    map(f.write, new_map)
+    with repo.wlock():
+        f = repo.vfs(GitHandler.map_file, 'wb')
+        map(f.write, new_map)
     ui.status(_('git commit map cleaned\n'))
 
 def findcommonoutgoing(orig, repo, other, *args, **kwargs):
diff --git a/hggit/git_handler.py b/hggit/git_handler.py
index 006c837f918199d5324e75b727e67d4dd1455a59_aGdnaXQvZ2l0X2hhbmRsZXIucHk=..78959c8e5e607a00f23e0991760439923bf30dfb_aGdnaXQvZ2l0X2hhbmRsZXIucHk= 100644
--- a/hggit/git_handler.py
+++ b/hggit/git_handler.py
@@ -197,16 +197,17 @@
         self._map_hg_real = map_hg_real
 
     def save_map(self, map_file):
-        file = self.repo.vfs(map_file, 'w+', atomictemp=True)
-        map_hg = self._map_hg
-        buf = cStringIO.StringIO()
-        bwrite = buf.write
-        for hgsha, gitsha in map_hg.iteritems():
-            bwrite("%s %s\n" % (gitsha, hgsha))
-        file.write(buf.getvalue())
-        buf.close()
-        # If this complains, atomictempfile no longer has close
-        file.close()
+        with self.repo.wlock():
+            file = self.repo.vfs(map_file, 'w+', atomictemp=True)
+            map_hg = self._map_hg
+            buf = cStringIO.StringIO()
+            bwrite = buf.write
+            for hgsha, gitsha in map_hg.iteritems():
+                bwrite("%s %s\n" % (gitsha, hgsha))
+            file.write(buf.getvalue())
+            buf.close()
+            # If this complains, atomictempfile no longer has close
+            file.close()
 
     def load_tags(self):
         self.tags = {}