diff --git a/doc/hgrc.5.txt b/doc/hgrc.5.txt --- a/doc/hgrc.5.txt +++ b/doc/hgrc.5.txt @@ -401,9 +401,8 @@ ui:: username;; The committer of a changeset created when running "commit". Typically a person's name and email address, e.g. "Fred Widget - ". Default is $EMAIL or username@hostname, unless - username is set to an empty string, which enforces specifying the - username manually. + ". Default is $EMAIL. If no default is found, + the username have to be specified manually. verbose;; Increase the amount of output printed. True or False. Default is False. diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -226,10 +226,8 @@ class ui(object): Searched in this order: $HGUSER, [ui] section of hgrcs, $EMAIL and stop searching if one of these is set. - Abort if found username is an empty string to force specifying - the commit user elsewhere, e.g. with line option or repo hgrc. - If not found, use ($LOGNAME or $USER or $LNAME or - $USERNAME) +"@full.hostname". + Abort if no username is found, to force specifying the commit user + with line option or repo hgrc. """ user = os.environ.get("HGUSER") if user is None: @@ -237,10 +235,7 @@ class ui(object): if user is None: user = os.environ.get("EMAIL") if user is None: - try: - user = '%s@%s' % (util.getuser(), socket.getfqdn()) - except KeyError: - raise util.Abort(_("Please specify a username.")) + raise util.Abort(_("No default username available, use -u")) return user def shortuser(self, user): diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -519,20 +519,6 @@ def is_win_9x(): except AttributeError: return os.name == 'nt' and 'command' in os.environ.get('comspec', '') -getuser_fallback = None - -def getuser(): - '''return name of current user''' - try: - return getpass.getuser() - except ImportError: - # import of pwd will fail on windows - try fallback - if getuser_fallback: - return getuser_fallback() - # raised if win32api not available - raise Abort(_('user name not available - set USERNAME ' - 'environment variable')) - # Platform specific variants if os.name == 'nt': demandload(globals(), "msvcrt") diff --git a/mercurial/util_win32.py b/mercurial/util_win32.py --- a/mercurial/util_win32.py +++ b/mercurial/util_win32.py @@ -297,5 +297,3 @@ class posixfile_nt(object): win32file.SetEndOfFile(self.handle) except pywintypes.error, err: raise WinIOError(err) - -getuser_fallback = win32api.GetUserName diff --git a/tests/test-committer b/tests/test-committer --- a/tests/test-committer +++ b/tests/test-committer @@ -10,3 +10,17 @@ touch asdf hg add asdf hg commit -d '1000000 0' -m commit-1 hg tip + +unset EMAIL +echo 1 > asdf +hg commit -d '1000000 0' -m commit-1 +hg commit -d '1000000 0' -u "foo@bar.com" -m commit-1 +hg tip +echo "[ui]" >> .hg/hgrc +echo "username = foobar " >> .hg/hgrc +echo 12 > asdf +hg commit -d '1000000 0' -m commit-1 +hg tip +echo 1 > asdf +hg commit -d '1000000 0' -u "foo@bar.com" -m commit-1 +hg tip diff --git a/tests/test-committer.out b/tests/test-committer.out --- a/tests/test-committer.out +++ b/tests/test-committer.out @@ -4,3 +4,24 @@ user: My Name +date: Mon Jan 12 13:46:40 1970 +0000 +summary: commit-1 + +changeset: 3:f9b58c5a6352 +tag: tip +user: foo@bar.com +date: Mon Jan 12 13:46:40 1970 +0000 +summary: commit-1 +