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 |