Mercurial > public > mercurial-scm > hg-stable
diff hgext/mq.py @ 16656:4ae3ba9e4d7a
mq: introduce mq.check setting
When:
[mq]
check = True
is set, qpush, qpop and qgoto behave as if -c/--check were passed. If
incompatible options like -f/--force or --exact are set, this setting is
ignored.
This setting enables what many users expect mq default behaviour to be.
author | Patrick Mezard <patrick@mezard.eu> |
---|---|
date | Sat, 12 May 2012 00:19:30 +0200 |
parents | 6ca125af882f |
children | b6081c2c4647 |
line wrap: on
line diff
--- a/hgext/mq.py Sat May 12 00:19:30 2012 +0200 +++ b/hgext/mq.py Sat May 12 00:19:30 2012 +0200 @@ -46,6 +46,17 @@ You will by default be managing a patch queue named "patches". You can create other, independent patch queues with the :hg:`qqueue` command. + +If the working directory contains uncommitted files, qpush, qpop and +qgoto abort immediately. If -f/--force is used, the changes are +discarded. Setting: + + [mq] + check = True + +make them behave as if -c/--check were passed, and non-conflicting +local changes will be tolerated and preserved. If incompatible options +such as -f/--force or --exact are passed, this setting is ignored. ''' from mercurial.i18n import _ @@ -1986,6 +1997,14 @@ self.removeundo(repo) return imported +def fixcheckopts(ui, opts): + if (not ui.configbool('mq', 'check') or opts.get('force') + or opts.get('exact')): + return opts + opts = dict(opts) + opts['check'] = True + return opts + @command("qdelete|qremove|qrm", [('k', 'keep', None, _('keep patch file')), ('r', 'rev', [], @@ -2533,6 +2552,7 @@ '''push or pop patches until named patch is at top of stack Returns 0 on success.''' + opts = fixcheckopts(ui, opts) q = repo.mq patch = q.lookup(patch) nobackup = opts.get('no_backup') @@ -2687,6 +2707,7 @@ q = repo.mq mergeq = None + opts = fixcheckopts(ui, opts) if opts.get('merge'): if opts.get('name'): newpath = repo.join(opts.get('name')) @@ -2725,6 +2746,7 @@ Return 0 on success. """ + opts = fixcheckopts(ui, opts) localupdate = True if opts.get('name'): q = queue(ui, repo.path, repo.join(opts.get('name')))