Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 126803 - Username priorities and changes
Username priorities and changes
Status: VERIFIED FIXED
Product: versioncontrol
Classification: Unclassified
Component: Mercurial
6.x
All All
: P3 (vote)
: 6.x
Assigned To: issues@versioncontrol
issues@versioncontrol
61fixes1-fixed
:
: 130508 130625 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-02-06 09:24 UTC by novakm
Modified: 2008-06-04 08:37 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
:


Attachments
Proposed patch - main_work_66767_93b93c6be87a-126803.patch (1.73 KB, text/plain)
2008-02-11 11:28 UTC, John Rice
Details
Username settings on Windows proposed patch (9.39 KB, text/plain)
2008-03-14 16:52 UTC, John Rice
Details
main_work_73381_51f01e967a06-username-part2.patch (25.45 KB, text/plain)
2008-03-26 18:37 UTC, John Rice
Details
main_out_72977_ef55c64dc8f3-username-part3.patch Unix addiitons (4.54 KB, text/plain)
2008-03-27 17:12 UTC, John Rice
Details
main_out_76499_3705fadb2f78-username-windows-gc.patch (1.11 KB, text/plain)
2008-03-31 17:58 UTC, John Rice
Details
main_work_76921_0b7d4a0c3043-username-properties-emailcheck.patch (6.36 KB, text/plain)
2008-04-02 16:13 UTC, John Rice
Details

Note You need to log in before you can comment on or make changes to this bug.
Description novakm 2008-02-06 09:24:19 UTC
At first I wanted to reopen issue #123744, but the problem is different I think
Consider following scenario:
1) Set some Mercurial User Name in Global Options - Tools | Options | Versioning | Mercurial
2) Create a new project, initialize and commit - verify that in Mercurial | Options... there is correctly the username
from step 1)
3) Make some changes, commit and verify in Mercurial | Show History that the username is really used
4) Set some other Mercurial User Name in Global Options - Tools | Options | Versioning | Mercurial
5) Make some changes and commit
result: The username in Mercurial | Options... didn't change and in Mercurial | Show History the username from step 1)
is still being used.

I guess that now the local username for repository has priority over a global one? But then I am unable to change it
since Mercurial | Options... is not editable anymore.
Comment 1 novakm 2008-02-06 09:28:41 UTC
One more question that is related to this and probably to issue #125835 as well. You can now have 3 locations of
username and other settings, am I am right?
Mercurial.ini, ~/hgrc an <project_path>/.hg/hgrc
The priorities are taken in the same order I named them (Mercurial.ini highest)?
Comment 2 John Rice 2008-02-06 09:59:55 UTC
I'll look into this:

On Windows Mercurial.ini takes the palce of ~/.hgrc on Unix

Order of priority is:
Windows: <project_path>/.hg/hgrc then if this is not set, Mercurial.ini
Unix: <project_path>/.hg/hgrc then if this is not set, ~/.hgrc
Comment 3 John Rice 2008-02-11 11:28:33 UTC
Created attachment 56426 [details]
Proposed patch - main_work_66767_93b93c6be87a-126803.patch
Comment 4 John Rice 2008-02-11 17:17:18 UTC
changeset:   66793:858b544e7729
user:        jrice@netbeans.org
date:        Mon Feb 11 11:26:01 2008 +0000
summary:     #126803: Username priorities and changes - last change was not being persisted from the Properties dialog,
unless you clicked back on a row - Ok now handles this
Comment 5 novakm 2008-02-26 11:57:50 UTC
Sorry for replying after such a long time...

Reopening as the process of determining username is not behaving as you described. There is also the ~/.hgrc on windows.
It is located in C:\Users\<username>\AppData\Roaming\Mercurial\ on Windows Vista (and I guess something like
C:\Documents and Settings\... on windows XP). It is created only when you change Mercurial User Name in options.

I've tried to figure out how it works now and it seems to me that it is like this (I am speaking about windows vista,
but will be the same for XP most probably):
1) <project_path>/.hg/hgrc
2) ~/.hgrc
3) <login_name@hostname>

