# HG changeset patch # User Bryan O'Sullivan # Date 1178655027 25200 # Node ID 905397be7688d6ce6ecace03913efe10263d1e42 # Parent 8014159074a98f6002097bed063ebf78f61aebb8 mq: add qgoto command. diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -1762,6 +1762,17 @@ def fold(ui, repo, *files, **opts): q.delete(repo, patches, opts) q.save_dirty() +def goto(ui, repo, patch, **opts): + '''push or pop patches until named patch is at top of stack''' + q = repo.mq + patch = q.lookup(patch) + if q.isapplied(patch): + ret = q.pop(repo, patch, force=opts['force']) + else: + ret = q.push(repo, patch, force=opts['force']) + q.save_dirty() + return ret + def guard(ui, repo, *args, **opts): '''set or print guards for a patch @@ -2202,6 +2213,8 @@ cmdtable = { ('k', 'keep', None, _('keep folded patch files')) ] + commands.commitopts, 'hg qfold [-e] [-m ] [-l > $HGRCPATH +echo "mq=" >> $HGRCPATH + +hg init a +cd a +echo a > a +hg ci -Ama + +hg qnew a.patch +echo a >> a +hg qrefresh + +hg qnew b.patch +echo b > b +hg add b +hg qrefresh + +hg qnew c.patch +echo c > c +hg add c +hg qrefresh + +hg qgoto a.patch +hg qgoto c.patch +hg qgoto b.patch diff --git a/tests/test-mq-qgoto.out b/tests/test-mq-qgoto.out new file mode 100644 --- /dev/null +++ b/tests/test-mq-qgoto.out @@ -0,0 +1,6 @@ +adding a +Now at: a.patch +applying b.patch +applying c.patch +Now at: c.patch +Now at: b.patch diff --git a/tests/test-mq.out b/tests/test-mq.out --- a/tests/test-mq.out +++ b/tests/test-mq.out @@ -30,6 +30,7 @@ list of commands: qdelete remove patches from queue qdiff diff of the current patch qfold fold the named patches into the current patch + qgoto push or pop patches until named patch is at top of stack qguard set or print guards for a patch qheader Print the header of the topmost or specified patch qimport import a patch