Mercurial > hg > crecord
changeset 61:ee97b8215eaa
Move user commands back to __init__
This allows other extensions to monkeypatch (q)crecord and dorecord
with extensions.wrapcommand.
This setup is similar e.g. to hgext.convert.__init__.py.
author | Christian Ebert <blacktrash@gmx.net> |
---|---|
date | Thu, 06 May 2010 20:15:53 +0200 |
parents | edc42ee97c41 |
children | 7ef671d7d75d |
files | crecord/__init__.py crecord/crecord_core.py |
diffstat | 2 files changed, 35 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/crecord/__init__.py +++ b/crecord/__init__.py @@ -11,7 +11,41 @@ from mercurial.i18n import _ from mercurial import commands, extensions -from crecord_core import crecord, qcrecord +from crecord_core import dorecord + +def crecord(ui, repo, *pats, **opts): + '''interactively select changes to commit + + If a list of files is omitted, all changes reported by "hg status" + will be candidates for recording. + + See 'hg help dates' for a list of formats valid for -d/--date. + + You will be shown a list of patch hunks from which you can select + those you would like to apply to the commit. + + ''' + dorecord(ui, repo, commands.commit, *pats, **opts) + + +def qcrecord(ui, repo, patch, *pats, **opts): + '''interactively record a new patch + + see 'hg help qnew' & 'hg help record' for more information and usage + ''' + + try: + mq = extensions.find('mq') + except KeyError: + raise util.Abort(_("'mq' extension not loaded")) + + def committomq(ui, repo, *pats, **opts): + mq.new(ui, repo, patch, *pats, **opts) + + opts = opts.copy() + opts['force'] = True # always 'qnew -f' + dorecord(ui, repo, committomq, *pats, **opts) + cmdtable = { "crecord":
--- a/crecord/crecord_core.py +++ b/crecord/crecord_core.py @@ -155,39 +155,3 @@ except OSError: pass return cmdutil.commit(ui, repo, recordfunc, pats, opts) - - -###### MAIN ENTRY POINTS FOR EXTENSION (crecord / qcrecord functions) ######## - -def crecord(ui, repo, *pats, **opts): - '''interactively select changes to commit - - If a list of files is omitted, all changes reported by "hg status" - will be candidates for recording. - - See 'hg help dates' for a list of formats valid for -d/--date. - - You will be shown a list of patch hunks from which you can select - those you would like to apply to the commit. - - ''' - dorecord(ui, repo, commands.commit, *pats, **opts) - - -def qcrecord(ui, repo, patch, *pats, **opts): - '''interactively record a new patch - - see 'hg help qnew' & 'hg help record' for more information and usage - ''' - - try: - mq = extensions.find('mq') - except KeyError: - raise util.Abort(_("'mq' extension not loaded")) - - def committomq(ui, repo, *pats, **opts): - mq.new(ui, repo, patch, *pats, **opts) - - opts = opts.copy() - opts['force'] = True # always 'qnew -f' - dorecord(ui, repo, committomq, *pats, **opts)