record.py
150 lines
| 4.9 KiB
| text/x-python
|
PythonLexer
/ hgext / record.py
Bryan O'Sullivan
|
r5037 | # record.py | ||
# | ||||
# Copyright 2007 Bryan O'Sullivan <bos@serpentine.com> | ||||
# | ||||
Martin Geisler
|
r8225 | # This software may be used and distributed according to the terms of the | ||
Matt Mackall
|
r10263 | # GNU General Public License version 2 or any later version. | ||
Bryan O'Sullivan
|
r5037 | |||
Pierre-Yves David
|
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
|
r28381 | from __future__ import absolute_import | ||
Bryan O'Sullivan
|
r5037 | |||
Yuya Nishihara
|
r29205 | from mercurial.i18n import _ | ||
timeless
|
r28381 | from mercurial import ( | ||
cmdutil, | ||||
commands, | ||||
error, | ||||
extensions, | ||||
Yuya Nishihara
|
r32337 | registrar, | ||
timeless
|
r28381 | ) | ||
Bryan O'Sullivan
|
r5037 | |||
Idan Kamara
|
r14408 | cmdtable = {} | ||
Yuya Nishihara
|
r32337 | command = registrar.command(cmdtable) | ||
Augie Fackler
|
r29841 | # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for | ||
Augie Fackler
|
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
|
r29841 | testedwith = 'ships-with-hg-core' | ||
Idan Kamara
|
r14408 | |||
Bryan O'Sullivan
|
r5037 | |||
Idan Kamara
|
r14408 | @command("record", | ||
Ingo Proetel
|
r14597 | # same options as commit + white space diff options | ||
Rodrigo Damazio
|
r40331 | [c for c in commands.table['commit|ci'][1][:] | ||
Yuya Nishihara
|
r32375 | if c[1] != "interactive"] + cmdutil.diffwsopts, | ||
rdamazio@google.com
|
r40329 | _('hg record [OPTION]... [FILE]...'), | ||
helpcategory=command.CATEGORY_COMMITTING) | ||||
Bryan O'Sullivan
|
r5037 | def record(ui, repo, *pats, **opts): | ||
Bryan O'Sullivan
|
r5154 | '''interactively select changes to commit | ||
Martin Geisler
|
r10973 | If a list of files is omitted, all changes reported by :hg:`status` | ||
Martin Geisler
|
r9272 | will be candidates for recording. | ||
Bryan O'Sullivan
|
r5154 | |||
Martin Geisler
|
r10973 | See :hg:`help dates` for a list of formats valid for -d/--date. | ||
Thomas Arendsen Hein
|
r6163 | |||
eloimorlaas
|
r31065 | If using the text interface (see :hg:`help config`), | ||
you will be prompted for whether to record changes to each | ||||
Martin Geisler
|
r9272 | modified file, and for files with multiple changes, for each | ||
change to use. For each query, the following responses are | ||||
possible:: | ||||
Bryan O'Sullivan
|
r5154 | |||
Martin Geisler
|
r9157 | y - record this change | ||
n - skip this change | ||||
A. S. Budden
|
r16324 | e - edit this change manually | ||
Bryan O'Sullivan
|
r5154 | |||
Martin Geisler
|
r9157 | s - skip remaining changes to this file | ||
f - record remaining changes to this file | ||||
Bryan O'Sullivan
|
r5154 | |||
Martin Geisler
|
r9157 | d - done, skip remaining changes and files | ||
a - record all changes to all remaining files | ||||
q - quit, recording no changes | ||||
Bryan O'Sullivan
|
r5154 | |||
Nicolas Dumazet
|
r11237 | ? - display help | ||
This command is not available when committing a merge.''' | ||||
Bryan O'Sullivan
|
r5037 | |||
FUJIWARA Katsunori
|
r25796 | if not ui.interactive(): | ||
Pierre-Yves David
|
r26587 | raise error.Abort(_('running non-interactively, use %s instead') % | ||
FUJIWARA Katsunori
|
r25796 | 'commit') | ||
Pulkit Goyal
|
r35404 | opts[r"interactive"] = True | ||
Jun Wu
|
r31458 | overrides = {('experimental', 'crecord'): False} | ||
with ui.configoverride(overrides, 'record'): | ||||
Philippe Pepiot
|
r30158 | return commands.commit(ui, repo, *pats, **opts) | ||
Kirill Smelkov
|
r5830 | |||
Matt Mackall
|
r15184 | def qrefresh(origfn, ui, repo, *pats, **opts): | ||
Pulkit Goyal
|
r35404 | if not opts[r'interactive']: | ||
Matt Mackall
|
r15184 | return origfn(ui, repo, *pats, **opts) | ||
Idan Kamara
|
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
|
r25798 | cmdutil.dorecord(ui, repo, committomq, None, True, | ||
Laurent Charignon
|
r24309 | cmdutil.recordfilter, *pats, **opts) | ||
Kirill Smelkov
|
r5830 | |||
Gregory Szorc
|
r21251 | # This command registration is replaced during uisetup(). | ||
Gregory Szorc
|
r21787 | @command('qrecord', | ||
[], | ||||
_('hg qrecord [OPTION]... PATCH [FILE]...'), | ||||
rdamazio@google.com
|
r40329 | helpcategory=command.CATEGORY_COMMITTING, | ||
Gregory Szorc
|
r21787 | inferrepo=True) | ||
Kirill Smelkov
|
r5932 | def qrecord(ui, repo, patch, *pats, **opts): | ||
'''interactively record a new patch | ||||
Kirill Smelkov
|
r5830 | |||
Martin Geisler
|
r10973 | See :hg:`help qnew` & :hg:`help record` for more information and | ||
Martin Geisler
|
r9272 | usage. | ||
Kirill Smelkov
|
r5830 | ''' | ||
FUJIWARA Katsunori
|
r25797 | return _qrecord('qnew', ui, repo, patch, *pats, **opts) | ||
Kirill Smelkov
|
r5830 | |||
FUJIWARA Katsunori
|
r25797 | def _qrecord(cmdsuggest, ui, repo, patch, *pats, **opts): | ||
Kirill Smelkov
|
r5830 | try: | ||
mq = extensions.find('mq') | ||||
except KeyError: | ||||
Pierre-Yves David
|
r26587 | raise error.Abort(_("'mq' extension not loaded")) | ||
Kirill Smelkov
|
r5830 | |||
Idan Kamara
|
r14424 | repo.mq.checkpatchname(patch) | ||
Dan Villiom Podlaski Christiansen
|
r10323 | def committomq(ui, repo, *pats, **opts): | ||
Pulkit Goyal
|
r35404 | opts[r'checkname'] = False | ||
Kirill Smelkov
|
r5932 | mq.new(ui, repo, patch, *pats, **opts) | ||
Kirill Smelkov
|
r5830 | |||
Jun Wu
|
r31458 | overrides = {('experimental', 'crecord'): False} | ||
with ui.configoverride(overrides, 'record'): | ||||
FUJIWARA Katsunori
|
r25797 | cmdutil.dorecord(ui, repo, committomq, cmdsuggest, False, | ||
Laurent Charignon
|
r25223 | cmdutil.recordfilter, *pats, **opts) | ||
Kirill Smelkov
|
r5827 | |||
Matt Mackall
|
r15184 | def qnew(origfn, ui, repo, patch, *args, **opts): | ||
Pulkit Goyal
|
r35404 | if opts[r'interactive']: | ||
FUJIWARA Katsunori
|
r25797 | return _qrecord(None, ui, repo, patch, *args, **opts) | ||
Matt Mackall
|
r15184 | return origfn(ui, repo, patch, *args, **opts) | ||
Bryan O'Sullivan
|
r5037 | |||
Martin Geisler
|
r9710 | def uisetup(ui): | ||
Kirill Smelkov
|
r5830 | try: | ||
mq = extensions.find('mq') | ||||
except KeyError: | ||||
return | ||||
Augie Fackler
|
r41925 | cmdtable["qrecord"] = ( | ||
qrecord, | ||||
# same options as qnew, but copy them so we don't get | ||||
# -i/--interactive for qrecord and add white space diff options | ||||
mq.cmdtable['qnew'][1][:] + cmdutil.diffwsopts, | ||||
_('hg qrecord [OPTION]... PATCH [FILE]...')) | ||||
Idan Kamara
|
r14426 | |||
Matt Mackall
|
r15184 | _wrapcmd('qnew', mq.cmdtable, qnew, _("interactively record a new patch")) | ||
Idan Kamara
|
r14426 | _wrapcmd('qrefresh', mq.cmdtable, qrefresh, | ||
_("interactively select changes to refresh")) | ||||
def _wrapcmd(cmd, table, wrapfn, msg): | ||||
Matt Mackall
|
r15184 | entry = extensions.wrapcommand(table, cmd, wrapfn) | ||
Idan Kamara
|
r14426 | entry[1].append(('i', 'interactive', None, msg)) | ||