[Secure-testing-commits] r15860 - lib/python

Florian Weimer fw at alioth.debian.org
Fri Jan 14 21:28:24 UTC 2011


Author: fw
Date: 2011-01-14 21:28:24 +0000 (Fri, 14 Jan 2011)
New Revision: 15860

Modified:
   lib/python/bugs.py
Log:
lib/python/bugs.py: switch to hash-based temporary names

Thanks to Stefan Fritsch for the suggestion.


Modified: lib/python/bugs.py
===================================================================
--- lib/python/bugs.py	2011-01-14 21:28:21 UTC (rev 15859)
+++ lib/python/bugs.py	2011-01-14 21:28:24 UTC (rev 15860)
@@ -18,6 +18,7 @@
 import debian_support
 import re
 import types
+import hashlib
 
 class Urgency(debian_support.PseudoEnum): pass
 
@@ -396,6 +397,14 @@
     def cveStatus(self):
         return 'REJECTED'
 
+def temp_bug_name(bug_number, description):
+    """Build a unique temporary name from the bug number and a
+    truncated hash of the description."""
+    digest = hashlib.md5()
+    digest.update(description)
+    hexdigest = digest.hexdigest()[0:6].upper()
+    return 'TEMP-%07d-%s' % (bug_number, hexdigest)
+
 class FileBase(debian_support.PackageFile):
     re_non_ascii = re.compile(r'.*([^\n\t -~]).*')
     re_empty = re.compile(r'^(?:\s*$|--)')
@@ -709,7 +718,7 @@
                             break
                         if first_bug:
                             break
-                    record_name = 'TEMP-%07d-%06d' % (first_bug, first_lineno)
+                    record_name = temp_bug_name(first_bug, description)
                 yield self.finishBug(Bug(self.file.name, first_lineno, date,
                                          record_name, description,
                                          comments, notes=pkg_notes, xref=xref))




More information about the Secure-testing-commits mailing list