##// END OF EJS Templates
ui: add the possibility to returns None as username in ui...
Boris Feld -
r34850:9f2891fb default
parent child Browse files
Show More
@@ -765,13 +765,15 b' class ui(object):'
765 765 return feature not in exceptions
766 766 return True
767 767
768 def username(self):
768 def username(self, acceptempty=False):
769 769 """Return default username to be used in commits.
770 770
771 771 Searched in this order: $HGUSER, [ui] section of hgrcs, $EMAIL
772 772 and stop searching if one of these is set.
773 If not found and acceptempty is True, returns None.
773 774 If not found and ui.askusername is True, ask the user, else use
774 775 ($LOGNAME or $USER or $LNAME or $USERNAME) + "@full.hostname".
776 If no username could be found, raise an Abort error.
775 777 """
776 778 user = encoding.environ.get("HGUSER")
777 779 if user is None:
@@ -780,6 +782,8 b' class ui(object):'
780 782 user = os.path.expandvars(user)
781 783 if user is None:
782 784 user = encoding.environ.get("EMAIL")
785 if user is None and acceptempty:
786 return user
783 787 if user is None and self.configbool("ui", "askusername"):
784 788 user = self.prompt(_("enter a commit username:"), default=None)
785 789 if user is None and not self.interactive():
General Comments 0
You need to be logged in to leave comments. Login now