##// END OF EJS Templates
pager: wrap _runcommand() no matter if stdout is redirected...
pager: wrap _runcommand() no matter if stdout is redirected We've made chg utilize the common code path implemented in pager.py (by 815e1cefd082 and 493935e0327a), but the chg server does not always start with a tty. Because of this, uisetup() of the pager extension could be skipped on the chg server. Kudos given to Sean Farley for dogfooding new chg and spotting this problem.

File last commit:

r30158:1baa0e2c default
r30847:e12553cf stable
Show More
record.py
152 lines | 4.9 KiB | text/x-python | PythonLexer
Bryan O'Sullivan
Add record extension, giving darcs-like interactive hunk picking
r5037 # record.py
#
# Copyright 2007 Bryan O'Sullivan <bos@serpentine.com>
#
Martin Geisler
updated license to be explicit about GPL version 2
r8225 # This software may be used and distributed according to the terms of the
Matt Mackall
Update license to GPLv2+
r10263 # GNU General Public License version 2 or any later version.
Bryan O'Sullivan
Add record extension, giving darcs-like interactive hunk picking
r5037
Pierre-Yves David
record: deprecate the extension...
r28697 '''commands to interactively select changes for commit/qrefresh (DEPRECATED)
The feature provided by this extension has been moved into core Mercurial as
:hg:`commit --interactive`.'''
timeless
record: use absolute_import
r28381 from __future__ import absolute_import
Bryan O'Sullivan
Add record extension, giving darcs-like interactive hunk picking
r5037
Yuya Nishihara
py3: move up symbol imports to enforce import-checker rules...
r29205 from mercurial.i18n import _
timeless
record: use absolute_import
r28381 from mercurial import (
cmdutil,
commands,
error,
extensions,
)
Bryan O'Sullivan
Add record extension, giving darcs-like interactive hunk picking
r5037
Idan Kamara
record: use cmdutil.command decorator
r14408 cmdtable = {}
command = cmdutil.command(cmdtable)
Augie Fackler
extensions: change magic "shipped with hg" string...
r29841 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
Augie Fackler
extensions: document that `testedwith = 'internal'` is special...
r25186 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
# be specifying the version(s) of Mercurial they are tested with, or
# leave the attribute unspecified.
Augie Fackler
extensions: change magic "shipped with hg" string...
r29841 testedwith = 'ships-with-hg-core'
Idan Kamara
record: use cmdutil.command decorator
r14408
Bryan O'Sullivan
Add record extension, giving darcs-like interactive hunk picking
r5037
Idan Kamara
record: use cmdutil.command decorator
r14408 @command("record",
Ingo Proetel
record: add white space diff options
r14597 # same options as commit + white space diff options
Laurent Charignon
record: add interactive option to the commit command
r24278 [c for c in commands.table['^commit|ci'][1][:]
if c[1] != "interactive"] + commands.diffwsopts,
Idan Kamara
record: use cmdutil.command decorator
r14408 _('hg record [OPTION]... [FILE]...'))
Bryan O'Sullivan
Add record extension, giving darcs-like interactive hunk picking
r5037 def record(ui, repo, *pats, **opts):
Bryan O'Sullivan
record: improve docs, improve prompts
r5154 '''interactively select changes to commit
Martin Geisler
Use hg role in help strings
r10973 If a list of files is omitted, all changes reported by :hg:`status`
Martin Geisler
record: wrap docstrings at 70 characters
r9272 will be candidates for recording.
Bryan O'Sullivan
record: improve docs, improve prompts
r5154
Martin Geisler
Use hg role in help strings
r10973 See :hg:`help dates` for a list of formats valid for -d/--date.
Thomas Arendsen Hein
Document log date ranges and mention 'hg help dates' for all commands (issue998)
r6163
Martin Geisler
record: wrap docstrings at 70 characters
r9272 You will be prompted for whether to record changes to each
modified file, and for files with multiple changes, for each
change to use. For each query, the following responses are
possible::
Bryan O'Sullivan
record: improve docs, improve prompts
r5154
Martin Geisler
commands: use minirst parser when displaying help
r9157 y - record this change
n - skip this change
A. S. Budden
record: allow splitting of hunks by manually editing patches...
r16324 e - edit this change manually
Bryan O'Sullivan
record: improve docs, improve prompts
r5154
Martin Geisler
commands: use minirst parser when displaying help
r9157 s - skip remaining changes to this file
f - record remaining changes to this file
Bryan O'Sullivan
record: improve docs, improve prompts
r5154
Martin Geisler
commands: use minirst parser when displaying help
r9157 d - done, skip remaining changes and files
a - record all changes to all remaining files
q - quit, recording no changes
Bryan O'Sullivan
record: improve docs, improve prompts
r5154
Nicolas Dumazet
record: check that we are not committing a merge before patch selection...
r11237 ? - display help
This command is not available when committing a merge.'''
Bryan O'Sullivan
Add record extension, giving darcs-like interactive hunk picking
r5037
FUJIWARA Katsunori
record: omit meaningless 'commit' suggestion at 'hg commit -i'...
r25796 if not ui.interactive():
Pierre-Yves David
error: get Abort from 'error' instead of 'util'...
r26587 raise error.Abort(_('running non-interactively, use %s instead') %
FUJIWARA Katsunori
record: omit meaningless 'commit' suggestion at 'hg commit -i'...
r25796 'commit')
Laurent Charignon
record: make record use commit -i
r24307 opts["interactive"] = True
Laurent Charignon
record: make hg record always use the non curses interface...
r25223 backup = ui.backupconfig('experimental', 'crecord')
try:
ui.setconfig('experimental', 'crecord', False, 'record')
Philippe Pepiot
record: return code from underlying commit
r30158 return commands.commit(ui, repo, *pats, **opts)
Laurent Charignon
record: make hg record always use the non curses interface...
r25223 finally:
ui.restoreconfig(backup)
Kirill Smelkov
hg qrecord -- like record, but for mq...
r5830
Matt Mackall
record: use command wrapper properly for qnew/qrefresh (issue3001)
r15184 def qrefresh(origfn, ui, repo, *pats, **opts):
if not opts['interactive']:
return origfn(ui, repo, *pats, **opts)
Idan Kamara
record: add qrefresh -i/--interactive...
r14426 mq = extensions.find('mq')
def committomq(ui, repo, *pats, **opts):
# At this point the working copy contains only changes that
# were accepted. All other changes were reverted.
# We can't pass *pats here since qrefresh will undo all other
# changed files in the patch that aren't in pats.
mq.refresh(ui, repo, **opts)
# backup all changed files
FUJIWARA Katsunori
record: omit meaningless 'qrefresh' suggestion at 'hg qrefresh -i'...
r25798 cmdutil.dorecord(ui, repo, committomq, None, True,
Laurent Charignon
record: change interface of dorecord to accept new filters...
r24309 cmdutil.recordfilter, *pats, **opts)
Kirill Smelkov
hg qrecord -- like record, but for mq...
r5830
Gregory Szorc
record: declare commands using decorator
r21251 # This command registration is replaced during uisetup().
Gregory Szorc
record: define inferrepo in command decorator
r21787 @command('qrecord',
[],
_('hg qrecord [OPTION]... PATCH [FILE]...'),
inferrepo=True)
Kirill Smelkov
qrecord: record complements commit, so qrecord should complement qnew...
r5932 def qrecord(ui, repo, patch, *pats, **opts):
'''interactively record a new patch
Kirill Smelkov
hg qrecord -- like record, but for mq...
r5830
Martin Geisler
Use hg role in help strings
r10973 See :hg:`help qnew` & :hg:`help record` for more information and
Martin Geisler
record: wrap docstrings at 70 characters
r9272 usage.
Kirill Smelkov
hg qrecord -- like record, but for mq...
r5830 '''
FUJIWARA Katsunori
record: omit meaningless 'qnew' suggestion at 'hg qnew -i'...
r25797 return _qrecord('qnew', ui, repo, patch, *pats, **opts)
Kirill Smelkov
hg qrecord -- like record, but for mq...
r5830
FUJIWARA Katsunori
record: omit meaningless 'qnew' suggestion at 'hg qnew -i'...
r25797 def _qrecord(cmdsuggest, ui, repo, patch, *pats, **opts):
Kirill Smelkov
hg qrecord -- like record, but for mq...
r5830 try:
mq = extensions.find('mq')
except KeyError:
Pierre-Yves David
error: get Abort from 'error' instead of 'util'...
r26587 raise error.Abort(_("'mq' extension not loaded"))
Kirill Smelkov
hg qrecord -- like record, but for mq...
r5830
Idan Kamara
record: check patch name is valid before prompting in qrecord
r14424 repo.mq.checkpatchname(patch)
Dan Villiom Podlaski Christiansen
record: function variable naming & signature cleanup....
r10323 def committomq(ui, repo, *pats, **opts):
Idan Kamara
record: check patch name is valid before prompting in qrecord
r14424 opts['checkname'] = False
Kirill Smelkov
qrecord: record complements commit, so qrecord should complement qnew...
r5932 mq.new(ui, repo, patch, *pats, **opts)
Kirill Smelkov
hg qrecord -- like record, but for mq...
r5830
Laurent Charignon
record: make hg record always use the non curses interface...
r25223 backup = ui.backupconfig('experimental', 'crecord')
try:
ui.setconfig('experimental', 'crecord', False, 'record')
FUJIWARA Katsunori
record: omit meaningless 'qnew' suggestion at 'hg qnew -i'...
r25797 cmdutil.dorecord(ui, repo, committomq, cmdsuggest, False,
Laurent Charignon
record: make hg record always use the non curses interface...
r25223 cmdutil.recordfilter, *pats, **opts)
finally:
ui.restoreconfig(backup)
Kirill Smelkov
record: refactor record into generic record driver...
r5827
Matt Mackall
record: use command wrapper properly for qnew/qrefresh (issue3001)
r15184 def qnew(origfn, ui, repo, patch, *args, **opts):
if opts['interactive']:
FUJIWARA Katsunori
record: omit meaningless 'qnew' suggestion at 'hg qnew -i'...
r25797 return _qrecord(None, ui, repo, patch, *args, **opts)
Matt Mackall
record: use command wrapper properly for qnew/qrefresh (issue3001)
r15184 return origfn(ui, repo, patch, *args, **opts)
Bryan O'Sullivan
Add record extension, giving darcs-like interactive hunk picking
r5037
Martin Geisler
record: use uisetup instead of extsetup to register qrecord...
r9710 def uisetup(ui):
Kirill Smelkov
hg qrecord -- like record, but for mq...
r5830 try:
mq = extensions.find('mq')
except KeyError:
return
Idan Kamara
record: use cmdutil.command decorator
r14408 cmdtable["qrecord"] = \
Idan Kamara
record: alias qrecord to qnew -i/--interactive
r14427 (qrecord,
# same options as qnew, but copy them so we don't get
Ingo Proetel
record: add white space diff options
r14597 # -i/--interactive for qrecord and add white space diff options
Jordi GutiƩrrez Hermoso
record: use commands.diffwsopts instead of ad-hoc diffopts...
r20300 mq.cmdtable['^qnew'][1][:] + commands.diffwsopts,
Idan Kamara
record: use cmdutil.command decorator
r14408 _('hg qrecord [OPTION]... PATCH [FILE]...'))
Idan Kamara
record: add qrefresh -i/--interactive...
r14426
Matt Mackall
record: use command wrapper properly for qnew/qrefresh (issue3001)
r15184 _wrapcmd('qnew', mq.cmdtable, qnew, _("interactively record a new patch"))
Idan Kamara
record: add qrefresh -i/--interactive...
r14426 _wrapcmd('qrefresh', mq.cmdtable, qrefresh,
_("interactively select changes to refresh"))
def _wrapcmd(cmd, table, wrapfn, msg):
Matt Mackall
record: use command wrapper properly for qnew/qrefresh (issue3001)
r15184 entry = extensions.wrapcommand(table, cmd, wrapfn)
Idan Kamara
record: add qrefresh -i/--interactive...
r14426 entry[1].append(('i', 'interactive', None, msg))