Radomir Dopieralski  committed 2f5f496

add no_merge parameter

  • Participants
  • Parent commits 9dd870a
  • Branches default

Comments (0)

Files changed (2)


 import mercurial.util
 import mercurial.simplemerge
+class ConflictError(ValueError):
+    """
+    Raised when there is a conflict while updating an item, and a merge is not
+    possible or wanted.
+    """
 class Storage(object):
         if (mercurial.util.binary(data) or
             mercurial.util.binary(parent_data) or
-            raise ValueError("conflict when saving binary data")
+            raise ConflictError("can't mege binary data for %r" % filename)
         m3 = mercurial.simplemerge.Merge3Text(parent_data, other_data, data)
         return ''.join(m3.merge_lines(start_marker='<<<<<<<',
             raise KeyError()
     def save(self, key, data, user=None, message=None, parent_rev=None,
-             encoding=None, force=False):
+             encoding=None, force=False, no_merge=False):
         """Save a new revision of the item."""
         if encoding:
         filename =
         parent, other = self._get_parents(filename, parent_rev)
+        if no_merge and other is not None:
+            raise ConflictError('conflict while updating %r' % key)
         if other is not None and not force:
             data = self._merge(filename, parent, other, data)

'title', u'a\ntext\na', 'user2', 'message2', 0, encoding='utf8')
         data = s.load('title')
         assert 'a\ntext\n<<<<<<<\nbb|||||||\nb=======\na>>>>>>>\n' == data
+        with py.test.raises(hgstorage.ConflictError):
+  'title', u'a\ntext\nb', 'user2', 'message2', 0,
+                   encoding='utf8', no_merge=True)
     def test_silly_parents(self, storage):
         s = storage.session()