763 '').strip().split(',') |
763 '').strip().split(',') |
764 if feature and exceptions: |
764 if feature and exceptions: |
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: |
778 user = self.config("ui", "username") |
780 user = self.config("ui", "username") |
779 if user is not None: |
781 if user is not None: |
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(): |
786 try: |
790 try: |
787 user = '%s@%s' % (util.getuser(), socket.getfqdn()) |
791 user = '%s@%s' % (util.getuser(), socket.getfqdn()) |