The mercurial.ini is ignored as far as I tested it. I deleted username section in both <project_path>/.hg/hgrc and
~/.hgrc, inserted username in Mercurial.ini and cleared Mercurial User Name in options. When I invoked Mercurial |
Properties... there was only <login@hostname> instead of what I entered in Mercurial.ini. I checked Mercurial User Name
in options again and it was set there <login@hostname>, although it was not in the ~/.hgrc as it would be if I had
entered it manually in options.
Comment 6 John Rice 2008-02-26 16:41:09 UTC
From the hgrc doc:
http://www.selenic.com/mercurial/wiki/index.cgi/.hgrc?action=show&redirect=mercurial.ini

(Unix)    $HOME/.hgrc::
(Windows) C:\Documents and Settings\USERNAME\Mercurial.ini::
(Windows) $HOME\Mercurial.ini::
    Per-user configuration file, for the user running Mercurial.
    Options in this file apply to all Mercurial commands executed by
    any user in any directory.  Options in this file override
    per-installation and per-system options.
    On Windows system, one of these is chosen exclusively according
    to definition of HOME environment variable.

Note the comment about "On Windows system, one of these is chosen exclusively according to definition of HOME
environment variable."

With your scenario I wonder what your $Home was set to and if you delete the ~/.hgrc would the ~/Mercurial.ini settings
now be read.

Can you try this out from the command line, using a test repo and a commit to see what username is added. Where was your
Mercurial.ini located?

Order of priority might be:
Windows: <project_path>/.hg/hgrc then if this is not set, $Home/.hgrc then $Home/Mercurial.ini ???
Unix: <project_path>/.hg/hgrc then if this is not set, ~/.hgrc


Thanks.

1) <project_path>/.hg/hgrc
2) ~/.hgrc
3) <login_name@hostname>
Comment 7 novakm 2008-02-27 09:00:14 UTC
Well I've found out that I have neither $home nor anything similar variable defined. (which surprised me a bit :) So
sorry for not accurate information. Anyway, it apparently uses %userprofile%\AppData\Roaming\Mercurial\, at least on
Windows Vista. I am using tortoisehg, might that be the problem? My mercurial.ini is located in "C:\Program
Files\TortoiseHg\mercurial.ini"

I tried following scenario (with fresh userdir, no %userprofile%\AppData\Roaming\Mercurial\.hgrc or
<project_path>/.hg/hgrc existed and I did not entered anything in Options so <login_name@hostname> was there):
1) Create new project in NB, initialize and commit from netbeans - <login_name@hostname> was used
2) Modify a file and commit it from command line - again, <login_name@hostname> was used, mercurial.ini was ignored again

Then I entered some username in options (which resulted in %userprofile%\AppData\Roaming\Mercurial\.hgrc) and
3) modified a file and committed it from IDE - username from %userprofile%\AppData\Roaming\Mercurial\.hgrc was used
4) modified a file and committed it from command line - <login_name@hostname> was used

Then I entered different username using Mercurial | Options... (which resulted in <project_path>/.hg/hgrc)
5) modified a file and committed it from IDE - username from <project_path>/.hg/hgrc
6) modified a file and committed it from commandline - username from <project_path>/.hg/hgrc

I've also tried to copy mercurial.ini to %userprofile%\AppData\Roaming\Mercurial\, but it was ignored again. In short,
it didn't use mercurial.ini at all...
Comment 8 John Rice 2008-02-27 10:23:55 UTC
Just to clarify:
"Then I entered some username in [Global Mercurial Options ???] options......
Then I entered different username using Mercurial | [Properties ???] Options... "

When I look at the code its clear we are only checking for a <WINDOWS_APP_DATA>/.hgrc, <WINDOWS_USER_APP_DATA>/.hgrc or
<project_path>/.hg/hgrc and if username is not set in any just go with whatever default mercurial gives us [don't have
--user on the hg commit command line].

