[Pkg-bazaar-commits] ./bzr/unstable r810: - New validate_revision_id function

Martin Pool mbp at sourcefrog.net
Fri Apr 10 08:21:06 UTC 2009


------------------------------------------------------------
revno: 810
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Mon 2005-07-04 17:33:32 +1000
message:
  - New validate_revision_id function
modified:
  bzrlib/revision.py
-------------- next part --------------
=== modified file 'bzrlib/revision.py'
--- a/bzrlib/revision.py	2005-06-28 05:33:40 +0000
+++ b/bzrlib/revision.py	2005-07-04 07:33:32 +0000
@@ -186,3 +186,18 @@
 
     rev.message = elt.findtext('message') # text of <message>
     return rev
+
+
+
+REVISION_ID_RE = None
+
+def validate_revision_id(rid):
+    """Check rid is syntactically valid for a revision id."""
+    global REVISION_ID_RE
+    if not REVISION_ID_RE:
+        import re
+        REVISION_ID_RE = re.compile('[\w.-]+@[\w.-]+-+\d+-[0-9a-f]+\Z')
+
+    if not REVISION_ID_RE.match(rid):
+        raise ValueError("malformed revision-id %r" % rid)
+    



More information about the Pkg-bazaar-commits mailing list