[PATCH] qseries: add --edit option for editing series file for current queue
Mads Kiilerich
mads at kiilerich.com
Wed Jun 16 11:10:00 CDT 2010
# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1276704454 -7200
# Node ID 494103438a6297642db2f0ca0313f29a55b35a20
# Parent db74e74ec2a6a1670dea24db10fe7979631ec69f
qseries: add --edit option for editing series file for current queue
Files in .hg should generally be edited with great care. MQ series files (such
as .hg/patches/series) must be edited manually for some common operations -
such as reordering patches. The new "multiple queues" can make it more tricky
to find and edit the right series file.
This introduces a convenient shortcut for editing the series file.
diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -1415,7 +1415,14 @@
return unapplied
def qseries(self, repo, missing=None, start=0, length=None, status=None,
- summary=False):
+ summary=False, edit=False):
+ if edit:
+ edited = repo.ui.edit('\n'.join(self.full_series) + '\n', '')
+ self.full_series = edited.splitlines()
+ self.parse_series()
+ self.series_dirty = True
+ return
+
def displayname(pfx, patchname, state):
if pfx:
self.ui.write(pfx)
@@ -1924,8 +1931,14 @@
commands.commit(r.ui, r, *pats, **opts)
def series(ui, repo, **opts):
- """print the entire series file"""
- repo.mq.qseries(repo, missing=opts['missing'], summary=opts['summary'])
+ """print the content of the series file
+
+ --edit is a shortcut for opening the series file for the current series in an
+ editor. Changes must be made with great care but can for example be used to
+ reorder patches - assuming that they are sufficiently commutative."""
+ repo.mq.qseries(repo, missing=opts['missing'], summary=opts['summary'],
+ edit=opts['edit'])
+ repo.mq.save_dirty()
return 0
def top(ui, repo, **opts):
@@ -2957,8 +2970,9 @@
"qseries":
(series,
[('m', 'missing', None, _('print patches not in series')),
+ ('e', 'edit', None, _('edit series file manually')),
] + seriesopts,
- _('hg qseries [-ms]')),
+ _('hg qseries [-mes]')),
"strip":
(strip,
[('f', 'force', None, _('force removal of changesets even if the '
diff --git a/tests/test-mq b/tests/test-mq
--- a/tests/test-mq
+++ b/tests/test-mq
@@ -176,6 +176,17 @@
hg qpush
hg sum | grep mq
+echo % qseries --edit
+cat > $HGTMP/editor <<'__EOF__'
+#!/bin/sh
+echo quux >> "$1"
+__EOF__
+chmod +x "$HGTMP"/editor
+HGEDITOR="'$HGTMP'"/editor hg qseries --edit
+hg qseries
+touch ../.hg/patches/quux
+hg qrm quux
+
echo % qapplied
hg qapplied
diff --git a/tests/test-mq.out b/tests/test-mq.out
--- a/tests/test-mq.out
+++ b/tests/test-mq.out
@@ -56,7 +56,7 @@
qrefresh update the current patch
qrename rename a patch
qselect set or print guarded patches to push
- qseries print the entire series file
+ qseries print the content of the series file
qtop print the name of the current patch
qunapplied print the patches not yet applied
strip strip a changeset and all its descendants from the repository
@@ -159,6 +159,10 @@
applying test2.patch
now at: test2.patch
mq: 2 applied
+% qseries --edit
+test.patch
+test2.patch
+quux
% qapplied
test.patch
test2.patch
More information about the Mercurial-devel
mailing list