# HG changeset patch # User Vadim Gelfer # Date 1141068730 28800 # Node ID e4abeafd6eb107b9120f221d88fbe4eadd574466 # Parent 1cc5f25653a3a02ed5d39a90a3881c0f65343da8 move shortuser into util module. diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -104,13 +104,7 @@ class ui(object): def shortuser(self, user): """Return a short representation of a user name or email address.""" - if not self.verbose: - f = user.find('@') - if f >= 0: - user = user[:f] - f = user.find('<') - if f >= 0: - user = user[f+1:] + if not self.verbose: user = util.shortuser(user) return user def expandpath(self, loc, root=""): diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -690,3 +690,13 @@ def datestr(date=None, format='%c'): (time.strftime(format, time.gmtime(float(t) - tz)), -tz / 3600, ((-tz % 3600) / 60))) + +def shortuser(user): + """Return a short representation of a user name or email address.""" + f = user.find('@') + if f >= 0: + user = user[:f] + f = user.find('<') + if f >= 0: + user = user[f+1:] + return user