# HG changeset patch
# User Henrik Stuart <h...@hstuart.dk>
# Date 1254073669 -7200
# Node ID 4a3b2db5e149aba85db48ef33bbbad1601246d47
# Parent  dffb0a41561a594540ef4745cf45d4aaa34d42ef
logview: parse known branch colors properly

There were a few corner cases that the original regex didn't handle gracefully.

diff -r dffb0a41561a -r 4a3b2db5e149 tortoisehg/hgtk/logview/revgraph.py
--- a/tortoisehg/hgtk/logview/revgraph.py       Sun Sep 27 09:33:25 2009 -0500
+++ b/tortoisehg/hgtk/logview/revgraph.py       Sun Sep 27 19:47:49 2009 +0200
@@ -77,18 +77,19 @@
     if not branchcolors:
         return {}
 
-    branchcolors = hglib.tounicode(branchcolors).decode('unicode_escape')
-    branchcolors = [x for x in re.split(r'(?<!\\) ', branchcolors) if x]
+    branchcolors = hglib.tounicode(branchcolors)
+    branchcolors = [x for x in re.split(r'(?:(?<=\\\\)|(?<!\\)) ', 
branchcolors) if x]
     values = {}
     for branchcolor in branchcolors:
-        parts = re.split(r'(?<!\\):', branchcolor)
+        parts = re.split(r'(?:(?<=\\\\)|(?<!\\)):', branchcolor)
         if len(parts) != 2:
             continue # ignore badly formed entry
 
         # Mercurial branch names are encoded in utf-8 so we must
         # make sure to encode back to that after having unescaped
         # the string.
-        values[hglib.toutf(parts[0])] = hglib.toutf(parts[1])
+        branch_name = hglib.toutf(parts[0].replace('\\:', ':').replace('\\ ', 
' ').decode('unicode_escape'))
+        values[branch_name] = hglib.toutf(parts[1])
 
     known_branch_colors = values, repo_setting
     return values

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Tortoisehg-develop mailing list
Tortoisehg-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tortoisehg-develop

Reply via email to