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