# HG changeset patch # User Kirill Smelkov # Date 2008-01-10 09:07:18 # Node ID c32d41affb68e3c1c782c1ba7df93f150301323d # Parent 784073457a0ffc9f13367d35f6677ee7e9ab1623 hg qrecord -- like record, but for mq I'm a former Darcs user, and I've discovered that it is very convenient to actually perform development using MQ first, and only when the patches are 'ready' move them to project's history in stone. Usually I work on some topic, temporarily forgetting about any version control, and just do coding, experimenting, debugging, etc. After some time, I approach a moment, where my work should actually go to patches/commits, and here is the problem:: As it is now, there is no way to put part of the changes into one patch, and another part of the changes into second patch. This works, but only when changes are touching separate files, and for semantically different changes touching the same file(s) there is now pretty way to put them into separate patches. For some time, I've tolerated the pain to run vim patches/... and move hunks between files by hand, but I think this affects my productivity badly. So, here is the first step towards untiing the problem: Let's use 'hg qrecord' for mq, like we use 'hg record' for usual commits! diff --git a/hgext/record.py b/hgext/record.py --- a/hgext/record.py +++ b/hgext/record.py @@ -5,10 +5,10 @@ # This software may be used and distributed according to the terms of # the GNU General Public License, incorporated herein by reference. -'''interactive change selection during commit''' +'''interactive change selection during commit or qrefresh''' from mercurial.i18n import _ -from mercurial import cmdutil, commands, cmdutil, hg, mdiff, patch, revlog +from mercurial import cmdutil, commands, cmdutil, extensions, hg, mdiff, patch, revlog from mercurial import util import copy, cStringIO, errno, operator, os, re, shutil, tempfile @@ -358,10 +358,27 @@ def record(ui, repo, *pats, **opts): ? - display help''' - def record_commiter(ui, repo, pats, opts): + def record_committer(ui, repo, pats, opts): commands.commit(ui, repo, *pats, **opts) - dorecord(ui, repo, record_commiter, *pats, **opts) + dorecord(ui, repo, record_committer, *pats, **opts) + + +def qrecord(ui, repo, *pats, **opts): + '''interactively select changes for qrefresh + + see 'hg help record' for more information and usage + ''' + + try: + mq = extensions.find('mq') + except KeyError: + raise util.Abort(_("'mq' extension not loaded")) + + def qrecord_committer(ui, repo, pats, opts): + mq.refresh(ui, repo, *pats, **opts) + + dorecord(ui, repo, qrecord_committer, *pats, **opts) def dorecord(ui, repo, committer, *pats, **opts): @@ -478,8 +495,29 @@ def dorecord(ui, repo, committer, *pats, cmdtable = { "record": (record, - [('A', 'addremove', None, - _('mark new/missing files as added/removed before committing')), - ] + commands.walkopts + commands.commitopts + commands.commitopts2, + + # add commit options + commands.table['^commit|ci'][1], + _('hg record [OPTION]... [FILE]...')), } + + +def extsetup(): + try: + mq = extensions.find('mq') + except KeyError: + return + + qcmdtable = { + "qrecord": + (qrecord, + + # add qrefresh options + mq.cmdtable['^qrefresh'][1], + + _('hg qrecord [OPTION]... [FILE]...')), + } + + cmdtable.update(qcmdtable) +