Mercurial > hg
comparison hgext/record.py @ 5830:c32d41affb68
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!
author | Kirill Smelkov <kirr@mns.spb.ru> |
---|---|
date | Thu, 10 Jan 2008 12:07:18 +0300 |
parents | 0c29977bd7db |
children | b014ff3fdaeb |
comparison
equal
deleted
inserted
replaced
5829:784073457a0f | 5830:c32d41affb68 |
---|---|
3 # Copyright 2007 Bryan O'Sullivan <bos@serpentine.com> | 3 # Copyright 2007 Bryan O'Sullivan <bos@serpentine.com> |
4 # | 4 # |
5 # This software may be used and distributed according to the terms of | 5 # This software may be used and distributed according to the terms of |
6 # the GNU General Public License, incorporated herein by reference. | 6 # the GNU General Public License, incorporated herein by reference. |
7 | 7 |
8 '''interactive change selection during commit''' | 8 '''interactive change selection during commit or qrefresh''' |
9 | 9 |
10 from mercurial.i18n import _ | 10 from mercurial.i18n import _ |
11 from mercurial import cmdutil, commands, cmdutil, hg, mdiff, patch, revlog | 11 from mercurial import cmdutil, commands, cmdutil, extensions, hg, mdiff, patch, revlog |
12 from mercurial import util | 12 from mercurial import util |
13 import copy, cStringIO, errno, operator, os, re, shutil, tempfile | 13 import copy, cStringIO, errno, operator, os, re, shutil, tempfile |
14 | 14 |
15 lines_re = re.compile(r'@@ -(\d+),(\d+) \+(\d+),(\d+) @@\s*(.*)') | 15 lines_re = re.compile(r'@@ -(\d+),(\d+) \+(\d+),(\d+) @@\s*(.*)') |
16 | 16 |
356 a - record all changes to all remaining files | 356 a - record all changes to all remaining files |
357 q - quit, recording no changes | 357 q - quit, recording no changes |
358 | 358 |
359 ? - display help''' | 359 ? - display help''' |
360 | 360 |
361 def record_commiter(ui, repo, pats, opts): | 361 def record_committer(ui, repo, pats, opts): |
362 commands.commit(ui, repo, *pats, **opts) | 362 commands.commit(ui, repo, *pats, **opts) |
363 | 363 |
364 dorecord(ui, repo, record_commiter, *pats, **opts) | 364 dorecord(ui, repo, record_committer, *pats, **opts) |
365 | |
366 | |
367 def qrecord(ui, repo, *pats, **opts): | |
368 '''interactively select changes for qrefresh | |
369 | |
370 see 'hg help record' for more information and usage | |
371 ''' | |
372 | |
373 try: | |
374 mq = extensions.find('mq') | |
375 except KeyError: | |
376 raise util.Abort(_("'mq' extension not loaded")) | |
377 | |
378 def qrecord_committer(ui, repo, pats, opts): | |
379 mq.refresh(ui, repo, *pats, **opts) | |
380 | |
381 dorecord(ui, repo, qrecord_committer, *pats, **opts) | |
365 | 382 |
366 | 383 |
367 def dorecord(ui, repo, committer, *pats, **opts): | 384 def dorecord(ui, repo, committer, *pats, **opts): |
368 if not ui.interactive: | 385 if not ui.interactive: |
369 raise util.Abort(_('running non-interactively, use commit instead')) | 386 raise util.Abort(_('running non-interactively, use commit instead')) |
476 return cmdutil.commit(ui, repo, recordfunc, pats, opts) | 493 return cmdutil.commit(ui, repo, recordfunc, pats, opts) |
477 | 494 |
478 cmdtable = { | 495 cmdtable = { |
479 "record": | 496 "record": |
480 (record, | 497 (record, |
481 [('A', 'addremove', None, | 498 |
482 _('mark new/missing files as added/removed before committing')), | 499 # add commit options |
483 ] + commands.walkopts + commands.commitopts + commands.commitopts2, | 500 commands.table['^commit|ci'][1], |
501 | |
484 _('hg record [OPTION]... [FILE]...')), | 502 _('hg record [OPTION]... [FILE]...')), |
485 } | 503 } |
504 | |
505 | |
506 def extsetup(): | |
507 try: | |
508 mq = extensions.find('mq') | |
509 except KeyError: | |
510 return | |
511 | |
512 qcmdtable = { | |
513 "qrecord": | |
514 (qrecord, | |
515 | |
516 # add qrefresh options | |
517 mq.cmdtable['^qrefresh'][1], | |
518 | |
519 _('hg qrecord [OPTION]... [FILE]...')), | |
520 } | |
521 | |
522 cmdtable.update(qcmdtable) | |
523 |