obsolete: add a devel.user.obsmarker
authorBoris Feld <boris.feld@octobus.net>
Fri, 06 Oct 2017 16:15:24 +0200
changeset 34575 dc91580a0a88
parent 34574 05c2a9f37a1d
child 34576 50b46054b869
obsolete: add a devel.user.obsmarker In tests, we often want to use a different username in obs-markers without changing the default user. Add a 'devel.user.obsmarker'.
mercurial/configitems.py
mercurial/obsolete.py
tests/test-obsmarker-template.t
--- a/mercurial/configitems.py	Thu Oct 05 15:11:34 2017 +0200
+++ b/mercurial/configitems.py	Fri Oct 06 16:15:24 2017 +0200
@@ -158,6 +158,9 @@
 coreconfigitem('devel', 'warn-config-default',
     default=None,
 )
+coreconfigitem('devel', 'user.obsmarker',
+    default=None,
+)
 coreconfigitem('diff', 'nodates',
     default=None,
 )
--- a/mercurial/obsolete.py	Thu Oct 05 15:11:34 2017 +0200
+++ b/mercurial/obsolete.py	Fri Oct 06 16:15:24 2017 +0200
@@ -1035,7 +1035,11 @@
     if metadata is None:
         metadata = {}
     if 'user' not in metadata:
-        metadata['user'] = repo.ui.username()
+        develuser = repo.ui.config('devel', 'user.obsmarker')
+        if develuser:
+            metadata['user'] = develuser
+        else:
+            metadata['user'] = repo.ui.username()
 
     # Operation metadata handling
     useoperation = repo.ui.configbool('experimental',
--- a/tests/test-obsmarker-template.t	Thu Oct 05 15:11:34 2017 +0200
+++ b/tests/test-obsmarker-template.t	Fri Oct 06 16:15:24 2017 +0200
@@ -42,8 +42,8 @@
   $ mkcommit ROOT
   $ mkcommit A0
   $ echo 42 >> A0
-  $ HGUSER=test1 hg commit --amend -m "A1" --config devel.default-date="1234567890 0"
-  $ HGUSER=test2 hg commit --amend -m "A2" --config devel.default-date="987654321 0"
+  $ hg commit --amend -m "A1" --config devel.default-date="1234567890 0" --config devel.user.obsmarker=test1
+  $ hg commit --amend -m "A2" --config devel.default-date="987654321 0" --config devel.user.obsmarker=test2
 
   $ hg log --hidden -G
   @  changeset:   3:d004c8f274b9