diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -978,7 +978,7 @@ class queue(object): raise util.Abort(_("patch %s not in series") % patch) def push(self, repo, patch=None, force=False, list=False, - mergeq=None, all=False): + mergeq=None, all=False, move=False): diffopts = self.diffopts() wlock = repo.wlock() try: @@ -1034,6 +1034,15 @@ class queue(object): if not force: self.check_localchanges(repo) + if move: + try: + del self.full_series[self.full_series.index(patch, start)] + except ValueError: + raise util.Abort(_("patch '%s' not found") % patch) + self.full_series.insert(start, patch) + self.parse_series() + self.series_dirty = 1 + self.applied_dirty = 1 if start > 0: self.check_toppatch(repo) @@ -2222,7 +2231,7 @@ def push(ui, repo, patch=None, **opts): mergeq = queue(ui, repo.join(""), newpath) ui.warn(_("merging with queue at: %s\n") % mergeq.path) ret = q.push(repo, patch, force=opts['force'], list=opts['list'], - mergeq=mergeq, all=opts.get('all')) + mergeq=mergeq, all=opts.get('all'), move=opts.get('move')) return ret def pop(ui, repo, patch=None, **opts): @@ -2735,8 +2744,9 @@ cmdtable = { ('l', 'list', None, _('list patch name in commit text')), ('a', 'all', None, _('apply all patches')), ('m', 'merge', None, _('merge from another queue (DEPRECATED)')), - ('n', 'name', '', _('merge queue name (DEPRECATED)'))], - _('hg qpush [-f] [-l] [-a] [-m] [-n NAME] [PATCH | INDEX]')), + ('n', 'name', '', _('merge queue name (DEPRECATED)')), + ('', 'move', None, _('reorder patch series and apply only the patch'))], + _('hg qpush [-f] [-l] [-a] [-m] [-n NAME] [--move] [PATCH | INDEX]')), "^qrefresh": (refresh, [('e', 'edit', None, _('edit commit message')), diff --git a/tests/test-mq b/tests/test-mq --- a/tests/test-mq +++ b/tests/test-mq @@ -219,6 +219,19 @@ hg qpop test2.patch-1 hg qpop test2.patch-2 hg qpush test1b.patch+1 +echo % qpush --move +hg qpop -a +hg qpush --move test2.patch # move to front +hg qpush --move test1b.patch +hg qpush --move test.patch # noop move +hg qseries -v +hg qpop -a +hg qpush --move test.patch # cleaning up +hg qpush --move test1b.patch +hg qpush --move bogus # nonexistent patch +hg qpush --move test.patch # already applied +hg qpush + echo % pop, qapplied, qunapplied hg qseries -v echo % qapplied -1 test.patch diff --git a/tests/test-mq.out b/tests/test-mq.out --- a/tests/test-mq.out +++ b/tests/test-mq.out @@ -193,6 +193,32 @@ now at: test.patch applying test1b.patch applying test2.patch now at: test2.patch +% qpush --move +popping test2.patch +popping test1b.patch +popping test.patch +patch queue now empty +applying test2.patch +now at: test2.patch +applying test1b.patch +now at: test1b.patch +applying test.patch +now at: test.patch +0 A test2.patch +1 A test1b.patch +2 A test.patch +popping test.patch +popping test1b.patch +popping test2.patch +patch queue now empty +applying test.patch +now at: test.patch +applying test1b.patch +now at: test1b.patch +abort: patch bogus not in series +abort: cannot push to a previous patch: test.patch +applying test2.patch +now at: test2.patch % pop, qapplied, qunapplied 0 A test.patch 1 A test1b.patch