Commits

Mike Bayer committed a5b9f5c

fix

Comments (0)

Files changed (1)

hggitonce/git_handler.py

 def replace_hg_tags(hg_map, hg_short_map, text):
     def repl(m):
         hash_ = m.group(1)
+        if hash_.startswith("r"):
+            r = True
+            hash_ = hash_[1:]
+        else:
+            r = False
+
         if hash_ in hg_short_map:
-            return hg_short_map[hash_]
+            return ("r" if r else "") + hg_short_map[hash_]
         elif hash_ in hg_map:
-            return hg_map[hash_]
+            return ("r" if r else "") + hg_map[hash_]
         else:
-            return hash_
+            return ("r" if r else "") + m.group(1) + hash_
     return re.sub(
-                r'\b([a-f0-9]{12,})\b', repl, text
+                r'\b(r?[a-f0-9]{12,})\b', repl, text
             )