Mercurial > evolve
comparison hgext3rd/topic/stack.py @ 3371:753e5ebabe7d
topics: take logic to parse username to a separate function
In next patch we will be adding support to `hg stack` to show users, and this
logic will be required there too. So let's take it out in a separate function.
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Wed, 27 Dec 2017 23:51:18 +0530 |
parents | e4c0332ecee4 |
children | fb4801478d5d |
comparison
equal
deleted
inserted
replaced
3370:1face8964965 | 3371:753e5ebabe7d |
---|---|
25 if not util.safehasattr(context.basectx, 'orphan'): | 25 if not util.safehasattr(context.basectx, 'orphan'): |
26 context.basectx.orphan = context.basectx.unstable | 26 context.basectx.orphan = context.basectx.unstable |
27 | 27 |
28 if not util.safehasattr(context.basectx, 'isunstable'): | 28 if not util.safehasattr(context.basectx, 'isunstable'): |
29 context.basectx.isunstable = context.basectx.troubled | 29 context.basectx.isunstable = context.basectx.troubled |
30 | |
31 def parseusername(user): | |
32 """parses the ctx user and returns the username without email ID if | |
33 possible, otherwise returns the mail address from that""" | |
34 username = None | |
35 if user: | |
36 # user is of form "abc <abc@xyz.com>" | |
37 username = user.split('<')[0] | |
38 if not username: | |
39 # assuming user is of form "<abc@xyz.com>" | |
40 if len(user) > 1: | |
41 username = user[1:-1] | |
42 else: | |
43 username = user | |
44 username = username.strip() | |
45 | |
46 return username | |
30 | 47 |
31 def _stackcandidates(repo): | 48 def _stackcandidates(repo): |
32 """build the smaller set of revs that might be part of a stack. | 49 """build the smaller set of revs that might be part of a stack. |
33 | 50 |
34 The intend is to build something more efficient than what revsets do in | 51 The intend is to build something more efficient than what revsets do in |