[PATCH STABLE] store: do not add duplicates to the fncache file

Adrian Buehlmann adrian at cadifra.com
Wed Mar 3 07:59:52 CST 2010


# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1267624235 -3600
# Branch stable
# Node ID ff8e6e2bcb56bc6eb05df72a3f5a0daa1c587caa
# Parent  d6c1279468ca89ae50b1fe23190f4bad931adeca
store: do not add duplicates to the fncache file

Newly added fncache entries were not added to the in-memory cache,
making it possible for 'hg convert' to cause duplicates in
.hg/store/fncache.

Duplicates in the fncache file are harmless, but excessive numbers
of duplicates from large converted repositories may slow down
execution speed considerably.

diff --git a/mercurial/store.py b/mercurial/store.py
--- a/mercurial/store.py
+++ b/mercurial/store.py
@@ -268,6 +268,7 @@ class fncache(object):
         if self.entries is None:
             self._load()
         self.opener('fncache', 'ab').write(encodedir(fn) + '\n')
+        self.entries.add(fn)
 
     def __contains__(self, fn):
         if self.entries is None:
diff --git a/tests/test-convert b/tests/test-convert
--- a/tests/test-convert
+++ b/tests/test-convert
@@ -56,4 +56,10 @@ hg convert --source-type foo a a-foo
 echo % convert with imaginary sink type
 hg convert --dest-type foo a a-foo
 
+echo
+echo % "testing: convert must not produce duplicate entries in fncache"
+hg convert a b
+echo % "contents of fncache file:"
+cat b/.hg/store/fncache
+
 true
diff --git a/tests/test-convert.out b/tests/test-convert.out
--- a/tests/test-convert.out
+++ b/tests/test-convert.out
@@ -273,3 +273,17 @@ initializing destination a-foo repositor
 abort: foo: invalid source repository type
 % convert with imaginary sink type
 abort: foo: invalid destination repository type
+
+% testing: convert must not produce duplicate entries in fncache
+initializing destination b repository
+scanning source...
+sorting...
+converting...
+4 a
+3 b
+2 c
+1 d
+0 e
+% contents of fncache file:
+data/a.i
+data/b.i


More information about the Mercurial-devel mailing list