From: W. Trevor King Date: Fri, 14 Nov 2008 05:10:44 +0000 (-0500) Subject: Cleaned up and docstringed libbe.cmdutil.unique_name(). X-Git-Tag: 1.0.0~171 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=67127ba95f877071ba2958d507527690ba70b231;p=be.git Cleaned up and docstringed libbe.cmdutil.unique_name(). Now the first bug will have a 3 char short name (used to be one char, with the second bug having a 3 char name). --- diff --git a/libbe/cmdutil.py b/libbe/cmdutil.py index 079601e..cc2b60f 100644 --- a/libbe/cmdutil.py +++ b/libbe/cmdutil.py @@ -24,14 +24,17 @@ from StringIO import StringIO import utility def unique_name(bug, bugs): - chars = 1 + """ + Generate short names from uuids. Picks the minimum number of + characters (>=3) from the beginning of the uuid such that the + short names are unique. + """ + chars = 3 for some_bug in bugs: if bug.uuid == some_bug.uuid: continue while (bug.uuid[:chars] == some_bug.uuid[:chars]): chars+=1 - if chars < 3: - chars = 3 return bug.uuid[:chars] class UserError(Exception):