Mercurial > hg
changeset 3466:8b55c0ba8048
makes username mandatory
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Wed, 18 Oct 2006 22:24:03 +0200 |
parents | 2d35a8d2b32d |
children | 2b3b703b3a2b |
files | doc/hgrc.5.txt mercurial/ui.py mercurial/util.py mercurial/util_win32.py tests/test-committer tests/test-committer.out |
diffstat | 6 files changed, 40 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- 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 - <fred@example.com>". Default is $EMAIL or username@hostname, unless - username is set to an empty string, which enforces specifying the - username manually. + <fred@example.com>". 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.
--- 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):
--- 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")
--- 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
--- 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 <foo@bar.com>" >> .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
--- 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 <foo@bar.com> +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 +