mercurial/ui.py
changeset 1147 d32b91ebad5d
parent 1129 ee4f60abad93
child 1292 141951276ba1
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -78,6 +78,17 @@ class ui:
                                 os.environ.get("USERNAME", "unknown"))
                  + '@' + socket.getfqdn()))
 
+    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:]
+        return user
+
     def expandpath(self, loc):
         paths = {}
         for name, path in self.configitems("paths"):