On windows we are not looking for the Mercurial.ini file. The code should be changed so we are using Mercurial.ini for
the user settings as opposed to the per project settings and be in agreement with the hgrc man page.

Looking at the mercurial code it is looking in:
Per-system:
<Mercurial Install>\Mercurial.ini
C:\Mercurial\Mercurial.ini

Per-user:
%HOME%\Mercurial.ini
%USERPROFILE%\Mercurial.ini
On Win < NT in:
<Parent of %APPDATA%>\Mercurial.ini

What is your $HOME set to? If you have a C:\Documents and Settings\USERNAME\Mercurial.ini or a $Home\Mercurial.ini file
with username set in it does this work from the command line?


(Windows) C:\Mercurial\Mercurial.ini
    Per-system configuration files. Options in these files override per-installation options. 
(Windows) C:\Documents and Settings\USERNAME\Mercurial.ini
(Windows) $HOME\Mercurial.ini
    Per-user configuration file, for the user running Mercurial. Options in this file override per-installation and
per-system options. 
On Windows system, one of these is chosen exclusively according to definition of HOME environment variable. 
(Unix, Windows) <repo>/.hg/hgrc
    Per-repository configuration options that only apply in a particular repository.
Comment 9 novakm 2008-02-27 11:10:35 UTC
I've checked and both in Windows XP and Vista, no %HOME% is set. It seems it can be determined concatenating %HOMEDRIVE%
and %HOMEPATH% which results in the same as %USERPROFILE%. So I think that looking %HOME%/whatever will not affect
anything on windows with default settings.
  Anyway I found, that I had another mercurial.ini in %USERPROFILE%\mercurial.ini which was probably added by prior
installation of selenic hg as tortoise does not create it. It contained username <login@hostname> which was almost
certainly causing ignoring of Mercurial.ini in tortoisehg installation folder. Sorry for the confusion it could cause. I
deleted it and now it finally uses username from Mercurial.ini if no username section is defined in
<project_path>/.hg/hgrc or <WINDOWS_APP_DATA>/.hgrc is found. Still if you invoke Mercurial | Properties..., the
username there is <username@hostname>, but the commit will use the proper one from mercurial.ini.
  As you said, following the same mechanism as in hgrc man page will be the best.
Comment 10 John Rice 2008-03-14 16:52:48 UTC
Created attachment 58401 [details]
Username settings on Windows proposed patch
Comment 11 novakm 2008-03-20 11:20:15 UTC
*** Issue 130508 has been marked as a duplicate of this issue. ***
Comment 12 novakm 2008-03-25 10:19:49 UTC
I tested the windows part of the patch, but now it seems it ignores <Mercurial Install>\Mercurial.ini. Other than that
it seems to follow the man page. I know that according to the link to the man page, only C:\Mercurial\Mercurial.ini is
checked, but I would suggest to check the <Mercurial Install>\Mercurial.ini as well as most users will probably use it.
Comment 13 John Rice 2008-03-26 18:33:31 UTC
There where a lot of inconsistencies here, when opening/closing the Options and Properties, I've done more work on the
code to clean things up. There is also a bug on Windows where the Ini4j package strips out \ of paths in any ini files
you read in, which we are now handling.

Settings are applied in the following order:

Per-installation configuration files.
(Windows) <Mercurial Install Dir>\Mercurial.ini or defaults to C:\Mercurial\Mercurial.ini
(Unix) /etc/mercurial/hgrc

Per-user configuration file, for the user running Mercurial. Options in this file override per-installation and
(Windows) %USERPROFILE%\Mercurial.ini
(Unix) ~/.hgrc

Per-repository configuration options that only apply in a particular repository.
(Unix, Windows) <repo>/.hg/hgrc

Opening Tools/Options/Micellaneous->Versioning, Mercurial:
----------------------------------------------------------
This takes username from the above Per-installation or Per-user config files if set and if not uses,
userId + "@" + hostName + ".zzz", where:
userId = System.getProperty("user.name") and 
hostName = InetAddress.getLocalHost().getHostName()
This ensures the email is vaild and changing it won't give you an error. Fixes issue in #130625.

