Patchwork [01,of,11,V2] obsolete: add a devel.user.obsmarker

login
register
mail settings
Submitter Boris Feld
Date Oct. 11, 2017, 12:09 p.m.
Message ID <1a50fb1db6c838a78c0c.1507723787@FB>
Download mbox | patch
Permalink /patch/24722/
State Accepted
Headers show

Comments

Boris Feld - Oct. 11, 2017, 12:09 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1507299324 -7200
#      Fri Oct 06 16:15:24 2017 +0200
# Node ID 1a50fb1db6c838a78c0c170a0284202dfa973a2b
# Parent  4a6a337f9c682bdf1659295f871dc43ff33677ca
# EXP-Topic obsfatekeyword
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 1a50fb1db6c8
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'.

Patch

diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -158,6 +158,9 @@ 
 coreconfigitem('devel', 'warn-config-default',
     default=None,
 )
+coreconfigitem('devel', 'user.obsmarker',
+    default=None,
+)
 coreconfigitem('diff', 'nodates',
     default=None,
 )
diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -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',
diff --git a/tests/test-obsmarker-template.t b/tests/test-obsmarker-template.t
--- a/tests/test-obsmarker-template.t
+++ b/tests/test-obsmarker-template.t
@@ -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