mercurial/utils/storageutil.py
changeset 39880 1b65fb4d43d6
parent 39879 d269ddbf54f0
child 39881 d63153611ed5
--- a/mercurial/utils/storageutil.py	Mon Sep 24 14:33:45 2018 -0700
+++ b/mercurial/utils/storageutil.py	Mon Sep 24 14:54:28 2018 -0700
@@ -69,3 +69,15 @@
 def iscensoredtext(text):
     meta = parsemeta(text)[0]
     return meta and b'censored' in meta
+
+def filtermetadata(text):
+    """Extract just the revision data from source text.
+
+    Returns ``text`` unless it has a metadata header, in which case we return
+    a new buffer without hte metadata.
+    """
+    if not text.startswith(b'\x01\n'):
+        return text
+
+    offset = text.index(b'\x01\n', 2)
+    return text[offset + 2:]