[PATCH] qseries: add --edit option for editing .hg/patches/series
Mads Kiilerich
mads at kiilerich.com
Thu Apr 29 19:33:00 CDT 2010
# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1272587569 -7200
# Node ID 1f42f28529c18064bf6b7b5079fe792e96bd679f
# Parent f4b82fe8c10f7904582563c73334e074e211c90c
qseries: add --edit option for editing .hg/patches/series
Files in .hg should be edited with great care and are not easy to navigate to.
The file .hg/patches/series has to be edited for some common operations - such
as reordering patches.
This introduces a convenient shortcut for editing the series file.
I assume that the help text needs some proofreading and bike shedding...
diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -1413,7 +1413,13 @@
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)
@@ -1922,8 +1928,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 .hg/patches/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):
@@ -2794,8 +2806,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 with local changes')),
diff --git a/tests/test-mq b/tests/test-mq
--- a/tests/test-mq
+++ b/tests/test-mq
@@ -172,6 +172,17 @@
hg qseries -vs
hg qpush
+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
@@ -52,7 +52,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 revision and all its descendants from the repository
@@ -153,6 +153,10 @@
1 U test2.patch:
applying test2.patch
now at: test2.patch
+% qseries --edit
+test.patch
+test2.patch
+quux
% qapplied
test.patch
test2.patch
More information about the Mercurial-devel
mailing list