If you do not alter the username and there is no Per-user config file, none will be created. You must alter the username
for one to be generated for you. Fixes issue in #130625.

Opening Mercurial Project Properties
-------------------------------------
This will take username from the above Per-installation, Per-user or Per-Repo config files if set and if not uses,
userId + "@" + hostName + ".zzz"

If you do not alter the username and there is no Per-Repo config file, none will be created. You must alter the username
for one to be generated for you. Fixes issue in #130625.
Comment 14 John Rice 2008-03-26 18:37:09 UTC
Created attachment 59160 [details]
main_work_73381_51f01e967a06-username-part2.patch
Comment 15 John Rice 2008-03-26 18:39:52 UTC
NOTE: both patches need to be applied:

main_work_73380_26cd68076a26-username-settings.patch
main_work_73381_51f01e967a06-username-part2.patch
Comment 16 John Rice 2008-03-26 18:41:04 UTC
*** Issue 130625 has been marked as a duplicate of this issue. ***
Comment 17 John Rice 2008-03-27 17:12:21 UTC
Created attachment 59230 [details]
main_out_72977_ef55c64dc8f3-username-part3.patch Unix addiitons
Comment 18 John Rice 2008-03-27 18:26:06 UTC
Patch comitted to head
Comment 19 novakm 2008-03-31 10:01:50 UTC
I've tested the windows part and have to reopen this issue again.
The default username in options is now correctly read from existing Mercurial.ini. If you change it in global options,
another Mercurial.ini is created in %USERPROFILE% (it is a copy of that in install location with changed username). But
then, the new username from %USERPROFILE%\Mercurial.ini is not used although it should override per-installation config
file.
Comment 20 John Rice 2008-03-31 17:58:43 UTC
Created attachment 59429 [details]
main_out_76499_3705fadb2f78-username-windows-gc.patch
Comment 21 Padraig Obriain 2008-04-01 10:49:10 UTC
Patch pushed in 154979465edd.
Comment 22 novakm 2008-04-02 10:34:57 UTC
  I've tested on windows vista and ubuntu and it looks good except for the userId + "@" + hostName + ".zzz". If you
don't have any hgrc/mercurial.ini, the userId + "@" + hostName + ".zzz" is displayed both in options and properties, but
for commit only userId + "@" + hostName is used. 
  Question is whether it does make sense to use the .zzz suffix. Maybe it would be better to use the default username as
it was before (userId@hostname) and do not insist that the username must be a valid email address in options? You see,
you can change your username to other than email address using properties so why should it be different in options?
Comment 23 John Rice 2008-04-02 16:13:09 UTC
Created attachment 59564 [details]
main_work_76921_0b7d4a0c3043-username-properties-emailcheck.patch
Comment 24 John Rice 2008-04-02 16:17:04 UTC
Removed addition of .zzz, if no username is set it defaults to userId@localhost. Still checking the email, but now
allows this format as well. Also check the username in Properties now and warns user if invalid, such as
userId@localhost. for example to be consistent with Options.

The fact that commit was using a different username than the Options and Properties was a bug.
Comment 25 John Rice 2008-04-02 16:31:52 UTC
Committed to main:

hg changeset:   77079:ff1a85f26792
tag:         tip
user:        jrice@netbeans.org
date:        Wed Apr 02 16:12:06 2008 +0100
summary:     #126803: Username email checking in properties now consistent with Options and also allows userid@localhost
Comment 26 novakm 2008-04-03 09:02:30 UTC
Finally verified in build 200804030004, thanks :)
Comment 27 rbalada 2008-04-25 17:02:21 UTC
Merged into release61_fixes repository

changeset:   77448:ff19eda2b4ed
user:        jrice@netbeans.org
date:        Wed Apr 02 16:12:06 2008 +0100
summary:     #126803: Username email checking in properties now consistent with Options and also allows userid@localhost
Comment 28 Peter Pis 2008-05-19 13:28:21 UTC
Verified on Patch1.


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo