diff mercurial/obsolete.py @ 17071:11f26e2669aa

command: creation of obsolete marker * add metadata encoding/decoding ability * add a method to obsstore to help creating marker * add a debug command to create marker
author Pierre-Yves.David@ens-lyon.org
date Thu, 07 Jun 2012 19:15:23 +0200
parents ad0d6c2b3279
children 517af63ba382
line wrap: on
line diff
--- a/mercurial/obsolete.py	Thu Jun 07 19:07:39 2012 +0200
+++ b/mercurial/obsolete.py	Thu Jun 07 19:15:23 2012 +0200
@@ -135,6 +135,23 @@
         self.precursors = {}
         self.successors = {}
 
+    def create(self, prec, succs=(), flag=0, metadata=None):
+        """obsolete: add a new obsolete marker
+
+        * ensuring it is hashable
+        * check mandatory metadata
+        * encode metadata
+        """
+        if metadata is None:
+            metadata = {}
+        if len(prec) != 20:
+            raise ValueError(prec)
+        for succ in succs:
+            if len(succ) != 20:
+                raise ValueError(prec)
+        marker = (str(prec), tuple(succs), int(flag), encodemeta(metadata))
+        self.add(marker)
+
     def add(self, marker):
         """Add a new marker to the store