]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Merging catalogs would sometimes mix translations from different runs.
authorChristopher Lenz <cmlenz@gmail.com>
Fri, 1 Feb 2008 14:46:32 +0000 (14:46 +0000)
committerChristopher Lenz <cmlenz@gmail.com>
Fri, 1 Feb 2008 14:46:32 +0000 (14:46 +0000)
ChangeLog
babel/messages/catalog.py
babel/messages/tests/catalog.py

index 5e2d545da79f8ce1337a3bde0a3d72adb98e7773..a2ce27d877dbf1fb57f1aae99437ca38d4f57c4e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,8 @@ http://svn.edgewall.org/repos/babel/tags/0.9.2/
 
  * Fixed catalogs' charset values not being recognized (ticket #66).
  * Fixed fuzzy matching when updating message catalogs (ticket #82).
+ * Fixed bug in catalog updating, that in some cases pulled in
+   translations from different catalogs based on the same template.
 
 
 Version 0.9.1
index 0de66461653bd642a5ddec7bed721b939d0fbc6a..f358fed79b3d8d600bff7bae3708041bdc423302 100644 (file)
@@ -92,6 +92,11 @@ class Message(object):
                 return cmp(self.id, obj.id[0])
         return cmp(self.id, obj.id)
 
+    def clone(self):
+        return Message(self.id, self.string, self.locations, self.flags,
+                       self.auto_comments, self.user_comments,
+                       self.previous_id, self.lineno)
+
     def fuzzy(self):
         return 'fuzzy' in self.flags
     fuzzy = property(fuzzy, doc="""\
@@ -624,6 +629,7 @@ class Catalog(object):
         fuzzy_matches = set()
 
         def _merge(message, oldkey, newkey):
+            message = message.clone()
             fuzzy = False
             if oldkey != newkey:
                 fuzzy = True
index f9ade90fee8d1ee9d6267be51f42b01310c856c0..475137ff83462f0287203de68812de1b82b39025 100644 (file)
@@ -174,6 +174,17 @@ class CatalogTestCase(unittest.TestCase):
         cat.update(tmpl, no_fuzzy_matching=True)
         self.assertEqual(2, len(cat.obsolete))
 
+    def test_update_no_template_mutation(self):
+        tmpl = catalog.Catalog()
+        tmpl.add('foo')
+        cat1 = catalog.Catalog()
+        cat1.add('foo', 'Voh')
+        cat1.update(tmpl)
+        cat2 = catalog.Catalog()
+        cat2.update(tmpl)
+
+        self.assertEqual(None, cat2['foo'].string)
+        self.assertEqual(False, cat2['foo'].fuzzy)
 
 def suite():
     suite = unittest.TestSuite()