mq: do not call ui.username unless it is necessary
authorMartin Geisler <mg@lazybytes.net>
Sat, 07 Nov 2009 00:13:05 +0100
changeset 9733 f16ec85f125c
parent 9732 092bcf431562
child 9734 36c388a1aa51
mq: do not call ui.username unless it is necessary After changeset c63c336ee2f7, ui.username will abort by default if no username is set. It is therefore wrong to call ui.username when a username was provided on the command line.
hgext/mq.py
tests/test-mq-qnew
tests/test-mq-qnew.out
--- a/hgext/mq.py	Fri Nov 06 22:54:51 2009 +0100
+++ b/hgext/mq.py	Sat Nov 07 00:13:05 2009 +0100
@@ -1914,11 +1914,10 @@
                      summary=opts.get('summary'))
 
 def setupheaderopts(ui, opts):
-    def do(opt, val):
-        if not opts[opt] and opts['current' + opt]:
-            opts[opt] = val
-    do('user', ui.username())
-    do('date', "%d %d" % util.makedate())
+    if not opts.get('user') and opts.get('currentuser'):
+        opts['user'] = ui.username()
+    if not opts.get('date') and opts.get('currentdate'):
+        opts['date'] = "%d %d" % util.makedate()
 
 def new(ui, repo, patch, *args, **opts):
     """create a new patch
--- a/tests/test-mq-qnew	Fri Nov 06 22:54:51 2009 +0100
+++ b/tests/test-mq-qnew	Sat Nov 07 00:13:05 2009 +0100
@@ -54,3 +54,7 @@
 hg st
 hg qnew -g -f p
 cat ../.hg/patches/p
+
+echo '% qnew -u with no username configured'
+HGUSER= hg qnew -u blue red
+cat ../.hg/patches/red
--- a/tests/test-mq-qnew.out	Fri Nov 06 22:54:51 2009 +0100
+++ b/tests/test-mq-qnew.out	Sat Nov 07 00:13:05 2009 +0100
@@ -32,3 +32,6 @@
 @@ -1,1 +1,2 @@
  b
 +b
+% qnew -u with no username configured
+From: blue
+