hgext3rd/topic/stack.py
branchmercurial-4.3
changeset 3418 85cdce113c2c
parent 3371 753e5ebabe7d
child 4067 fb4801478d5d
--- a/hgext3rd/topic/stack.py	Sat Dec 16 23:40:39 2017 +0100
+++ b/hgext3rd/topic/stack.py	Tue Jan 16 04:35:34 2018 +0100
@@ -28,6 +28,23 @@
 if not util.safehasattr(context.basectx, 'isunstable'):
     context.basectx.isunstable = context.basectx.troubled
 
+def parseusername(user):
+    """parses the ctx user and returns the username without email ID if
+    possible, otherwise returns the mail address from that"""
+    username = None
+    if user:
+        # user is of form "abc <abc@xyz.com>"
+        username = user.split('<')[0]
+        if not username:
+            # assuming user is of form "<abc@xyz.com>"
+            if len(user) > 1:
+                username = user[1:-1]
+            else:
+                username = user
+        username = username.strip()
+
+    return username
+
 def _stackcandidates(repo):
     """build the smaller set of revs that might be part of a stack.