Changeset e72139488071…
Parent c6ad5c7ed8ef…
by
Changes to 2 files · Browse files at e72139488071 Showing diff from parent c6ad5c7ed8ef Diff from another changeset...
@@ -138,9 +138,9 @@ return None
return hglib.tounicode(value)[:80]
elif item == 'user':
- return hglib.tounicode(ctx.user())
+ return hglib.tounicode(hglib.user(ctx))
elif item == 'shortuser':
- return hglib.tounicode(hglib.username(ctx.user()))
+ return hglib.tounicode(hglib.username(hglib.user(ctx)))
elif item == 'dateage':
date = self.get_data('date', *args)
age = self.get_data('age', *args)
|
@@ -23,7 +23,7 @@ demandimport.enable()
from mercurial import ui, util, extensions, match, bundlerepo, url, cmdutil
-from mercurial import dispatch, encoding, templatefilters, filemerge
+from mercurial import dispatch, encoding, templatefilters, filemerge, error
_encoding = encoding.encoding
_encodingmode = encoding.encodingmode
@@ -520,6 +520,22 @@ author = util.shortuser(user)
return author
+def user(ctx):
+ '''
+ Get the username of the change context. Does not abort and just returns
+ an empty string if ctx is a working context and no username has been set
+ in mercurial's config.
+ '''
+ try:
+ user = ctx.user()
+ except error.Abort:
+ if ctx._rev is not None:
+ raise
+ # ctx is a working context and probably no username has
+ # been configured in mercurial's config
+ user = ''
+ return user
+
def get_revision_desc(fctx, curpath=None):
"""return the revision description as a string"""
author = tounicode(username(fctx.user()))
|
Loading...