config: allow 'user' in .hgrc ui section (issue3169) stable
authoranatoly techtonik <techtonik@gmail.com>
Sat, 26 Jul 2014 09:27:11 +0300
branchstable
changeset 21955 6dfb78f18bdb
parent 21954 838025b15925
child 21956 93b804fced5a
config: allow 'user' in .hgrc ui section (issue3169)
mercurial/ui.py
tests/test-committer.t
--- a/mercurial/ui.py	Wed Jul 30 14:51:56 2014 -0500
+++ b/mercurial/ui.py	Sat Jul 26 09:27:11 2014 +0300
@@ -437,7 +437,7 @@
         """
         user = os.environ.get("HGUSER")
         if user is None:
-            user = self.config("ui", "username")
+            user = self.config("ui", ["username", "user"])
             if user is not None:
                 user = os.path.expandvars(user)
         if user is None:
--- a/tests/test-committer.t	Wed Jul 30 14:51:56 2014 -0500
+++ b/tests/test-committer.t	Sat Jul 26 09:27:11 2014 +0300
@@ -52,15 +52,34 @@
   abort: no username supplied
   (use "hg config --edit" to set your username)
   [255]
+
+# test alternate config var
+
+  $ echo 1234 > asdf
+  $ echo "[ui]" > .hg/hgrc
+  $ echo "user = Foo Bar II <foo2@bar.com>" >> .hg/hgrc
+  $ hg commit -m commit-1
+  $ hg tip
+  changeset:   4:6f24bfb4c617
+  tag:         tip
+  user:        Foo Bar II <foo2@bar.com>
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     commit-1
+  
+# test no .hg/hgrc (uses generated non-interactive username)
+
+  $ echo space > asdf
   $ rm .hg/hgrc
   $ hg commit -m commit-1 2>&1
   no username found, using '[^']*' instead (re)
 
-  $ echo space > asdf
+  $ echo space2 > asdf
   $ hg commit -u ' ' -m commit-1
   transaction abort!
   rollback completed
   abort: empty username!
   [255]
 
+# don't add tests here, previous test is unstable
+
   $ cd ..