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.
--- 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
+