# HG changeset patch # User Benoit Boissinot # Date 1161203043 -7200 # Node ID 8b55c0ba8048a60c2653ca0e4044a39c1c0ced6f # Parent 2d35a8d2b32dadd7dc715f2ec6ca5a67b2acf6a0 makes username mandatory diff -r 2d35a8d2b32d -r 8b55c0ba8048 doc/hgrc.5.txt --- a/doc/hgrc.5.txt Wed Oct 18 10:37:34 2006 -0700 +++ b/doc/hgrc.5.txt Wed Oct 18 22:24:03 2006 +0200 @@ -401,9 +401,8 @@ 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 -r 2d35a8d2b32d -r 8b55c0ba8048 mercurial/ui.py --- a/mercurial/ui.py Wed Oct 18 10:37:34 2006 -0700 +++ b/mercurial/ui.py Wed Oct 18 22:24:03 2006 +0200 @@ -226,10 +226,8 @@ 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 @@ 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 -r 2d35a8d2b32d -r 8b55c0ba8048 mercurial/util.py --- a/mercurial/util.py Wed Oct 18 10:37:34 2006 -0700 +++ b/mercurial/util.py Wed Oct 18 22:24:03 2006 +0200 @@ -519,20 +519,6 @@ 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 -r 2d35a8d2b32d -r 8b55c0ba8048 mercurial/util_win32.py --- a/mercurial/util_win32.py Wed Oct 18 10:37:34 2006 -0700 +++ b/mercurial/util_win32.py Wed Oct 18 22:24:03 2006 +0200 @@ -297,5 +297,3 @@ win32file.SetEndOfFile(self.handle) except pywintypes.error, err: raise WinIOError(err) - -getuser_fallback = win32api.GetUserName diff -r 2d35a8d2b32d -r 8b55c0ba8048 tests/test-committer --- a/tests/test-committer Wed Oct 18 10:37:34 2006 -0700 +++ b/tests/test-committer Wed Oct 18 22:24:03 2006 +0200 @@ -10,3 +10,17 @@ 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 -r 2d35a8d2b32d -r 8b55c0ba8048 tests/test-committer.out --- a/tests/test-committer.out Wed Oct 18 10:37:34 2006 -0700 +++ b/tests/test-committer.out Wed Oct 18 22:24:03 2006 +0200 @@ -4,3 +4,24 @@ date: Mon Jan 12 13:46:40 1970 +0000 summary: commit-1 +abort: No default username available, use -u +transaction abort! +rollback completed +changeset: 1:2becd0bae6e6 +tag: tip +user: foo@bar.com +date: Mon Jan 12 13:46:40 1970 +0000 +summary: commit-1 + +changeset: 2:7a0176714f78 +tag: tip +user: foobar +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 +