##// END OF EJS Templates
Move generating short username to display in hg/hgweb annotate to ui module.
Thomas Arendsen Hein -
r1129:ee4f60ab default
parent child Browse files
Show More
@@ -472,14 +472,7 b' def annotate(ui, repo, *pats, **opts):'
472 return bcache[rev]
472 return bcache[rev]
473 except KeyError:
473 except KeyError:
474 cl = repo.changelog.read(repo.changelog.node(rev))
474 cl = repo.changelog.read(repo.changelog.node(rev))
475 name = cl[1]
475 bcache[rev] = name = ui.shortuser(cl[1])
476 f = name.find('@')
477 if f >= 0:
478 name = name[:f]
479 f = name.find('<')
480 if f >= 0:
481 name = name[f+1:]
482 bcache[rev] = name
483 return name
476 return name
484
477
485 if not pats:
478 if not pats:
@@ -507,14 +507,7 b' class hgweb:'
507 name = bcache[r]
507 name = bcache[r]
508 except KeyError:
508 except KeyError:
509 cl = self.repo.changelog.read(cnode)
509 cl = self.repo.changelog.read(cnode)
510 name = cl[1]
510 bcache[r] = name = self.repo.ui.shortuser(cl[1])
511 f = name.find('@')
512 if f >= 0:
513 name = name[:f]
514 f = name.find('<')
515 if f >= 0:
516 name = name[f+1:]
517 bcache[r] = name
518
511
519 if last != cnode:
512 if last != cnode:
520 parity = 1 - parity
513 parity = 1 - parity
@@ -78,6 +78,16 b' class ui:'
78 os.environ.get("USERNAME", "unknown"))
78 os.environ.get("USERNAME", "unknown"))
79 + '@' + socket.getfqdn()))
79 + '@' + socket.getfqdn()))
80
80
81 def shortuser(self, user):
82 """Return a short representation of a user name or email address."""
83 f = user.find('@')
84 if f >= 0:
85 user = user[:f]
86 f = user.find('<')
87 if f >= 0:
88 user = user[f+1:]
89 return user
90
81 def expandpath(self, loc):
91 def expandpath(self, loc):
82 paths = {}
92 paths = {}
83 for name, path in self.configitems("paths"):
93 for name, path in self.configitems("paths"):
General Comments 0
You need to be logged in to leave comments. Login now