Mercurial > hg
changeset 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 |
files | hgext/mq.py tests/test-mq-qpush-fail.t tests/test-mq.t |
diffstat | 3 files changed, 66 insertions(+), 0 deletions(-) [+] |
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')))
--- a/tests/test-mq-qpush-fail.t Sat May 12 00:19:30 2012 +0200 +++ b/tests/test-mq-qpush-fail.t Sat May 12 00:19:30 2012 +0200 @@ -387,3 +387,38 @@ now at: p2 $ hg st a M a + +test mq.check setting + + $ hg --config mq.check=1 qpush + applying p3 + now at: p3 + $ hg st a + M a + $ hg --config mq.check=1 qpop + popping p3 + now at: p2 + $ hg st a + M a + $ hg --config mq.check=1 qgoto p3 + applying p3 + now at: p3 + $ hg st a + M a + $ echo b >> b + $ hg --config mq.check=1 qpop --force + popping p3 + now at: p2 + $ hg st b + $ hg --config mq.check=1 qpush --exact + abort: local changes found, refresh first + [255] + $ hg revert -qa a + $ hg qpop + popping p2 + patch queue now empty + $ echo a >> a + $ hg --config mq.check=1 qpush --force + applying p2 + now at: p2 + $ hg st a
--- a/tests/test-mq.t Sat May 12 00:19:30 2012 +0200 +++ b/tests/test-mq.t Sat May 12 00:19:30 2012 +0200 @@ -59,6 +59,15 @@ 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. + list of commands: qapplied print the patches already applied