Patchwork [hgext] drop unused legacy code

login
register
mail settings
Submitter Pierre-Yves David
Date April 1, 2013, 2:15 a.m.
Message ID <cf4e11a638db129ba9d4.1364782514@yamac.lan>
Download mbox | patch
Permalink /patch/1230/
State Deferred
Headers show

Comments

Pierre-Yves David - April 1, 2013, 2:15 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1364782470 -7200
# Node ID cf4e11a638db129ba9d4ef422d8b47a0ce22b9ae
# Parent  3ce3f2b059a1c1ab2b7b125a864bb48d20030f16
[hgext] drop unused legacy code

This changeset drops a very old extension that nobody is using anyway.

This is a big win for future maintenance as three thousands lines of code and
than thousands line of test can be dropped.

This solve multiple issues in the process:  issue3874, issue2358, issue2435,
issue2481, issue2610, issue2640, issue2641, issue2696, issue2952, issue2958,
issue2991, issue3284, issue3455, issue3479, issue3508, issue3824, issue2599,
issue1622, issue3647, issue3742, issue3812
tonfa - April 1, 2013, 10:56 a.m.
On Mon, Apr 1, 2013 at 4:15 AM, Pierre-Yves David <
pierre-yves.david@ens-lyon.org> wrote:

> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
> # Date 1364782470 -7200
> # Node ID cf4e11a638db129ba9d4ef422d8b47a0ce22b9ae
> # Parent  3ce3f2b059a1c1ab2b7b125a864bb48d20030f16
> [hgext] drop unused legacy code
>
> This changeset drops a very old extension that nobody is using anyway.
>
> This is a big win for future maintenance as three thousands lines of code
> and
> than thousands line of test can be dropped.
>
> This solve multiple issues in the process:  issue3874, issue2358,
> issue2435,
> issue2481, issue2610, issue2640, issue2641, issue2696, issue2952,
> issue2958,
> issue2991, issue3284, issue3455, issue3479, issue3508, issue3824,
> issue2599,
> issue1622, issue3647, issue3742, issue3812
>
> diff --git a/hgext/mq.py b/hgext/mq.py
> deleted file mode 100644
> --- a/hgext/mq.py
> +++ /dev/null
> @@ -1,3602 +0,0 @@
> -# mq.py - patch queues for mercurial
> -#
> -# Copyright 2005, 2006 Chris Mason <mason@suse.com>
> -#
> -# This software may be used and distributed according to the terms of the
> -# GNU General Public License version 2 or any later version.
>

Obviously, please keep a stub extension which documents that this extension
is to be replaced with another.

Also did you consider a reimplementation on top of obsolete?

Cheers,

Benoit
Angel Ezquerra - April 1, 2013, 11:14 a.m.
On Mon, Apr 1, 2013 at 4:15 AM, Pierre-Yves David
<pierre-yves.david@ens-lyon.org> wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
> # Date 1364782470 -7200
> # Node ID cf4e11a638db129ba9d4ef422d8b47a0ce22b9ae
> # Parent  3ce3f2b059a1c1ab2b7b125a864bb48d20030f16
> [hgext] drop unused legacy code
>
> This changeset drops a very old extension that nobody is using anyway.
>
> This is a big win for future maintenance as three thousands lines of code and
> than thousands line of test can be dropped.
>
> This solve multiple issues in the process:  issue3874, issue2358, issue2435,
> issue2481, issue2610, issue2640, issue2641, issue2696, issue2952, issue2958,
> issue2991, issue3284, issue3455, issue3479, issue3508, issue3824, issue2599,
> issue1622, issue3647, issue3742, issue3812

Nice,

in other news, did you see the new Gmail Blue
(http://www.youtube.com/watch?feature=player_embedded&v=Zr4JwPb99qU)?
:->

Angel
Bryan O'Sullivan - April 1, 2013, 3:54 p.m.
On Sun, Mar 31, 2013 at 7:15 PM, Pierre-Yves David <
pierre-yves.david@ens-lyon.org> wrote:

> [hgext] drop unused legacy code
>

Vive la révolution d'évolution!
Simon Heimberg - May 1, 2013, 5:16 p.m.
On 2013-04-01, 12:56 +0200 Benoit Boissinot wrote:

> On Mon, Apr 1, 2013 at 4:15 AM, Pierre-Yves David
> <pierre-yves.david@ens-lyon.org> wrote:
>         # HG changeset patch
>         # User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
>         # Date 1364782470 -7200
>         # Node ID cf4e11a638db129ba9d4ef422d8b47a0ce22b9ae
>         # Parent  3ce3f2b059a1c1ab2b7b125a864bb48d20030f16
>         [hgext] drop unused legacy code
>         
>         This changeset drops a very old extension that nobody is using
>         anyway.

Oops, I am nobody.

>         
>         This is a big win for future maintenance as three thousands
>         lines of code and
>         than thousands line of test can be dropped.
>         
<snip>
> 
> 
> Obviously, please keep a stub extension which documents that this
> extension is to be replaced with another.

Yes please.

For not being nobody anymore: What should I use instead of mq? 
I hope it is supported by gui tools. (mq is supported by several ones
like tortoisehg, gquilt, ...)

What is an alternative command for strip?

Maybe mq could be deprecated for one release before being removed?
(Maybe with a message when loading.)

And at least this page should get a hint at the start:
 http://mercurial.selenic.com/wiki/MqExtension
there are also many other sites refering mq. Examples:
http://mercurial.selenic.com/wiki/EditingHistory#Editing_recent_history_with_MQ
http://mercurial.selenic.com/wiki/MqTutorial
http://mercurial.selenic.com/wiki/HandlingRejects#Rejects_when_working_with_MQ (outdated? does rebase work with applied patches?)
http://mercurial.selenic.com/wiki/TipsAndTricks#Use_an_extension_only_for_one_call_.28without_editing_hgrc.29

> 
> 
> Also did you consider a reimplementation on top of obsolete?

Sounds interesting

> 
> Cheers,
> 
> 
> Benoit
Matt Mackall - May 1, 2013, 6:22 p.m.
On Wed, 2013-05-01 at 19:16 +0200, Simon Heimberg wrote:
> On 2013-04-01, 12:56 +0200 Benoit Boissinot wrote:
> 
> > On Mon, Apr 1, 2013 at 4:15 AM, Pierre-Yves David
> > <pierre-yves.david@ens-lyon.org> wrote:
> >         # HG changeset patch
> >         # User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
> >         # Date 1364782470 -7200
> >         # Node ID cf4e11a638db129ba9d4ef422d8b47a0ce22b9ae
> >         # Parent  3ce3f2b059a1c1ab2b7b125a864bb48d20030f16
> >         [hgext] drop unused legacy code
> >         
> >         This changeset drops a very old extension that nobody is using
> >         anyway.
> 
> Oops, I am nobody.

Check the date of the original post.
Simon Heimberg - May 2, 2013, 8:30 a.m.
On 2013-05-01 Matt Mackall wrote:

> >On Wed, 2013-05-01 at 19:16 +0200, Simon Heimberg wrote:
> > On 2013-04-01, 12:56 +0200 Benoit Boissinot wrote:
> > 
> > > On Mon, Apr 1, 2013 at 4:15 AM, Pierre-Yves David 
> > > <pierre-yves.david@ens-lyon.org> wrote:
> > >         # HG changeset patch
> > >         # User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
> > >         # Date 1364782470 -7200
> > >         # Node ID cf4e11a638db129ba9d4ef422d8b47a0ce22b9ae
> > >         # Parent  3ce3f2b059a1c1ab2b7b125a864bb48d20030f16
> > >         [hgext] drop unused legacy code
> > >         
> > >         This changeset drops a very old extension that nobody is using
> > >         anyway.
> > 
> > Oops, I am nobody.
>
> Check the date of the original post.

Got it.
Thank you for the hint.

And congratulation to Pierre-Yves David.

> --
> Mathematics is the supreme nostalgia of our time.

Patch

diff --git a/hgext/mq.py b/hgext/mq.py
deleted file mode 100644
--- a/hgext/mq.py
+++ /dev/null
@@ -1,3602 +0,0 @@ 
-# mq.py - patch queues for mercurial
-#
-# Copyright 2005, 2006 Chris Mason <mason@suse.com>
-#
-# This software may be used and distributed according to the terms of the
-# GNU General Public License version 2 or any later version.
-
-'''manage a stack of patches
-
-This extension lets you work with a stack of patches in a Mercurial
-repository. It manages two stacks of patches - all known patches, and
-applied patches (subset of known patches).
-
-Known patches are represented as patch files in the .hg/patches
-directory. Applied patches are both patch files and changesets.
-
-Common tasks (use :hg:`help command` for more details)::
-
-  create new patch                          qnew
-  import existing patch                     qimport
-
-  print patch series                        qseries
-  print applied patches                     qapplied
-
-  add known patch to applied stack          qpush
-  remove patch from applied stack           qpop
-  refresh contents of top applied patch     qrefresh
-
-By default, mq will automatically use git patches when required to
-avoid losing file mode changes, copy records, binary files or empty
-files creations or deletions. This behaviour can be configured with::
-
-  [mq]
-  git = auto/keep/yes/no
-
-If set to 'keep', mq will obey the [diff] section configuration while
-preserving existing git patches upon qrefresh. If set to 'yes' or
-'no', mq will override the [diff] section and always generate git or
-regular patches, possibly losing data in the second case.
-
-It may be desirable for mq changesets to be kept in the secret phase (see
-:hg:`help phases`), which can be enabled with the following setting::
-
-  [mq]
-  secret = True
-
-You will by default be managing a patch queue named "patches". You can
-create other, independent patch queues with the :hg:`qqueue` command.
-
-If the working directory contains uncommitted files, qpush, qpop and
-qgoto abort immediately. If -f/--force is used, the changes are
-discarded. Setting::
-
-  [mq]
-  keepchanges = True
-
-make them behave as if --keep-changes were passed, and non-conflicting
-local changes will be tolerated and preserved. If incompatible options
-such as -f/--force or --exact are passed, this setting is ignored.
-'''
-
-from mercurial.i18n import _
-from mercurial.node import bin, hex, short, nullid, nullrev
-from mercurial.lock import release
-from mercurial import commands, cmdutil, hg, scmutil, util, revset
-from mercurial import repair, extensions, error, phases
-from mercurial import patch as patchmod
-import os, re, errno, shutil
-
-commands.norepo += " qclone"
-
-seriesopts = [('s', 'summary', None, _('print first line of patch header'))]
-
-cmdtable = {}
-command = cmdutil.command(cmdtable)
-testedwith = 'internal'
-
-# Patch names looks like unix-file names.
-# They must be joinable with queue directory and result in the patch path.
-normname = util.normpath
-
-class statusentry(object):
-    def __init__(self, node, name):
-        self.node, self.name = node, name
-    def __repr__(self):
-        return hex(self.node) + ':' + self.name
-
-class patchheader(object):
-    def __init__(self, pf, plainmode=False):
-        def eatdiff(lines):
-            while lines:
-                l = lines[-1]
-                if (l.startswith("diff -") or
-                    l.startswith("Index:") or
-                    l.startswith("===========")):
-                    del lines[-1]
-                else:
-                    break
-        def eatempty(lines):
-            while lines:
-                if not lines[-1].strip():
-                    del lines[-1]
-                else:
-                    break
-
-        message = []
-        comments = []
-        user = None
-        date = None
-        parent = None
-        format = None
-        subject = None
-        branch = None
-        nodeid = None
-        diffstart = 0
-
-        for line in file(pf):
-            line = line.rstrip()
-            if (line.startswith('diff --git')
-                or (diffstart and line.startswith('+++ '))):
-                diffstart = 2
-                break
-            diffstart = 0 # reset
-            if line.startswith("--- "):
-                diffstart = 1
-                continue
-            elif format == "hgpatch":
-                # parse values when importing the result of an hg export
-                if line.startswith("# User "):
-                    user = line[7:]
-                elif line.startswith("# Date "):
-                    date = line[7:]
-                elif line.startswith("# Parent "):
-                    parent = line[9:].lstrip()
-                elif line.startswith("# Branch "):
-                    branch = line[9:]
-                elif line.startswith("# Node ID "):
-                    nodeid = line[10:]
-                elif not line.startswith("# ") and line:
-                    message.append(line)
-                    format = None
-            elif line == '# HG changeset patch':
-                message = []
-                format = "hgpatch"
-            elif (format != "tagdone" and (line.startswith("Subject: ") or
-                                           line.startswith("subject: "))):
-                subject = line[9:]
-                format = "tag"
-            elif (format != "tagdone" and (line.startswith("From: ") or
-                                           line.startswith("from: "))):
-                user = line[6:]
-                format = "tag"
-            elif (format != "tagdone" and (line.startswith("Date: ") or
-                                           line.startswith("date: "))):
-                date = line[6:]
-                format = "tag"
-            elif format == "tag" and line == "":
-                # when looking for tags (subject: from: etc) they
-                # end once you find a blank line in the source
-                format = "tagdone"
-            elif message or line:
-                message.append(line)
-            comments.append(line)
-
-        eatdiff(message)
-        eatdiff(comments)
-        # Remember the exact starting line of the patch diffs before consuming
-        # empty lines, for external use by TortoiseHg and others
-        self.diffstartline = len(comments)
-        eatempty(message)
-        eatempty(comments)
-
-        # make sure message isn't empty
-        if format and format.startswith("tag") and subject:
-            message.insert(0, "")
-            message.insert(0, subject)
-
-        self.message = message
-        self.comments = comments
-        self.user = user
-        self.date = date
-        self.parent = parent
-        # nodeid and branch are for external use by TortoiseHg and others
-        self.nodeid = nodeid
-        self.branch = branch
-        self.haspatch = diffstart > 1
-        self.plainmode = plainmode
-
-    def setuser(self, user):
-        if not self.updateheader(['From: ', '# User '], user):
-            try:
-                patchheaderat = self.comments.index('# HG changeset patch')
-                self.comments.insert(patchheaderat + 1, '# User ' + user)
-            except ValueError:
-                if self.plainmode or self._hasheader(['Date: ']):
-                    self.comments = ['From: ' + user] + self.comments
-                else:
-                    tmp = ['# HG changeset patch', '# User ' + user, '']
-                    self.comments = tmp + self.comments
-        self.user = user
-
-    def setdate(self, date):
-        if not self.updateheader(['Date: ', '# Date '], date):
-            try:
-                patchheaderat = self.comments.index('# HG changeset patch')
-                self.comments.insert(patchheaderat + 1, '# Date ' + date)
-            except ValueError:
-                if self.plainmode or self._hasheader(['From: ']):
-                    self.comments = ['Date: ' + date] + self.comments
-                else:
-                    tmp = ['# HG changeset patch', '# Date ' + date, '']
-                    self.comments = tmp + self.comments
-        self.date = date
-
-    def setparent(self, parent):
-        if not self.updateheader(['# Parent '], parent):
-            try:
-                patchheaderat = self.comments.index('# HG changeset patch')
-                self.comments.insert(patchheaderat + 1, '# Parent ' + parent)
-            except ValueError:
-                pass
-        self.parent = parent
-
-    def setmessage(self, message):
-        if self.comments:
-            self._delmsg()
-        self.message = [message]
-        self.comments += self.message
-
-    def updateheader(self, prefixes, new):
-        '''Update all references to a field in the patch header.
-        Return whether the field is present.'''
-        res = False
-        for prefix in prefixes:
-            for i in xrange(len(self.comments)):
-                if self.comments[i].startswith(prefix):
-                    self.comments[i] = prefix + new
-                    res = True
-                    break
-        return res
-
-    def _hasheader(self, prefixes):
-        '''Check if a header starts with any of the given prefixes.'''
-        for prefix in prefixes:
-            for comment in self.comments:
-                if comment.startswith(prefix):
-                    return True
-        return False
-
-    def __str__(self):
-        if not self.comments:
-            return ''
-        return '\n'.join(self.comments) + '\n\n'
-
-    def _delmsg(self):
-        '''Remove existing message, keeping the rest of the comments fields.
-        If comments contains 'subject: ', message will prepend
-        the field and a blank line.'''
-        if self.message:
-            subj = 'subject: ' + self.message[0].lower()
-            for i in xrange(len(self.comments)):
-                if subj == self.comments[i].lower():
-                    del self.comments[i]
-                    self.message = self.message[2:]
-                    break
-        ci = 0
-        for mi in self.message:
-            while mi != self.comments[ci]:
-                ci += 1
-            del self.comments[ci]
-
-def newcommit(repo, phase, *args, **kwargs):
-    """helper dedicated to ensure a commit respect mq.secret setting
-
-    It should be used instead of repo.commit inside the mq source for operation
-    creating new changeset.
-    """
-    repo = repo.unfiltered()
-    if phase is None:
-        if repo.ui.configbool('mq', 'secret', False):
-            phase = phases.secret
-    if phase is not None:
-        backup = repo.ui.backupconfig('phases', 'new-commit')
-    # Marking the repository as committing an mq patch can be used
-    # to optimize operations like branchtags().
-    repo._committingpatch = True
-    try:
-        if phase is not None:
-            repo.ui.setconfig('phases', 'new-commit', phase)
-        return repo.commit(*args, **kwargs)
-    finally:
-        repo._committingpatch = False
-        if phase is not None:
-            repo.ui.restoreconfig(backup)
-
-class AbortNoCleanup(error.Abort):
-    pass
-
-class queue(object):
-    def __init__(self, ui, path, patchdir=None):
-        self.basepath = path
-        try:
-            fh = open(os.path.join(path, 'patches.queue'))
-            cur = fh.read().rstrip()
-            fh.close()
-            if not cur:
-                curpath = os.path.join(path, 'patches')
-            else:
-                curpath = os.path.join(path, 'patches-' + cur)
-        except IOError:
-            curpath = os.path.join(path, 'patches')
-        self.path = patchdir or curpath
-        self.opener = scmutil.opener(self.path)
-        self.ui = ui
-        self.applieddirty = False
-        self.seriesdirty = False
-        self.added = []
-        self.seriespath = "series"
-        self.statuspath = "status"
-        self.guardspath = "guards"
-        self.activeguards = None
-        self.guardsdirty = False
-        # Handle mq.git as a bool with extended values
-        try:
-            gitmode = ui.configbool('mq', 'git', None)
-            if gitmode is None:
-                raise error.ConfigError
-            self.gitmode = gitmode and 'yes' or 'no'
-        except error.ConfigError:
-            self.gitmode = ui.config('mq', 'git', 'auto').lower()
-        self.plainmode = ui.configbool('mq', 'plain', False)
-
-    @util.propertycache
-    def applied(self):
-        def parselines(lines):
-            for l in lines:
-                entry = l.split(':', 1)
-                if len(entry) > 1:
-                    n, name = entry
-                    yield statusentry(bin(n), name)
-                elif l.strip():
-                    self.ui.warn(_('malformated mq status line: %s\n') % entry)
-                # else we ignore empty lines
-        try:
-            lines = self.opener.read(self.statuspath).splitlines()
-            return list(parselines(lines))
-        except IOError, e:
-            if e.errno == errno.ENOENT:
-                return []
-            raise
-
-    @util.propertycache
-    def fullseries(self):
-        try:
-            return self.opener.read(self.seriespath).splitlines()
-        except IOError, e:
-            if e.errno == errno.ENOENT:
-                return []
-            raise
-
-    @util.propertycache
-    def series(self):
-        self.parseseries()
-        return self.series
-
-    @util.propertycache
-    def seriesguards(self):
-        self.parseseries()
-        return self.seriesguards
-
-    def invalidate(self):
-        for a in 'applied fullseries series seriesguards'.split():
-            if a in self.__dict__:
-                delattr(self, a)
-        self.applieddirty = False
-        self.seriesdirty = False
-        self.guardsdirty = False
-        self.activeguards = None
-
-    def diffopts(self, opts={}, patchfn=None):
-        diffopts = patchmod.diffopts(self.ui, opts)
-        if self.gitmode == 'auto':
-            diffopts.upgrade = True
-        elif self.gitmode == 'keep':
-            pass
-        elif self.gitmode in ('yes', 'no'):
-            diffopts.git = self.gitmode == 'yes'
-        else:
-            raise util.Abort(_('mq.git option can be auto/keep/yes/no'
-                               ' got %s') % self.gitmode)
-        if patchfn:
-            diffopts = self.patchopts(diffopts, patchfn)
-        return diffopts
-
-    def patchopts(self, diffopts, *patches):
-        """Return a copy of input diff options with git set to true if
-        referenced patch is a git patch and should be preserved as such.
-        """
-        diffopts = diffopts.copy()
-        if not diffopts.git and self.gitmode == 'keep':
-            for patchfn in patches:
-                patchf = self.opener(patchfn, 'r')
-                # if the patch was a git patch, refresh it as a git patch
-                for line in patchf:
-                    if line.startswith('diff --git'):
-                        diffopts.git = True
-                        break
-                patchf.close()
-        return diffopts
-
-    def join(self, *p):
-        return os.path.join(self.path, *p)
-
-    def findseries(self, patch):
-        def matchpatch(l):
-            l = l.split('#', 1)[0]
-            return l.strip() == patch
-        for index, l in enumerate(self.fullseries):
-            if matchpatch(l):
-                return index
-        return None
-
-    guard_re = re.compile(r'\s?#([-+][^-+# \t\r\n\f][^# \t\r\n\f]*)')
-
-    def parseseries(self):
-        self.series = []
-        self.seriesguards = []
-        for l in self.fullseries:
-            h = l.find('#')
-            if h == -1:
-                patch = l
-                comment = ''
-            elif h == 0:
-                continue
-            else:
-                patch = l[:h]
-                comment = l[h:]
-            patch = patch.strip()
-            if patch:
-                if patch in self.series:
-                    raise util.Abort(_('%s appears more than once in %s') %
-                                     (patch, self.join(self.seriespath)))
-                self.series.append(patch)
-                self.seriesguards.append(self.guard_re.findall(comment))
-
-    def checkguard(self, guard):
-        if not guard:
-            return _('guard cannot be an empty string')
-        bad_chars = '# \t\r\n\f'
-        first = guard[0]
-        if first in '-+':
-            return (_('guard %r starts with invalid character: %r') %
-                      (guard, first))
-        for c in bad_chars:
-            if c in guard:
-                return _('invalid character in guard %r: %r') % (guard, c)
-
-    def setactive(self, guards):
-        for guard in guards:
-            bad = self.checkguard(guard)
-            if bad:
-                raise util.Abort(bad)
-        guards = sorted(set(guards))
-        self.ui.debug('active guards: %s\n' % ' '.join(guards))
-        self.activeguards = guards
-        self.guardsdirty = True
-
-    def active(self):
-        if self.activeguards is None:
-            self.activeguards = []
-            try:
-                guards = self.opener.read(self.guardspath).split()
-            except IOError, err:
-                if err.errno != errno.ENOENT:
-                    raise
-                guards = []
-            for i, guard in enumerate(guards):
-                bad = self.checkguard(guard)
-                if bad:
-                    self.ui.warn('%s:%d: %s\n' %
-                                 (self.join(self.guardspath), i + 1, bad))
-                else:
-                    self.activeguards.append(guard)
-        return self.activeguards
-
-    def setguards(self, idx, guards):
-        for g in guards:
-            if len(g) < 2:
-                raise util.Abort(_('guard %r too short') % g)
-            if g[0] not in '-+':
-                raise util.Abort(_('guard %r starts with invalid char') % g)
-            bad = self.checkguard(g[1:])
-            if bad:
-                raise util.Abort(bad)
-        drop = self.guard_re.sub('', self.fullseries[idx])
-        self.fullseries[idx] = drop + ''.join([' #' + g for g in guards])
-        self.parseseries()
-        self.seriesdirty = True
-
-    def pushable(self, idx):
-        if isinstance(idx, str):
-            idx = self.series.index(idx)
-        patchguards = self.seriesguards[idx]
-        if not patchguards:
-            return True, None
-        guards = self.active()
-        exactneg = [g for g in patchguards if g[0] == '-' and g[1:] in guards]
-        if exactneg:
-            return False, repr(exactneg[0])
-        pos = [g for g in patchguards if g[0] == '+']
-        exactpos = [g for g in pos if g[1:] in guards]
-        if pos:
-            if exactpos:
-                return True, repr(exactpos[0])
-            return False, ' '.join(map(repr, pos))
-        return True, ''
-
-    def explainpushable(self, idx, all_patches=False):
-        write = all_patches and self.ui.write or self.ui.warn
-        if all_patches or self.ui.verbose:
-            if isinstance(idx, str):
-                idx = self.series.index(idx)
-            pushable, why = self.pushable(idx)
-            if all_patches and pushable:
-                if why is None:
-                    write(_('allowing %s - no guards in effect\n') %
-                          self.series[idx])
-                else:
-                    if not why:
-                        write(_('allowing %s - no matching negative guards\n') %
-                              self.series[idx])
-                    else:
-                        write(_('allowing %s - guarded by %s\n') %
-                              (self.series[idx], why))
-            if not pushable:
-                if why:
-                    write(_('skipping %s - guarded by %s\n') %
-                          (self.series[idx], why))
-                else:
-                    write(_('skipping %s - no matching guards\n') %
-                          self.series[idx])
-
-    def savedirty(self):
-        def writelist(items, path):
-            fp = self.opener(path, 'w')
-            for i in items:
-                fp.write("%s\n" % i)
-            fp.close()
-        if self.applieddirty:
-            writelist(map(str, self.applied), self.statuspath)
-            self.applieddirty = False
-        if self.seriesdirty:
-            writelist(self.fullseries, self.seriespath)
-            self.seriesdirty = False
-        if self.guardsdirty:
-            writelist(self.activeguards, self.guardspath)
-            self.guardsdirty = False
-        if self.added:
-            qrepo = self.qrepo()
-            if qrepo:
-                qrepo[None].add(f for f in self.added if f not in qrepo[None])
-            self.added = []
-
-    def removeundo(self, repo):
-        undo = repo.sjoin('undo')
-        if not os.path.exists(undo):
-            return
-        try:
-            os.unlink(undo)
-        except OSError, inst:
-            self.ui.warn(_('error removing undo: %s\n') % str(inst))
-
-    def backup(self, repo, files, copy=False):
-        # backup local changes in --force case
-        for f in sorted(files):
-            absf = repo.wjoin(f)
-            if os.path.lexists(absf):
-                self.ui.note(_('saving current version of %s as %s\n') %
-                             (f, f + '.orig'))
-                if copy:
-                    util.copyfile(absf, absf + '.orig')
-                else:
-                    util.rename(absf, absf + '.orig')
-
-    def printdiff(self, repo, diffopts, node1, node2=None, files=None,
-                  fp=None, changes=None, opts={}):
-        stat = opts.get('stat')
-        m = scmutil.match(repo[node1], files, opts)
-        cmdutil.diffordiffstat(self.ui, repo, diffopts, node1, node2,  m,
-                               changes, stat, fp)
-
-    def mergeone(self, repo, mergeq, head, patch, rev, diffopts):
-        # first try just applying the patch
-        (err, n) = self.apply(repo, [patch], update_status=False,
-                              strict=True, merge=rev)
-
-        if err == 0:
-            return (err, n)
-
-        if n is None:
-            raise util.Abort(_("apply failed for patch %s") % patch)
-
-        self.ui.warn(_("patch didn't work out, merging %s\n") % patch)
-
-        # apply failed, strip away that rev and merge.
-        hg.clean(repo, head)
-        self.strip(repo, [n], update=False, backup='strip')
-
-        ctx = repo[rev]
-        ret = hg.merge(repo, rev)
-        if ret:
-            raise util.Abort(_("update returned %d") % ret)
-        n = newcommit(repo, None, ctx.description(), ctx.user(), force=True)
-        if n is None:
-            raise util.Abort(_("repo commit failed"))
-        try:
-            ph = patchheader(mergeq.join(patch), self.plainmode)
-        except Exception:
-            raise util.Abort(_("unable to read %s") % patch)
-
-        diffopts = self.patchopts(diffopts, patch)
-        patchf = self.opener(patch, "w")
-        comments = str(ph)
-        if comments:
-            patchf.write(comments)
-        self.printdiff(repo, diffopts, head, n, fp=patchf)
-        patchf.close()
-        self.removeundo(repo)
-        return (0, n)
-
-    def qparents(self, repo, rev=None):
-        if rev is None:
-            (p1, p2) = repo.dirstate.parents()
-            if p2 == nullid:
-                return p1
-            if not self.applied:
-                return None
-            return self.applied[-1].node
-        p1, p2 = repo.changelog.parents(rev)
-        if p2 != nullid and p2 in [x.node for x in self.applied]:
-            return p2
-        return p1
-
-    def mergepatch(self, repo, mergeq, series, diffopts):
-        if not self.applied:
-            # each of the patches merged in will have two parents.  This
-            # can confuse the qrefresh, qdiff, and strip code because it
-            # needs to know which parent is actually in the patch queue.
-            # so, we insert a merge marker with only one parent.  This way
-            # the first patch in the queue is never a merge patch
-            #
-            pname = ".hg.patches.merge.marker"
-            n = newcommit(repo, None, '[mq]: merge marker', force=True)
-            self.removeundo(repo)
-            self.applied.append(statusentry(n, pname))
-            self.applieddirty = True
-
-        head = self.qparents(repo)
-
-        for patch in series:
-            patch = mergeq.lookup(patch, strict=True)
-            if not patch:
-                self.ui.warn(_("patch %s does not exist\n") % patch)
-                return (1, None)
-            pushable, reason = self.pushable(patch)
-            if not pushable:
-                self.explainpushable(patch, all_patches=True)
-                continue
-            info = mergeq.isapplied(patch)
-            if not info:
-                self.ui.warn(_("patch %s is not applied\n") % patch)
-                return (1, None)
-            rev = info[1]
-            err, head = self.mergeone(repo, mergeq, head, patch, rev, diffopts)
-            if head:
-                self.applied.append(statusentry(head, patch))
-                self.applieddirty = True
-            if err:
-                return (err, head)
-        self.savedirty()
-        return (0, head)
-
-    def patch(self, repo, patchfile):
-        '''Apply patchfile  to the working directory.
-        patchfile: name of patch file'''
-        files = set()
-        try:
-            fuzz = patchmod.patch(self.ui, repo, patchfile, strip=1,
-                                  files=files, eolmode=None)
-            return (True, list(files), fuzz)
-        except Exception, inst:
-            self.ui.note(str(inst) + '\n')
-            if not self.ui.verbose:
-                self.ui.warn(_("patch failed, unable to continue (try -v)\n"))
-            self.ui.traceback()
-            return (False, list(files), False)
-
-    def apply(self, repo, series, list=False, update_status=True,
-              strict=False, patchdir=None, merge=None, all_files=None,
-              tobackup=None, keepchanges=False):
-        wlock = lock = tr = None
-        try:
-            wlock = repo.wlock()
-            lock = repo.lock()
-            tr = repo.transaction("qpush")
-            try:
-                ret = self._apply(repo, series, list, update_status,
-                                  strict, patchdir, merge, all_files=all_files,
-                                  tobackup=tobackup, keepchanges=keepchanges)
-                tr.close()
-                self.savedirty()
-                return ret
-            except AbortNoCleanup:
-                tr.close()
-                self.savedirty()
-                return 2, repo.dirstate.p1()
-            except: # re-raises
-                try:
-                    tr.abort()
-                finally:
-                    repo.invalidate()
-                    repo.dirstate.invalidate()
-                    self.invalidate()
-                raise
-        finally:
-            release(tr, lock, wlock)
-            self.removeundo(repo)
-
-    def _apply(self, repo, series, list=False, update_status=True,
-               strict=False, patchdir=None, merge=None, all_files=None,
-               tobackup=None, keepchanges=False):
-        """returns (error, hash)
-
-        error = 1 for unable to read, 2 for patch failed, 3 for patch
-        fuzz. tobackup is None or a set of files to backup before they
-        are modified by a patch.
-        """
-        # TODO unify with commands.py
-        if not patchdir:
-            patchdir = self.path
-        err = 0
-        n = None
-        for patchname in series:
-            pushable, reason = self.pushable(patchname)
-            if not pushable:
-                self.explainpushable(patchname, all_patches=True)
-                continue
-            self.ui.status(_("applying %s\n") % patchname)
-            pf = os.path.join(patchdir, patchname)
-
-            try:
-                ph = patchheader(self.join(patchname), self.plainmode)
-            except IOError:
-                self.ui.warn(_("unable to read %s\n") % patchname)
-                err = 1
-                break
-
-            message = ph.message
-            if not message:
-                # The commit message should not be translated
-                message = "imported patch %s\n" % patchname
-            else:
-                if list:
-                    # The commit message should not be translated
-                    message.append("\nimported patch %s" % patchname)
-                message = '\n'.join(message)
-
-            if ph.haspatch:
-                if tobackup:
-                    touched = patchmod.changedfiles(self.ui, repo, pf)
-                    touched = set(touched) & tobackup
-                    if touched and keepchanges:
-                        raise AbortNoCleanup(
-                            _("local changes found, refresh first"))
-                    self.backup(repo, touched, copy=True)
-                    tobackup = tobackup - touched
-                (patcherr, files, fuzz) = self.patch(repo, pf)
-                if all_files is not None:
-                    all_files.update(files)
-                patcherr = not patcherr
-            else:
-                self.ui.warn(_("patch %s is empty\n") % patchname)
-                patcherr, files, fuzz = 0, [], 0
-
-            if merge and files:
-                # Mark as removed/merged and update dirstate parent info
-                removed = []
-                merged = []
-                for f in files:
-                    if os.path.lexists(repo.wjoin(f)):
-                        merged.append(f)
-                    else:
-                        removed.append(f)
-                for f in removed:
-                    repo.dirstate.remove(f)
-                for f in merged:
-                    repo.dirstate.merge(f)
-                p1, p2 = repo.dirstate.parents()
-                repo.setparents(p1, merge)
-
-            match = scmutil.matchfiles(repo, files or [])
-            oldtip = repo['tip']
-            n = newcommit(repo, None, message, ph.user, ph.date, match=match,
-                          force=True)
-            if repo['tip'] == oldtip:
-                raise util.Abort(_("qpush exactly duplicates child changeset"))
-            if n is None:
-                raise util.Abort(_("repository commit failed"))
-
-            if update_status:
-                self.applied.append(statusentry(n, patchname))
-
-            if patcherr:
-                self.ui.warn(_("patch failed, rejects left in working dir\n"))
-                err = 2
-                break
-
-            if fuzz and strict:
-                self.ui.warn(_("fuzz found when applying patch, stopping\n"))
-                err = 3
-                break
-        return (err, n)
-
-    def _cleanup(self, patches, numrevs, keep=False):
-        if not keep:
-            r = self.qrepo()
-            if r:
-                r[None].forget(patches)
-            for p in patches:
-                try:
-                    os.unlink(self.join(p))
-                except OSError, inst:
-                    if inst.errno != errno.ENOENT:
-                        raise
-
-        qfinished = []
-        if numrevs:
-            qfinished = self.applied[:numrevs]
-            del self.applied[:numrevs]
-            self.applieddirty = True
-
-        unknown = []
-
-        for (i, p) in sorted([(self.findseries(p), p) for p in patches],
-                             reverse=True):
-            if i is not None:
-                del self.fullseries[i]
-            else:
-                unknown.append(p)
-
-        if unknown:
-            if numrevs:
-                rev  = dict((entry.name, entry.node) for entry in qfinished)
-                for p in unknown:
-                    msg = _('revision %s refers to unknown patches: %s\n')
-                    self.ui.warn(msg % (short(rev[p]), p))
-            else:
-                msg = _('unknown patches: %s\n')
-                raise util.Abort(''.join(msg % p for p in unknown))
-
-        self.parseseries()
-        self.seriesdirty = True
-        return [entry.node for entry in qfinished]
-
-    def _revpatches(self, repo, revs):
-        firstrev = repo[self.applied[0].node].rev()
-        patches = []
-        for i, rev in enumerate(revs):
-
-            if rev < firstrev:
-                raise util.Abort(_('revision %d is not managed') % rev)
-
-            ctx = repo[rev]
-            base = self.applied[i].node
-            if ctx.node() != base:
-                msg = _('cannot delete revision %d above applied patches')
-                raise util.Abort(msg % rev)
-
-            patch = self.applied[i].name
-            for fmt in ('[mq]: %s', 'imported patch %s'):
-                if ctx.description() == fmt % patch:
-                    msg = _('patch %s finalized without changeset message\n')
-                    repo.ui.status(msg % patch)
-                    break
-
-            patches.append(patch)
-        return patches
-
-    def finish(self, repo, revs):
-        # Manually trigger phase computation to ensure phasedefaults is
-        # executed before we remove the patches.
-        repo._phasecache
-        patches = self._revpatches(repo, sorted(revs))
-        qfinished = self._cleanup(patches, len(patches))
-        if qfinished and repo.ui.configbool('mq', 'secret', False):
-            # only use this logic when the secret option is added
-            oldqbase = repo[qfinished[0]]
-            tphase = repo.ui.config('phases', 'new-commit', phases.draft)
-            if oldqbase.phase() > tphase and oldqbase.p1().phase() <= tphase:
-                phases.advanceboundary(repo, tphase, qfinished)
-
-    def delete(self, repo, patches, opts):
-        if not patches and not opts.get('rev'):
-            raise util.Abort(_('qdelete requires at least one revision or '
-                               'patch name'))
-
-        realpatches = []
-        for patch in patches:
-            patch = self.lookup(patch, strict=True)
-            info = self.isapplied(patch)
-            if info:
-                raise util.Abort(_("cannot delete applied patch %s") % patch)
-            if patch not in self.series:
-                raise util.Abort(_("patch %s not in series file") % patch)
-            if patch not in realpatches:
-                realpatches.append(patch)
-
-        numrevs = 0
-        if opts.get('rev'):
-            if not self.applied:
-                raise util.Abort(_('no patches applied'))
-            revs = scmutil.revrange(repo, opts.get('rev'))
-            if len(revs) > 1 and revs[0] > revs[1]:
-                revs.reverse()
-            revpatches = self._revpatches(repo, revs)
-            realpatches += revpatches
-            numrevs = len(revpatches)
-
-        self._cleanup(realpatches, numrevs, opts.get('keep'))
-
-    def checktoppatch(self, repo):
-        '''check that working directory is at qtip'''
-        if self.applied:
-            top = self.applied[-1].node
-            patch = self.applied[-1].name
-            if repo.dirstate.p1() != top:
-                raise util.Abort(_("working directory revision is not qtip"))
-            return top, patch
-        return None, None
-
-    def checksubstate(self, repo, baserev=None):
-        '''return list of subrepos at a different revision than substate.
-        Abort if any subrepos have uncommitted changes.'''
-        inclsubs = []
-        wctx = repo[None]
-        if baserev:
-            bctx = repo[baserev]
-        else:
-            bctx = wctx.parents()[0]
-        for s in sorted(wctx.substate):
-            if wctx.sub(s).dirty(True):
-                raise util.Abort(
-                    _("uncommitted changes in subrepository %s") % s)
-            elif s not in bctx.substate or bctx.sub(s).dirty():
-                inclsubs.append(s)
-        return inclsubs
-
-    def putsubstate2changes(self, substatestate, changes):
-        for files in changes[:3]:
-            if '.hgsubstate' in files:
-                return # already listed up
-        # not yet listed up
-        if substatestate in 'a?':
-            changes[1].append('.hgsubstate')
-        elif substatestate in 'r':
-            changes[2].append('.hgsubstate')
-        else: # modified
-            changes[0].append('.hgsubstate')
-
-    def localchangesfound(self, refresh=True):
-        if refresh:
-            raise util.Abort(_("local changes found, refresh first"))
-        else:
-            raise util.Abort(_("local changes found"))
-
-    def checklocalchanges(self, repo, force=False, refresh=True):
-        m, a, r, d = repo.status()[:4]
-        if (m or a or r or d) and not force:
-            self.localchangesfound(refresh)
-        return m, a, r, d
-
-    _reserved = ('series', 'status', 'guards', '.', '..')
-    def checkreservedname(self, name):
-        if name in self._reserved:
-            raise util.Abort(_('"%s" cannot be used as the name of a patch')
-                             % name)
-        for prefix in ('.hg', '.mq'):
-            if name.startswith(prefix):
-                raise util.Abort(_('patch name cannot begin with "%s"')
-                                 % prefix)
-        for c in ('#', ':'):
-            if c in name:
-                raise util.Abort(_('"%s" cannot be used in the name of a patch')
-                                 % c)
-
-    def checkpatchname(self, name, force=False):
-        self.checkreservedname(name)
-        if not force and os.path.exists(self.join(name)):
-            if os.path.isdir(self.join(name)):
-                raise util.Abort(_('"%s" already exists as a directory')
-                                 % name)
-            else:
-                raise util.Abort(_('patch "%s" already exists') % name)
-
-    def checkkeepchanges(self, keepchanges, force):
-        if force and keepchanges:
-            raise util.Abort(_('cannot use both --force and --keep-changes'))
-
-    def new(self, repo, patchfn, *pats, **opts):
-        """options:
-           msg: a string or a no-argument function returning a string
-        """
-        msg = opts.get('msg')
-        user = opts.get('user')
-        date = opts.get('date')
-        if date:
-            date = util.parsedate(date)
-        diffopts = self.diffopts({'git': opts.get('git')})
-        if opts.get('checkname', True):
-            self.checkpatchname(patchfn)
-        inclsubs = self.checksubstate(repo)
-        if inclsubs:
-            inclsubs.append('.hgsubstate')
-            substatestate = repo.dirstate['.hgsubstate']
-        if opts.get('include') or opts.get('exclude') or pats:
-            if inclsubs:
-                pats = list(pats or []) + inclsubs
-            match = scmutil.match(repo[None], pats, opts)
-            # detect missing files in pats
-            def badfn(f, msg):
-                if f != '.hgsubstate': # .hgsubstate is auto-created
-                    raise util.Abort('%s: %s' % (f, msg))
-            match.bad = badfn
-            changes = repo.status(match=match)
-            m, a, r, d = changes[:4]
-        else:
-            changes = self.checklocalchanges(repo, force=True)
-            m, a, r, d = changes
-        match = scmutil.matchfiles(repo, m + a + r + inclsubs)
-        if len(repo[None].parents()) > 1:
-            raise util.Abort(_('cannot manage merge changesets'))
-        commitfiles = m + a + r
-        self.checktoppatch(repo)
-        insert = self.fullseriesend()
-        wlock = repo.wlock()
-        try:
-            try:
-                # if patch file write fails, abort early
-                p = self.opener(patchfn, "w")
-            except IOError, e:
-                raise util.Abort(_('cannot write patch "%s": %s')
-                                 % (patchfn, e.strerror))
-            try:
-                if self.plainmode:
-                    if user:
-                        p.write("From: " + user + "\n")
-                        if not date:
-                            p.write("\n")
-                    if date:
-                        p.write("Date: %d %d\n\n" % date)
-                else:
-                    p.write("# HG changeset patch\n")
-                    p.write("# Parent "
-                            + hex(repo[None].p1().node()) + "\n")
-                    if user:
-                        p.write("# User " + user + "\n")
-                    if date:
-                        p.write("# Date %s %s\n\n" % date)
-                if util.safehasattr(msg, '__call__'):
-                    msg = msg()
-                commitmsg = msg and msg or ("[mq]: %s" % patchfn)
-                n = newcommit(repo, None, commitmsg, user, date, match=match,
-                              force=True)
-                if n is None:
-                    raise util.Abort(_("repo commit failed"))
-                try:
-                    self.fullseries[insert:insert] = [patchfn]
-                    self.applied.append(statusentry(n, patchfn))
-                    self.parseseries()
-                    self.seriesdirty = True
-                    self.applieddirty = True
-                    if msg:
-                        msg = msg + "\n\n"
-                        p.write(msg)
-                    if commitfiles:
-                        parent = self.qparents(repo, n)
-                        if inclsubs:
-                            self.putsubstate2changes(substatestate, changes)
-                        chunks = patchmod.diff(repo, node1=parent, node2=n,
-                                               changes=changes, opts=diffopts)
-                        for chunk in chunks:
-                            p.write(chunk)
-                    p.close()
-                    r = self.qrepo()
-                    if r:
-                        r[None].add([patchfn])
-                except: # re-raises
-                    repo.rollback()
-                    raise
-            except Exception:
-                patchpath = self.join(patchfn)
-                try:
-                    os.unlink(patchpath)
-                except OSError:
-                    self.ui.warn(_('error unlinking %s\n') % patchpath)
-                raise
-            self.removeundo(repo)
-        finally:
-            release(wlock)
-
-    def strip(self, repo, revs, update=True, backup="all", force=None):
-        wlock = lock = None
-        try:
-            wlock = repo.wlock()
-            lock = repo.lock()
-
-            if update:
-                self.checklocalchanges(repo, force=force, refresh=False)
-                urev = self.qparents(repo, revs[0])
-                hg.clean(repo, urev)
-                repo.dirstate.write()
-
-            repair.strip(self.ui, repo, revs, backup)
-        finally:
-            release(lock, wlock)
-
-    def isapplied(self, patch):
-        """returns (index, rev, patch)"""
-        for i, a in enumerate(self.applied):
-            if a.name == patch:
-                return (i, a.node, a.name)
-        return None
-
-    # if the exact patch name does not exist, we try a few
-    # variations.  If strict is passed, we try only #1
-    #
-    # 1) a number (as string) to indicate an offset in the series file
-    # 2) a unique substring of the patch name was given
-    # 3) patchname[-+]num to indicate an offset in the series file
-    def lookup(self, patch, strict=False):
-        def partialname(s):
-            if s in self.series:
-                return s
-            matches = [x for x in self.series if s in x]
-            if len(matches) > 1:
-                self.ui.warn(_('patch name "%s" is ambiguous:\n') % s)
-                for m in matches:
-                    self.ui.warn('  %s\n' % m)
-                return None
-            if matches:
-                return matches[0]
-            if self.series and self.applied:
-                if s == 'qtip':
-                    return self.series[self.seriesend(True) - 1]
-                if s == 'qbase':
-                    return self.series[0]
-            return None
-
-        if patch in self.series:
-            return patch
-
-        if not os.path.isfile(self.join(patch)):
-            try:
-                sno = int(patch)
-            except (ValueError, OverflowError):
-                pass
-            else:
-                if -len(self.series) <= sno < len(self.series):
-                    return self.series[sno]
-
-            if not strict:
-                res = partialname(patch)
-                if res:
-                    return res
-                minus = patch.rfind('-')
-                if minus >= 0:
-                    res = partialname(patch[:minus])
-                    if res:
-                        i = self.series.index(res)
-                        try:
-                            off = int(patch[minus + 1:] or 1)
-                        except (ValueError, OverflowError):
-                            pass
-                        else:
-                            if i - off >= 0:
-                                return self.series[i - off]
-                plus = patch.rfind('+')
-                if plus >= 0:
-                    res = partialname(patch[:plus])
-                    if res:
-                        i = self.series.index(res)
-                        try:
-                            off = int(patch[plus + 1:] or 1)
-                        except (ValueError, OverflowError):
-                            pass
-                        else:
-                            if i + off < len(self.series):
-                                return self.series[i + off]
-        raise util.Abort(_("patch %s not in series") % patch)
-
-    def push(self, repo, patch=None, force=False, list=False, mergeq=None,
-             all=False, move=False, exact=False, nobackup=False,
-             keepchanges=False):
-        self.checkkeepchanges(keepchanges, force)
-        diffopts = self.diffopts()
-        wlock = repo.wlock()
-        try:
-            heads = []
-            for b, ls in repo.branchmap().iteritems():
-                heads += ls
-            if not heads:
-                heads = [nullid]
-            if repo.dirstate.p1() not in heads and not exact:
-                self.ui.status(_("(working directory not at a head)\n"))
-
-            if not self.series:
-                self.ui.warn(_('no patches in series\n'))
-                return 0
-
-            # Suppose our series file is: A B C and the current 'top'
-            # patch is B. qpush C should be performed (moving forward)
-            # qpush B is a NOP (no change) qpush A is an error (can't
-            # go backwards with qpush)
-            if patch:
-                patch = self.lookup(patch)
-                info = self.isapplied(patch)
-                if info and info[0] >= len(self.applied) - 1:
-                    self.ui.warn(
-                        _('qpush: %s is already at the top\n') % patch)
-                    return 0
-
-                pushable, reason = self.pushable(patch)
-                if pushable:
-                    if self.series.index(patch) < self.seriesend():
-                        raise util.Abort(
-                            _("cannot push to a previous patch: %s") % patch)
-                else:
-                    if reason:
-                        reason = _('guarded by %s') % reason
-                    else:
-                        reason = _('no matching guards')
-                    self.ui.warn(_("cannot push '%s' - %s\n") % (patch, reason))
-                    return 1
-            elif all:
-                patch = self.series[-1]
-                if self.isapplied(patch):
-                    self.ui.warn(_('all patches are currently applied\n'))
-                    return 0
-
-            # Following the above example, starting at 'top' of B:
-            # qpush should be performed (pushes C), but a subsequent
-            # qpush without an argument is an error (nothing to
-            # apply). This allows a loop of "...while hg qpush..." to
-            # work as it detects an error when done
-            start = self.seriesend()
-            if start == len(self.series):
-                self.ui.warn(_('patch series already fully applied\n'))
-                return 1
-            if not force and not keepchanges:
-                self.checklocalchanges(repo, refresh=self.applied)
-
-            if exact:
-                if keepchanges:
-                    raise util.Abort(
-                        _("cannot use --exact and --keep-changes together"))
-                if move:
-                    raise util.Abort(_('cannot use --exact and --move '
-                                       'together'))
-                if self.applied:
-                    raise util.Abort(_('cannot push --exact with applied '
-                                       'patches'))
-                root = self.series[start]
-                target = patchheader(self.join(root), self.plainmode).parent
-                if not target:
-                    raise util.Abort(
-                        _("%s does not have a parent recorded") % root)
-                if not repo[target] == repo['.']:
-                    hg.update(repo, target)
-
-            if move:
-                if not patch:
-                    raise util.Abort(_("please specify the patch to move"))
-                for fullstart, rpn in enumerate(self.fullseries):
-                    # strip markers for patch guards
-                    if self.guard_re.split(rpn, 1)[0] == self.series[start]:
-                        break
-                for i, rpn in enumerate(self.fullseries[fullstart:]):
-                    # strip markers for patch guards
-                    if self.guard_re.split(rpn, 1)[0] == patch:
-                        break
-                index = fullstart + i
-                assert index < len(self.fullseries)
-                fullpatch = self.fullseries[index]
-                del self.fullseries[index]
-                self.fullseries.insert(fullstart, fullpatch)
-                self.parseseries()
-                self.seriesdirty = True
-
-            self.applieddirty = True
-            if start > 0:
-                self.checktoppatch(repo)
-            if not patch:
-                patch = self.series[start]
-                end = start + 1
-            else:
-                end = self.series.index(patch, start) + 1
-
-            tobackup = set()
-            if (not nobackup and force) or keepchanges:
-                m, a, r, d = self.checklocalchanges(repo, force=True)
-                if keepchanges:
-                    tobackup.update(m + a + r + d)
-                else:
-                    tobackup.update(m + a)
-
-            s = self.series[start:end]
-            all_files = set()
-            try:
-                if mergeq:
-                    ret = self.mergepatch(repo, mergeq, s, diffopts)
-                else:
-                    ret = self.apply(repo, s, list, all_files=all_files,
-                                     tobackup=tobackup, keepchanges=keepchanges)
-            except: # re-raises
-                self.ui.warn(_('cleaning up working directory...'))
-                node = repo.dirstate.p1()
-                hg.revert(repo, node, None)
-                # only remove unknown files that we know we touched or
-                # created while patching
-                for f in all_files:
-                    if f not in repo.dirstate:
-                        util.unlinkpath(repo.wjoin(f), ignoremissing=True)
-                self.ui.warn(_('done\n'))
-                raise
-
-            if not self.applied:
-                return ret[0]
-            top = self.applied[-1].name
-            if ret[0] and ret[0] > 1:
-                msg = _("errors during apply, please fix and refresh %s\n")
-                self.ui.write(msg % top)
-            else:
-                self.ui.write(_("now at: %s\n") % top)
-            return ret[0]
-
-        finally:
-            wlock.release()
-
-    def pop(self, repo, patch=None, force=False, update=True, all=False,
-            nobackup=False, keepchanges=False):
-        self.checkkeepchanges(keepchanges, force)
-        wlock = repo.wlock()
-        try:
-            if patch:
-                # index, rev, patch
-                info = self.isapplied(patch)
-                if not info:
-                    patch = self.lookup(patch)
-                info = self.isapplied(patch)
-                if not info:
-                    raise util.Abort(_("patch %s is not applied") % patch)
-
-            if not self.applied:
-                # Allow qpop -a to work repeatedly,
-                # but not qpop without an argument
-                self.ui.warn(_("no patches applied\n"))
-                return not all
-
-            if all:
-                start = 0
-            elif patch:
-                start = info[0] + 1
-            else:
-                start = len(self.applied) - 1
-
-            if start >= len(self.applied):
-                self.ui.warn(_("qpop: %s is already at the top\n") % patch)
-                return
-
-            if not update:
-                parents = repo.dirstate.parents()
-                rr = [x.node for x in self.applied]
-                for p in parents:
-                    if p in rr:
-                        self.ui.warn(_("qpop: forcing dirstate update\n"))
-                        update = True
-            else:
-                parents = [p.node() for p in repo[None].parents()]
-                needupdate = False
-                for entry in self.applied[start:]:
-                    if entry.node in parents:
-                        needupdate = True
-                        break
-                update = needupdate
-
-            tobackup = set()
-            if update:
-                m, a, r, d = self.checklocalchanges(
-                    repo, force=force or keepchanges)
-                if force:
-                    if not nobackup:
-                        tobackup.update(m + a)
-                elif keepchanges:
-                    tobackup.update(m + a + r + d)
-
-            self.applieddirty = True
-            end = len(self.applied)
-            rev = self.applied[start].node
-
-            try:
-                heads = repo.changelog.heads(rev)
-            except error.LookupError:
-                node = short(rev)
-                raise util.Abort(_('trying to pop unknown node %s') % node)
-
-            if heads != [self.applied[-1].node]:
-                raise util.Abort(_("popping would remove a revision not "
-                                   "managed by this patch queue"))
-            if not repo[self.applied[-1].node].mutable():
-                raise util.Abort(
-                    _("popping would remove an immutable revision"),
-                    hint=_('see "hg help phases" for details'))
-
-            # we know there are no local changes, so we can make a simplified
-            # form of hg.update.
-            if update:
-                qp = self.qparents(repo, rev)
-                ctx = repo[qp]
-                m, a, r, d = repo.status(qp, '.')[:4]
-                if d:
-                    raise util.Abort(_("deletions found between repo revs"))
-
-                tobackup = set(a + m + r) & tobackup
-                if keepchanges and tobackup:
-                    self.localchangesfound()
-                self.backup(repo, tobackup)
-
-                for f in a:
-                    util.unlinkpath(repo.wjoin(f), ignoremissing=True)
-                    repo.dirstate.drop(f)
-                for f in m + r:
-                    fctx = ctx[f]
-                    repo.wwrite(f, fctx.data(), fctx.flags())
-                    repo.dirstate.normal(f)
-                repo.setparents(qp, nullid)
-            for patch in reversed(self.applied[start:end]):
-                self.ui.status(_("popping %s\n") % patch.name)
-            del self.applied[start:end]
-            self.strip(repo, [rev], update=False, backup='strip')
-            if self.applied:
-                self.ui.write(_("now at: %s\n") % self.applied[-1].name)
-            else:
-                self.ui.write(_("patch queue now empty\n"))
-        finally:
-            wlock.release()
-
-    def diff(self, repo, pats, opts):
-        top, patch = self.checktoppatch(repo)
-        if not top:
-            self.ui.write(_("no patches applied\n"))
-            return
-        qp = self.qparents(repo, top)
-        if opts.get('reverse'):
-            node1, node2 = None, qp
-        else:
-            node1, node2 = qp, None
-        diffopts = self.diffopts(opts, patch)
-        self.printdiff(repo, diffopts, node1, node2, files=pats, opts=opts)
-
-    def refresh(self, repo, pats=None, **opts):
-        if not self.applied:
-            self.ui.write(_("no patches applied\n"))
-            return 1
-        msg = opts.get('msg', '').rstrip()
-        newuser = opts.get('user')
-        newdate = opts.get('date')
-        if newdate:
-            newdate = '%d %d' % util.parsedate(newdate)
-        wlock = repo.wlock()
-
-        try:
-            self.checktoppatch(repo)
-            (top, patchfn) = (self.applied[-1].node, self.applied[-1].name)
-            if repo.changelog.heads(top) != [top]:
-                raise util.Abort(_("cannot refresh a revision with children"))
-            if not repo[top].mutable():
-                raise util.Abort(_("cannot refresh immutable revision"),
-                                 hint=_('see "hg help phases" for details'))
-
-            cparents = repo.changelog.parents(top)
-            patchparent = self.qparents(repo, top)
-
-            inclsubs = self.checksubstate(repo, hex(patchparent))
-            if inclsubs:
-                inclsubs.append('.hgsubstate')
-                substatestate = repo.dirstate['.hgsubstate']
-
-            ph = patchheader(self.join(patchfn), self.plainmode)
-            diffopts = self.diffopts({'git': opts.get('git')}, patchfn)
-            if msg:
-                ph.setmessage(msg)
-            if newuser:
-                ph.setuser(newuser)
-            if newdate:
-                ph.setdate(newdate)
-            ph.setparent(hex(patchparent))
-
-            # only commit new patch when write is complete
-            patchf = self.opener(patchfn, 'w', atomictemp=True)
-
-            comments = str(ph)
-            if comments:
-                patchf.write(comments)
-
-            # update the dirstate in place, strip off the qtip commit
-            # and then commit.
-            #
-            # this should really read:
-            #   mm, dd, aa = repo.status(top, patchparent)[:3]
-            # but we do it backwards to take advantage of manifest/changelog
-            # caching against the next repo.status call
-            mm, aa, dd = repo.status(patchparent, top)[:3]
-            changes = repo.changelog.read(top)
-            man = repo.manifest.read(changes[0])
-            aaa = aa[:]
-            matchfn = scmutil.match(repo[None], pats, opts)
-            # in short mode, we only diff the files included in the
-            # patch already plus specified files
-            if opts.get('short'):
-                # if amending a patch, we start with existing
-                # files plus specified files - unfiltered
-                match = scmutil.matchfiles(repo, mm + aa + dd + matchfn.files())
-                # filter with include/exclude options
-                matchfn = scmutil.match(repo[None], opts=opts)
-            else:
-                match = scmutil.matchall(repo)
-            m, a, r, d = repo.status(match=match)[:4]
-            mm = set(mm)
-            aa = set(aa)
-            dd = set(dd)
-
-            # we might end up with files that were added between
-            # qtip and the dirstate parent, but then changed in the
-            # local dirstate. in this case, we want them to only
-            # show up in the added section
-            for x in m:
-                if x not in aa:
-                    mm.add(x)
-            # we might end up with files added by the local dirstate that
-            # were deleted by the patch.  In this case, they should only
-            # show up in the changed section.
-            for x in a:
-                if x in dd:
-                    dd.remove(x)
-                    mm.add(x)
-                else:
-                    aa.add(x)
-            # make sure any files deleted in the local dirstate
-            # are not in the add or change column of the patch
-            forget = []
-            for x in d + r:
-                if x in aa:
-                    aa.remove(x)
-                    forget.append(x)
-                    continue
-                else:
-                    mm.discard(x)
-                dd.add(x)
-
-            m = list(mm)
-            r = list(dd)
-            a = list(aa)
-
-            # create 'match' that includes the files to be recommitted.
-            # apply matchfn via repo.status to ensure correct case handling.
-            cm, ca, cr, cd = repo.status(patchparent, match=matchfn)[:4]
-            allmatches = set(cm + ca + cr + cd)
-            refreshchanges = [x.intersection(allmatches) for x in (mm, aa, dd)]
-
-            files = set(inclsubs)
-            for x in refreshchanges:
-                files.update(x)
-            match = scmutil.matchfiles(repo, files)
-
-            bmlist = repo[top].bookmarks()
-
-            try:
-                if diffopts.git or diffopts.upgrade:
-                    copies = {}
-                    for dst in a:
-                        src = repo.dirstate.copied(dst)
-                        # during qfold, the source file for copies may
-                        # be removed. Treat this as a simple add.
-                        if src is not None and src in repo.dirstate:
-                            copies.setdefault(src, []).append(dst)
-                        repo.dirstate.add(dst)
-                    # remember the copies between patchparent and qtip
-                    for dst in aaa:
-                        f = repo.file(dst)
-                        src = f.renamed(man[dst])
-                        if src:
-                            copies.setdefault(src[0], []).extend(
-                                copies.get(dst, []))
-                            if dst in a:
-                                copies[src[0]].append(dst)
-                        # we can't copy a file created by the patch itself
-                        if dst in copies:
-                            del copies[dst]
-                    for src, dsts in copies.iteritems():
-                        for dst in dsts:
-                            repo.dirstate.copy(src, dst)
-                else:
-                    for dst in a:
-                        repo.dirstate.add(dst)
-                    # Drop useless copy information
-                    for f in list(repo.dirstate.copies()):
-                        repo.dirstate.copy(None, f)
-                for f in r:
-                    repo.dirstate.remove(f)
-                # if the patch excludes a modified file, mark that
-                # file with mtime=0 so status can see it.
-                mm = []
-                for i in xrange(len(m) - 1, -1, -1):
-                    if not matchfn(m[i]):
-                        mm.append(m[i])
-                        del m[i]
-                for f in m:
-                    repo.dirstate.normal(f)
-                for f in mm:
-                    repo.dirstate.normallookup(f)
-                for f in forget:
-                    repo.dirstate.drop(f)
-
-                if not msg:
-                    if not ph.message:
-                        message = "[mq]: %s\n" % patchfn
-                    else:
-                        message = "\n".join(ph.message)
-                else:
-                    message = msg
-
-                user = ph.user or changes[1]
-
-                oldphase = repo[top].phase()
-
-                # assumes strip can roll itself back if interrupted
-                repo.setparents(*cparents)
-                self.applied.pop()
-                self.applieddirty = True
-                self.strip(repo, [top], update=False,
-                           backup='strip')
-            except: # re-raises
-                repo.dirstate.invalidate()
-                raise
-
-            try:
-                # might be nice to attempt to roll back strip after this
-
-                # Ensure we create a new changeset in the same phase than
-                # the old one.
-                n = newcommit(repo, oldphase, message, user, ph.date,
-                              match=match, force=True)
-                # only write patch after a successful commit
-                c = [list(x) for x in refreshchanges]
-                if inclsubs:
-                    self.putsubstate2changes(substatestate, c)
-                chunks = patchmod.diff(repo, patchparent,
-                                       changes=c, opts=diffopts)
-                for chunk in chunks:
-                    patchf.write(chunk)
-                patchf.close()
-
-                marks = repo._bookmarks
-                for bm in bmlist:
-                    marks[bm] = n
-                marks.write()
-
-                self.applied.append(statusentry(n, patchfn))
-            except: # re-raises
-                ctx = repo[cparents[0]]
-                repo.dirstate.rebuild(ctx.node(), ctx.manifest())
-                self.savedirty()
-                self.ui.warn(_('refresh interrupted while patch was popped! '
-                               '(revert --all, qpush to recover)\n'))
-                raise
-        finally:
-            wlock.release()
-            self.removeundo(repo)
-
-    def init(self, repo, create=False):
-        if not create and os.path.isdir(self.path):
-            raise util.Abort(_("patch queue directory already exists"))
-        try:
-            os.mkdir(self.path)
-        except OSError, inst:
-            if inst.errno != errno.EEXIST or not create:
-                raise
-        if create:
-            return self.qrepo(create=True)
-
-    def unapplied(self, repo, patch=None):
-        if patch and patch not in self.series:
-            raise util.Abort(_("patch %s is not in series file") % patch)
-        if not patch:
-            start = self.seriesend()
-        else:
-            start = self.series.index(patch) + 1
-        unapplied = []
-        for i in xrange(start, len(self.series)):
-            pushable, reason = self.pushable(i)
-            if pushable:
-                unapplied.append((i, self.series[i]))
-            self.explainpushable(i)
-        return unapplied
-
-    def qseries(self, repo, missing=None, start=0, length=None, status=None,
-                summary=False):
-        def displayname(pfx, patchname, state):
-            if pfx:
-                self.ui.write(pfx)
-            if summary:
-                ph = patchheader(self.join(patchname), self.plainmode)
-                msg = ph.message and ph.message[0] or ''
-                if self.ui.formatted():
-                    width = self.ui.termwidth() - len(pfx) - len(patchname) - 2
-                    if width > 0:
-                        msg = util.ellipsis(msg, width)
-                    else:
-                        msg = ''
-                self.ui.write(patchname, label='qseries.' + state)
-                self.ui.write(': ')
-                self.ui.write(msg, label='qseries.message.' + state)
-            else:
-                self.ui.write(patchname, label='qseries.' + state)
-            self.ui.write('\n')
-
-        applied = set([p.name for p in self.applied])
-        if length is None:
-            length = len(self.series) - start
-        if not missing:
-            if self.ui.verbose:
-                idxwidth = len(str(start + length - 1))
-            for i in xrange(start, start + length):
-                patch = self.series[i]
-                if patch in applied:
-                    char, state = 'A', 'applied'
-                elif self.pushable(i)[0]:
-                    char, state = 'U', 'unapplied'
-                else:
-                    char, state = 'G', 'guarded'
-                pfx = ''
-                if self.ui.verbose:
-                    pfx = '%*d %s ' % (idxwidth, i, char)
-                elif status and status != char:
-                    continue
-                displayname(pfx, patch, state)
-        else:
-            msng_list = []
-            for root, dirs, files in os.walk(self.path):
-                d = root[len(self.path) + 1:]
-                for f in files:
-                    fl = os.path.join(d, f)
-                    if (fl not in self.series and
-                        fl not in (self.statuspath, self.seriespath,
-                                   self.guardspath)
-                        and not fl.startswith('.')):
-                        msng_list.append(fl)
-            for x in sorted(msng_list):
-                pfx = self.ui.verbose and ('D ') or ''
-                displayname(pfx, x, 'missing')
-
-    def issaveline(self, l):
-        if l.name == '.hg.patches.save.line':
-            return True
-
-    def qrepo(self, create=False):
-        ui = self.ui.copy()
-        ui.setconfig('paths', 'default', '', overlay=False)
-        ui.setconfig('paths', 'default-push', '', overlay=False)
-        if create or os.path.isdir(self.join(".hg")):
-            return hg.repository(ui, path=self.path, create=create)
-
-    def restore(self, repo, rev, delete=None, qupdate=None):
-        desc = repo[rev].description().strip()
-        lines = desc.splitlines()
-        i = 0
-        datastart = None
-        series = []
-        applied = []
-        qpp = None
-        for i, line in enumerate(lines):
-            if line == 'Patch Data:':
-                datastart = i + 1
-            elif line.startswith('Dirstate:'):
-                l = line.rstrip()
-                l = l[10:].split(' ')
-                qpp = [bin(x) for x in l]
-            elif datastart is not None:
-                l = line.rstrip()
-                n, name = l.split(':', 1)
-                if n:
-                    applied.append(statusentry(bin(n), name))
-                else:
-                    series.append(l)
-        if datastart is None:
-            self.ui.warn(_("no saved patch data found\n"))
-            return 1
-        self.ui.warn(_("restoring status: %s\n") % lines[0])
-        self.fullseries = series
-        self.applied = applied
-        self.parseseries()
-        self.seriesdirty = True
-        self.applieddirty = True
-        heads = repo.changelog.heads()
-        if delete:
-            if rev not in heads:
-                self.ui.warn(_("save entry has children, leaving it alone\n"))
-            else:
-                self.ui.warn(_("removing save entry %s\n") % short(rev))
-                pp = repo.dirstate.parents()
-                if rev in pp:
-                    update = True
-                else:
-                    update = False
-                self.strip(repo, [rev], update=update, backup='strip')
-        if qpp:
-            self.ui.warn(_("saved queue repository parents: %s %s\n") %
-                         (short(qpp[0]), short(qpp[1])))
-            if qupdate:
-                self.ui.status(_("updating queue directory\n"))
-                r = self.qrepo()
-                if not r:
-                    self.ui.warn(_("unable to load queue repository\n"))
-                    return 1
-                hg.clean(r, qpp[0])
-
-    def save(self, repo, msg=None):
-        if not self.applied:
-            self.ui.warn(_("save: no patches applied, exiting\n"))
-            return 1
-        if self.issaveline(self.applied[-1]):
-            self.ui.warn(_("status is already saved\n"))
-            return 1
-
-        if not msg:
-            msg = _("hg patches saved state")
-        else:
-            msg = "hg patches: " + msg.rstrip('\r\n')
-        r = self.qrepo()
-        if r:
-            pp = r.dirstate.parents()
-            msg += "\nDirstate: %s %s" % (hex(pp[0]), hex(pp[1]))
-        msg += "\n\nPatch Data:\n"
-        msg += ''.join('%s\n' % x for x in self.applied)
-        msg += ''.join(':%s\n' % x for x in self.fullseries)
-        n = repo.commit(msg, force=True)
-        if not n:
-            self.ui.warn(_("repo commit failed\n"))
-            return 1
-        self.applied.append(statusentry(n, '.hg.patches.save.line'))
-        self.applieddirty = True
-        self.removeundo(repo)
-
-    def fullseriesend(self):
-        if self.applied:
-            p = self.applied[-1].name
-            end = self.findseries(p)
-            if end is None:
-                return len(self.fullseries)
-            return end + 1
-        return 0
-
-    def seriesend(self, all_patches=False):
-        """If all_patches is False, return the index of the next pushable patch
-        in the series, or the series length. If all_patches is True, return the
-        index of the first patch past the last applied one.
-        """
-        end = 0
-        def next(start):
-            if all_patches or start >= len(self.series):
-                return start
-            for i in xrange(start, len(self.series)):
-                p, reason = self.pushable(i)
-                if p:
-                    return i
-                self.explainpushable(i)
-            return len(self.series)
-        if self.applied:
-            p = self.applied[-1].name
-            try:
-                end = self.series.index(p)
-            except ValueError:
-                return 0
-            return next(end + 1)
-        return next(end)
-
-    def appliedname(self, index):
-        pname = self.applied[index].name
-        if not self.ui.verbose:
-            p = pname
-        else:
-            p = str(self.series.index(pname)) + " " + pname
-        return p
-
-    def qimport(self, repo, files, patchname=None, rev=None, existing=None,
-                force=None, git=False):
-        def checkseries(patchname):
-            if patchname in self.series:
-                raise util.Abort(_('patch %s is already in the series file')
-                                 % patchname)
-
-        if rev:
-            if files:
-                raise util.Abort(_('option "-r" not valid when importing '
-                                   'files'))
-            rev = scmutil.revrange(repo, rev)
-            rev.sort(reverse=True)
-        elif not files:
-            raise util.Abort(_('no files or revisions specified'))
-        if (len(files) > 1 or len(rev) > 1) and patchname:
-            raise util.Abort(_('option "-n" not valid when importing multiple '
-                               'patches'))
-        imported = []
-        if rev:
-            # If mq patches are applied, we can only import revisions
-            # that form a linear path to qbase.
-            # Otherwise, they should form a linear path to a head.
-            heads = repo.changelog.heads(repo.changelog.node(rev[-1]))
-            if len(heads) > 1:
-                raise util.Abort(_('revision %d is the root of more than one '
-                                   'branch') % rev[-1])
-            if self.applied:
-                base = repo.changelog.node(rev[0])
-                if base in [n.node for n in self.applied]:
-                    raise util.Abort(_('revision %d is already managed')
-                                     % rev[0])
-                if heads != [self.applied[-1].node]:
-                    raise util.Abort(_('revision %d is not the parent of '
-                                       'the queue') % rev[0])
-                base = repo.changelog.rev(self.applied[0].node)
-                lastparent = repo.changelog.parentrevs(base)[0]
-            else:
-                if heads != [repo.changelog.node(rev[0])]:
-                    raise util.Abort(_('revision %d has unmanaged children')
-                                     % rev[0])
-                lastparent = None
-
-            diffopts = self.diffopts({'git': git})
-            for r in rev:
-                if not repo[r].mutable():
-                    raise util.Abort(_('revision %d is not mutable') % r,
-                                     hint=_('see "hg help phases" for details'))
-                p1, p2 = repo.changelog.parentrevs(r)
-                n = repo.changelog.node(r)
-                if p2 != nullrev:
-                    raise util.Abort(_('cannot import merge revision %d') % r)
-                if lastparent and lastparent != r:
-                    raise util.Abort(_('revision %d is not the parent of %d')
-                                     % (r, lastparent))
-                lastparent = p1
-
-                if not patchname:
-                    patchname = normname('%d.diff' % r)
-                checkseries(patchname)
-                self.checkpatchname(patchname, force)
-                self.fullseries.insert(0, patchname)
-
-                patchf = self.opener(patchname, "w")
-                cmdutil.export(repo, [n], fp=patchf, opts=diffopts)
-                patchf.close()
-
-                se = statusentry(n, patchname)
-                self.applied.insert(0, se)
-
-                self.added.append(patchname)
-                imported.append(patchname)
-                patchname = None
-            if rev and repo.ui.configbool('mq', 'secret', False):
-                # if we added anything with --rev, we must move the secret root
-                phases.retractboundary(repo, phases.secret, [n])
-            self.parseseries()
-            self.applieddirty = True
-            self.seriesdirty = True
-
-        for i, filename in enumerate(files):
-            if existing:
-                if filename == '-':
-                    raise util.Abort(_('-e is incompatible with import from -'))
-                filename = normname(filename)
-                self.checkreservedname(filename)
-                originpath = self.join(filename)
-                if not os.path.isfile(originpath):
-                    raise util.Abort(_("patch %s does not exist") % filename)
-
-                if patchname:
-                    self.checkpatchname(patchname, force)
-
-                    self.ui.write(_('renaming %s to %s\n')
-                                        % (filename, patchname))
-                    util.rename(originpath, self.join(patchname))
-                else:
-                    patchname = filename
-
-            else:
-                if filename == '-' and not patchname:
-                    raise util.Abort(_('need --name to import a patch from -'))
-                elif not patchname:
-                    patchname = normname(os.path.basename(filename.rstrip('/')))
-                self.checkpatchname(patchname, force)
-                try:
-                    if filename == '-':
-                        text = self.ui.fin.read()
-                    else:
-                        fp = hg.openpath(self.ui, filename)
-                        text = fp.read()
-                        fp.close()
-                except (OSError, IOError):
-                    raise util.Abort(_("unable to read file %s") % filename)
-                patchf = self.opener(patchname, "w")
-                patchf.write(text)
-                patchf.close()
-            if not force:
-                checkseries(patchname)
-            if patchname not in self.series:
-                index = self.fullseriesend() + i
-                self.fullseries[index:index] = [patchname]
-            self.parseseries()
-            self.seriesdirty = True
-            self.ui.warn(_("adding %s to series file\n") % patchname)
-            self.added.append(patchname)
-            imported.append(patchname)
-            patchname = None
-
-        self.removeundo(repo)
-        return imported
-
-def fixkeepchangesopts(ui, opts):
-    if (not ui.configbool('mq', 'keepchanges') or opts.get('force')
-        or opts.get('exact')):
-        return opts
-    opts = dict(opts)
-    opts['keep_changes'] = True
-    return opts
-
-@command("qdelete|qremove|qrm",
-         [('k', 'keep', None, _('keep patch file')),
-          ('r', 'rev', [],
-           _('stop managing a revision (DEPRECATED)'), _('REV'))],
-         _('hg qdelete [-k] [PATCH]...'))
-def delete(ui, repo, *patches, **opts):
-    """remove patches from queue
-
-    The patches must not be applied, and at least one patch is required. Exact
-    patch identifiers must be given. With -k/--keep, the patch files are
-    preserved in the patch directory.
-
-    To stop managing a patch and move it into permanent history,
-    use the :hg:`qfinish` command."""
-    q = repo.mq
-    q.delete(repo, patches, opts)
-    q.savedirty()
-    return 0
-
-@command("qapplied",
-         [('1', 'last', None, _('show only the preceding applied patch'))
-          ] + seriesopts,
-         _('hg qapplied [-1] [-s] [PATCH]'))
-def applied(ui, repo, patch=None, **opts):
-    """print the patches already applied
-
-    Returns 0 on success."""
-
-    q = repo.mq
-
-    if patch:
-        if patch not in q.series:
-            raise util.Abort(_("patch %s is not in series file") % patch)
-        end = q.series.index(patch) + 1
-    else:
-        end = q.seriesend(True)
-
-    if opts.get('last') and not end:
-        ui.write(_("no patches applied\n"))
-        return 1
-    elif opts.get('last') and end == 1:
-        ui.write(_("only one patch applied\n"))
-        return 1
-    elif opts.get('last'):
-        start = end - 2
-        end = 1
-    else:
-        start = 0
-
-    q.qseries(repo, length=end, start=start, status='A',
-              summary=opts.get('summary'))
-
-
-@command("qunapplied",
-         [('1', 'first', None, _('show only the first patch'))] + seriesopts,
-         _('hg qunapplied [-1] [-s] [PATCH]'))
-def unapplied(ui, repo, patch=None, **opts):
-    """print the patches not yet applied
-
-    Returns 0 on success."""
-
-    q = repo.mq
-    if patch:
-        if patch not in q.series:
-            raise util.Abort(_("patch %s is not in series file") % patch)
-        start = q.series.index(patch) + 1
-    else:
-        start = q.seriesend(True)
-
-    if start == len(q.series) and opts.get('first'):
-        ui.write(_("all patches applied\n"))
-        return 1
-
-    length = opts.get('first') and 1 or None
-    q.qseries(repo, start=start, length=length, status='U',
-              summary=opts.get('summary'))
-
-@command("qimport",
-         [('e', 'existing', None, _('import file in patch directory')),
-          ('n', 'name', '',
-           _('name of patch file'), _('NAME')),
-          ('f', 'force', None, _('overwrite existing files')),
-          ('r', 'rev', [],
-           _('place existing revisions under mq control'), _('REV')),
-          ('g', 'git', None, _('use git extended diff format')),
-          ('P', 'push', None, _('qpush after importing'))],
-         _('hg qimport [-e] [-n NAME] [-f] [-g] [-P] [-r REV]... [FILE]...'))
-def qimport(ui, repo, *filename, **opts):
-    """import a patch or existing changeset
-
-    The patch is inserted into the series after the last applied
-    patch. If no patches have been applied, qimport prepends the patch
-    to the series.
-
-    The patch will have the same name as its source file unless you
-    give it a new one with -n/--name.
-
-    You can register an existing patch inside the patch directory with
-    the -e/--existing flag.
-
-    With -f/--force, an existing patch of the same name will be
-    overwritten.
-
-    An existing changeset may be placed under mq control with -r/--rev
-    (e.g. qimport --rev tip -n patch will place tip under mq control).
-    With -g/--git, patches imported with --rev will use the git diff
-    format. See the diffs help topic for information on why this is
-    important for preserving rename/copy information and permission
-    changes. Use :hg:`qfinish` to remove changesets from mq control.
-
-    To import a patch from standard input, pass - as the patch file.
-    When importing from standard input, a patch name must be specified
-    using the --name flag.
-
-    To import an existing patch while renaming it::
-
-      hg qimport -e existing-patch -n new-name
-
-    Returns 0 if import succeeded.
-    """
-    lock = repo.lock() # cause this may move phase
-    try:
-        q = repo.mq
-        try:
-            imported = q.qimport(
-                repo, filename, patchname=opts.get('name'),
-                existing=opts.get('existing'), force=opts.get('force'),
-                rev=opts.get('rev'), git=opts.get('git'))
-        finally:
-            q.savedirty()
-    finally:
-        lock.release()
-
-    if imported and opts.get('push') and not opts.get('rev'):
-        return q.push(repo, imported[-1])
-    return 0
-
-def qinit(ui, repo, create):
-    """initialize a new queue repository
-
-    This command also creates a series file for ordering patches, and
-    an mq-specific .hgignore file in the queue repository, to exclude
-    the status and guards files (these contain mostly transient state).
-
-    Returns 0 if initialization succeeded."""
-    q = repo.mq
-    r = q.init(repo, create)
-    q.savedirty()
-    if r:
-        if not os.path.exists(r.wjoin('.hgignore')):
-            fp = r.wopener('.hgignore', 'w')
-            fp.write('^\\.hg\n')
-            fp.write('^\\.mq\n')
-            fp.write('syntax: glob\n')
-            fp.write('status\n')
-            fp.write('guards\n')
-            fp.close()
-        if not os.path.exists(r.wjoin('series')):
-            r.wopener('series', 'w').close()
-        r[None].add(['.hgignore', 'series'])
-        commands.add(ui, r)
-    return 0
-
-@command("^qinit",
-         [('c', 'create-repo', None, _('create queue repository'))],
-         _('hg qinit [-c]'))
-def init(ui, repo, **opts):
-    """init a new queue repository (DEPRECATED)
-
-    The queue repository is unversioned by default. If
-    -c/--create-repo is specified, qinit will create a separate nested
-    repository for patches (qinit -c may also be run later to convert
-    an unversioned patch repository into a versioned one). You can use
-    qcommit to commit changes to this queue repository.
-
-    This command is deprecated. Without -c, it's implied by other relevant
-    commands. With -c, use :hg:`init --mq` instead."""
-    return qinit(ui, repo, create=opts.get('create_repo'))
-
-@command("qclone",
-         [('', 'pull', None, _('use pull protocol to copy metadata')),
-          ('U', 'noupdate', None,
-           _('do not update the new working directories')),
-          ('', 'uncompressed', None,
-           _('use uncompressed transfer (fast over LAN)')),
-          ('p', 'patches', '',
-           _('location of source patch repository'), _('REPO')),
-         ] + commands.remoteopts,
-         _('hg qclone [OPTION]... SOURCE [DEST]'))
-def clone(ui, source, dest=None, **opts):
-    '''clone main and patch repository at same time
-
-    If source is local, destination will have no patches applied. If
-    source is remote, this command can not check if patches are
-    applied in source, so cannot guarantee that patches are not
-    applied in destination. If you clone remote repository, be sure
-    before that it has no patches applied.
-
-    Source patch repository is looked for in <src>/.hg/patches by
-    default. Use -p <url> to change.
-
-    The patch directory must be a nested Mercurial repository, as
-    would be created by :hg:`init --mq`.
-
-    Return 0 on success.
-    '''
-    def patchdir(repo):
-        """compute a patch repo url from a repo object"""
-        url = repo.url()
-        if url.endswith('/'):
-            url = url[:-1]
-        return url + '/.hg/patches'
-
-    # main repo (destination and sources)
-    if dest is None:
-        dest = hg.defaultdest(source)
-    sr = hg.peer(ui, opts, ui.expandpath(source))
-
-    # patches repo (source only)
-    if opts.get('patches'):
-        patchespath = ui.expandpath(opts.get('patches'))
-    else:
-        patchespath = patchdir(sr)
-    try:
-        hg.peer(ui, opts, patchespath)
-    except error.RepoError:
-        raise util.Abort(_('versioned patch repository not found'
-                           ' (see init --mq)'))
-    qbase, destrev = None, None
-    if sr.local():
-        repo = sr.local()
-        if repo.mq.applied and repo[qbase].phase() != phases.secret:
-            qbase = repo.mq.applied[0].node
-            if not hg.islocal(dest):
-                heads = set(repo.heads())
-                destrev = list(heads.difference(repo.heads(qbase)))
-                destrev.append(repo.changelog.parents(qbase)[0])
-    elif sr.capable('lookup'):
-        try:
-            qbase = sr.lookup('qbase')
-        except error.RepoError:
-            pass
-
-    ui.note(_('cloning main repository\n'))
-    sr, dr = hg.clone(ui, opts, sr.url(), dest,
-                      pull=opts.get('pull'),
-                      rev=destrev,
-                      update=False,
-                      stream=opts.get('uncompressed'))
-
-    ui.note(_('cloning patch repository\n'))
-    hg.clone(ui, opts, opts.get('patches') or patchdir(sr), patchdir(dr),
-             pull=opts.get('pull'), update=not opts.get('noupdate'),
-             stream=opts.get('uncompressed'))
-
-    if dr.local():
-        repo = dr.local()
-        if qbase:
-            ui.note(_('stripping applied patches from destination '
-                      'repository\n'))
-            repo.mq.strip(repo, [qbase], update=False, backup=None)
-        if not opts.get('noupdate'):
-            ui.note(_('updating destination repository\n'))
-            hg.update(repo, repo.changelog.tip())
-
-@command("qcommit|qci",
-         commands.table["^commit|ci"][1],
-         _('hg qcommit [OPTION]... [FILE]...'))
-def commit(ui, repo, *pats, **opts):
-    """commit changes in the queue repository (DEPRECATED)
-
-    This command is deprecated; use :hg:`commit --mq` instead."""
-    q = repo.mq
-    r = q.qrepo()
-    if not r:
-        raise util.Abort('no queue repository')
-    commands.commit(r.ui, r, *pats, **opts)
-
-@command("qseries",
-         [('m', 'missing', None, _('print patches not in series')),
-         ] + seriesopts,
-          _('hg qseries [-ms]'))
-def series(ui, repo, **opts):
-    """print the entire series file
-
-    Returns 0 on success."""
-    repo.mq.qseries(repo, missing=opts.get('missing'),
-                    summary=opts.get('summary'))
-    return 0
-
-@command("qtop", seriesopts, _('hg qtop [-s]'))
-def top(ui, repo, **opts):
-    """print the name of the current patch
-
-    Returns 0 on success."""
-    q = repo.mq
-    t = q.applied and q.seriesend(True) or 0
-    if t:
-        q.qseries(repo, start=t - 1, length=1, status='A',
-                  summary=opts.get('summary'))
-    else:
-        ui.write(_("no patches applied\n"))
-        return 1
-
-@command("qnext", seriesopts, _('hg qnext [-s]'))
-def next(ui, repo, **opts):
-    """print the name of the next pushable patch
-
-    Returns 0 on success."""
-    q = repo.mq
-    end = q.seriesend()
-    if end == len(q.series):
-        ui.write(_("all patches applied\n"))
-        return 1
-    q.qseries(repo, start=end, length=1, summary=opts.get('summary'))
-
-@command("qprev", seriesopts, _('hg qprev [-s]'))
-def prev(ui, repo, **opts):
-    """print the name of the preceding applied patch
-
-    Returns 0 on success."""
-    q = repo.mq
-    l = len(q.applied)
-    if l == 1:
-        ui.write(_("only one patch applied\n"))
-        return 1
-    if not l:
-        ui.write(_("no patches applied\n"))
-        return 1
-    idx = q.series.index(q.applied[-2].name)
-    q.qseries(repo, start=idx, length=1, status='A',
-              summary=opts.get('summary'))
-
-def setupheaderopts(ui, opts):
-    if not opts.get('user') and opts.get('currentuser'):
-        opts['user'] = ui.username()
-    if not opts.get('date') and opts.get('currentdate'):
-        opts['date'] = "%d %d" % util.makedate()
-
-@command("^qnew",
-         [('e', 'edit', None, _('edit commit message')),
-          ('f', 'force', None, _('import uncommitted changes (DEPRECATED)')),
-          ('g', 'git', None, _('use git extended diff format')),
-          ('U', 'currentuser', None, _('add "From: <current user>" to patch')),
-          ('u', 'user', '',
-           _('add "From: <USER>" to patch'), _('USER')),
-          ('D', 'currentdate', None, _('add "Date: <current date>" to patch')),
-          ('d', 'date', '',
-           _('add "Date: <DATE>" to patch'), _('DATE'))
-          ] + commands.walkopts + commands.commitopts,
-         _('hg qnew [-e] [-m TEXT] [-l FILE] PATCH [FILE]...'))
-def new(ui, repo, patch, *args, **opts):
-    """create a new patch
-
-    qnew creates a new patch on top of the currently-applied patch (if
-    any). The patch will be initialized with any outstanding changes
-    in the working directory. You may also use -I/--include,
-    -X/--exclude, and/or a list of files after the patch name to add
-    only changes to matching files to the new patch, leaving the rest
-    as uncommitted modifications.
-
-    -u/--user and -d/--date can be used to set the (given) user and
-    date, respectively. -U/--currentuser and -D/--currentdate set user
-    to current user and date to current date.
-
-    -e/--edit, -m/--message or -l/--logfile set the patch header as
-    well as the commit message. If none is specified, the header is
-    empty and the commit message is '[mq]: PATCH'.
-
-    Use the -g/--git option to keep the patch in the git extended diff
-    format. Read the diffs help topic for more information on why this
-    is important for preserving permission changes and copy/rename
-    information.
-
-    Returns 0 on successful creation of a new patch.
-    """
-    msg = cmdutil.logmessage(ui, opts)
-    def getmsg():
-        return ui.edit(msg, opts.get('user') or ui.username())
-    q = repo.mq
-    opts['msg'] = msg
-    if opts.get('edit'):
-        opts['msg'] = getmsg
-    else:
-        opts['msg'] = msg
-    setupheaderopts(ui, opts)
-    q.new(repo, patch, *args, **opts)
-    q.savedirty()
-    return 0
-
-@command("^qrefresh",
-         [('e', 'edit', None, _('edit commit message')),
-          ('g', 'git', None, _('use git extended diff format')),
-          ('s', 'short', None,
-           _('refresh only files already in the patch and specified files')),
-          ('U', 'currentuser', None,
-           _('add/update author field in patch with current user')),
-          ('u', 'user', '',
-           _('add/update author field in patch with given user'), _('USER')),
-          ('D', 'currentdate', None,
-           _('add/update date field in patch with current date')),
-          ('d', 'date', '',
-           _('add/update date field in patch with given date'), _('DATE'))
-          ] + commands.walkopts + commands.commitopts,
-         _('hg qrefresh [-I] [-X] [-e] [-m TEXT] [-l FILE] [-s] [FILE]...'))
-def refresh(ui, repo, *pats, **opts):
-    """update the current patch
-
-    If any file patterns are provided, the refreshed patch will
-    contain only the modifications that match those patterns; the
-    remaining modifications will remain in the working directory.
-
-    If -s/--short is specified, files currently included in the patch
-    will be refreshed just like matched files and remain in the patch.
-
-    If -e/--edit is specified, Mercurial will start your configured editor for
-    you to enter a message. In case qrefresh fails, you will find a backup of
-    your message in ``.hg/last-message.txt``.
-
-    hg add/remove/copy/rename work as usual, though you might want to
-    use git-style patches (-g/--git or [diff] git=1) to track copies
-    and renames. See the diffs help topic for more information on the
-    git diff format.
-
-    Returns 0 on success.
-    """
-    q = repo.mq
-    message = cmdutil.logmessage(ui, opts)
-    if opts.get('edit'):
-        if not q.applied:
-            ui.write(_("no patches applied\n"))
-            return 1
-        if message:
-            raise util.Abort(_('option "-e" incompatible with "-m" or "-l"'))
-        patch = q.applied[-1].name
-        ph = patchheader(q.join(patch), q.plainmode)
-        message = ui.edit('\n'.join(ph.message), ph.user or ui.username())
-        # We don't want to lose the patch message if qrefresh fails (issue2062)
-        repo.savecommitmessage(message)
-    setupheaderopts(ui, opts)
-    wlock = repo.wlock()
-    try:
-        ret = q.refresh(repo, pats, msg=message, **opts)
-        q.savedirty()
-        return ret
-    finally:
-        wlock.release()
-
-@command("^qdiff",
-         commands.diffopts + commands.diffopts2 + commands.walkopts,
-         _('hg qdiff [OPTION]... [FILE]...'))
-def diff(ui, repo, *pats, **opts):
-    """diff of the current patch and subsequent modifications
-
-    Shows a diff which includes the current patch as well as any
-    changes which have been made in the working directory since the
-    last refresh (thus showing what the current patch would become
-    after a qrefresh).
-
-    Use :hg:`diff` if you only want to see the changes made since the
-    last qrefresh, or :hg:`export qtip` if you want to see changes
-    made by the current patch without including changes made since the
-    qrefresh.
-
-    Returns 0 on success.
-    """
-    repo.mq.diff(repo, pats, opts)
-    return 0
-
-@command('qfold',
-         [('e', 'edit', None, _('edit patch header')),
-          ('k', 'keep', None, _('keep folded patch files')),
-         ] + commands.commitopts,
-         _('hg qfold [-e] [-k] [-m TEXT] [-l FILE] PATCH...'))
-def fold(ui, repo, *files, **opts):
-    """fold the named patches into the current patch
-
-    Patches must not yet be applied. Each patch will be successively
-    applied to the current patch in the order given. If all the
-    patches apply successfully, the current patch will be refreshed
-    with the new cumulative patch, and the folded patches will be
-    deleted. With -k/--keep, the folded patch files will not be
-    removed afterwards.
-
-    The header for each folded patch will be concatenated with the
-    current patch header, separated by a line of ``* * *``.
-
-    Returns 0 on success."""
-    q = repo.mq
-    if not files:
-        raise util.Abort(_('qfold requires at least one patch name'))
-    if not q.checktoppatch(repo)[0]:
-        raise util.Abort(_('no patches applied'))
-    q.checklocalchanges(repo)
-
-    message = cmdutil.logmessage(ui, opts)
-    if opts.get('edit'):
-        if message:
-            raise util.Abort(_('option "-e" incompatible with "-m" or "-l"'))
-
-    parent = q.lookup('qtip')
-    patches = []
-    messages = []
-    for f in files:
-        p = q.lookup(f)
-        if p in patches or p == parent:
-            ui.warn(_('skipping already folded patch %s\n') % p)
-        if q.isapplied(p):
-            raise util.Abort(_('qfold cannot fold already applied patch %s')
-                             % p)
-        patches.append(p)
-
-    for p in patches:
-        if not message:
-            ph = patchheader(q.join(p), q.plainmode)
-            if ph.message:
-                messages.append(ph.message)
-        pf = q.join(p)
-        (patchsuccess, files, fuzz) = q.patch(repo, pf)
-        if not patchsuccess:
-            raise util.Abort(_('error folding patch %s') % p)
-
-    if not message:
-        ph = patchheader(q.join(parent), q.plainmode)
-        message, user = ph.message, ph.user
-        for msg in messages:
-            message.append('* * *')
-            message.extend(msg)
-        message = '\n'.join(message)
-
-    if opts.get('edit'):
-        message = ui.edit(message, user or ui.username())
-
-    diffopts = q.patchopts(q.diffopts(), *patches)
-    wlock = repo.wlock()
-    try:
-        q.refresh(repo, msg=message, git=diffopts.git)
-        q.delete(repo, patches, opts)
-        q.savedirty()
-    finally:
-        wlock.release()
-
-@command("qgoto",
-         [('', 'keep-changes', None,
-           _('tolerate non-conflicting local changes')),
-          ('f', 'force', None, _('overwrite any local changes')),
-          ('', 'no-backup', None, _('do not save backup copies of files'))],
-         _('hg qgoto [OPTION]... PATCH'))
-def goto(ui, repo, patch, **opts):
-    '''push or pop patches until named patch is at top of stack
-
-    Returns 0 on success.'''
-    opts = fixkeepchangesopts(ui, opts)
-    q = repo.mq
-    patch = q.lookup(patch)
-    nobackup = opts.get('no_backup')
-    keepchanges = opts.get('keep_changes')
-    if q.isapplied(patch):
-        ret = q.pop(repo, patch, force=opts.get('force'), nobackup=nobackup,
-                    keepchanges=keepchanges)
-    else:
-        ret = q.push(repo, patch, force=opts.get('force'), nobackup=nobackup,
-                     keepchanges=keepchanges)
-    q.savedirty()
-    return ret
-
-@command("qguard",
-         [('l', 'list', None, _('list all patches and guards')),
-          ('n', 'none', None, _('drop all guards'))],
-         _('hg qguard [-l] [-n] [PATCH] [-- [+GUARD]... [-GUARD]...]'))
-def guard(ui, repo, *args, **opts):
-    '''set or print guards for a patch
-
-    Guards control whether a patch can be pushed. A patch with no
-    guards is always pushed. A patch with a positive guard ("+foo") is
-    pushed only if the :hg:`qselect` command has activated it. A patch with
-    a negative guard ("-foo") is never pushed if the :hg:`qselect` command
-    has activated it.
-
-    With no arguments, print the currently active guards.
-    With arguments, set guards for the named patch.
-
-    .. note::
-       Specifying negative guards now requires '--'.
-
-    To set guards on another patch::
-
-      hg qguard other.patch -- +2.6.17 -stable
-
-    Returns 0 on success.
-    '''
-    def status(idx):
-        guards = q.seriesguards[idx] or ['unguarded']
-        if q.series[idx] in applied:
-            state = 'applied'
-        elif q.pushable(idx)[0]:
-            state = 'unapplied'
-        else:
-            state = 'guarded'
-        label = 'qguard.patch qguard.%s qseries.%s' % (state, state)
-        ui.write('%s: ' % ui.label(q.series[idx], label))
-
-        for i, guard in enumerate(guards):
-            if guard.startswith('+'):
-                ui.write(guard, label='qguard.positive')
-            elif guard.startswith('-'):
-                ui.write(guard, label='qguard.negative')
-            else:
-                ui.write(guard, label='qguard.unguarded')
-            if i != len(guards) - 1:
-                ui.write(' ')
-        ui.write('\n')
-    q = repo.mq
-    applied = set(p.name for p in q.applied)
-    patch = None
-    args = list(args)
-    if opts.get('list'):
-        if args or opts.get('none'):
-            raise util.Abort(_('cannot mix -l/--list with options or '
-                               'arguments'))
-        for i in xrange(len(q.series)):
-            status(i)
-        return
-    if not args or args[0][0:1] in '-+':
-        if not q.applied:
-            raise util.Abort(_('no patches applied'))
-        patch = q.applied[-1].name
-    if patch is None and args[0][0:1] not in '-+':
-        patch = args.pop(0)
-    if patch is None:
-        raise util.Abort(_('no patch to work with'))
-    if args or opts.get('none'):
-        idx = q.findseries(patch)
-        if idx is None:
-            raise util.Abort(_('no patch named %s') % patch)
-        q.setguards(idx, args)
-        q.savedirty()
-    else:
-        status(q.series.index(q.lookup(patch)))
-
-@command("qheader", [], _('hg qheader [PATCH]'))
-def header(ui, repo, patch=None):
-    """print the header of the topmost or specified patch
-
-    Returns 0 on success."""
-    q = repo.mq
-
-    if patch:
-        patch = q.lookup(patch)
-    else:
-        if not q.applied:
-            ui.write(_('no patches applied\n'))
-            return 1
-        patch = q.lookup('qtip')
-    ph = patchheader(q.join(patch), q.plainmode)
-
-    ui.write('\n'.join(ph.message) + '\n')
-
-def lastsavename(path):
-    (directory, base) = os.path.split(path)
-    names = os.listdir(directory)
-    namere = re.compile("%s.([0-9]+)" % base)
-    maxindex = None
-    maxname = None
-    for f in names:
-        m = namere.match(f)
-        if m:
-            index = int(m.group(1))
-            if maxindex is None or index > maxindex:
-                maxindex = index
-                maxname = f
-    if maxname:
-        return (os.path.join(directory, maxname), maxindex)
-    return (None, None)
-
-def savename(path):
-    (last, index) = lastsavename(path)
-    if last is None:
-        index = 0
-    newpath = path + ".%d" % (index + 1)
-    return newpath
-
-@command("^qpush",
-         [('', 'keep-changes', None,
-           _('tolerate non-conflicting local changes')),
-          ('f', 'force', None, _('apply on top of local changes')),
-          ('e', 'exact', None,
-           _('apply the target patch to its recorded parent')),
-          ('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)'), _('NAME')),
-          ('', 'move', None,
-           _('reorder patch series and apply only the patch')),
-          ('', 'no-backup', None, _('do not save backup copies of files'))],
-         _('hg qpush [-f] [-l] [-a] [--move] [PATCH | INDEX]'))
-def push(ui, repo, patch=None, **opts):
-    """push the next patch onto the stack
-
-    By default, abort if the working directory contains uncommitted
-    changes. With --keep-changes, abort only if the uncommitted files
-    overlap with patched files. With -f/--force, backup and patch over
-    uncommitted changes.
-
-    Return 0 on success.
-    """
-    q = repo.mq
-    mergeq = None
-
-    opts = fixkeepchangesopts(ui, opts)
-    if opts.get('merge'):
-        if opts.get('name'):
-            newpath = repo.join(opts.get('name'))
-        else:
-            newpath, i = lastsavename(q.path)
-        if not newpath:
-            ui.warn(_("no saved queues found, please use -n\n"))
-            return 1
-        mergeq = queue(ui, repo.path, newpath)
-        ui.warn(_("merging with queue at: %s\n") % mergeq.path)
-    ret = q.push(repo, patch, force=opts.get('force'), list=opts.get('list'),
-                 mergeq=mergeq, all=opts.get('all'), move=opts.get('move'),
-                 exact=opts.get('exact'), nobackup=opts.get('no_backup'),
-                 keepchanges=opts.get('keep_changes'))
-    return ret
-
-@command("^qpop",
-         [('a', 'all', None, _('pop all patches')),
-          ('n', 'name', '',
-           _('queue name to pop (DEPRECATED)'), _('NAME')),
-          ('', 'keep-changes', None,
-           _('tolerate non-conflicting local changes')),
-          ('f', 'force', None, _('forget any local changes to patched files')),
-          ('', 'no-backup', None, _('do not save backup copies of files'))],
-         _('hg qpop [-a] [-f] [PATCH | INDEX]'))
-def pop(ui, repo, patch=None, **opts):
-    """pop the current patch off the stack
-
-    Without argument, pops off the top of the patch stack. If given a
-    patch name, keeps popping off patches until the named patch is at
-    the top of the stack.
-
-    By default, abort if the working directory contains uncommitted
-    changes. With --keep-changes, abort only if the uncommitted files
-    overlap with patched files. With -f/--force, backup and discard
-    changes made to such files.
-
-    Return 0 on success.
-    """
-    opts = fixkeepchangesopts(ui, opts)
-    localupdate = True
-    if opts.get('name'):
-        q = queue(ui, repo.path, repo.join(opts.get('name')))
-        ui.warn(_('using patch queue: %s\n') % q.path)
-        localupdate = False
-    else:
-        q = repo.mq
-    ret = q.pop(repo, patch, force=opts.get('force'), update=localupdate,
-                all=opts.get('all'), nobackup=opts.get('no_backup'),
-                keepchanges=opts.get('keep_changes'))
-    q.savedirty()
-    return ret
-
-@command("qrename|qmv", [], _('hg qrename PATCH1 [PATCH2]'))
-def rename(ui, repo, patch, name=None, **opts):
-    """rename a patch
-
-    With one argument, renames the current patch to PATCH1.
-    With two arguments, renames PATCH1 to PATCH2.
-
-    Returns 0 on success."""
-    q = repo.mq
-    if not name:
-        name = patch
-        patch = None
-
-    if patch:
-        patch = q.lookup(patch)
-    else:
-        if not q.applied:
-            ui.write(_('no patches applied\n'))
-            return
-        patch = q.lookup('qtip')
-    absdest = q.join(name)
-    if os.path.isdir(absdest):
-        name = normname(os.path.join(name, os.path.basename(patch)))
-        absdest = q.join(name)
-    q.checkpatchname(name)
-
-    ui.note(_('renaming %s to %s\n') % (patch, name))
-    i = q.findseries(patch)
-    guards = q.guard_re.findall(q.fullseries[i])
-    q.fullseries[i] = name + ''.join([' #' + g for g in guards])
-    q.parseseries()
-    q.seriesdirty = True
-
-    info = q.isapplied(patch)
-    if info:
-        q.applied[info[0]] = statusentry(info[1], name)
-    q.applieddirty = True
-
-    destdir = os.path.dirname(absdest)
-    if not os.path.isdir(destdir):
-        os.makedirs(destdir)
-    util.rename(q.join(patch), absdest)
-    r = q.qrepo()
-    if r and patch in r.dirstate:
-        wctx = r[None]
-        wlock = r.wlock()
-        try:
-            if r.dirstate[patch] == 'a':
-                r.dirstate.drop(patch)
-                r.dirstate.add(name)
-            else:
-                wctx.copy(patch, name)
-                wctx.forget([patch])
-        finally:
-            wlock.release()
-
-    q.savedirty()
-
-@command("qrestore",
-         [('d', 'delete', None, _('delete save entry')),
-          ('u', 'update', None, _('update queue working directory'))],
-         _('hg qrestore [-d] [-u] REV'))
-def restore(ui, repo, rev, **opts):
-    """restore the queue state saved by a revision (DEPRECATED)
-
-    This command is deprecated, use :hg:`rebase` instead."""
-    rev = repo.lookup(rev)
-    q = repo.mq
-    q.restore(repo, rev, delete=opts.get('delete'),
-              qupdate=opts.get('update'))
-    q.savedirty()
-    return 0
-
-@command("qsave",
-         [('c', 'copy', None, _('copy patch directory')),
-          ('n', 'name', '',
-           _('copy directory name'), _('NAME')),
-          ('e', 'empty', None, _('clear queue status file')),
-          ('f', 'force', None, _('force copy'))] + commands.commitopts,
-         _('hg qsave [-m TEXT] [-l FILE] [-c] [-n NAME] [-e] [-f]'))
-def save(ui, repo, **opts):
-    """save current queue state (DEPRECATED)
-
-    This command is deprecated, use :hg:`rebase` instead."""
-    q = repo.mq
-    message = cmdutil.logmessage(ui, opts)
-    ret = q.save(repo, msg=message)
-    if ret:
-        return ret
-    q.savedirty() # save to .hg/patches before copying
-    if opts.get('copy'):
-        path = q.path
-        if opts.get('name'):
-            newpath = os.path.join(q.basepath, opts.get('name'))
-            if os.path.exists(newpath):
-                if not os.path.isdir(newpath):
-                    raise util.Abort(_('destination %s exists and is not '
-                                       'a directory') % newpath)
-                if not opts.get('force'):
-                    raise util.Abort(_('destination %s exists, '
-                                       'use -f to force') % newpath)
-        else:
-            newpath = savename(path)
-        ui.warn(_("copy %s to %s\n") % (path, newpath))
-        util.copyfiles(path, newpath)
-    if opts.get('empty'):
-        del q.applied[:]
-        q.applieddirty = True
-        q.savedirty()
-    return 0
-
-@command("strip",
-         [
-          ('r', 'rev', [], _('strip specified revision (optional, '
-                               'can specify revisions without this '
-                               'option)'), _('REV')),
-          ('f', 'force', None, _('force removal of changesets, discard '
-                                 'uncommitted changes (no backup)')),
-          ('b', 'backup', None, _('bundle only changesets with local revision'
-                                  ' number greater than REV which are not'
-                                  ' descendants of REV (DEPRECATED)')),
-          ('', 'no-backup', None, _('no backups')),
-          ('', 'nobackup', None, _('no backups (DEPRECATED)')),
-          ('n', '', None, _('ignored  (DEPRECATED)')),
-          ('k', 'keep', None, _("do not modify working copy during strip")),
-          ('B', 'bookmark', '', _("remove revs only reachable from given"
-                                  " bookmark"))],
-          _('hg strip [-k] [-f] [-n] [-B bookmark] [-r] REV...'))
-def strip(ui, repo, *revs, **opts):
-    """strip changesets and all their descendants from the repository
-
-    The strip command removes the specified changesets and all their
-    descendants. If the working directory has uncommitted changes, the
-    operation is aborted unless the --force flag is supplied, in which
-    case changes will be discarded.
-
-    If a parent of the working directory is stripped, then the working
-    directory will automatically be updated to the most recent
-    available ancestor of the stripped parent after the operation
-    completes.
-
-    Any stripped changesets are stored in ``.hg/strip-backup`` as a
-    bundle (see :hg:`help bundle` and :hg:`help unbundle`). They can
-    be restored by running :hg:`unbundle .hg/strip-backup/BUNDLE`,
-    where BUNDLE is the bundle file created by the strip. Note that
-    the local revision numbers will in general be different after the
-    restore.
-
-    Use the --no-backup option to discard the backup bundle once the
-    operation completes.
-
-    Strip is not a history-rewriting operation and can be used on
-    changesets in the public phase. But if the stripped changesets have
-    been pushed to a remote repository you will likely pull them again.
-
-    Return 0 on success.
-    """
-    backup = 'all'
-    if opts.get('backup'):
-        backup = 'strip'
-    elif opts.get('no_backup') or opts.get('nobackup'):
-        backup = 'none'
-
-    cl = repo.changelog
-    revs = list(revs) + opts.get('rev')
-    revs = set(scmutil.revrange(repo, revs))
-
-    if opts.get('bookmark'):
-        mark = opts.get('bookmark')
-        marks = repo._bookmarks
-        if mark not in marks:
-            raise util.Abort(_("bookmark '%s' not found") % mark)
-
-        # If the requested bookmark is not the only one pointing to a
-        # a revision we have to only delete the bookmark and not strip
-        # anything. revsets cannot detect that case.
-        uniquebm = True
-        for m, n in marks.iteritems():
-            if m != mark and n == repo[mark].node():
-                uniquebm = False
-                break
-        if uniquebm:
-            rsrevs = repo.revs("ancestors(bookmark(%s)) - "
-                               "ancestors(head() and not bookmark(%s)) - "
-                               "ancestors(bookmark() and not bookmark(%s))",
-                               mark, mark, mark)
-            revs.update(set(rsrevs))
-        if not revs:
-            del marks[mark]
-            marks.write()
-            ui.write(_("bookmark '%s' deleted\n") % mark)
-
-    if not revs:
-        raise util.Abort(_('empty revision set'))
-
-    descendants = set(cl.descendants(revs))
-    strippedrevs = revs.union(descendants)
-    roots = revs.difference(descendants)
-
-    update = False
-    # if one of the wdir parent is stripped we'll need
-    # to update away to an earlier revision
-    for p in repo.dirstate.parents():
-        if p != nullid and cl.rev(p) in strippedrevs:
-            update = True
-            break
-
-    rootnodes = set(cl.node(r) for r in roots)
-
-    q = repo.mq
-    if q.applied:
-        # refresh queue state if we're about to strip
-        # applied patches
-        if cl.rev(repo.lookup('qtip')) in strippedrevs:
-            q.applieddirty = True
-            start = 0
-            end = len(q.applied)
-            for i, statusentry in enumerate(q.applied):
-                if statusentry.node in rootnodes:
-                    # if one of the stripped roots is an applied
-                    # patch, only part of the queue is stripped
-                    start = i
-                    break
-            del q.applied[start:end]
-            q.savedirty()
-
-    revs = sorted(rootnodes)
-    if update and opts.get('keep'):
-        wlock = repo.wlock()
-        try:
-            urev = repo.mq.qparents(repo, revs[0])
-            uctx = repo[urev]
-
-            # only reset the dirstate for files that would actually change
-            # between the working context and uctx
-            descendantrevs = repo.revs("%s::." % uctx.rev())
-            changedfiles = []
-            for rev in descendantrevs:
-                # blindy reset the files, regardless of what actually changed
-                changedfiles.extend(repo[rev].files())
-
-            # reset files that only changed in the dirstate too
-            dirstate = repo.dirstate
-            dirchanges = [f for f in dirstate if dirstate[f] != 'n']
-            changedfiles.extend(dirchanges)
-
-            repo.dirstate.rebuild(urev, uctx.manifest(), changedfiles)
-            repo.dirstate.write()
-            update = False
-        finally:
-            wlock.release()
-
-    if opts.get('bookmark'):
-        del marks[mark]
-        marks.write()
-        ui.write(_("bookmark '%s' deleted\n") % mark)
-
-    repo.mq.strip(repo, revs, backup=backup, update=update,
-                  force=opts.get('force'))
-
-    return 0
-
-@command("qselect",
-         [('n', 'none', None, _('disable all guards')),
-          ('s', 'series', None, _('list all guards in series file')),
-          ('', 'pop', None, _('pop to before first guarded applied patch')),
-          ('', 'reapply', None, _('pop, then reapply patches'))],
-         _('hg qselect [OPTION]... [GUARD]...'))
-def select(ui, repo, *args, **opts):
-    '''set or print guarded patches to push
-
-    Use the :hg:`qguard` command to set or print guards on patch, then use
-    qselect to tell mq which guards to use. A patch will be pushed if
-    it has no guards or any positive guards match the currently
-    selected guard, but will not be pushed if any negative guards
-    match the current guard. For example::
-
-        qguard foo.patch -- -stable    (negative guard)
-        qguard bar.patch    +stable    (positive guard)
-        qselect stable
-
-    This activates the "stable" guard. mq will skip foo.patch (because
-    it has a negative match) but push bar.patch (because it has a
-    positive match).
-
-    With no arguments, prints the currently active guards.
-    With one argument, sets the active guard.
-
-    Use -n/--none to deactivate guards (no other arguments needed).
-    When no guards are active, patches with positive guards are
-    skipped and patches with negative guards are pushed.
-
-    qselect can change the guards on applied patches. It does not pop
-    guarded patches by default. Use --pop to pop back to the last
-    applied patch that is not guarded. Use --reapply (which implies
-    --pop) to push back to the current patch afterwards, but skip
-    guarded patches.
-
-    Use -s/--series to print a list of all guards in the series file
-    (no other arguments needed). Use -v for more information.
-
-    Returns 0 on success.'''
-
-    q = repo.mq
-    guards = q.active()
-    if args or opts.get('none'):
-        old_unapplied = q.unapplied(repo)
-        old_guarded = [i for i in xrange(len(q.applied)) if
-                       not q.pushable(i)[0]]
-        q.setactive(args)
-        q.savedirty()
-        if not args:
-            ui.status(_('guards deactivated\n'))
-        if not opts.get('pop') and not opts.get('reapply'):
-            unapplied = q.unapplied(repo)
-            guarded = [i for i in xrange(len(q.applied))
-                       if not q.pushable(i)[0]]
-            if len(unapplied) != len(old_unapplied):
-                ui.status(_('number of unguarded, unapplied patches has '
-                            'changed from %d to %d\n') %
-                          (len(old_unapplied), len(unapplied)))
-            if len(guarded) != len(old_guarded):
-                ui.status(_('number of guarded, applied patches has changed '
-                            'from %d to %d\n') %
-                          (len(old_guarded), len(guarded)))
-    elif opts.get('series'):
-        guards = {}
-        noguards = 0
-        for gs in q.seriesguards:
-            if not gs:
-                noguards += 1
-            for g in gs:
-                guards.setdefault(g, 0)
-                guards[g] += 1
-        if ui.verbose:
-            guards['NONE'] = noguards
-        guards = guards.items()
-        guards.sort(key=lambda x: x[0][1:])
-        if guards:
-            ui.note(_('guards in series file:\n'))
-            for guard, count in guards:
-                ui.note('%2d  ' % count)
-                ui.write(guard, '\n')
-        else:
-            ui.note(_('no guards in series file\n'))
-    else:
-        if guards:
-            ui.note(_('active guards:\n'))
-            for g in guards:
-                ui.write(g, '\n')
-        else:
-            ui.write(_('no active guards\n'))
-    reapply = opts.get('reapply') and q.applied and q.appliedname(-1)
-    popped = False
-    if opts.get('pop') or opts.get('reapply'):
-        for i in xrange(len(q.applied)):
-            pushable, reason = q.pushable(i)
-            if not pushable:
-                ui.status(_('popping guarded patches\n'))
-                popped = True
-                if i == 0:
-                    q.pop(repo, all=True)
-                else:
-                    q.pop(repo, str(i - 1))
-                break
-    if popped:
-        try:
-            if reapply:
-                ui.status(_('reapplying unguarded patches\n'))
-                q.push(repo, reapply)
-        finally:
-            q.savedirty()
-
-@command("qfinish",
-         [('a', 'applied', None, _('finish all applied changesets'))],
-         _('hg qfinish [-a] [REV]...'))
-def finish(ui, repo, *revrange, **opts):
-    """move applied patches into repository history
-
-    Finishes the specified revisions (corresponding to applied
-    patches) by moving them out of mq control into regular repository
-    history.
-
-    Accepts a revision range or the -a/--applied option. If --applied
-    is specified, all applied mq revisions are removed from mq
-    control. Otherwise, the given revisions must be at the base of the
-    stack of applied patches.
-
-    This can be especially useful if your changes have been applied to
-    an upstream repository, or if you are about to push your changes
-    to upstream.
-
-    Returns 0 on success.
-    """
-    if not opts.get('applied') and not revrange:
-        raise util.Abort(_('no revisions specified'))
-    elif opts.get('applied'):
-        revrange = ('qbase::qtip',) + revrange
-
-    q = repo.mq
-    if not q.applied:
-        ui.status(_('no patches applied\n'))
-        return 0
-
-    revs = scmutil.revrange(repo, revrange)
-    if repo['.'].rev() in revs and repo[None].files():
-        ui.warn(_('warning: uncommitted changes in the working directory\n'))
-    # queue.finish may changes phases but leave the responsibility to lock the
-    # repo to the caller to avoid deadlock with wlock. This command code is
-    # responsibility for this locking.
-    lock = repo.lock()
-    try:
-        q.finish(repo, revs)
-        q.savedirty()
-    finally:
-        lock.release()
-    return 0
-
-@command("qqueue",
-         [('l', 'list', False, _('list all available queues')),
-          ('', 'active', False, _('print name of active queue')),
-          ('c', 'create', False, _('create new queue')),
-          ('', 'rename', False, _('rename active queue')),
-          ('', 'delete', False, _('delete reference to queue')),
-          ('', 'purge', False, _('delete queue, and remove patch dir')),
-         ],
-         _('[OPTION] [QUEUE]'))
-def qqueue(ui, repo, name=None, **opts):
-    '''manage multiple patch queues
-
-    Supports switching between different patch queues, as well as creating
-    new patch queues and deleting existing ones.
-
-    Omitting a queue name or specifying -l/--list will show you the registered
-    queues - by default the "normal" patches queue is registered. The currently
-    active queue will be marked with "(active)". Specifying --active will print
-    only the name of the active queue.
-
-    To create a new queue, use -c/--create. The queue is automatically made
-    active, except in the case where there are applied patches from the
-    currently active queue in the repository. Then the queue will only be
-    created and switching will fail.
-
-    To delete an existing queue, use --delete. You cannot delete the currently
-    active queue.
-
-    Returns 0 on success.
-    '''
-    q = repo.mq
-    _defaultqueue = 'patches'
-    _allqueues = 'patches.queues'
-    _activequeue = 'patches.queue'
-
-    def _getcurrent():
-        cur = os.path.basename(q.path)
-        if cur.startswith('patches-'):
-            cur = cur[8:]
-        return cur
-
-    def _noqueues():
-        try:
-            fh = repo.opener(_allqueues, 'r')
-            fh.close()
-        except IOError:
-            return True
-
-        return False
-
-    def _getqueues():
-        current = _getcurrent()
-
-        try:
-            fh = repo.opener(_allqueues, 'r')
-            queues = [queue.strip() for queue in fh if queue.strip()]
-            fh.close()
-            if current not in queues:
-                queues.append(current)
-        except IOError:
-            queues = [_defaultqueue]
-
-        return sorted(queues)
-
-    def _setactive(name):
-        if q.applied:
-            raise util.Abort(_('new queue created, but cannot make active '
-                               'as patches are applied'))
-        _setactivenocheck(name)
-
-    def _setactivenocheck(name):
-        fh = repo.opener(_activequeue, 'w')
-        if name != 'patches':
-            fh.write(name)
-        fh.close()
-
-    def _addqueue(name):
-        fh = repo.opener(_allqueues, 'a')
-        fh.write('%s\n' % (name,))
-        fh.close()
-
-    def _queuedir(name):
-        if name == 'patches':
-            return repo.join('patches')
-        else:
-            return repo.join('patches-' + name)
-
-    def _validname(name):
-        for n in name:
-            if n in ':\\/.':
-                return False
-        return True
-
-    def _delete(name):
-        if name not in existing:
-            raise util.Abort(_('cannot delete queue that does not exist'))
-
-        current = _getcurrent()
-
-        if name == current:
-            raise util.Abort(_('cannot delete currently active queue'))
-
-        fh = repo.opener('patches.queues.new', 'w')
-        for queue in existing:
-            if queue == name:
-                continue
-            fh.write('%s\n' % (queue,))
-        fh.close()
-        util.rename(repo.join('patches.queues.new'), repo.join(_allqueues))
-
-    if not name or opts.get('list') or opts.get('active'):
-        current = _getcurrent()
-        if opts.get('active'):
-            ui.write('%s\n' % (current,))
-            return
-        for queue in _getqueues():
-            ui.write('%s' % (queue,))
-            if queue == current and not ui.quiet:
-                ui.write(_(' (active)\n'))
-            else:
-                ui.write('\n')
-        return
-
-    if not _validname(name):
-        raise util.Abort(
-                _('invalid queue name, may not contain the characters ":\\/."'))
-
-    existing = _getqueues()
-
-    if opts.get('create'):
-        if name in existing:
-            raise util.Abort(_('queue "%s" already exists') % name)
-        if _noqueues():
-            _addqueue(_defaultqueue)
-        _addqueue(name)
-        _setactive(name)
-    elif opts.get('rename'):
-        current = _getcurrent()
-        if name == current:
-            raise util.Abort(_('can\'t rename "%s" to its current name') % name)
-        if name in existing:
-            raise util.Abort(_('queue "%s" already exists') % name)
-
-        olddir = _queuedir(current)
-        newdir = _queuedir(name)
-
-        if os.path.exists(newdir):
-            raise util.Abort(_('non-queue directory "%s" already exists') %
-                    newdir)
-
-        fh = repo.opener('patches.queues.new', 'w')
-        for queue in existing:
-            if queue == current:
-                fh.write('%s\n' % (name,))
-                if os.path.exists(olddir):
-                    util.rename(olddir, newdir)
-            else:
-                fh.write('%s\n' % (queue,))
-        fh.close()
-        util.rename(repo.join('patches.queues.new'), repo.join(_allqueues))
-        _setactivenocheck(name)
-    elif opts.get('delete'):
-        _delete(name)
-    elif opts.get('purge'):
-        if name in existing:
-            _delete(name)
-        qdir = _queuedir(name)
-        if os.path.exists(qdir):
-            shutil.rmtree(qdir)
-    else:
-        if name not in existing:
-            raise util.Abort(_('use --create to create a new queue'))
-        _setactive(name)
-
-def mqphasedefaults(repo, roots):
-    """callback used to set mq changeset as secret when no phase data exists"""
-    if repo.mq.applied:
-        if repo.ui.configbool('mq', 'secret', False):
-            mqphase = phases.secret
-        else:
-            mqphase = phases.draft
-        qbase = repo[repo.mq.applied[0].node]
-        roots[mqphase].add(qbase.node())
-    return roots
-
-def reposetup(ui, repo):
-    class mqrepo(repo.__class__):
-        @util.propertycache
-        def mq(self):
-            return queue(self.ui, self.path)
-
-        def abortifwdirpatched(self, errmsg, force=False):
-            if self.mq.applied and not force:
-                parents = self.dirstate.parents()
-                patches = [s.node for s in self.mq.applied]
-                if parents[0] in patches or parents[1] in patches:
-                    raise util.Abort(errmsg)
-
-        def commit(self, text="", user=None, date=None, match=None,
-                   force=False, editor=False, extra={}):
-            self.abortifwdirpatched(
-                _('cannot commit over an applied mq patch'),
-                force)
-
-            return super(mqrepo, self).commit(text, user, date, match, force,
-                                              editor, extra)
-
-        def checkpush(self, force, revs):
-            if self.mq.applied and not force:
-                outapplied = [e.node for e in self.mq.applied]
-                if revs:
-                    # Assume applied patches have no non-patch descendants and
-                    # are not on remote already. Filtering any changeset not
-                    # pushed.
-                    heads = set(revs)
-                    for node in reversed(outapplied):
-                        if node in heads:
-                            break
-                        else:
-                            outapplied.pop()
-                # looking for pushed and shared changeset
-                for node in outapplied:
-                    if self[node].phase() < phases.secret:
-                        raise util.Abort(_('source has mq patches applied'))
-                # no non-secret patches pushed
-            super(mqrepo, self).checkpush(force, revs)
-
-        def _findtags(self):
-            '''augment tags from base class with patch tags'''
-            result = super(mqrepo, self)._findtags()
-
-            q = self.mq
-            if not q.applied:
-                return result
-
-            mqtags = [(patch.node, patch.name) for patch in q.applied]
-
-            try:
-                # for now ignore filtering business
-                self.unfiltered().changelog.rev(mqtags[-1][0])
-            except error.LookupError:
-                self.ui.warn(_('mq status file refers to unknown node %s\n')
-                             % short(mqtags[-1][0]))
-                return result
-
-            # do not add fake tags for filtered revisions
-            included = self.changelog.hasnode
-            mqtags = [mqt for mqt in mqtags if included(mqt[0])]
-            if not mqtags:
-                return result
-
-            mqtags.append((mqtags[-1][0], 'qtip'))
-            mqtags.append((mqtags[0][0], 'qbase'))
-            mqtags.append((self.changelog.parents(mqtags[0][0])[0], 'qparent'))
-            tags = result[0]
-            for patch in mqtags:
-                if patch[1] in tags:
-                    self.ui.warn(_('tag %s overrides mq patch of the same '
-                                   'name\n') % patch[1])
-                else:
-                    tags[patch[1]] = patch[0]
-
-            return result
-
-    if repo.local():
-        repo.__class__ = mqrepo
-
-        repo._phasedefaults.append(mqphasedefaults)
-
-def mqimport(orig, ui, repo, *args, **kwargs):
-    if (util.safehasattr(repo, 'abortifwdirpatched')
-        and not kwargs.get('no_commit', False)):
-        repo.abortifwdirpatched(_('cannot import over an applied patch'),
-                                   kwargs.get('force'))
-    return orig(ui, repo, *args, **kwargs)
-
-def mqinit(orig, ui, *args, **kwargs):
-    mq = kwargs.pop('mq', None)
-
-    if not mq:
-        return orig(ui, *args, **kwargs)
-
-    if args:
-        repopath = args[0]
-        if not hg.islocal(repopath):
-            raise util.Abort(_('only a local queue repository '
-                               'may be initialized'))
-    else:
-        repopath = cmdutil.findrepo(os.getcwd())
-        if not repopath:
-            raise util.Abort(_('there is no Mercurial repository here '
-                               '(.hg not found)'))
-    repo = hg.repository(ui, repopath)
-    return qinit(ui, repo, True)
-
-def mqcommand(orig, ui, repo, *args, **kwargs):
-    """Add --mq option to operate on patch repository instead of main"""
-
-    # some commands do not like getting unknown options
-    mq = kwargs.pop('mq', None)
-
-    if not mq:
-        return orig(ui, repo, *args, **kwargs)
-
-    q = repo.mq
-    r = q.qrepo()
-    if not r:
-        raise util.Abort(_('no queue repository'))
-    return orig(r.ui, r, *args, **kwargs)
-
-def summary(orig, ui, repo, *args, **kwargs):
-    r = orig(ui, repo, *args, **kwargs)
-    q = repo.mq
-    m = []
-    a, u = len(q.applied), len(q.unapplied(repo))
-    if a:
-        m.append(ui.label(_("%d applied"), 'qseries.applied') % a)
-    if u:
-        m.append(ui.label(_("%d unapplied"), 'qseries.unapplied') % u)
-    if m:
-        # i18n: column positioning for "hg summary"
-        ui.write(_("mq:     %s\n") % ', '.join(m))
-    else:
-        # i18n: column positioning for "hg summary"
-        ui.note(_("mq:     (empty queue)\n"))
-    return r
-
-def revsetmq(repo, subset, x):
-    """``mq()``
-    Changesets managed by MQ.
-    """
-    revset.getargs(x, 0, 0, _("mq takes no arguments"))
-    applied = set([repo[r.node].rev() for r in repo.mq.applied])
-    return [r for r in subset if r in applied]
-
-# tell hggettext to extract docstrings from these functions:
-i18nfunctions = [revsetmq]
-
-def extsetup(ui):
-    # Ensure mq wrappers are called first, regardless of extension load order by
-    # NOT wrapping in uisetup() and instead deferring to init stage two here.
-    mqopt = [('', 'mq', None, _("operate on patch repository"))]
-
-    extensions.wrapcommand(commands.table, 'import', mqimport)
-    extensions.wrapcommand(commands.table, 'summary', summary)
-
-    entry = extensions.wrapcommand(commands.table, 'init', mqinit)
-    entry[1].extend(mqopt)
-
-    nowrap = set(commands.norepo.split(" "))
-
-    def dotable(cmdtable):
-        for cmd in cmdtable.keys():
-            cmd = cmdutil.parsealiases(cmd)[0]
-            if cmd in nowrap:
-                continue
-            entry = extensions.wrapcommand(cmdtable, cmd, mqcommand)
-            entry[1].extend(mqopt)
-
-    dotable(commands.table)
-
-    for extname, extmodule in extensions.extensions():
-        if extmodule.__file__ != __file__:
-            dotable(getattr(extmodule, 'cmdtable', {}))
-
-    revset.symbols['mq'] = revsetmq
-
-colortable = {'qguard.negative': 'red',
-              'qguard.positive': 'yellow',
-              'qguard.unguarded': 'green',
-              'qseries.applied': 'blue bold underline',
-              'qseries.guarded': 'black bold',
-              'qseries.missing': 'red bold',
-              'qseries.unapplied': 'black bold'}
-
-commands.inferrepo += " qnew qrefresh qdiff qcommit"
diff --git a/tests/test-mq-eol.t b/tests/test-mq-eol.t
deleted file mode 100644
--- a/tests/test-mq-eol.t
+++ /dev/null
@@ -1,207 +0,0 @@ 
-
-Test interactions between mq and patch.eol
-
-
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "mq=" >> $HGRCPATH
-  $ echo "[diff]" >> $HGRCPATH
-  $ echo "nodates=1" >> $HGRCPATH
-
-  $ cat > makepatch.py <<EOF
-  > f = file('eol.diff', 'wb')
-  > w = f.write
-  > w('test message\n')
-  > w('diff --git a/a b/a\n')
-  > w('--- a/a\n')
-  > w('+++ b/a\n')
-  > w('@@ -1,5 +1,5 @@\n')
-  > w(' a\n')
-  > w('-b\r\n')
-  > w('+y\r\n')
-  > w(' c\r\n')
-  > w(' d\n')
-  > w('-e\n')
-  > w('\ No newline at end of file\n')
-  > w('+z\r\n')
-  > w('\ No newline at end of file\r\n')
-  > EOF
-
-  $ cat > cateol.py <<EOF
-  > import sys
-  > for line in file(sys.argv[1], 'rb'):
-  >     line = line.replace('\r', '<CR>')
-  >     line = line.replace('\n', '<LF>')
-  >     print line
-  > EOF
-
-  $ hg init repo
-  $ cd repo
-  $ echo '\.diff' > .hgignore
-  $ echo '\.rej' >> .hgignore
-
-
-Test different --eol values
-
-  $ python -c 'file("a", "wb").write("a\nb\nc\nd\ne")'
-  $ hg ci -Am adda
-  adding .hgignore
-  adding a
-  $ python ../makepatch.py
-  $ hg qimport eol.diff
-  adding eol.diff to series file
-
-should fail in strict mode
-
-  $ hg qpush
-  applying eol.diff
-  patching file a
-  Hunk #1 FAILED at 0
-  1 out of 1 hunks FAILED -- saving rejects to file a.rej
-  patch failed, unable to continue (try -v)
-  patch failed, rejects left in working dir
-  errors during apply, please fix and refresh eol.diff
-  [2]
-  $ hg qpop
-  popping eol.diff
-  patch queue now empty
-
-invalid eol
-
-  $ hg --config patch.eol='LFCR' qpush
-  applying eol.diff
-  patch failed, unable to continue (try -v)
-  patch failed, rejects left in working dir
-  errors during apply, please fix and refresh eol.diff
-  [2]
-  $ hg qpop
-  popping eol.diff
-  patch queue now empty
-
-force LF
-
-  $ hg --config patch.eol='CRLF' qpush
-  applying eol.diff
-  now at: eol.diff
-  $ hg qrefresh
-  $ python ../cateol.py .hg/patches/eol.diff
-  test message<LF>
-  <LF>
-  diff -r 0d0bf99a8b7a a<LF>
-  --- a/a<LF>
-  +++ b/a<LF>
-  @@ -1,5 +1,5 @@<LF>
-  -a<LF>
-  -b<LF>
-  -c<LF>
-  -d<LF>
-  -e<LF>
-  \ No newline at end of file<LF>
-  +a<CR><LF>
-  +y<CR><LF>
-  +c<CR><LF>
-  +d<CR><LF>
-  +z<LF>
-  \ No newline at end of file<LF>
-  $ python ../cateol.py a
-  a<CR><LF>
-  y<CR><LF>
-  c<CR><LF>
-  d<CR><LF>
-  z
-  $ hg qpop
-  popping eol.diff
-  patch queue now empty
-
-push again forcing LF and compare revisions
-
-  $ hg --config patch.eol='CRLF' qpush
-  applying eol.diff
-  now at: eol.diff
-  $ python ../cateol.py a
-  a<CR><LF>
-  y<CR><LF>
-  c<CR><LF>
-  d<CR><LF>
-  z
-  $ hg qpop
-  popping eol.diff
-  patch queue now empty
-
-push again without LF and compare revisions
-
-  $ hg qpush
-  applying eol.diff
-  now at: eol.diff
-  $ python ../cateol.py a
-  a<CR><LF>
-  y<CR><LF>
-  c<CR><LF>
-  d<CR><LF>
-  z
-  $ hg qpop
-  popping eol.diff
-  patch queue now empty
-  $ cd ..
-
-
-Test .rej file EOL are left unchanged
-
-  $ hg init testeol
-  $ cd testeol
-  $ python -c "file('a', 'wb').write('1\r\n2\r\n3\r\n4')"
-  $ hg ci -Am adda
-  adding a
-  $ python -c "file('a', 'wb').write('1\r\n2\r\n33\r\n4')"
-  $ hg qnew patch1
-  $ hg qpop
-  popping patch1
-  patch queue now empty
-  $ python -c "file('a', 'wb').write('1\r\n22\r\n33\r\n4')"
-  $ hg ci -m changea
-
-  $ hg --config 'patch.eol=LF' qpush
-  applying patch1
-  patching file a
-  Hunk #1 FAILED at 0
-  1 out of 1 hunks FAILED -- saving rejects to file a.rej
-  patch failed, unable to continue (try -v)
-  patch failed, rejects left in working dir
-  errors during apply, please fix and refresh patch1
-  [2]
-  $ hg qpop
-  popping patch1
-  patch queue now empty
-  $ cat a.rej
-  --- a
-  +++ a
-  @@ -1,4 +1,4 @@
-   1\r (esc)
-   2\r (esc)
-  -3\r (esc)
-  +33\r (esc)
-   4
-  \ No newline at end of file
-
-  $ hg --config 'patch.eol=auto' qpush
-  applying patch1
-  patching file a
-  Hunk #1 FAILED at 0
-  1 out of 1 hunks FAILED -- saving rejects to file a.rej
-  patch failed, unable to continue (try -v)
-  patch failed, rejects left in working dir
-  errors during apply, please fix and refresh patch1
-  [2]
-  $ hg qpop
-  popping patch1
-  patch queue now empty
-  $ cat a.rej
-  --- a
-  +++ a
-  @@ -1,4 +1,4 @@
-   1\r (esc)
-   2\r (esc)
-  -3\r (esc)
-  +33\r (esc)
-   4
-  \ No newline at end of file
-  $ cd ..
diff --git a/tests/test-mq-git.t b/tests/test-mq-git.t
deleted file mode 100644
--- a/tests/test-mq-git.t
+++ /dev/null
@@ -1,210 +0,0 @@ 
-# Test the plumbing of mq.git option
-# Automatic upgrade itself is tested elsewhere.
-
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "mq=" >> $HGRCPATH
-  $ echo "[diff]" >> $HGRCPATH
-  $ echo "nodates=1" >> $HGRCPATH
-
-  $ hg init repo-auto
-  $ cd repo-auto
-
-git=auto: regular patch creation:
-
-  $ echo a > a
-  $ hg add a
-  $ hg qnew -d '0 0' -f adda
-
-  $ cat .hg/patches/adda
-  # HG changeset patch
-  # Parent 0000000000000000000000000000000000000000
-  # Date 0 0
-  
-  diff -r 000000000000 -r ef8dafc9fa4c a
-  --- /dev/null
-  +++ b/a
-  @@ -0,0 +1,1 @@
-  +a
-
-git=auto: git patch creation with copy:
-
-  $ hg cp a b
-  $ hg qnew -d '0 0' -f copy
-
-  $ cat .hg/patches/copy
-  # HG changeset patch
-  # Parent ef8dafc9fa4caff80f6e243eb0171bcd60c455b4
-  # Date 0 0
-  
-  diff --git a/a b/b
-  copy from a
-  copy to b
-
-git=auto: git patch when using --git:
-
-  $ echo regular > regular
-  $ hg add regular
-  $ hg qnew -d '0 0' --git -f git
-
-  $ cat .hg/patches/git
-  # HG changeset patch
-  # Parent 99586d5f048c399e20f81cee41fbb3809c0e735d
-  # Date 0 0
-  
-  diff --git a/regular b/regular
-  new file mode 100644
-  --- /dev/null
-  +++ b/regular
-  @@ -0,0 +1,1 @@
-  +regular
-
-git=auto: regular patch after qrefresh without --git:
-
-  $ hg qrefresh -d '0 0'
-
-  $ cat .hg/patches/git
-  # HG changeset patch
-  # Parent 99586d5f048c399e20f81cee41fbb3809c0e735d
-  # Date 0 0
-  
-  diff -r 99586d5f048c regular
-  --- /dev/null
-  +++ b/regular
-  @@ -0,0 +1,1 @@
-  +regular
-
-  $ cd ..
-
-  $ hg init repo-keep
-  $ cd repo-keep
-  $ echo '[mq]' > .hg/hgrc
-  $ echo 'git = KEEP' >> .hg/hgrc
-
-git=keep: git patch with --git:
-
-  $ echo a > a
-  $ hg add a
-  $ hg qnew -d '0 0' -f --git git
-
-  $ cat .hg/patches/git
-  # HG changeset patch
-  # Parent 0000000000000000000000000000000000000000
-  # Date 0 0
-  
-  diff --git a/a b/a
-  new file mode 100644
-  --- /dev/null
-  +++ b/a
-  @@ -0,0 +1,1 @@
-  +a
-
-git=keep: git patch after qrefresh without --git:
-
-  $ echo a >> a
-  $ hg qrefresh -d '0 0'
-
-  $ cat .hg/patches/git
-  # HG changeset patch
-  # Parent 0000000000000000000000000000000000000000
-  # Date 0 0
-  
-  diff --git a/a b/a
-  new file mode 100644
-  --- /dev/null
-  +++ b/a
-  @@ -0,0 +1,2 @@
-  +a
-  +a
-  $ cd ..
-
-  $ hg init repo-yes
-  $ cd repo-yes
-  $ echo '[mq]' > .hg/hgrc
-  $ echo 'git = yes' >> .hg/hgrc
-
-git=yes: git patch:
-
-  $ echo a > a
-  $ hg add a
-  $ hg qnew -d '0 0' -f git
-
-  $ cat .hg/patches/git
-  # HG changeset patch
-  # Parent 0000000000000000000000000000000000000000
-  # Date 0 0
-  
-  diff --git a/a b/a
-  new file mode 100644
-  --- /dev/null
-  +++ b/a
-  @@ -0,0 +1,1 @@
-  +a
-
-git=yes: git patch after qrefresh:
-
-  $ echo a >> a
-  $ hg qrefresh -d '0 0'
-
-  $ cat .hg/patches/git
-  # HG changeset patch
-  # Parent 0000000000000000000000000000000000000000
-  # Date 0 0
-  
-  diff --git a/a b/a
-  new file mode 100644
-  --- /dev/null
-  +++ b/a
-  @@ -0,0 +1,2 @@
-  +a
-  +a
-  $ cd ..
-
-  $ hg init repo-no
-  $ cd repo-no
-  $ echo '[diff]' > .hg/hgrc
-  $ echo 'git = True' >> .hg/hgrc
-  $ echo '[mq]' > .hg/hgrc
-  $ echo 'git = False' >> .hg/hgrc
-
-git=no: regular patch with copy:
-
-  $ echo a > a
-  $ hg add a
-  $ hg qnew -d '0 0' -f adda
-  $ hg cp a b
-  $ hg qnew -d '0 0' -f regular
-
-  $ cat .hg/patches/regular
-  # HG changeset patch
-  # Parent ef8dafc9fa4caff80f6e243eb0171bcd60c455b4
-  # Date 0 0
-  
-  diff -r ef8dafc9fa4c -r a70404f79ba3 b
-  --- /dev/null
-  +++ b/b
-  @@ -0,0 +1,1 @@
-  +a
-
-git=no: regular patch after qrefresh with copy:
-
-  $ hg cp a c
-  $ hg qrefresh -d '0 0'
-
-  $ cat .hg/patches/regular
-  # HG changeset patch
-  # Parent ef8dafc9fa4caff80f6e243eb0171bcd60c455b4
-  # Date 0 0
-  
-  diff -r ef8dafc9fa4c b
-  --- /dev/null
-  +++ b/b
-  @@ -0,0 +1,1 @@
-  +a
-  diff -r ef8dafc9fa4c c
-  --- /dev/null
-  +++ b/c
-  @@ -0,0 +1,1 @@
-  +a
-
-  $ cd ..
-
diff --git a/tests/test-mq-guards.t b/tests/test-mq-guards.t
deleted file mode 100644
--- a/tests/test-mq-guards.t
+++ /dev/null
@@ -1,509 +0,0 @@ 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "mq=" >> $HGRCPATH
-
-  $ hg init
-  $ hg qinit
-
-  $ echo x > x
-  $ hg ci -Ama
-  adding x
-
-  $ hg qnew a.patch
-  $ echo a > a
-  $ hg add 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 qpop -a
-  popping c.patch
-  popping b.patch
-  popping a.patch
-  patch queue now empty
-
-
-should fail
-
-  $ hg qguard does-not-exist.patch +bleh
-  abort: no patch named does-not-exist.patch
-  [255]
-
-
-should fail
-
-  $ hg qguard +fail
-  abort: no patches applied
-  [255]
-
-  $ hg qpush
-  applying a.patch
-  now at: a.patch
-
-should guard a.patch
-
-  $ hg qguard +a
-
-should print +a
-
-  $ hg qguard
-  a.patch: +a
-  $ hg qpop
-  popping a.patch
-  patch queue now empty
-
-
-should fail
-
-  $ hg qpush a.patch
-  cannot push 'a.patch' - guarded by '+a'
-  [1]
-
-  $ hg qguard a.patch
-  a.patch: +a
-
-should push b.patch
-
-  $ hg qpush
-  applying b.patch
-  now at: b.patch
-
-  $ hg qpop
-  popping b.patch
-  patch queue now empty
-
-test selection of an empty guard
-
-  $ hg qselect ""
-  abort: guard cannot be an empty string
-  [255]
-  $ hg qselect a
-  number of unguarded, unapplied patches has changed from 2 to 3
-
-should push a.patch
-
-  $ hg qpush
-  applying a.patch
-  now at: a.patch
-
-  $ hg qguard -- c.patch -a
-
-should print -a
-
-  $ hg qguard c.patch
-  c.patch: -a
-
-
-should skip c.patch
-
-  $ hg qpush -a
-  applying b.patch
-  skipping c.patch - guarded by '-a'
-  now at: b.patch
-  $ hg qnext
-  all patches applied
-  [1]
-
-should display b.patch
-
-  $ hg qtop
-  b.patch
-
-  $ hg qguard -n c.patch
-
-should push c.patch
-
-  $ hg qpush -a
-  applying c.patch
-  now at: c.patch
-
-  $ hg qpop -a
-  popping c.patch
-  popping b.patch
-  popping a.patch
-  patch queue now empty
-  $ hg qselect -n
-  guards deactivated
-  number of unguarded, unapplied patches has changed from 3 to 2
-
-should push all
-
-  $ hg qpush -a
-  applying b.patch
-  applying c.patch
-  now at: c.patch
-
-  $ hg qpop -a
-  popping c.patch
-  popping b.patch
-  patch queue now empty
-  $ hg qguard a.patch +1
-  $ hg qguard b.patch +2
-  $ hg qselect 1
-  number of unguarded, unapplied patches has changed from 1 to 2
-
-should push a.patch, not b.patch
-
-  $ hg qpush
-  applying a.patch
-  now at: a.patch
-  $ hg qpush
-  applying c.patch
-  now at: c.patch
-  $ hg qpop -a
-  popping c.patch
-  popping a.patch
-  patch queue now empty
-
-  $ hg qselect 2
-
-should push b.patch
-
-  $ hg qpush
-  applying b.patch
-  now at: b.patch
-  $ hg qpush -a
-  applying c.patch
-  now at: c.patch
-  $ hg qprev
-  b.patch
-
-Used to be an issue with holes in the patch sequence
-So, put one hole on the base and ask for topmost patch.
-
-  $ hg qtop
-  c.patch
-  $ hg qpop -a
-  popping c.patch
-  popping b.patch
-  patch queue now empty
-
-  $ hg qselect 1 2
-  number of unguarded, unapplied patches has changed from 2 to 3
-
-should push a.patch, b.patch
-
-  $ hg qpush
-  applying a.patch
-  now at: a.patch
-  $ hg qpush
-  applying b.patch
-  now at: b.patch
-  $ hg qpop -a
-  popping b.patch
-  popping a.patch
-  patch queue now empty
-
-  $ hg qguard -- a.patch +1 +2 -3
-  $ hg qselect 1 2 3
-  number of unguarded, unapplied patches has changed from 3 to 2
-
-
-list patches and guards
-
-  $ hg qguard -l
-  a.patch: +1 +2 -3
-  b.patch: +2
-  c.patch: unguarded
-
-have at least one patch applied to test coloring
-
-  $ hg qpush
-  applying b.patch
-  now at: b.patch
-
-list patches and guards with color
-
-  $ hg --config extensions.color= qguard --config color.mode=ansi \
-  >     -l --color=always
-  \x1b[0;30;1ma.patch\x1b[0m: \x1b[0;33m+1\x1b[0m \x1b[0;33m+2\x1b[0m \x1b[0;31m-3\x1b[0m (esc)
-  \x1b[0;34;1;4mb.patch\x1b[0m: \x1b[0;33m+2\x1b[0m (esc)
-  \x1b[0;30;1mc.patch\x1b[0m: \x1b[0;32munguarded\x1b[0m (esc)
-
-should pop b.patch
-
-  $ hg qpop
-  popping b.patch
-  patch queue now empty
-
-list series
-
-  $ hg qseries -v
-  0 G a.patch
-  1 U b.patch
-  2 U c.patch
-
-list guards
-
-  $ hg qselect
-  1
-  2
-  3
-
-should push b.patch
-
-  $ hg qpush
-  applying b.patch
-  now at: b.patch
-
-  $ hg qpush -a
-  applying c.patch
-  now at: c.patch
-  $ hg qselect -n --reapply
-  guards deactivated
-  popping guarded patches
-  popping c.patch
-  popping b.patch
-  patch queue now empty
-  reapplying unguarded patches
-  applying c.patch
-  now at: c.patch
-
-guards in series file: +1 +2 -3
-
-  $ hg qselect -s
-  +1
-  +2
-  -3
-
-should show c.patch
-
-  $ hg qapplied
-  c.patch
-
-  $ hg qrename a.patch new.patch
-
-should show :
-
-
-new.patch: +1 +2 -3
-
-
-b.patch: +2
-
-
-c.patch: unguarded
-
-  $ hg qguard -l
-  new.patch: +1 +2 -3
-  b.patch: +2
-  c.patch: unguarded
-
-  $ hg qnew d.patch
-  $ hg qpop
-  popping d.patch
-  now at: c.patch
-
-should show new.patch and b.patch as Guarded, c.patch as Applied
-
-
-and d.patch as Unapplied
-
-  $ hg qseries -v
-  0 G new.patch
-  1 G b.patch
-  2 A c.patch
-  3 U d.patch
-
-qseries again, but with color
-
-  $ hg --config extensions.color= --config color.mode=ansi qseries -v --color=always
-  0 G \x1b[0;30;1mnew.patch\x1b[0m (esc)
-  1 G \x1b[0;30;1mb.patch\x1b[0m (esc)
-  2 A \x1b[0;34;1;4mc.patch\x1b[0m (esc)
-  3 U \x1b[0;30;1md.patch\x1b[0m (esc)
-
-  $ hg qguard d.patch +2
-
-new.patch, b.patch: Guarded. c.patch: Applied. d.patch: Guarded.
-
-  $ hg qseries -v
-  0 G new.patch
-  1 G b.patch
-  2 A c.patch
-  3 G d.patch
-
-  $ qappunappv()
-  > {
-  >     for command in qapplied "qapplied -v" qunapplied "qunapplied -v"; do
-  >         echo % hg $command
-  >         hg $command
-  >     done
-  > }
-
-  $ hg qpop -a
-  popping c.patch
-  patch queue now empty
-  $ hg qguard -l
-  new.patch: +1 +2 -3
-  b.patch: +2
-  c.patch: unguarded
-  d.patch: +2
-  $ qappunappv
-  % hg qapplied
-  % hg qapplied -v
-  % hg qunapplied
-  c.patch
-  % hg qunapplied -v
-  0 G new.patch
-  1 G b.patch
-  2 U c.patch
-  3 G d.patch
-  $ hg qselect 1
-  number of unguarded, unapplied patches has changed from 1 to 2
-  $ qappunappv
-  % hg qapplied
-  % hg qapplied -v
-  % hg qunapplied
-  new.patch
-  c.patch
-  % hg qunapplied -v
-  0 U new.patch
-  1 G b.patch
-  2 U c.patch
-  3 G d.patch
-  $ hg qpush -a
-  applying new.patch
-  skipping b.patch - guarded by '+2'
-  applying c.patch
-  skipping d.patch - guarded by '+2'
-  now at: c.patch
-  $ qappunappv
-  % hg qapplied
-  new.patch
-  c.patch
-  % hg qapplied -v
-  0 A new.patch
-  1 G b.patch
-  2 A c.patch
-  % hg qunapplied
-  % hg qunapplied -v
-  3 G d.patch
-  $ hg qselect 2
-  number of unguarded, unapplied patches has changed from 0 to 1
-  number of guarded, applied patches has changed from 1 to 0
-  $ qappunappv
-  % hg qapplied
-  new.patch
-  c.patch
-  % hg qapplied -v
-  0 A new.patch
-  1 U b.patch
-  2 A c.patch
-  % hg qunapplied
-  d.patch
-  % hg qunapplied -v
-  3 U d.patch
-
-  $ for patch in `hg qseries`; do
-  >     echo % hg qapplied $patch
-  >     hg qapplied $patch
-  >     echo % hg qunapplied $patch
-  >     hg qunapplied $patch
-  > done
-  % hg qapplied new.patch
-  new.patch
-  % hg qunapplied new.patch
-  b.patch
-  d.patch
-  % hg qapplied b.patch
-  new.patch
-  % hg qunapplied b.patch
-  d.patch
-  % hg qapplied c.patch
-  new.patch
-  c.patch
-  % hg qunapplied c.patch
-  d.patch
-  % hg qapplied d.patch
-  new.patch
-  c.patch
-  % hg qunapplied d.patch
-
-
-hg qseries -m: only b.patch should be shown
-the guards file was not ignored in the past
-
-  $ hg qdelete -k b.patch
-  $ hg qseries -m
-  b.patch
-
-hg qseries -m with color
-
-  $ hg --config extensions.color= --config color.mode=ansi qseries -m --color=always
-  \x1b[0;31;1mb.patch\x1b[0m (esc)
-
-
-excercise cornercases in "qselect --reapply"
-
-  $ hg qpop -a
-  popping c.patch
-  popping new.patch
-  patch queue now empty
-  $ hg qguard -- new.patch -not-new
-  $ hg qguard -- c.patch -not-c
-  $ hg qguard -- d.patch -not-d
-  $ hg qpush -a
-  applying new.patch
-  applying c.patch
-  applying d.patch
-  patch d.patch is empty
-  now at: d.patch
-  $ hg qguard -l
-  new.patch: -not-new
-  c.patch: -not-c
-  d.patch: -not-d
-  $ hg qselect --reapply not-d
-  popping guarded patches
-  popping d.patch
-  now at: c.patch
-  reapplying unguarded patches
-  cannot push 'd.patch' - guarded by '-not-d'
-  $ hg qser -v
-  0 A new.patch
-  1 A c.patch
-  2 G d.patch
-  $ hg qselect --reapply -n
-  guards deactivated
-  $ hg qpush
-  applying d.patch
-  patch d.patch is empty
-  now at: d.patch
-  $ hg qser -v
-  0 A new.patch
-  1 A c.patch
-  2 A d.patch
-  $ hg qselect --reapply not-c
-  popping guarded patches
-  popping d.patch
-  popping c.patch
-  now at: new.patch
-  reapplying unguarded patches
-  applying d.patch
-  patch d.patch is empty
-  now at: d.patch
-  $ hg qser -v
-  0 A new.patch
-  1 G c.patch
-  2 A d.patch
-  $ hg qselect --reapply not-new
-  popping guarded patches
-  popping d.patch
-  popping new.patch
-  patch queue now empty
-  reapplying unguarded patches
-  applying c.patch
-  applying d.patch
-  patch d.patch is empty
-  now at: d.patch
-  $ hg qser -v
-  0 G new.patch
-  1 A c.patch
-  2 A d.patch
diff --git a/tests/test-mq-header-date.t b/tests/test-mq-header-date.t
deleted file mode 100644
--- a/tests/test-mq-header-date.t
+++ /dev/null
@@ -1,902 +0,0 @@ 
-
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "mq=" >> $HGRCPATH
-  $ echo "[diff]" >> $HGRCPATH
-  $ echo "nodates=true" >> $HGRCPATH
-  $ catpatch() {
-  >     cat .hg/patches/$1.patch | sed -e "s/^diff \-r [0-9a-f]* /diff -r ... /" \
-  >                                    -e "s/^\(# Parent \).*/\1/"
-  > }
-  $ catlog() {
-  >     catpatch $1
-  >     hg log --template "{rev}: {desc} - {author}\n"
-  > }
-  $ catlogd() {
-  >     catpatch $1
-  >     hg log --template "{rev}: {desc} - {author} - {date}\n"
-  > }
-  $ drop() {
-  >     hg qpop
-  >     hg qdel $1.patch
-  > }
-  $ runtest() {
-  >     echo ==== init
-  >     hg init a
-  >     cd a
-  >     hg qinit
-  > 
-  > 
-  >     echo ==== qnew -d
-  >     hg qnew -d '3 0' 1.patch
-  >     catlogd 1
-  > 
-  >     echo ==== qref
-  >     echo "1" >1
-  >     hg add
-  >     hg qref
-  >     catlogd 1
-  > 
-  >     echo ==== qref -d
-  >     hg qref -d '4 0'
-  >     catlogd 1
-  > 
-  > 
-  >     echo ==== qnew
-  >     hg qnew 2.patch
-  >     echo "2" >2
-  >     hg add
-  >     hg qref
-  >     catlog 2
-  > 
-  >     echo ==== qref -d
-  >     hg qref -d '5 0'
-  >     catlog 2
-  > 
-  >     drop 2
-  > 
-  > 
-  >     echo ==== qnew -d -m
-  >     hg qnew -d '6 0' -m "Three" 3.patch
-  >     catlogd 3
-  > 
-  >     echo ==== qref
-  >     echo "3" >3
-  >     hg add
-  >     hg qref
-  >     catlogd 3
-  > 
-  >     echo ==== qref -m
-  >     hg qref -m "Drei"
-  >     catlogd 3
-  > 
-  >     echo ==== qref -d
-  >     hg qref -d '7 0'
-  >     catlogd 3
-  > 
-  >     echo ==== qref -d -m
-  >     hg qref -d '8 0' -m "Three (again)"
-  >     catlogd 3
-  > 
-  > 
-  >     echo ==== qnew -m
-  >     hg qnew -m "Four" 4.patch
-  >     echo "4" >4
-  >     hg add
-  >     hg qref
-  >     catlog 4
-  > 
-  >     echo ==== qref -d
-  >     hg qref -d '9 0'
-  >     catlog 4
-  > 
-  >     drop 4
-  > 
-  > 
-  >     echo ==== qnew with HG header
-  >     hg qnew --config 'mq.plain=true' 5.patch
-  >     hg qpop
-  >     echo "# HG changeset patch" >>.hg/patches/5.patch
-  >     echo "# Date 10 0" >>.hg/patches/5.patch
-  >     hg qpush 2>&1 | grep 'Now at'
-  >     catlogd 5
-  > 
-  >     echo ==== hg qref
-  >     echo "5" >5
-  >     hg add
-  >     hg qref
-  >     catlogd 5
-  > 
-  >     echo ==== hg qref -d
-  >     hg qref -d '11 0'
-  >     catlogd 5
-  > 
-  > 
-  >     echo ==== qnew with plain header
-  >     hg qnew --config 'mq.plain=true' -d '12 0' 6.patch
-  >     hg qpop
-  >     hg qpush 2>&1 | grep 'now at'
-  >     catlog 6
-  > 
-  >     echo ==== hg qref
-  >     echo "6" >6
-  >     hg add
-  >     hg qref
-  >     catlogd 6
-  > 
-  >     echo ==== hg qref -d
-  >     hg qref -d '13 0'
-  >     catlogd 6
-  > 
-  >     drop 6
-  > 
-  > 
-  >     echo ==== qnew -u
-  >     hg qnew -u jane 6.patch
-  >     echo "6" >6
-  >     hg add
-  >     hg qref
-  >     catlog 6
-  > 
-  >     echo ==== qref -d
-  >     hg qref -d '12 0'
-  >     catlog 6
-  > 
-  >     drop 6
-  > 
-  > 
-  >     echo ==== qnew -d
-  >     hg qnew -d '13 0' 7.patch
-  >     echo "7" >7
-  >     hg add
-  >     hg qref
-  >     catlog 7
-  > 
-  >     echo ==== qref -u
-  >     hg qref -u john
-  >     catlogd 7
-  > 
-  > 
-  >     echo ==== qnew
-  >     hg qnew 8.patch
-  >     echo "8" >8
-  >     hg add
-  >     hg qref
-  >     catlog 8
-  > 
-  >     echo ==== qref -u -d
-  >     hg qref -u john -d '14 0'
-  >     catlog 8
-  > 
-  >     drop 8
-  > 
-  > 
-  >     echo ==== qnew -m
-  >     hg qnew -m "Nine" 9.patch
-  >     echo "9" >9
-  >     hg add
-  >     hg qref
-  >     catlog 9
-  > 
-  >     echo ==== qref -u -d
-  >     hg qref -u john -d '15 0'
-  >     catlog 9
-  > 
-  >     drop 9
-  > 
-  > 
-  >     echo ==== "qpop -a / qpush -a"
-  >     hg qpop -a
-  >     hg qpush -a
-  >     hg log --template "{rev}: {desc} - {author} - {date}\n"
-  > }
-
-======= plain headers
-
-  $ echo "[mq]" >> $HGRCPATH
-  $ echo "plain=true" >> $HGRCPATH
-  $ mkdir sandbox
-  $ (cd sandbox ; runtest)
-  ==== init
-  ==== qnew -d
-  Date: 3 0
-  
-  0: [mq]: 1.patch - test - 3.00
-  ==== qref
-  adding 1
-  Date: 3 0
-  
-  diff -r ... 1
-  --- /dev/null
-  +++ b/1
-  @@ -0,0 +1,1 @@
-  +1
-  0: [mq]: 1.patch - test - 3.00
-  ==== qref -d
-  Date: 4 0
-  
-  diff -r ... 1
-  --- /dev/null
-  +++ b/1
-  @@ -0,0 +1,1 @@
-  +1
-  0: [mq]: 1.patch - test - 4.00
-  ==== qnew
-  adding 2
-  diff -r ... 2
-  --- /dev/null
-  +++ b/2
-  @@ -0,0 +1,1 @@
-  +2
-  1: [mq]: 2.patch - test
-  0: [mq]: 1.patch - test
-  ==== qref -d
-  Date: 5 0
-  
-  diff -r ... 2
-  --- /dev/null
-  +++ b/2
-  @@ -0,0 +1,1 @@
-  +2
-  1: [mq]: 2.patch - test
-  0: [mq]: 1.patch - test
-  popping 2.patch
-  now at: 1.patch
-  ==== qnew -d -m
-  Date: 6 0
-  
-  Three
-  
-  1: Three - test - 6.00
-  0: [mq]: 1.patch - test - 4.00
-  ==== qref
-  adding 3
-  Date: 6 0
-  
-  Three
-  
-  diff -r ... 3
-  --- /dev/null
-  +++ b/3
-  @@ -0,0 +1,1 @@
-  +3
-  1: Three - test - 6.00
-  0: [mq]: 1.patch - test - 4.00
-  ==== qref -m
-  Date: 6 0
-  
-  Drei
-  
-  diff -r ... 3
-  --- /dev/null
-  +++ b/3
-  @@ -0,0 +1,1 @@
-  +3
-  1: Drei - test - 6.00
-  0: [mq]: 1.patch - test - 4.00
-  ==== qref -d
-  Date: 7 0
-  
-  Drei
-  
-  diff -r ... 3
-  --- /dev/null
-  +++ b/3
-  @@ -0,0 +1,1 @@
-  +3
-  1: Drei - test - 7.00
-  0: [mq]: 1.patch - test - 4.00
-  ==== qref -d -m
-  Date: 8 0
-  
-  Three (again)
-  
-  diff -r ... 3
-  --- /dev/null
-  +++ b/3
-  @@ -0,0 +1,1 @@
-  +3
-  1: Three (again) - test - 8.00
-  0: [mq]: 1.patch - test - 4.00
-  ==== qnew -m
-  adding 4
-  Four
-  
-  diff -r ... 4
-  --- /dev/null
-  +++ b/4
-  @@ -0,0 +1,1 @@
-  +4
-  2: Four - test
-  1: Three (again) - test
-  0: [mq]: 1.patch - test
-  ==== qref -d
-  Date: 9 0
-  Four
-  
-  diff -r ... 4
-  --- /dev/null
-  +++ b/4
-  @@ -0,0 +1,1 @@
-  +4
-  2: Four - test
-  1: Three (again) - test
-  0: [mq]: 1.patch - test
-  popping 4.patch
-  now at: 3.patch
-  ==== qnew with HG header
-  popping 5.patch
-  now at: 3.patch
-  # HG changeset patch
-  # Date 10 0
-  2: imported patch 5.patch - test - 10.00
-  1: Three (again) - test - 8.00
-  0: [mq]: 1.patch - test - 4.00
-  ==== hg qref
-  adding 5
-  # HG changeset patch
-  # Parent 
-  # Date 10 0
-  
-  diff -r ... 5
-  --- /dev/null
-  +++ b/5
-  @@ -0,0 +1,1 @@
-  +5
-  2: [mq]: 5.patch - test - 10.00
-  1: Three (again) - test - 8.00
-  0: [mq]: 1.patch - test - 4.00
-  ==== hg qref -d
-  # HG changeset patch
-  # Parent 
-  # Date 11 0
-  
-  diff -r ... 5
-  --- /dev/null
-  +++ b/5
-  @@ -0,0 +1,1 @@
-  +5
-  2: [mq]: 5.patch - test - 11.00
-  1: Three (again) - test - 8.00
-  0: [mq]: 1.patch - test - 4.00
-  ==== qnew with plain header
-  popping 6.patch
-  now at: 5.patch
-  now at: 6.patch
-  Date: 12 0
-  
-  3: imported patch 6.patch - test
-  2: [mq]: 5.patch - test
-  1: Three (again) - test
-  0: [mq]: 1.patch - test
-  ==== hg qref
-  adding 6
-  Date: 12 0
-  
-  diff -r ... 6
-  --- /dev/null
-  +++ b/6
-  @@ -0,0 +1,1 @@
-  +6
-  3: [mq]: 6.patch - test - 12.00
-  2: [mq]: 5.patch - test - 11.00
-  1: Three (again) - test - 8.00
-  0: [mq]: 1.patch - test - 4.00
-  ==== hg qref -d
-  Date: 13 0
-  
-  diff -r ... 6
-  --- /dev/null
-  +++ b/6
-  @@ -0,0 +1,1 @@
-  +6
-  3: [mq]: 6.patch - test - 13.00
-  2: [mq]: 5.patch - test - 11.00
-  1: Three (again) - test - 8.00
-  0: [mq]: 1.patch - test - 4.00
-  popping 6.patch
-  now at: 5.patch
-  ==== qnew -u
-  adding 6
-  From: jane
-  
-  diff -r ... 6
-  --- /dev/null
-  +++ b/6
-  @@ -0,0 +1,1 @@
-  +6
-  3: [mq]: 6.patch - jane
-  2: [mq]: 5.patch - test
-  1: Three (again) - test
-  0: [mq]: 1.patch - test
-  ==== qref -d
-  Date: 12 0
-  From: jane
-  
-  diff -r ... 6
-  --- /dev/null
-  +++ b/6
-  @@ -0,0 +1,1 @@
-  +6
-  3: [mq]: 6.patch - jane
-  2: [mq]: 5.patch - test
-  1: Three (again) - test
-  0: [mq]: 1.patch - test
-  popping 6.patch
-  now at: 5.patch
-  ==== qnew -d
-  adding 7
-  Date: 13 0
-  
-  diff -r ... 7
-  --- /dev/null
-  +++ b/7
-  @@ -0,0 +1,1 @@
-  +7
-  3: [mq]: 7.patch - test
-  2: [mq]: 5.patch - test
-  1: Three (again) - test
-  0: [mq]: 1.patch - test
-  ==== qref -u
-  From: john
-  Date: 13 0
-  
-  diff -r ... 7
-  --- /dev/null
-  +++ b/7
-  @@ -0,0 +1,1 @@
-  +7
-  3: [mq]: 7.patch - john - 13.00
-  2: [mq]: 5.patch - test - 11.00
-  1: Three (again) - test - 8.00
-  0: [mq]: 1.patch - test - 4.00
-  ==== qnew
-  adding 8
-  diff -r ... 8
-  --- /dev/null
-  +++ b/8
-  @@ -0,0 +1,1 @@
-  +8
-  4: [mq]: 8.patch - test
-  3: [mq]: 7.patch - john
-  2: [mq]: 5.patch - test
-  1: Three (again) - test
-  0: [mq]: 1.patch - test
-  ==== qref -u -d
-  Date: 14 0
-  From: john
-  
-  diff -r ... 8
-  --- /dev/null
-  +++ b/8
-  @@ -0,0 +1,1 @@
-  +8
-  4: [mq]: 8.patch - john
-  3: [mq]: 7.patch - john
-  2: [mq]: 5.patch - test
-  1: Three (again) - test
-  0: [mq]: 1.patch - test
-  popping 8.patch
-  now at: 7.patch
-  ==== qnew -m
-  adding 9
-  Nine
-  
-  diff -r ... 9
-  --- /dev/null
-  +++ b/9
-  @@ -0,0 +1,1 @@
-  +9
-  4: Nine - test
-  3: [mq]: 7.patch - john
-  2: [mq]: 5.patch - test
-  1: Three (again) - test
-  0: [mq]: 1.patch - test
-  ==== qref -u -d
-  Date: 15 0
-  From: john
-  Nine
-  
-  diff -r ... 9
-  --- /dev/null
-  +++ b/9
-  @@ -0,0 +1,1 @@
-  +9
-  4: Nine - john
-  3: [mq]: 7.patch - john
-  2: [mq]: 5.patch - test
-  1: Three (again) - test
-  0: [mq]: 1.patch - test
-  popping 9.patch
-  now at: 7.patch
-  ==== qpop -a / qpush -a
-  popping 7.patch
-  popping 5.patch
-  popping 3.patch
-  popping 1.patch
-  patch queue now empty
-  applying 1.patch
-  applying 3.patch
-  applying 5.patch
-  applying 7.patch
-  now at: 7.patch
-  3: imported patch 7.patch - john - 13.00
-  2: imported patch 5.patch - test - 11.00
-  1: Three (again) - test - 8.00
-  0: imported patch 1.patch - test - 4.00
-  $ rm -r sandbox
-
-======= hg headers
-
-  $ echo "plain=false" >> $HGRCPATH
-  $ mkdir sandbox
-  $ (cd sandbox ; runtest)
-  ==== init
-  ==== qnew -d
-  # HG changeset patch
-  # Parent 
-  # Date 3 0
-  
-  0: [mq]: 1.patch - test - 3.00
-  ==== qref
-  adding 1
-  # HG changeset patch
-  # Parent 
-  # Date 3 0
-  
-  diff -r ... 1
-  --- /dev/null
-  +++ b/1
-  @@ -0,0 +1,1 @@
-  +1
-  0: [mq]: 1.patch - test - 3.00
-  ==== qref -d
-  # HG changeset patch
-  # Parent 
-  # Date 4 0
-  
-  diff -r ... 1
-  --- /dev/null
-  +++ b/1
-  @@ -0,0 +1,1 @@
-  +1
-  0: [mq]: 1.patch - test - 4.00
-  ==== qnew
-  adding 2
-  # HG changeset patch
-  # Parent 
-  
-  diff -r ... 2
-  --- /dev/null
-  +++ b/2
-  @@ -0,0 +1,1 @@
-  +2
-  1: [mq]: 2.patch - test
-  0: [mq]: 1.patch - test
-  ==== qref -d
-  # HG changeset patch
-  # Date 5 0
-  # Parent 
-  
-  diff -r ... 2
-  --- /dev/null
-  +++ b/2
-  @@ -0,0 +1,1 @@
-  +2
-  1: [mq]: 2.patch - test
-  0: [mq]: 1.patch - test
-  popping 2.patch
-  now at: 1.patch
-  ==== qnew -d -m
-  # HG changeset patch
-  # Parent 
-  # Date 6 0
-  
-  Three
-  
-  1: Three - test - 6.00
-  0: [mq]: 1.patch - test - 4.00
-  ==== qref
-  adding 3
-  # HG changeset patch
-  # Parent 
-  # Date 6 0
-  
-  Three
-  
-  diff -r ... 3
-  --- /dev/null
-  +++ b/3
-  @@ -0,0 +1,1 @@
-  +3
-  1: Three - test - 6.00
-  0: [mq]: 1.patch - test - 4.00
-  ==== qref -m
-  # HG changeset patch
-  # Parent 
-  # Date 6 0
-  
-  Drei
-  
-  diff -r ... 3
-  --- /dev/null
-  +++ b/3
-  @@ -0,0 +1,1 @@
-  +3
-  1: Drei - test - 6.00
-  0: [mq]: 1.patch - test - 4.00
-  ==== qref -d
-  # HG changeset patch
-  # Parent 
-  # Date 7 0
-  
-  Drei
-  
-  diff -r ... 3
-  --- /dev/null
-  +++ b/3
-  @@ -0,0 +1,1 @@
-  +3
-  1: Drei - test - 7.00
-  0: [mq]: 1.patch - test - 4.00
-  ==== qref -d -m
-  # HG changeset patch
-  # Parent 
-  # Date 8 0
-  
-  Three (again)
-  
-  diff -r ... 3
-  --- /dev/null
-  +++ b/3
-  @@ -0,0 +1,1 @@
-  +3
-  1: Three (again) - test - 8.00
-  0: [mq]: 1.patch - test - 4.00
-  ==== qnew -m
-  adding 4
-  # HG changeset patch
-  # Parent 
-  Four
-  
-  diff -r ... 4
-  --- /dev/null
-  +++ b/4
-  @@ -0,0 +1,1 @@
-  +4
-  2: Four - test
-  1: Three (again) - test
-  0: [mq]: 1.patch - test
-  ==== qref -d
-  # HG changeset patch
-  # Date 9 0
-  # Parent 
-  Four
-  
-  diff -r ... 4
-  --- /dev/null
-  +++ b/4
-  @@ -0,0 +1,1 @@
-  +4
-  2: Four - test
-  1: Three (again) - test
-  0: [mq]: 1.patch - test
-  popping 4.patch
-  now at: 3.patch
-  ==== qnew with HG header
-  popping 5.patch
-  now at: 3.patch
-  # HG changeset patch
-  # Date 10 0
-  2: imported patch 5.patch - test - 10.00
-  1: Three (again) - test - 8.00
-  0: [mq]: 1.patch - test - 4.00
-  ==== hg qref
-  adding 5
-  # HG changeset patch
-  # Parent 
-  # Date 10 0
-  
-  diff -r ... 5
-  --- /dev/null
-  +++ b/5
-  @@ -0,0 +1,1 @@
-  +5
-  2: [mq]: 5.patch - test - 10.00
-  1: Three (again) - test - 8.00
-  0: [mq]: 1.patch - test - 4.00
-  ==== hg qref -d
-  # HG changeset patch
-  # Parent 
-  # Date 11 0
-  
-  diff -r ... 5
-  --- /dev/null
-  +++ b/5
-  @@ -0,0 +1,1 @@
-  +5
-  2: [mq]: 5.patch - test - 11.00
-  1: Three (again) - test - 8.00
-  0: [mq]: 1.patch - test - 4.00
-  ==== qnew with plain header
-  popping 6.patch
-  now at: 5.patch
-  now at: 6.patch
-  Date: 12 0
-  
-  3: imported patch 6.patch - test
-  2: [mq]: 5.patch - test
-  1: Three (again) - test
-  0: [mq]: 1.patch - test
-  ==== hg qref
-  adding 6
-  Date: 12 0
-  
-  diff -r ... 6
-  --- /dev/null
-  +++ b/6
-  @@ -0,0 +1,1 @@
-  +6
-  3: [mq]: 6.patch - test - 12.00
-  2: [mq]: 5.patch - test - 11.00
-  1: Three (again) - test - 8.00
-  0: [mq]: 1.patch - test - 4.00
-  ==== hg qref -d
-  Date: 13 0
-  
-  diff -r ... 6
-  --- /dev/null
-  +++ b/6
-  @@ -0,0 +1,1 @@
-  +6
-  3: [mq]: 6.patch - test - 13.00
-  2: [mq]: 5.patch - test - 11.00
-  1: Three (again) - test - 8.00
-  0: [mq]: 1.patch - test - 4.00
-  popping 6.patch
-  now at: 5.patch
-  ==== qnew -u
-  adding 6
-  # HG changeset patch
-  # Parent 
-  # User jane
-  
-  diff -r ... 6
-  --- /dev/null
-  +++ b/6
-  @@ -0,0 +1,1 @@
-  +6
-  3: [mq]: 6.patch - jane
-  2: [mq]: 5.patch - test
-  1: Three (again) - test
-  0: [mq]: 1.patch - test
-  ==== qref -d
-  # HG changeset patch
-  # Date 12 0
-  # Parent 
-  # User jane
-  
-  diff -r ... 6
-  --- /dev/null
-  +++ b/6
-  @@ -0,0 +1,1 @@
-  +6
-  3: [mq]: 6.patch - jane
-  2: [mq]: 5.patch - test
-  1: Three (again) - test
-  0: [mq]: 1.patch - test
-  popping 6.patch
-  now at: 5.patch
-  ==== qnew -d
-  adding 7
-  # HG changeset patch
-  # Parent 
-  # Date 13 0
-  
-  diff -r ... 7
-  --- /dev/null
-  +++ b/7
-  @@ -0,0 +1,1 @@
-  +7
-  3: [mq]: 7.patch - test
-  2: [mq]: 5.patch - test
-  1: Three (again) - test
-  0: [mq]: 1.patch - test
-  ==== qref -u
-  # HG changeset patch
-  # User john
-  # Parent 
-  # Date 13 0
-  
-  diff -r ... 7
-  --- /dev/null
-  +++ b/7
-  @@ -0,0 +1,1 @@
-  +7
-  3: [mq]: 7.patch - john - 13.00
-  2: [mq]: 5.patch - test - 11.00
-  1: Three (again) - test - 8.00
-  0: [mq]: 1.patch - test - 4.00
-  ==== qnew
-  adding 8
-  # HG changeset patch
-  # Parent 
-  
-  diff -r ... 8
-  --- /dev/null
-  +++ b/8
-  @@ -0,0 +1,1 @@
-  +8
-  4: [mq]: 8.patch - test
-  3: [mq]: 7.patch - john
-  2: [mq]: 5.patch - test
-  1: Three (again) - test
-  0: [mq]: 1.patch - test
-  ==== qref -u -d
-  # HG changeset patch
-  # Date 14 0
-  # User john
-  # Parent 
-  
-  diff -r ... 8
-  --- /dev/null
-  +++ b/8
-  @@ -0,0 +1,1 @@
-  +8
-  4: [mq]: 8.patch - john
-  3: [mq]: 7.patch - john
-  2: [mq]: 5.patch - test
-  1: Three (again) - test
-  0: [mq]: 1.patch - test
-  popping 8.patch
-  now at: 7.patch
-  ==== qnew -m
-  adding 9
-  # HG changeset patch
-  # Parent 
-  Nine
-  
-  diff -r ... 9
-  --- /dev/null
-  +++ b/9
-  @@ -0,0 +1,1 @@
-  +9
-  4: Nine - test
-  3: [mq]: 7.patch - john
-  2: [mq]: 5.patch - test
-  1: Three (again) - test
-  0: [mq]: 1.patch - test
-  ==== qref -u -d
-  # HG changeset patch
-  # Date 15 0
-  # User john
-  # Parent 
-  Nine
-  
-  diff -r ... 9
-  --- /dev/null
-  +++ b/9
-  @@ -0,0 +1,1 @@
-  +9
-  4: Nine - john
-  3: [mq]: 7.patch - john
-  2: [mq]: 5.patch - test
-  1: Three (again) - test
-  0: [mq]: 1.patch - test
-  popping 9.patch
-  now at: 7.patch
-  ==== qpop -a / qpush -a
-  popping 7.patch
-  popping 5.patch
-  popping 3.patch
-  popping 1.patch
-  patch queue now empty
-  applying 1.patch
-  applying 3.patch
-  applying 5.patch
-  applying 7.patch
-  now at: 7.patch
-  3: imported patch 7.patch - john - 13.00
-  2: imported patch 5.patch - test - 11.00
-  1: Three (again) - test - 8.00
-  0: imported patch 1.patch - test - 4.00
-  $ rm -r sandbox
diff --git a/tests/test-mq-header-from.t b/tests/test-mq-header-from.t
deleted file mode 100644
--- a/tests/test-mq-header-from.t
+++ /dev/null
@@ -1,971 +0,0 @@ 
-
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "mq=" >> $HGRCPATH
-  $ echo "[diff]" >> $HGRCPATH
-  $ echo "nodates=true" >> $HGRCPATH
-  $ catlog() {
-  >     cat .hg/patches/$1.patch | sed -e "s/^diff \-r [0-9a-f]* /diff -r ... /" \
-  >                                    -e "s/^\(# Parent \).*/\1/"
-  >     hg log --template "{rev}: {desc} - {author}\n"
-  > }
-  $ runtest() {
-  >     echo ==== init
-  >     hg init a
-  >     cd a
-  >     hg qinit
-  > 
-  > 
-  >     echo ==== qnew -U
-  >     hg qnew -U 1.patch
-  >     catlog 1
-  > 
-  >     echo ==== qref
-  >     echo "1" >1
-  >     hg add
-  >     hg qref
-  >     catlog 1
-  > 
-  >     echo ==== qref -u
-  >     hg qref -u mary
-  >     catlog 1
-  > 
-  >     echo ==== qnew
-  >     hg qnew 2.patch
-  >     echo "2" >2
-  >     hg add
-  >     hg qref
-  >     catlog 2
-  > 
-  >     echo ==== qref -u
-  >     hg qref -u jane
-  >     catlog 2
-  > 
-  > 
-  >     echo ==== qnew -U -m
-  >     hg qnew -U -m "Three" 3.patch
-  >     catlog 3
-  > 
-  >     echo ==== qref
-  >     echo "3" >3
-  >     hg add
-  >     hg qref
-  >     catlog 3
-  > 
-  >     echo ==== qref -m
-  >     hg qref -m "Drei"
-  >     catlog 3
-  > 
-  >     echo ==== qref -u
-  >     hg qref -u mary
-  >     catlog 3
-  > 
-  >     echo ==== qref -u -m
-  >     hg qref -u maria -m "Three (again)"
-  >     catlog 3
-  > 
-  >     echo ==== qnew -m
-  >     hg qnew -m "Four" 4.patch
-  >     echo "4" >4of t
-  >     hg add
-  >     hg qref
-  >     catlog 4
-  > 
-  >     echo ==== qref -u
-  >     hg qref -u jane
-  >     catlog 4
-  > 
-  > 
-  >     echo ==== qnew with HG header
-  >     hg qnew --config 'mq.plain=true' 5.patch
-  >     hg qpop
-  >     echo "# HG changeset patch" >>.hg/patches/5.patch
-  >     echo "# User johndoe" >>.hg/patches/5.patch
-  >     hg qpush 2>&1 | grep 'now at'
-  >     catlog 5
-  > 
-  >     echo ==== hg qref
-  >     echo "5" >5
-  >     hg add
-  >     hg qref
-  >     catlog 5
-  > 
-  >     echo ==== hg qref -U
-  >     hg qref -U
-  >     catlog 5
-  > 
-  >     echo ==== hg qref -u
-  >     hg qref -u johndeere
-  >     catlog 5
-  > 
-  > 
-  >     echo ==== qnew with plain header
-  >     hg qnew --config 'mq.plain=true' -U 6.patch
-  >     hg qpop
-  >     hg qpush 2>&1 | grep 'now at'
-  >     catlog 6
-  > 
-  >     echo ==== hg qref
-  >     echo "6" >6
-  >     hg add
-  >     hg qref
-  >     catlog 6
-  > 
-  >     echo ==== hg qref -U
-  >     hg qref -U
-  >     catlog 6
-  > 
-  >     echo ==== hg qref -u
-  >     hg qref -u johndeere
-  >     catlog 6
-  > 
-  > 
-  >     echo ==== "qpop -a / qpush -a"
-  >     hg qpop -a
-  >     hg qpush -a
-  >     hg log --template "{rev}: {desc} - {author}\n"
-  > }
-
-======= plain headers
-
-  $ echo "[mq]" >> $HGRCPATH
-  $ echo "plain=true" >> $HGRCPATH
-  $ mkdir sandbox
-  $ (cd sandbox ; runtest)
-  ==== init
-  ==== qnew -U
-  From: test
-  
-  0: [mq]: 1.patch - test
-  ==== qref
-  adding 1
-  From: test
-  
-  diff -r ... 1
-  --- /dev/null
-  +++ b/1
-  @@ -0,0 +1,1 @@
-  +1
-  0: [mq]: 1.patch - test
-  ==== qref -u
-  From: mary
-  
-  diff -r ... 1
-  --- /dev/null
-  +++ b/1
-  @@ -0,0 +1,1 @@
-  +1
-  0: [mq]: 1.patch - mary
-  ==== qnew
-  adding 2
-  diff -r ... 2
-  --- /dev/null
-  +++ b/2
-  @@ -0,0 +1,1 @@
-  +2
-  1: [mq]: 2.patch - test
-  0: [mq]: 1.patch - mary
-  ==== qref -u
-  From: jane
-  
-  diff -r ... 2
-  --- /dev/null
-  +++ b/2
-  @@ -0,0 +1,1 @@
-  +2
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== qnew -U -m
-  From: test
-  
-  Three
-  
-  2: Three - test
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== qref
-  adding 3
-  From: test
-  
-  Three
-  
-  diff -r ... 3
-  --- /dev/null
-  +++ b/3
-  @@ -0,0 +1,1 @@
-  +3
-  2: Three - test
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== qref -m
-  From: test
-  
-  Drei
-  
-  diff -r ... 3
-  --- /dev/null
-  +++ b/3
-  @@ -0,0 +1,1 @@
-  +3
-  2: Drei - test
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== qref -u
-  From: mary
-  
-  Drei
-  
-  diff -r ... 3
-  --- /dev/null
-  +++ b/3
-  @@ -0,0 +1,1 @@
-  +3
-  2: Drei - mary
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== qref -u -m
-  From: maria
-  
-  Three (again)
-  
-  diff -r ... 3
-  --- /dev/null
-  +++ b/3
-  @@ -0,0 +1,1 @@
-  +3
-  2: Three (again) - maria
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== qnew -m
-  adding 4of
-  Four
-  
-  diff -r ... 4of
-  --- /dev/null
-  +++ b/4of
-  @@ -0,0 +1,1 @@
-  +4 t
-  3: Four - test
-  2: Three (again) - maria
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== qref -u
-  From: jane
-  Four
-  
-  diff -r ... 4of
-  --- /dev/null
-  +++ b/4of
-  @@ -0,0 +1,1 @@
-  +4 t
-  3: Four - jane
-  2: Three (again) - maria
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== qnew with HG header
-  popping 5.patch
-  now at: 4.patch
-  now at: 5.patch
-  # HG changeset patch
-  # User johndoe
-  4: imported patch 5.patch - johndoe
-  3: Four - jane
-  2: Three (again) - maria
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== hg qref
-  adding 5
-  # HG changeset patch
-  # Parent 
-  # User johndoe
-  
-  diff -r ... 5
-  --- /dev/null
-  +++ b/5
-  @@ -0,0 +1,1 @@
-  +5
-  4: [mq]: 5.patch - johndoe
-  3: Four - jane
-  2: Three (again) - maria
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== hg qref -U
-  # HG changeset patch
-  # Parent 
-  # User test
-  
-  diff -r ... 5
-  --- /dev/null
-  +++ b/5
-  @@ -0,0 +1,1 @@
-  +5
-  4: [mq]: 5.patch - test
-  3: Four - jane
-  2: Three (again) - maria
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== hg qref -u
-  # HG changeset patch
-  # Parent 
-  # User johndeere
-  
-  diff -r ... 5
-  --- /dev/null
-  +++ b/5
-  @@ -0,0 +1,1 @@
-  +5
-  4: [mq]: 5.patch - johndeere
-  3: Four - jane
-  2: Three (again) - maria
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== qnew with plain header
-  popping 6.patch
-  now at: 5.patch
-  now at: 6.patch
-  From: test
-  
-  5: imported patch 6.patch - test
-  4: [mq]: 5.patch - johndeere
-  3: Four - jane
-  2: Three (again) - maria
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== hg qref
-  adding 6
-  From: test
-  
-  diff -r ... 6
-  --- /dev/null
-  +++ b/6
-  @@ -0,0 +1,1 @@
-  +6
-  5: [mq]: 6.patch - test
-  4: [mq]: 5.patch - johndeere
-  3: Four - jane
-  2: Three (again) - maria
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== hg qref -U
-  From: test
-  
-  diff -r ... 6
-  --- /dev/null
-  +++ b/6
-  @@ -0,0 +1,1 @@
-  +6
-  5: [mq]: 6.patch - test
-  4: [mq]: 5.patch - johndeere
-  3: Four - jane
-  2: Three (again) - maria
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== hg qref -u
-  From: johndeere
-  
-  diff -r ... 6
-  --- /dev/null
-  +++ b/6
-  @@ -0,0 +1,1 @@
-  +6
-  5: [mq]: 6.patch - johndeere
-  4: [mq]: 5.patch - johndeere
-  3: Four - jane
-  2: Three (again) - maria
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== qpop -a / qpush -a
-  popping 6.patch
-  popping 5.patch
-  popping 4.patch
-  popping 3.patch
-  popping 2.patch
-  popping 1.patch
-  patch queue now empty
-  applying 1.patch
-  applying 2.patch
-  applying 3.patch
-  applying 4.patch
-  applying 5.patch
-  applying 6.patch
-  now at: 6.patch
-  5: imported patch 6.patch - johndeere
-  4: imported patch 5.patch - johndeere
-  3: Four - jane
-  2: Three (again) - maria
-  1: imported patch 2.patch - jane
-  0: imported patch 1.patch - mary
-  $ rm -r sandbox
-
-======= hg headers
-
-  $ echo "plain=false" >> $HGRCPATH
-  $ mkdir sandbox
-  $ (cd sandbox ; runtest)
-  ==== init
-  ==== qnew -U
-  # HG changeset patch
-  # Parent 
-  # User test
-  0: [mq]: 1.patch - test
-  ==== qref
-  adding 1
-  # HG changeset patch
-  # Parent 
-  # User test
-  
-  diff -r ... 1
-  --- /dev/null
-  +++ b/1
-  @@ -0,0 +1,1 @@
-  +1
-  0: [mq]: 1.patch - test
-  ==== qref -u
-  # HG changeset patch
-  # Parent 
-  # User mary
-  
-  diff -r ... 1
-  --- /dev/null
-  +++ b/1
-  @@ -0,0 +1,1 @@
-  +1
-  0: [mq]: 1.patch - mary
-  ==== qnew
-  adding 2
-  # HG changeset patch
-  # Parent 
-  
-  diff -r ... 2
-  --- /dev/null
-  +++ b/2
-  @@ -0,0 +1,1 @@
-  +2
-  1: [mq]: 2.patch - test
-  0: [mq]: 1.patch - mary
-  ==== qref -u
-  # HG changeset patch
-  # User jane
-  # Parent 
-  
-  diff -r ... 2
-  --- /dev/null
-  +++ b/2
-  @@ -0,0 +1,1 @@
-  +2
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== qnew -U -m
-  # HG changeset patch
-  # Parent 
-  # User test
-  Three
-  
-  2: Three - test
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== qref
-  adding 3
-  # HG changeset patch
-  # Parent 
-  # User test
-  Three
-  
-  diff -r ... 3
-  --- /dev/null
-  +++ b/3
-  @@ -0,0 +1,1 @@
-  +3
-  2: Three - test
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== qref -m
-  # HG changeset patch
-  # Parent 
-  # User test
-  Drei
-  
-  diff -r ... 3
-  --- /dev/null
-  +++ b/3
-  @@ -0,0 +1,1 @@
-  +3
-  2: Drei - test
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== qref -u
-  # HG changeset patch
-  # Parent 
-  # User mary
-  Drei
-  
-  diff -r ... 3
-  --- /dev/null
-  +++ b/3
-  @@ -0,0 +1,1 @@
-  +3
-  2: Drei - mary
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== qref -u -m
-  # HG changeset patch
-  # Parent 
-  # User maria
-  Three (again)
-  
-  diff -r ... 3
-  --- /dev/null
-  +++ b/3
-  @@ -0,0 +1,1 @@
-  +3
-  2: Three (again) - maria
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== qnew -m
-  adding 4of
-  # HG changeset patch
-  # Parent 
-  Four
-  
-  diff -r ... 4of
-  --- /dev/null
-  +++ b/4of
-  @@ -0,0 +1,1 @@
-  +4 t
-  3: Four - test
-  2: Three (again) - maria
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== qref -u
-  # HG changeset patch
-  # User jane
-  # Parent 
-  Four
-  
-  diff -r ... 4of
-  --- /dev/null
-  +++ b/4of
-  @@ -0,0 +1,1 @@
-  +4 t
-  3: Four - jane
-  2: Three (again) - maria
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== qnew with HG header
-  popping 5.patch
-  now at: 4.patch
-  now at: 5.patch
-  # HG changeset patch
-  # User johndoe
-  4: imported patch 5.patch - johndoe
-  3: Four - jane
-  2: Three (again) - maria
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== hg qref
-  adding 5
-  # HG changeset patch
-  # Parent 
-  # User johndoe
-  
-  diff -r ... 5
-  --- /dev/null
-  +++ b/5
-  @@ -0,0 +1,1 @@
-  +5
-  4: [mq]: 5.patch - johndoe
-  3: Four - jane
-  2: Three (again) - maria
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== hg qref -U
-  # HG changeset patch
-  # Parent 
-  # User test
-  
-  diff -r ... 5
-  --- /dev/null
-  +++ b/5
-  @@ -0,0 +1,1 @@
-  +5
-  4: [mq]: 5.patch - test
-  3: Four - jane
-  2: Three (again) - maria
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== hg qref -u
-  # HG changeset patch
-  # Parent 
-  # User johndeere
-  
-  diff -r ... 5
-  --- /dev/null
-  +++ b/5
-  @@ -0,0 +1,1 @@
-  +5
-  4: [mq]: 5.patch - johndeere
-  3: Four - jane
-  2: Three (again) - maria
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== qnew with plain header
-  popping 6.patch
-  now at: 5.patch
-  now at: 6.patch
-  From: test
-  
-  5: imported patch 6.patch - test
-  4: [mq]: 5.patch - johndeere
-  3: Four - jane
-  2: Three (again) - maria
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== hg qref
-  adding 6
-  From: test
-  
-  diff -r ... 6
-  --- /dev/null
-  +++ b/6
-  @@ -0,0 +1,1 @@
-  +6
-  5: [mq]: 6.patch - test
-  4: [mq]: 5.patch - johndeere
-  3: Four - jane
-  2: Three (again) - maria
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== hg qref -U
-  From: test
-  
-  diff -r ... 6
-  --- /dev/null
-  +++ b/6
-  @@ -0,0 +1,1 @@
-  +6
-  5: [mq]: 6.patch - test
-  4: [mq]: 5.patch - johndeere
-  3: Four - jane
-  2: Three (again) - maria
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== hg qref -u
-  From: johndeere
-  
-  diff -r ... 6
-  --- /dev/null
-  +++ b/6
-  @@ -0,0 +1,1 @@
-  +6
-  5: [mq]: 6.patch - johndeere
-  4: [mq]: 5.patch - johndeere
-  3: Four - jane
-  2: Three (again) - maria
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== qpop -a / qpush -a
-  popping 6.patch
-  popping 5.patch
-  popping 4.patch
-  popping 3.patch
-  popping 2.patch
-  popping 1.patch
-  patch queue now empty
-  applying 1.patch
-  applying 2.patch
-  applying 3.patch
-  applying 4.patch
-  applying 5.patch
-  applying 6.patch
-  now at: 6.patch
-  5: imported patch 6.patch - johndeere
-  4: imported patch 5.patch - johndeere
-  3: Four - jane
-  2: Three (again) - maria
-  1: imported patch 2.patch - jane
-  0: imported patch 1.patch - mary
-  $ rm -r sandbox
-  $ runtest
-  ==== init
-  ==== qnew -U
-  # HG changeset patch
-  # Parent 
-  # User test
-  0: [mq]: 1.patch - test
-  ==== qref
-  adding 1
-  # HG changeset patch
-  # Parent 
-  # User test
-  
-  diff -r ... 1
-  --- /dev/null
-  +++ b/1
-  @@ -0,0 +1,1 @@
-  +1
-  0: [mq]: 1.patch - test
-  ==== qref -u
-  # HG changeset patch
-  # Parent 
-  # User mary
-  
-  diff -r ... 1
-  --- /dev/null
-  +++ b/1
-  @@ -0,0 +1,1 @@
-  +1
-  0: [mq]: 1.patch - mary
-  ==== qnew
-  adding 2
-  # HG changeset patch
-  # Parent 
-  
-  diff -r ... 2
-  --- /dev/null
-  +++ b/2
-  @@ -0,0 +1,1 @@
-  +2
-  1: [mq]: 2.patch - test
-  0: [mq]: 1.patch - mary
-  ==== qref -u
-  # HG changeset patch
-  # User jane
-  # Parent 
-  
-  diff -r ... 2
-  --- /dev/null
-  +++ b/2
-  @@ -0,0 +1,1 @@
-  +2
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== qnew -U -m
-  # HG changeset patch
-  # Parent 
-  # User test
-  Three
-  
-  2: Three - test
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== qref
-  adding 3
-  # HG changeset patch
-  # Parent 
-  # User test
-  Three
-  
-  diff -r ... 3
-  --- /dev/null
-  +++ b/3
-  @@ -0,0 +1,1 @@
-  +3
-  2: Three - test
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== qref -m
-  # HG changeset patch
-  # Parent 
-  # User test
-  Drei
-  
-  diff -r ... 3
-  --- /dev/null
-  +++ b/3
-  @@ -0,0 +1,1 @@
-  +3
-  2: Drei - test
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== qref -u
-  # HG changeset patch
-  # Parent 
-  # User mary
-  Drei
-  
-  diff -r ... 3
-  --- /dev/null
-  +++ b/3
-  @@ -0,0 +1,1 @@
-  +3
-  2: Drei - mary
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== qref -u -m
-  # HG changeset patch
-  # Parent 
-  # User maria
-  Three (again)
-  
-  diff -r ... 3
-  --- /dev/null
-  +++ b/3
-  @@ -0,0 +1,1 @@
-  +3
-  2: Three (again) - maria
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== qnew -m
-  adding 4of
-  # HG changeset patch
-  # Parent 
-  Four
-  
-  diff -r ... 4of
-  --- /dev/null
-  +++ b/4of
-  @@ -0,0 +1,1 @@
-  +4 t
-  3: Four - test
-  2: Three (again) - maria
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== qref -u
-  # HG changeset patch
-  # User jane
-  # Parent 
-  Four
-  
-  diff -r ... 4of
-  --- /dev/null
-  +++ b/4of
-  @@ -0,0 +1,1 @@
-  +4 t
-  3: Four - jane
-  2: Three (again) - maria
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== qnew with HG header
-  popping 5.patch
-  now at: 4.patch
-  now at: 5.patch
-  # HG changeset patch
-  # User johndoe
-  4: imported patch 5.patch - johndoe
-  3: Four - jane
-  2: Three (again) - maria
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== hg qref
-  adding 5
-  # HG changeset patch
-  # Parent 
-  # User johndoe
-  
-  diff -r ... 5
-  --- /dev/null
-  +++ b/5
-  @@ -0,0 +1,1 @@
-  +5
-  4: [mq]: 5.patch - johndoe
-  3: Four - jane
-  2: Three (again) - maria
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== hg qref -U
-  # HG changeset patch
-  # Parent 
-  # User test
-  
-  diff -r ... 5
-  --- /dev/null
-  +++ b/5
-  @@ -0,0 +1,1 @@
-  +5
-  4: [mq]: 5.patch - test
-  3: Four - jane
-  2: Three (again) - maria
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== hg qref -u
-  # HG changeset patch
-  # Parent 
-  # User johndeere
-  
-  diff -r ... 5
-  --- /dev/null
-  +++ b/5
-  @@ -0,0 +1,1 @@
-  +5
-  4: [mq]: 5.patch - johndeere
-  3: Four - jane
-  2: Three (again) - maria
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== qnew with plain header
-  popping 6.patch
-  now at: 5.patch
-  now at: 6.patch
-  From: test
-  
-  5: imported patch 6.patch - test
-  4: [mq]: 5.patch - johndeere
-  3: Four - jane
-  2: Three (again) - maria
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== hg qref
-  adding 6
-  From: test
-  
-  diff -r ... 6
-  --- /dev/null
-  +++ b/6
-  @@ -0,0 +1,1 @@
-  +6
-  5: [mq]: 6.patch - test
-  4: [mq]: 5.patch - johndeere
-  3: Four - jane
-  2: Three (again) - maria
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== hg qref -U
-  From: test
-  
-  diff -r ... 6
-  --- /dev/null
-  +++ b/6
-  @@ -0,0 +1,1 @@
-  +6
-  5: [mq]: 6.patch - test
-  4: [mq]: 5.patch - johndeere
-  3: Four - jane
-  2: Three (again) - maria
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== hg qref -u
-  From: johndeere
-  
-  diff -r ... 6
-  --- /dev/null
-  +++ b/6
-  @@ -0,0 +1,1 @@
-  +6
-  5: [mq]: 6.patch - johndeere
-  4: [mq]: 5.patch - johndeere
-  3: Four - jane
-  2: Three (again) - maria
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
-  ==== qpop -a / qpush -a
-  popping 6.patch
-  popping 5.patch
-  popping 4.patch
-  popping 3.patch
-  popping 2.patch
-  popping 1.patch
-  patch queue now empty
-  applying 1.patch
-  applying 2.patch
-  applying 3.patch
-  applying 4.patch
-  applying 5.patch
-  applying 6.patch
-  now at: 6.patch
-  5: imported patch 6.patch - johndeere
-  4: imported patch 5.patch - johndeere
-  3: Four - jane
-  2: Three (again) - maria
-  1: imported patch 2.patch - jane
-  0: imported patch 1.patch - mary
-
-  $ cd ..
diff --git a/tests/test-mq-merge.t b/tests/test-mq-merge.t
deleted file mode 100644
--- a/tests/test-mq-merge.t
+++ /dev/null
@@ -1,173 +0,0 @@ 
-Setup extension:
-
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "mq =" >> $HGRCPATH
-  $ echo "[mq]" >> $HGRCPATH
-  $ echo "git = keep" >> $HGRCPATH
-
-Test merge with mq changeset as the second parent:
-
-  $ hg init m
-  $ cd m
-  $ touch a b c
-  $ hg add a
-  $ hg commit -m a
-  $ hg add b
-  $ hg qnew -d "0 0" b
-  $ hg update 0
-  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  $ hg add c
-  $ hg commit -m c
-  created new head
-  $ hg merge
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  (branch merge, don't forget to commit)
-  $ hg commit -m merge
-  abort: cannot commit over an applied mq patch
-  [255]
-  $ cd ..
-
-Issue529: mq aborts when merging patch deleting files
-
-  $ checkundo()
-  > {
-  >     if [ -f .hg/store/undo ]; then
-  >         echo ".hg/store/undo still exists"
-  >     fi
-  > }
-
-Commit two dummy files in "init" changeset:
-
-  $ hg init t
-  $ cd t
-  $ echo a > a
-  $ echo b > b
-  $ hg ci -Am init
-  adding a
-  adding b
-  $ hg tag -l init
-
-Create a patch removing a:
-
-  $ hg qnew rm_a
-  $ hg rm a
-  $ hg qrefresh -m "rm a"
-
-Save the patch queue so we can merge it later:
-
-  $ hg qsave -c -e
-  copy $TESTTMP/t/.hg/patches to $TESTTMP/t/.hg/patches.1 (glob)
-  $ checkundo
-
-Update b and commit in an "update" changeset:
-
-  $ hg up -C init
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ echo b >> b
-  $ hg st
-  M b
-  $ hg ci -m update
-  created new head
-
-# Here, qpush used to abort with :
-# The system cannot find the file specified => a
-  $ hg manifest
-  a
-  b
-
-  $ hg qpush -a -m
-  merging with queue at: $TESTTMP/t/.hg/patches.1 (glob)
-  applying rm_a
-  now at: rm_a
-
-  $ checkundo
-  $ hg manifest
-  b
-
-Ensure status is correct after merge:
-
-  $ hg qpop -a
-  popping rm_a
-  popping .hg.patches.merge.marker
-  patch queue now empty
-
-  $ cd ..
-
-Classic MQ merge sequence *with an explicit named queue*:
-
-  $ hg init t2
-  $ cd t2
-  $ echo '[diff]' > .hg/hgrc
-  $ echo 'nodates = 1' >> .hg/hgrc
-  $ echo a > a
-  $ hg ci -Am init
-  adding a
-  $ echo b > a
-  $ hg ci -m changea
-  $ hg up -C 0
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hg cp a aa
-  $ echo c >> a
-  $ hg qnew --git -f -e patcha
-  $ echo d >> a
-  $ hg qnew -d '0 0' -f -e patcha2
-
-Create the reference queue:
-
-  $ hg qsave -c -e -n refqueue
-  copy $TESTTMP/t2/.hg/patches to $TESTTMP/t2/.hg/refqueue (glob)
-  $ hg up -C 1
-  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
-
-Merge:
-
-  $ HGMERGE=internal:other hg qpush -a -m -n refqueue
-  merging with queue at: $TESTTMP/t2/.hg/refqueue (glob)
-  applying patcha
-  patching file a
-  Hunk #1 succeeded at 2 with fuzz 1 (offset 0 lines).
-  fuzz found when applying patch, stopping
-  patch didn't work out, merging patcha
-  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  0 files updated, 2 files merged, 0 files removed, 0 files unresolved
-  (branch merge, don't forget to commit)
-  applying patcha2
-  now at: patcha2
-
-Check patcha is still a git patch:
-
-  $ cat .hg/patches/patcha
-  # HG changeset patch
-  # Parent d3873e73d99ef67873dac33fbcc66268d5d2b6f4
-  
-  diff --git a/a b/a
-  --- a/a
-  +++ b/a
-  @@ -1,1 +1,2 @@
-  -b
-  +a
-  +c
-  diff --git a/aa b/aa
-  new file mode 100644
-  --- /dev/null
-  +++ b/aa
-  @@ -0,0 +1,1 @@
-  +a
-
-Check patcha2 is still a regular patch:
-
-  $ cat .hg/patches/patcha2
-  # HG changeset patch
-  # Parent ???????????????????????????????????????? (glob)
-  # Date 0 0
-  
-  diff -r ???????????? -r ???????????? a (glob)
-  --- a/a
-  +++ b/a
-  @@ -1,2 +1,3 @@
-   a
-   c
-  +d
-
-  $ cd ..
-
diff --git a/tests/test-mq-missingfiles.t b/tests/test-mq-missingfiles.t
deleted file mode 100644
--- a/tests/test-mq-missingfiles.t
+++ /dev/null
@@ -1,195 +0,0 @@ 
-
-Issue835: qpush fails immediately when patching a missing file, but
-remaining added files are still created empty which will trick a
-future qrefresh.
-
-  $ cat > writelines.py <<EOF
-  > import sys
-  > path = sys.argv[1]
-  > args = sys.argv[2:]
-  > assert (len(args) % 2) == 0
-  > 
-  > f = file(path, 'wb')
-  > for i in xrange(len(args)/2):
-  >    count, s = args[2*i:2*i+2]
-  >    count = int(count)
-  >    s = s.decode('string_escape')
-  >    f.write(s*count)
-  > f.close()
-  > EOF
-
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "mq=" >> $HGRCPATH
-
-  $ hg init normal
-  $ cd normal
-  $ python ../writelines.py b 10 'a\n'
-  $ hg ci -Am addb
-  adding b
-  $ echo a > a
-  $ python ../writelines.py b 2 'b\n' 10 'a\n' 2 'c\n'
-  $ echo c > c
-  $ hg add a c
-  $ hg qnew -f changeb
-  $ hg qpop
-  popping changeb
-  patch queue now empty
-  $ hg rm b
-  $ hg ci -Am rmb
-
-Push patch with missing target:
-
-  $ hg qpush
-  applying changeb
-  unable to find 'b' for patching
-  2 out of 2 hunks FAILED -- saving rejects to file b.rej
-  patch failed, unable to continue (try -v)
-  patch failed, rejects left in working dir
-  errors during apply, please fix and refresh changeb
-  [2]
-
-Display added files:
-
-  $ cat a
-  a
-  $ cat c
-  c
-
-Display rejections:
-
-  $ cat b.rej
-  --- b
-  +++ b
-  @@ -1,3 +1,5 @@
-  +b
-  +b
-   a
-   a
-   a
-  @@ -8,3 +10,5 @@
-   a
-   a
-   a
-  +c
-  +c
-
-Test missing renamed file
-
-  $ hg qpop
-  popping changeb
-  patch queue now empty
-  $ hg up -qC 0
-  $ echo a > a
-  $ hg mv b bb
-  $ python ../writelines.py bb 2 'b\n' 10 'a\n' 2 'c\n'
-  $ echo c > c
-  $ hg add a c
-  $ hg qnew changebb
-  $ hg qpop
-  popping changebb
-  patch queue now empty
-  $ hg up -qC 1
-  $ hg qpush
-  applying changebb
-  patching file bb
-  Hunk #1 FAILED at 0
-  Hunk #2 FAILED at 7
-  2 out of 2 hunks FAILED -- saving rejects to file bb.rej
-  b not tracked!
-  patch failed, unable to continue (try -v)
-  patch failed, rejects left in working dir
-  errors during apply, please fix and refresh changebb
-  [2]
-  $ cat a
-  a
-  $ cat c
-  c
-  $ cat bb.rej
-  --- bb
-  +++ bb
-  @@ -1,3 +1,5 @@
-  +b
-  +b
-   a
-   a
-   a
-  @@ -8,3 +10,5 @@
-   a
-   a
-   a
-  +c
-  +c
-
-  $ cd ..
-
-
-  $ echo "[diff]" >> $HGRCPATH
-  $ echo "git=1" >> $HGRCPATH
-
-  $ hg init git
-  $ cd git
-  $ python ../writelines.py b 1 '\x00'
-  $ hg ci -Am addb
-  adding b
-  $ echo a > a
-  $ python ../writelines.py b 1 '\x01' 1 '\x00'
-  $ echo c > c
-  $ hg add a c
-  $ hg qnew -f changeb
-  $ hg qpop
-  popping changeb
-  patch queue now empty
-  $ hg rm b
-  $ hg ci -Am rmb
-
-Push git patch with missing target:
-
-  $ hg qpush
-  applying changeb
-  unable to find 'b' for patching
-  1 out of 1 hunks FAILED -- saving rejects to file b.rej
-  patch failed, unable to continue (try -v)
-  patch failed, rejects left in working dir
-  errors during apply, please fix and refresh changeb
-  [2]
-  $ hg st
-  ? b.rej
-
-Display added files:
-
-  $ cat a
-  a
-  $ cat c
-  c
-
-Display rejections:
-
-  $ cat b.rej
-  --- b
-  +++ b
-  GIT binary patch
-  literal 2
-  Jc${No0000400IC2
-  
-  $ cd ..
-
-Test push creating directory during git copy or rename:
-
-  $ hg init missingdir
-  $ cd missingdir
-  $ echo a > a
-  $ hg ci -Am adda
-  adding a
-  $ mkdir d
-  $ hg copy a d/a2
-  $ hg mv a d/a
-  $ hg qnew -g -f patch
-  $ hg qpop
-  popping patch
-  patch queue now empty
-  $ hg qpush
-  applying patch
-  now at: patch
-
-  $ cd ..
-
diff --git a/tests/test-mq-pull-from-bundle.t b/tests/test-mq-pull-from-bundle.t
deleted file mode 100644
--- a/tests/test-mq-pull-from-bundle.t
+++ /dev/null
@@ -1,135 +0,0 @@ 
-  $ cat <<EOF >> $HGRCPATH
-  > [extensions]
-  > mq=
-  > [alias]
-  > tlog = log --template "{rev}: {desc}\\n"
-  > theads = heads --template "{rev}: {desc}\\n"
-  > tincoming = incoming --template "{rev}: {desc}\\n"
-  > EOF
-
-Setup main:
-
-  $ hg init base
-  $ cd base
-  $ echo "One" > one
-  $ hg add
-  adding one
-  $ hg ci -m "main: one added"
-  $ echo "++" >> one
-  $ hg ci -m "main: one updated"
-
-Bundle main:
-
-  $ hg bundle --base=null ../main.hg
-  2 changesets found
-
-  $ cd ..
-
-Incoming to fresh repo:
-
-  $ hg init fresh
-
-  $ hg -R fresh tincoming main.hg
-  comparing with main.hg
-  0: main: one added
-  1: main: one updated
-  $ test -f ./fresh/.hg/hg-bundle* && echo 'temp. bundle file remained' || true
-
-  $ hg -R fresh tincoming bundle:fresh+main.hg
-  comparing with bundle:fresh+main.hg
-  0: main: one added
-  1: main: one updated
-
-
-Setup queue:
-
-  $ cd base
-  $ hg qinit -c
-  $ hg qnew -m "patch: two added" two.patch
-  $ echo two > two
-  $ hg add
-  adding two
-  $ hg qrefresh
-  $ hg qcommit -m "queue: two.patch added"
-  $ hg qpop -a
-  popping two.patch
-  patch queue now empty
-
-Bundle queue:
-
-  $ hg -R .hg/patches bundle --base=null ../queue.hgq
-  1 changesets found
-  $ test -f ./fresh/.hg/hg-bundle* && echo 'temp. bundle file remained' || true
-
-  $ cd ..
-
-
-Clone base:
-
-  $ hg clone base copy
-  updating to branch default
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ cd copy
-  $ hg qinit -c
-
-Incoming queue bundle:
-
-  $ hg -R .hg/patches tincoming ../queue.hgq
-  comparing with ../queue.hgq
-  0: queue: two.patch added
-  $ test -f .hg/hg-bundle* && echo 'temp. bundle file remained' || true
-
-Pull queue bundle:
-
-  $ hg -R .hg/patches pull --update ../queue.hgq
-  pulling from ../queue.hgq
-  requesting all changes
-  adding changesets
-  adding manifests
-  adding file changes
-  added 1 changesets with 3 changes to 3 files
-  merging series
-  2 files updated, 1 files merged, 0 files removed, 0 files unresolved
-  $ test -f .hg/patches/hg-bundle* && echo 'temp. bundle file remained' || true
-
-  $ hg -R .hg/patches theads
-  0: queue: two.patch added
-
-  $ hg -R .hg/patches tlog
-  0: queue: two.patch added
-
-  $ hg qseries
-  two.patch
-
-  $ cd ..
-
-
-Clone base again:
-
-  $ hg clone base copy2
-  updating to branch default
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ cd copy2
-  $ hg qinit -c
-
-Unbundle queue bundle:
-
-  $ hg -R .hg/patches unbundle --update ../queue.hgq
-  adding changesets
-  adding manifests
-  adding file changes
-  added 1 changesets with 3 changes to 3 files
-  merging series
-  2 files updated, 1 files merged, 0 files removed, 0 files unresolved
-
-  $ hg -R .hg/patches theads
-  0: queue: two.patch added
-
-  $ hg -R .hg/patches tlog
-  0: queue: two.patch added
-
-  $ hg qseries
-  two.patch
-
-  $ cd ..
-
diff --git a/tests/test-mq-qclone-http.t b/tests/test-mq-qclone-http.t
deleted file mode 100644
--- a/tests/test-mq-qclone-http.t
+++ /dev/null
@@ -1,156 +0,0 @@ 
-  $ "$TESTDIR/hghave" killdaemons || exit 80
-
-hide outer repo
-  $ hg init
-
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "mq=" >> $HGRCPATH
-  $ mkdir webdir
-  $ cd webdir
-  $ hg init a
-  $ hg --cwd a qinit -c
-  $ echo a > a/a
-  $ hg --cwd a ci -A -m a
-  adding a
-  $ echo b > a/b
-  $ hg --cwd a addremove
-  adding b
-  $ hg --cwd a qnew -f b.patch
-  $ hg --cwd a qcommit -m b.patch
-  $ hg --cwd a log --template "{desc}\n"
-  [mq]: b.patch
-  a
-  $ hg --cwd a/.hg/patches log --template "{desc}\n"
-  b.patch
-  $ root=`pwd`
-  $ cd ..
-
-test with recursive collection
-
-  $ cat > collections.conf <<EOF
-  > [paths]
-  > /=$root/**
-  > EOF
-  $ hg serve -p $HGPORT -d --pid-file=hg.pid --webdir-conf collections.conf \
-  >     -A access-paths.log -E error-paths-1.log
-  $ cat hg.pid >> $DAEMON_PIDS
-  $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT '?style=raw'
-  200 Script output follows
-  
-  
-  /a/
-  /a/.hg/patches/
-  
-  $ hg qclone http://localhost:$HGPORT/a b
-  requesting all changes
-  adding changesets
-  adding manifests
-  adding file changes
-  added 2 changesets with 2 changes to 2 files
-  requesting all changes
-  adding changesets
-  adding manifests
-  adding file changes
-  added 1 changesets with 3 changes to 3 files
-  updating to branch default
-  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hg --cwd b log --template "{desc}\n"
-  a
-  $ hg --cwd b qpush -a
-  applying b.patch
-  now at: b.patch
-  $ hg --cwd b log --template "{desc}\n"
-  imported patch b.patch
-  a
-
-test with normal collection
-
-  $ cat > collections1.conf <<EOF
-  > [paths]
-  > /=$root/*
-  > EOF
-  $ hg serve -p $HGPORT1 -d --pid-file=hg.pid --webdir-conf collections1.conf \
-  >     -A access-paths.log -E error-paths-1.log
-  $ cat hg.pid >> $DAEMON_PIDS
-  $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT1 '?style=raw'
-  200 Script output follows
-  
-  
-  /a/
-  /a/.hg/patches/
-  
-  $ hg qclone http://localhost:$HGPORT1/a c
-  requesting all changes
-  adding changesets
-  adding manifests
-  adding file changes
-  added 2 changesets with 2 changes to 2 files
-  requesting all changes
-  adding changesets
-  adding manifests
-  adding file changes
-  added 1 changesets with 3 changes to 3 files
-  updating to branch default
-  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hg --cwd c log --template "{desc}\n"
-  a
-  $ hg --cwd c qpush -a
-  applying b.patch
-  now at: b.patch
-  $ hg --cwd c log --template "{desc}\n"
-  imported patch b.patch
-  a
-
-test with old-style collection
-
-  $ cat > collections2.conf <<EOF
-  > [collections]
-  > $root=$root
-  > EOF
-  $ hg serve -p $HGPORT2 -d --pid-file=hg.pid --webdir-conf collections2.conf \
-  >     -A access-paths.log -E error-paths-1.log
-  $ cat hg.pid >> $DAEMON_PIDS
-  $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT2 '?style=raw'
-  200 Script output follows
-  
-  
-  /a/
-  /a/.hg/patches/
-  
-  $ hg qclone http://localhost:$HGPORT2/a d
-  requesting all changes
-  adding changesets
-  adding manifests
-  adding file changes
-  added 2 changesets with 2 changes to 2 files
-  requesting all changes
-  adding changesets
-  adding manifests
-  adding file changes
-  added 1 changesets with 3 changes to 3 files
-  updating to branch default
-  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hg --cwd d log --template "{desc}\n"
-  a
-  $ hg --cwd d qpush -a
-  applying b.patch
-  now at: b.patch
-  $ hg --cwd d log --template "{desc}\n"
-  imported patch b.patch
-  a
-
-test --mq works and uses correct repository config
-
-  $ hg --cwd d outgoing --mq
-  comparing with http://localhost:$HGPORT2/a/.hg/patches
-  searching for changes
-  no changes found
-  [1]
-  $ hg --cwd d log --mq --template '{rev} {desc|firstline}\n'
-  0 b.patch
-
-  $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS
-
diff --git a/tests/test-mq-qdelete.t b/tests/test-mq-qdelete.t
deleted file mode 100644
--- a/tests/test-mq-qdelete.t
+++ /dev/null
@@ -1,197 +0,0 @@ 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "mq=" >> $HGRCPATH
-
-  $ hg init a
-  $ cd a
-
-  $ echo 'base' > base
-  $ hg ci -Ambase -d '1 0'
-  adding base
-
-  $ hg qnew -d '1 0' pa
-  $ hg qnew -d '1 0' pb
-  $ hg qnew -d '1 0' pc
-
-  $ hg qdel
-  abort: qdelete requires at least one revision or patch name
-  [255]
-
-  $ hg qdel pc
-  abort: cannot delete applied patch pc
-  [255]
-
-  $ hg qpop
-  popping pc
-  now at: pb
-
-Delete the same patch twice in one command (issue2427)
-
-  $ hg qdel pc pc
-
-  $ hg qseries
-  pa
-  pb
-
-  $ ls .hg/patches
-  pa
-  pb
-  series
-  status
-
-  $ hg qpop
-  popping pb
-  now at: pa
-
-  $ hg qdel -k 1
-
-  $ ls .hg/patches
-  pa
-  pb
-  series
-  status
-
-  $ hg qdel -r pa
-  patch pa finalized without changeset message
-
-  $ hg qapplied
-
-  $ hg log --template '{rev} {desc}\n'
-  1 [mq]: pa
-  0 base
-
-  $ hg qnew pd
-  $ hg qnew pe
-  $ hg qnew pf
-
-  $ hg qdel -r pe
-  abort: cannot delete revision 3 above applied patches
-  [255]
-
-  $ hg qdel -r qbase:pe
-  patch pd finalized without changeset message
-  patch pe finalized without changeset message
-
-  $ hg qapplied
-  pf
-
-  $ hg log --template '{rev} {desc}\n'
-  4 [mq]: pf
-  3 [mq]: pe
-  2 [mq]: pd
-  1 [mq]: pa
-  0 base
-
-  $ cd ..
-
-  $ hg init b
-  $ cd b
-
-  $ echo 'base' > base
-  $ hg ci -Ambase -d '1 0'
-  adding base
-
-  $ hg qfinish
-  abort: no revisions specified
-  [255]
-
-  $ hg qfinish -a
-  no patches applied
-
-  $ hg qnew -d '1 0' pa
-  $ hg qnew -d '1 0' pb
-  $ hg qnew pc # XXX fails to apply by /usr/bin/patch if we put a date
-
-  $ hg qfinish 0
-  abort: revision 0 is not managed
-  [255]
-
-  $ hg qfinish pb
-  abort: cannot delete revision 2 above applied patches
-  [255]
-
-  $ hg qpop
-  popping pc
-  now at: pb
-
-  $ hg qfinish -a pc
-  abort: unknown revision 'pc'!
-  [255]
-
-  $ hg qpush
-  applying pc
-  patch pc is empty
-  now at: pc
-
-  $ hg qfinish qbase:pb
-  patch pa finalized without changeset message
-  patch pb finalized without changeset message
-
-  $ hg qapplied
-  pc
-
-  $ hg log --template '{rev} {desc}\n'
-  3 imported patch pc
-  2 [mq]: pb
-  1 [mq]: pa
-  0 base
-
-  $ hg qfinish -a pc
-  patch pc finalized without changeset message
-
-  $ hg qapplied
-
-  $ hg log --template '{rev} {desc}\n'
-  3 imported patch pc
-  2 [mq]: pb
-  1 [mq]: pa
-  0 base
-
-  $ ls .hg/patches
-  series
-  status
-
-qdel -k X && hg qimp -e X used to trigger spurious output with versioned queues
-
-  $ hg init --mq
-  $ hg qimport -r 3
-  $ hg qpop
-  popping 3.diff
-  patch queue now empty
-  $ hg qdel -k 3.diff
-  $ hg qimp -e 3.diff
-  adding 3.diff to series file
-  $ hg qfinish -a
-  no patches applied
-
-
-resilience to inconsistency: qfinish -a with applied patches not in series
-
-  $ hg qser
-  3.diff
-  $ hg qapplied
-  $ hg qpush
-  applying 3.diff
-  patch 3.diff is empty
-  now at: 3.diff
-  $ echo next >>  base
-  $ hg qrefresh -d '1 0'
-  $ echo > .hg/patches/series # remove 3.diff from series to confuse mq
-  $ hg qfinish -a
-  revision 47dfa8501675 refers to unknown patches: 3.diff
-
-more complex state 'both known and unknown patches
-
-  $ echo hip >>  base
-  $ hg qnew -f -d '1 0' -m 4 4.diff
-  $ echo hop >>  base
-  $ hg qnew -f -d '1 0' -m 5 5.diff
-  $ echo > .hg/patches/series # remove 4.diff and 5.diff from series to confuse mq
-  $ echo hup >>  base
-  $ hg qnew -f -d '1 0' -m 6 6.diff
-  $ echo pup > base
-  $ hg qfinish -a
-  warning: uncommitted changes in the working directory
-  revision 2b1c98802260 refers to unknown patches: 5.diff
-  revision 33a6861311c0 refers to unknown patches: 4.diff
-
-  $ cd ..
diff --git a/tests/test-mq-qdiff.t b/tests/test-mq-qdiff.t
deleted file mode 100644
--- a/tests/test-mq-qdiff.t
+++ /dev/null
@@ -1,177 +0,0 @@ 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "mq=" >> $HGRCPATH
-  $ echo "[mq]" >> $HGRCPATH
-  $ echo "git=keep" >> $HGRCPATH
-
-  $ hg init a
-  $ cd a
-
-  $ echo 'base' > base
-  $ hg ci -Ambase
-  adding base
-
-  $ hg qnew -mmqbase mqbase
-
-  $ echo 'patched' > base
-  $ hg qrefresh
-
-qdiff:
-
-  $ hg qdiff
-  diff -r d20a80d4def3 base
-  --- a/base	Thu Jan 01 00:00:00 1970 +0000
-  +++ b/base* (glob)
-  @@ -1,1 +1,1 @@
-  -base
-  +patched
-
-qdiff dirname:
-
-  $ hg qdiff --nodates .
-  diff -r d20a80d4def3 base
-  --- a/base
-  +++ b/base
-  @@ -1,1 +1,1 @@
-  -base
-  +patched
-
-qdiff filename:
-
-  $ hg qdiff --nodates base
-  diff -r d20a80d4def3 base
-  --- a/base
-  +++ b/base
-  @@ -1,1 +1,1 @@
-  -base
-  +patched
-
-  $ hg revert -a
-
-  $ hg qpop
-  popping mqbase
-  patch queue now empty
-
-  $ hg qdelete mqbase
-
-  $ printf '1\n2\n3\n4\nhello world\ngoodbye world\n7\n8\n9\n' > lines
-  $ hg ci -Amlines -d '2 0'
-  adding lines
-
-  $ hg qnew -mmqbase2 mqbase2
-  $ printf '\n\n1\n2\n3\n4\nhello  world\n     goodbye world\n7\n8\n9\n' > lines
-
-  $ hg qdiff --nodates -U 1
-  diff -r b0c220e1cf43 lines
-  --- a/lines
-  +++ b/lines
-  @@ -1,1 +1,3 @@
-  +
-  +
-   1
-  @@ -4,4 +6,4 @@
-   4
-  -hello world
-  -goodbye world
-  +hello  world
-  +     goodbye world
-   7
-
-  $ hg qdiff --nodates -b
-  diff -r b0c220e1cf43 lines
-  --- a/lines
-  +++ b/lines
-  @@ -1,9 +1,11 @@
-  +
-  +
-   1
-   2
-   3
-   4
-   hello world
-  -goodbye world
-  +     goodbye world
-   7
-   8
-   9
-
-  $ hg qdiff --nodates -U 1 -B
-  diff -r b0c220e1cf43 lines
-  --- a/lines
-  +++ b/lines
-  @@ -4,4 +4,4 @@
-   4
-  -hello world
-  -goodbye world
-  +hello  world
-  +     goodbye world
-   7
-
-  $ hg qdiff --nodates -w
-  diff -r b0c220e1cf43 lines
-  --- a/lines
-  +++ b/lines
-  @@ -1,3 +1,5 @@
-  +
-  +
-   1
-   2
-   3
-
-  $ hg qdiff --nodates --reverse
-  diff -r b0c220e1cf43 lines
-  --- a/lines
-  +++ b/lines
-  @@ -1,11 +1,9 @@
-  -
-  -
-   1
-   2
-   3
-   4
-  -hello  world
-  -     goodbye world
-  +hello world
-  +goodbye world
-   7
-   8
-   9
-
-qdiff preserve existing git flag:
-
-  $ hg qrefresh --git
-  $ echo a >> lines
-  $ hg qdiff
-  diff --git a/lines b/lines
-  --- a/lines
-  +++ b/lines
-  @@ -1,9 +1,12 @@
-  +
-  +
-   1
-   2
-   3
-   4
-  -hello world
-  -goodbye world
-  +hello  world
-  +     goodbye world
-   7
-   8
-   9
-  +a
-
-  $ hg qdiff --stat
-   lines |  7 +++++--
-   1 files changed, 5 insertions(+), 2 deletions(-)
-  $ hg qrefresh
-
-qdiff when file deleted (but not removed) in working dir:
-
-  $ hg qnew deleted-file
-  $ echo a > newfile
-  $ hg add newfile
-  $ hg qrefresh
-  $ rm newfile
-  $ hg qdiff
-
-  $ cd ..
diff --git a/tests/test-mq-qfold.t b/tests/test-mq-qfold.t
deleted file mode 100644
--- a/tests/test-mq-qfold.t
+++ /dev/null
@@ -1,144 +0,0 @@ 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "mq=" >> $HGRCPATH
-  $ echo "[mq]" >> $HGRCPATH
-  $ echo "git=keep" >> $HGRCPATH
-  $ echo "[diff]" >> $HGRCPATH
-  $ echo "nodates=1" >> $HGRCPATH
-
-init:
-
-  $ hg init repo
-  $ cd repo
-  $ echo a > a
-  $ hg ci -Am adda
-  adding a
-  $ echo a >> a
-  $ hg qnew -f p1
-  $ echo b >> a
-  $ hg qnew -f p2
-  $ echo c >> a
-  $ hg qnew -f p3
-
-Fold in the middle of the queue:
-
-  $ hg qpop p1
-  popping p3
-  popping p2
-  now at: p1
-
-  $ hg qdiff
-  diff -r 07f494440405 a
-  --- a/a
-  +++ b/a
-  @@ -1,1 +1,2 @@
-   a
-  +a
-
-  $ hg qfold p2
-  $ grep git .hg/patches/p1 && echo 'git patch found!'
-  [1]
-
-  $ hg qser
-  p1
-  p3
-
-  $ hg qdiff
-  diff -r 07f494440405 a
-  --- a/a
-  +++ b/a
-  @@ -1,1 +1,3 @@
-   a
-  +a
-  +b
-
-Fold with local changes:
-
-  $ echo d >> a
-  $ hg qfold p3
-  abort: local changes found, refresh first
-  [255]
-
-  $ hg diff -c .
-  diff -r 07f494440405 -r ???????????? a (glob)
-  --- a/a
-  +++ b/a
-  @@ -1,1 +1,3 @@
-   a
-  +a
-  +b
-
-  $ hg revert -a --no-backup
-  reverting a
-
-Fold git patch into a regular patch, expect git patch:
-
-  $ echo a >> a
-  $ hg qnew -f regular
-  $ hg cp a aa
-  $ hg qnew --git -f git
-
-  $ hg qpop
-  popping git
-  now at: regular
-
-  $ hg qfold git
-
-  $ cat .hg/patches/regular
-  # HG changeset patch
-  # Parent ???????????????????????????????????????? (glob)
-  
-  diff --git a/a b/a
-  --- a/a
-  +++ b/a
-  @@ -1,3 +1,4 @@
-   a
-   a
-   b
-  +a
-  diff --git a/a b/aa
-  copy from a
-  copy to aa
-  --- a/a
-  +++ b/aa
-  @@ -1,3 +1,4 @@
-   a
-   a
-   b
-  +a
-
-  $ hg qpop
-  popping regular
-  now at: p1
-
-  $ hg qdel regular
-
-Fold regular patch into a git patch, expect git patch:
-
-  $ hg cp a aa
-  $ hg qnew --git -f git
-  $ echo b >> aa
-  $ hg qnew -f regular
-
-  $ hg qpop
-  popping regular
-  now at: git
-
-  $ hg qfold regular
-
-  $ cat .hg/patches/git
-  # HG changeset patch
-  # Parent ???????????????????????????????????????? (glob)
-  
-  diff --git a/a b/aa
-  copy from a
-  copy to aa
-  --- a/a
-  +++ b/aa
-  @@ -1,3 +1,4 @@
-   a
-   a
-   b
-  +b
-
-  $ cd ..
-
diff --git a/tests/test-mq-qgoto.t b/tests/test-mq-qgoto.t
deleted file mode 100644
--- a/tests/test-mq-qgoto.t
+++ /dev/null
@@ -1,93 +0,0 @@ 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "mq=" >> $HGRCPATH
-
-  $ hg init a
-  $ cd a
-  $ echo a > a
-  $ hg ci -Ama
-  adding a
-
-  $ 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
-  popping c.patch
-  popping b.patch
-  now at: a.patch
-
-  $ hg qgoto c.patch
-  applying b.patch
-  applying c.patch
-  now at: c.patch
-
-  $ hg qgoto b.patch
-  popping c.patch
-  now at: b.patch
-
-Using index:
-
-  $ hg qgoto 0
-  popping b.patch
-  now at: a.patch
-
-  $ hg qgoto 2
-  applying b.patch
-  applying c.patch
-  now at: c.patch
-
-No warnings when using index ... and update from non-qtip and with pending
-changes in unrelated files:
-
-  $ hg qnew bug314159
-  $ echo d >> c
-  $ hg qrefresh
-  $ hg qnew bug141421
-  $ echo e >> b
-  $ hg qrefresh
-
-  $ hg up -r bug314159
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ echo f >> a
-  $ echo f >> b
-  $ echo f >> c
-
-  $ hg qgoto 1
-  abort: local changes found, refresh first
-  [255]
-  $ hg qgoto 1 -f
-  popping bug141421
-  popping bug314159
-  popping c.patch
-  now at: b.patch
-  $ hg st
-  M a
-  M b
-  ? c.orig
-  $ hg up -qCr.
-
-  $ hg qgoto 3
-  applying c.patch
-  applying bug314159
-  now at: bug314159
-
-Detect ambiguous non-index:
-
-  $ hg qgoto 14
-  patch name "14" is ambiguous:
-    bug314159
-    bug141421
-  abort: patch 14 not in series
-  [255]
-
-  $ cd ..
diff --git a/tests/test-mq-qimport-fail-cleanup.t b/tests/test-mq-qimport-fail-cleanup.t
deleted file mode 100644
--- a/tests/test-mq-qimport-fail-cleanup.t
+++ /dev/null
@@ -1,42 +0,0 @@ 
-Failed qimport of patches from files should cleanup by recording successfully
-imported patches in series file.
-
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "mq=" >> $HGRCPATH
-  $ hg init repo
-  $ cd repo
-  $ echo a > a
-  $ hg ci -Am'add a'
-  adding a
-  $ cat >b.patch<<EOF
-  > diff --git a/a b/a
-  > --- a/a
-  > +++ b/a
-  > @@ -1,1 +1,2 @@
-  >  a
-  > +b
-  > EOF
-
-empty series
-
-  $ hg qseries
-
-qimport valid patch followed by invalid patch
-
-  $ hg qimport b.patch fakepatch
-  adding b.patch to series file
-  abort: unable to read file fakepatch
-  [255]
-
-valid patches before fail added to series
-
-  $ hg qseries
-  b.patch
-
-  $ hg pull -q -r 0 . # update phase
-  $ hg qimport -r 0
-  abort: revision 0 is not mutable
-  (see "hg help phases" for details)
-  [255]
-
-  $ cd ..
diff --git a/tests/test-mq-qimport.t b/tests/test-mq-qimport.t
deleted file mode 100644
--- a/tests/test-mq-qimport.t
+++ /dev/null
@@ -1,282 +0,0 @@ 
-  $ "$TESTDIR/hghave" killdaemons || exit 80
-
-  $ cat > writelines.py <<EOF
-  > import sys
-  > path = sys.argv[1]
-  > args = sys.argv[2:]
-  > assert (len(args) % 2) == 0
-  > 
-  > f = file(path, 'wb')
-  > for i in xrange(len(args)/2):
-  >    count, s = args[2*i:2*i+2]
-  >    count = int(count)
-  >    s = s.decode('string_escape')
-  >    f.write(s*count)
-  > f.close()
-  > 
-  > EOF
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "mq=" >> $HGRCPATH
-  $ echo "[diff]" >> $HGRCPATH
-  $ echo "git=1" >> $HGRCPATH
-  $ hg init repo
-  $ cd repo
-
-qimport without file or revision
-
-  $ hg qimport
-  abort: no files or revisions specified
-  [255]
-
-qimport non-existing-file
-
-  $ hg qimport non-existing-file
-  abort: unable to read file non-existing-file
-  [255]
-
-qimport null revision
-
-  $ hg qimport -r null
-  abort: revision -1 is not mutable
-  (see "hg help phases" for details)
-  [255]
-  $ hg qseries
-
-import email
-
-  $ hg qimport --push -n email - <<EOF
-  > From: Username in email <test@example.net>
-  > Subject: [PATCH] Message in email
-  > Date: Fri, 02 Jan 1970 00:00:00 +0000
-  > 
-  > Text before patch.
-  > 
-  > # HG changeset patch
-  > # User Username in patch <test@example.net>
-  > # Date 0 0
-  > # Node ID 1a706973a7d84cb549823634a821d9bdf21c6220
-  > # Parent  0000000000000000000000000000000000000000
-  > First line of commit message.
-  > 
-  > More text in commit message.
-  > --- confuse the diff detection
-  > 
-  > diff --git a/x b/x
-  > new file mode 100644
-  > --- /dev/null
-  > +++ b/x
-  > @@ -0,0 +1,1 @@
-  > +new file
-  > Text after patch.
-  > 
-  > EOF
-  adding email to series file
-  applying email
-  now at: email
-
-hg tip -v
-
-  $ hg tip -v
-  changeset:   0:1a706973a7d8
-  tag:         email
-  tag:         qbase
-  tag:         qtip
-  tag:         tip
-  user:        Username in patch <test@example.net>
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  files:       x
-  description:
-  First line of commit message.
-  
-  More text in commit message.
-  
-  
-  $ hg qpop
-  popping email
-  patch queue now empty
-  $ hg qdelete email
-
-import URL
-
-  $ echo foo >> foo
-  $ hg add foo
-  $ hg diff > url.diff
-  $ hg revert --no-backup foo
-  $ rm foo
-
-Under unix: file:///foobar/blah
-Under windows: file:///c:/foobar/blah
-
-  $ patchurl=`pwd | tr '\\\\' /`/url.diff
-  $ expr "$patchurl" : "\/" > /dev/null || patchurl="/$patchurl"
-  $ hg qimport file://"$patchurl"
-  adding url.diff to series file
-  $ rm url.diff
-  $ hg qun
-  url.diff
-
-import patch that already exists
-
-  $ echo foo2 >> foo
-  $ hg add foo
-  $ hg diff > ../url.diff
-  $ hg revert --no-backup foo
-  $ rm foo
-  $ hg qimport ../url.diff
-  abort: patch "url.diff" already exists
-  [255]
-  $ hg qpush
-  applying url.diff
-  now at: url.diff
-  $ cat foo
-  foo
-  $ hg qpop
-  popping url.diff
-  patch queue now empty
-
-qimport -f
-
-  $ hg qimport -f ../url.diff
-  adding url.diff to series file
-  $ hg qpush
-  applying url.diff
-  now at: url.diff
-  $ cat foo
-  foo2
-  $ hg qpop
-  popping url.diff
-  patch queue now empty
-
-build diff with CRLF
-
-  $ python ../writelines.py b 5 'a\n' 5 'a\r\n'
-  $ hg ci -Am addb
-  adding b
-  $ python ../writelines.py b 2 'a\n' 10 'b\n' 2 'a\r\n'
-  $ hg diff > b.diff
-  $ hg up -C
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-
-qimport CRLF diff
-
-  $ hg qimport b.diff
-  adding b.diff to series file
-  $ hg qpush
-  applying b.diff
-  now at: b.diff
-
-try to import --push
-
-  $ cat > appendfoo.diff <<EOF
-  > append foo
-  > 
-  > diff -r 07f494440405 -r 261500830e46 baz
-  > --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
-  > +++ b/baz	Thu Jan 01 00:00:00 1970 +0000
-  > @@ -0,0 +1,1 @@
-  > +foo
-  > EOF
-
-  $ cat > appendbar.diff <<EOF
-  > append bar
-  > 
-  > diff -r 07f494440405 -r 261500830e46 baz
-  > --- a/baz	Thu Jan 01 00:00:00 1970 +0000
-  > +++ b/baz	Thu Jan 01 00:00:00 1970 +0000
-  > @@ -1,1 +1,2 @@
-  >  foo
-  > +bar
-  > EOF
-
-  $ hg qimport --push appendfoo.diff appendbar.diff
-  adding appendfoo.diff to series file
-  adding appendbar.diff to series file
-  applying appendfoo.diff
-  applying appendbar.diff
-  now at: appendbar.diff
-  $ hg qfin -a
-  patch b.diff finalized without changeset message
-  $ hg qimport -r 'p1(.)::' -P
-  $ hg qpop -a
-  popping 3.diff
-  popping 2.diff
-  patch queue now empty
-  $ hg qdel 3.diff
-  $ hg qdel -k 2.diff
-
-qimport -e
-
-  $ hg qimport -e 2.diff
-  adding 2.diff to series file
-  $ hg qdel -k 2.diff
-
-qimport -e --name newname oldexisitingpatch
-
-  $ hg qimport -e --name this-name-is-better 2.diff
-  renaming 2.diff to this-name-is-better
-  adding this-name-is-better to series file
-  $ hg qser
-  this-name-is-better
-  url.diff
-
-qimport -e --name without --force
-
-  $ cp .hg/patches/this-name-is-better .hg/patches/3.diff
-  $ hg qimport -e --name this-name-is-better 3.diff
-  abort: patch "this-name-is-better" already exists
-  [255]
-  $ hg qser
-  this-name-is-better
-  url.diff
-
-qimport -e --name with --force
-
-  $ hg qimport --force -e --name this-name-is-better 3.diff
-  renaming 3.diff to this-name-is-better
-  adding this-name-is-better to series file
-  $ hg qser
-  this-name-is-better
-  url.diff
-
-qimport with bad name, should abort before reading file
-
-  $ hg qimport non-existent-file --name .hg
-  abort: patch name cannot begin with ".hg"
-  [255]
-
-qimport http:// patch with leading slashes in url
-
-set up hgweb
-
-  $ cd ..
-  $ hg init served
-  $ cd served
-  $ echo a > a
-  $ hg ci -Am patch
-  adding a
-  $ hg serve -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
-  $ cat hg.pid >> $DAEMON_PIDS
-
-  $ cd ../repo
-  $ hg qimport http://localhost:$HGPORT/raw-rev/0///
-  adding 0 to series file
-
-check qimport phase:
-
-  $ hg -q qpush
-  now at: 0
-  $ hg phase qparent
-  1: draft
-  $ hg qimport -r qparent
-  $ hg phase qbase
-  1: draft
-  $ hg qfinish qbase
-  $ echo '[mq]' >> $HGRCPATH
-  $ echo 'secret=true' >> $HGRCPATH
-  $ hg qimport -r qparent
-  $ hg phase qbase
-  1: secret
-
-  $ cd ..
-
-  $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS
diff --git a/tests/test-mq-qnew.t b/tests/test-mq-qnew.t
deleted file mode 100644
--- a/tests/test-mq-qnew.t
+++ /dev/null
@@ -1,235 +0,0 @@ 
-
-  $ catpatch() {
-  >     cat $1 | sed -e "s/^\(# Parent \).*/\1/"
-  > }
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "mq=" >> $HGRCPATH
-  $ runtest() {
-  >     hg init mq
-  >     cd mq
-  > 
-  >     echo a > a
-  >     hg ci -Ama
-  > 
-  >     echo '% qnew should refuse bad patch names'
-  >     hg qnew series
-  >     hg qnew status
-  >     hg qnew guards
-  >     hg qnew .
-  >     hg qnew ..
-  >     hg qnew .hgignore
-  >     hg qnew .mqfoo
-  >     hg qnew 'foo#bar'
-  >     hg qnew 'foo:bar'
-  > 
-  >     hg qinit -c
-  > 
-  >     echo '% qnew with name containing slash'
-  >     hg qnew foo/
-  >     hg qnew foo/bar.patch
-  >     hg qnew foo
-  >     hg qseries
-  >     hg qpop
-  >     hg qdelete foo/bar.patch
-  > 
-  >     echo '% qnew with uncommitted changes'
-  >     echo a > somefile
-  >     hg add somefile
-  >     hg qnew uncommitted.patch
-  >     hg st
-  >     hg qseries
-  > 
-  >     echo '% qnew implies add'
-  >     hg -R .hg/patches st
-  > 
-  >     echo '% qnew missing'
-  >     hg qnew missing.patch missing
-  > 
-  >     echo '% qnew -m'
-  >     hg qnew -m 'foo bar' mtest.patch
-  >     catpatch .hg/patches/mtest.patch
-  > 
-  >     echo '% qnew twice'
-  >     hg qnew first.patch
-  >     hg qnew first.patch
-  > 
-  >     touch ../first.patch
-  >     hg qimport ../first.patch
-  > 
-  >     echo '% qnew -f from a subdirectory'
-  >     hg qpop -a
-  >     mkdir d
-  >     cd d
-  >     echo b > b
-  >     hg ci -Am t
-  >     echo b >> b
-  >     hg st
-  >     hg qnew -g -f p
-  >     catpatch ../.hg/patches/p
-  > 
-  >     echo '% qnew -u with no username configured'
-  >     HGUSER= hg qnew -u blue red
-  >     catpatch ../.hg/patches/red
-  > 
-  >     echo '% qnew -e -u with no username configured'
-  >     HGUSER= hg qnew -e -u chartreuse fucsia
-  >     catpatch ../.hg/patches/fucsia
-  > 
-  >     echo '% fail when trying to import a merge'
-  >     hg init merge
-  >     cd merge
-  >     touch a
-  >     hg ci -Am null
-  >     echo a >> a
-  >     hg ci -m a
-  >     hg up -r 0
-  >     echo b >> a
-  >     hg ci -m b
-  >     hg merge -f 1
-  >     hg resolve --mark a
-  >     hg qnew -f merge
-  > 
-  >     cd ../../..
-  >     rm -r mq
-  > }
-
-plain headers
-
-  $ echo "[mq]" >> $HGRCPATH
-  $ echo "plain=true" >> $HGRCPATH
-  $ mkdir sandbox
-  $ (cd sandbox ; runtest)
-  adding a
-  % qnew should refuse bad patch names
-  abort: "series" cannot be used as the name of a patch
-  abort: "status" cannot be used as the name of a patch
-  abort: "guards" cannot be used as the name of a patch
-  abort: "." cannot be used as the name of a patch
-  abort: ".." cannot be used as the name of a patch
-  abort: patch name cannot begin with ".hg"
-  abort: patch name cannot begin with ".mq"
-  abort: "#" cannot be used in the name of a patch
-  abort: ":" cannot be used in the name of a patch
-  % qnew with name containing slash
-  abort: path ends in directory separator: foo/ (glob)
-  abort: "foo" already exists as a directory
-  foo/bar.patch
-  popping foo/bar.patch
-  patch queue now empty
-  % qnew with uncommitted changes
-  uncommitted.patch
-  % qnew implies add
-  A .hgignore
-  A series
-  A uncommitted.patch
-  % qnew missing
-  abort: missing: * (glob)
-  % qnew -m
-  foo bar
-  
-  % qnew twice
-  abort: patch "first.patch" already exists
-  abort: patch "first.patch" already exists
-  % qnew -f from a subdirectory
-  popping first.patch
-  popping mtest.patch
-  popping uncommitted.patch
-  patch queue now empty
-  adding d/b
-  M d/b
-  diff --git a/d/b b/d/b
-  --- a/d/b
-  +++ b/d/b
-  @@ -1,1 +1,2 @@
-   b
-  +b
-  % qnew -u with no username configured
-  From: blue
-  
-  % qnew -e -u with no username configured
-  From: chartreuse
-  
-  % fail when trying to import a merge
-  adding a
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  created new head
-  merging a
-  warning: conflicts during merge.
-  merging a incomplete! (edit conflicts, then use 'hg resolve --mark')
-  0 files updated, 0 files merged, 0 files removed, 1 files unresolved
-  use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
-  abort: cannot manage merge changesets
-  $ rm -r sandbox
-
-hg headers
-
-  $ echo "plain=false" >> $HGRCPATH
-  $ mkdir sandbox
-  $ (cd sandbox ; runtest)
-  adding a
-  % qnew should refuse bad patch names
-  abort: "series" cannot be used as the name of a patch
-  abort: "status" cannot be used as the name of a patch
-  abort: "guards" cannot be used as the name of a patch
-  abort: "." cannot be used as the name of a patch
-  abort: ".." cannot be used as the name of a patch
-  abort: patch name cannot begin with ".hg"
-  abort: patch name cannot begin with ".mq"
-  abort: "#" cannot be used in the name of a patch
-  abort: ":" cannot be used in the name of a patch
-  % qnew with name containing slash
-  abort: path ends in directory separator: foo/ (glob)
-  abort: "foo" already exists as a directory
-  foo/bar.patch
-  popping foo/bar.patch
-  patch queue now empty
-  % qnew with uncommitted changes
-  uncommitted.patch
-  % qnew implies add
-  A .hgignore
-  A series
-  A uncommitted.patch
-  % qnew missing
-  abort: missing: * (glob)
-  % qnew -m
-  # HG changeset patch
-  # Parent 
-  foo bar
-  
-  % qnew twice
-  abort: patch "first.patch" already exists
-  abort: patch "first.patch" already exists
-  % qnew -f from a subdirectory
-  popping first.patch
-  popping mtest.patch
-  popping uncommitted.patch
-  patch queue now empty
-  adding d/b
-  M d/b
-  # HG changeset patch
-  # Parent 
-  diff --git a/d/b b/d/b
-  --- a/d/b
-  +++ b/d/b
-  @@ -1,1 +1,2 @@
-   b
-  +b
-  % qnew -u with no username configured
-  # HG changeset patch
-  # Parent 
-  # User blue
-  % qnew -e -u with no username configured
-  # HG changeset patch
-  # Parent 
-  # User chartreuse
-  % fail when trying to import a merge
-  adding a
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  created new head
-  merging a
-  warning: conflicts during merge.
-  merging a incomplete! (edit conflicts, then use 'hg resolve --mark')
-  0 files updated, 0 files merged, 0 files removed, 1 files unresolved
-  use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
-  abort: cannot manage merge changesets
-  $ rm -r sandbox
diff --git a/tests/test-mq-qpush-exact.t b/tests/test-mq-qpush-exact.t
deleted file mode 100644
--- a/tests/test-mq-qpush-exact.t
+++ /dev/null
@@ -1,289 +0,0 @@ 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "mq=" >> $HGRCPATH
-  $ echo "graphlog=" >> $HGRCPATH
-
-make a test repository that looks like this:
-
-o    2:28bc7b1afd6a
-|
-| @  1:d7fe2034f71b
-|/
-o    0/62ecad8b70e5
-
-  $ hg init r0
-  $ cd r0
-  $ touch f0
-  $ hg ci -m0 -Aq
-  $ touch f1
-  $ hg ci -m1 -Aq
-
-  $ hg update 0 -q
-  $ touch f2
-  $ hg ci -m2 -Aq
-  $ hg update 1 -q
-
-make some patches with a parent: 1:d7fe2034f71b -> p0 -> p1
-
-  $ echo cp0 >> fp0
-  $ hg add fp0
-  $ hg ci -m p0 -d "0 0"
-  $ hg export -r. > p0
-  $ hg strip -qn .
-  $ hg qimport p0
-  adding p0 to series file
-  $ hg qpush
-  applying p0
-  now at: p0
-
-  $ echo cp1 >> fp1
-  $ hg add fp1
-  $ hg qnew p1 -d "0 0"
-
-  $ hg qpop -aq
-  patch queue now empty
-
-qpush --exact when at the parent
-
-  $ hg update 1 -q
-  $ hg qpush -e
-  applying p0
-  now at: p0
-  $ hg parents -qr qbase
-  1:d7fe2034f71b
-  $ hg qpop -aq
-  patch queue now empty
-
-  $ hg qpush -e p0
-  applying p0
-  now at: p0
-  $ hg parents -qr qbase
-  1:d7fe2034f71b
-  $ hg qpop -aq
-  patch queue now empty
-
-  $ hg qpush -e p1
-  applying p0
-  applying p1
-  now at: p1
-  $ hg parents -qr qbase
-  1:d7fe2034f71b
-  $ hg qpop -aq
-  patch queue now empty
-
-qpush --exact when at another rev
-
-  $ hg update 0 -q
-  $ hg qpush -e
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  applying p0
-  now at: p0
-  $ hg parents -qr qbase
-  1:d7fe2034f71b
-  $ hg qpop -aq
-  patch queue now empty
-
-  $ hg update 0 -q
-  $ hg qpush -e p0
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  applying p0
-  now at: p0
-  $ hg parents -qr qbase
-  1:d7fe2034f71b
-  $ hg qpop -aq
-  patch queue now empty
-
-  $ hg update 0 -q
-  $ hg qpush -e p1
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  applying p0
-  applying p1
-  now at: p1
-  $ hg parents -qr qbase
-  1:d7fe2034f71b
-  $ hg qpop -aq
-  patch queue now empty
-
-  $ hg update 0 -q
-  $ hg qpush -ea
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  applying p0
-  applying p1
-  now at: p1
-  $ hg parents -qr qbase
-  1:d7fe2034f71b
-  $ hg qpop -aq
-  patch queue now empty
-
-qpush --exact while crossing branches
-
-  $ hg update 2 -q
-  $ hg qpush -e
-  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  applying p0
-  now at: p0
-  $ hg parents -qr qbase
-  1:d7fe2034f71b
-  $ hg qpop -aq
-  patch queue now empty
-
-  $ hg update 2 -q
-  $ hg qpush -e p0
-  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  applying p0
-  now at: p0
-  $ hg parents -qr qbase
-  1:d7fe2034f71b
-  $ hg qpop -aq
-  patch queue now empty
-
-  $ hg update 2 -q
-  $ hg qpush -e p1
-  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  applying p0
-  applying p1
-  now at: p1
-  $ hg parents -qr qbase
-  1:d7fe2034f71b
-  $ hg qpop -aq
-  patch queue now empty
-
-  $ hg update 2 -q
-  $ hg qpush -ea
-  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  applying p0
-  applying p1
-  now at: p1
-  $ hg parents -qr qbase
-  1:d7fe2034f71b
-  $ hg qpop -aq
-  patch queue now empty
-
-qpush --exact --force with changes to an unpatched file
-
-  $ hg update 1 -q
-  $ echo c0 >> f0
-  $ hg qpush -e
-  abort: local changes found
-  [255]
-  $ hg qpush -ef
-  applying p0
-  now at: p0
-  $ cat f0
-  c0
-  $ rm f0
-  $ touch f0
-  $ hg qpop -aq
-  patch queue now empty
-
-  $ hg update 1 -q
-  $ echo c0 >> f0
-  $ hg qpush -e p1
-  abort: local changes found
-  [255]
-  $ hg qpush -e p1 -f
-  applying p0
-  applying p1
-  now at: p1
-  $ cat f0
-  c0
-  $ rm f0
-  $ touch f0
-  $ hg qpop -aq
-  patch queue now empty
-
-qpush --exact --force with changes to a patched file
-
-  $ hg update 1 -q
-  $ echo cp0-bad >> fp0
-  $ hg add fp0
-  $ hg qpush -e
-  abort: local changes found
-  [255]
-  $ hg qpush -ef
-  applying p0
-  file fp0 already exists
-  1 out of 1 hunks FAILED -- saving rejects to file fp0.rej
-  patch failed, unable to continue (try -v)
-  patch failed, rejects left in working dir
-  errors during apply, please fix and refresh p0
-  [2]
-  $ cat fp0
-  cp0-bad
-  $ cat fp0.rej
-  --- fp0
-  +++ fp0
-  @@ -0,0 +1,1 @@
-  +cp0
-  $ hg qpop -aqf
-  patch queue now empty
-  $ rm fp0
-  $ rm fp0.rej
-
-  $ hg update 1 -q
-  $ echo cp1-bad >> fp1
-  $ hg add fp1
-  $ hg qpush -e p1
-  abort: local changes found
-  [255]
-  $ hg qpush -e p1 -f
-  applying p0
-  applying p1
-  file fp1 already exists
-  1 out of 1 hunks FAILED -- saving rejects to file fp1.rej
-  patch failed, unable to continue (try -v)
-  patch failed, rejects left in working dir
-  errors during apply, please fix and refresh p1
-  [2]
-  $ cat fp1
-  cp1-bad
-  $ cat fp1.rej
-  --- fp1
-  +++ fp1
-  @@ -0,0 +1,1 @@
-  +cp1
-  $ hg qpop -aqf
-  patch queue now empty
-  $ rm fp1
-  $ rm fp1.rej
-
-qpush --exact when already at a patch
-
-  $ hg update 1
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hg qpush -e p0
-  applying p0
-  now at: p0
-  $ hg qpush -e p1
-  abort: cannot push --exact with applied patches
-  [255]
-  $ hg qpop -aq
-  patch queue now empty
-
-qpush --exact --move should fail
-
-  $ hg qpush -e --move p1
-  abort: cannot use --exact and --move together
-  [255]
-
-qpush --exact a patch without a parent recorded
-
-  $ hg qpush -q
-  now at: p0
-  $ grep -v '# Parent' .hg/patches/p0 > p0.new
-  $ mv p0.new .hg/patches/p0
-  $ hg qpop -aq
-  patch queue now empty
-  $ hg qpush -e
-  abort: p0 does not have a parent recorded
-  [255]
-  $ hg qpush -e p0
-  abort: p0 does not have a parent recorded
-  [255]
-  $ hg qpush -e p1
-  abort: p0 does not have a parent recorded
-  [255]
-  $ hg qpush -ea
-  abort: p0 does not have a parent recorded
-  [255]
-
-  $ cd ..
diff --git a/tests/test-mq-qpush-fail.t b/tests/test-mq-qpush-fail.t
deleted file mode 100644
--- a/tests/test-mq-qpush-fail.t
+++ /dev/null
@@ -1,425 +0,0 @@ 
-Test that qpush cleans things up if it doesn't complete
-
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "mq=" >> $HGRCPATH
-  $ hg init repo
-  $ cd repo
-  $ echo foo > foo
-  $ hg ci -Am 'add foo'
-  adding foo
-  $ touch untracked-file
-  $ echo 'syntax: glob' > .hgignore
-  $ echo '.hgignore' >> .hgignore
-  $ hg qinit
-
-test qpush on empty series
-
-  $ hg qpush
-  no patches in series
-  $ hg qnew patch1
-  $ echo >> foo
-  $ hg qrefresh -m 'patch 1'
-  $ hg qnew patch2
-  $ echo bar > bar
-  $ hg add bar
-  $ hg qrefresh -m 'patch 2'
-  $ hg qnew --config 'mq.plain=true' bad-patch
-  $ echo >> foo
-  $ hg qrefresh
-  $ hg qpop -a
-  popping bad-patch
-  popping patch2
-  popping patch1
-  patch queue now empty
-  $ python -c 'print "\xe9"' > message
-  $ cat .hg/patches/bad-patch >> message
-  $ mv message .hg/patches/bad-patch
-  $ hg qpush -a && echo 'qpush succeeded?!'
-  applying patch1
-  applying patch2
-  applying bad-patch
-  transaction abort!
-  rollback completed
-  cleaning up working directory...done
-  abort: decoding near '\xe9': 'ascii' codec can't decode byte 0xe9 in position 0: ordinal not in range(128)! (esc)
-  [255]
-  $ hg parents
-  changeset:   0:bbd179dfa0a7
-  tag:         tip
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     add foo
-  
-
-test corrupt status file
-  $ hg qpush
-  applying patch1
-  now at: patch1
-  $ cp .hg/patches/status .hg/patches/status.orig
-  $ hg qpop
-  popping patch1
-  patch queue now empty
-  $ cp .hg/patches/status.orig .hg/patches/status
-  $ hg qpush
-  abort: working directory revision is not qtip
-  [255]
-  $ rm .hg/patches/status .hg/patches/status.orig
-
-
-bar should be gone; other unknown/ignored files should still be around
-
-  $ hg status -A
-  ? untracked-file
-  I .hgignore
-  C foo
-
-preparing qpush of a missing patch
-
-  $ hg qpop -a
-  no patches applied
-  $ hg qpush
-  applying patch1
-  now at: patch1
-  $ rm .hg/patches/patch2
-
-now we expect the push to fail, but it should NOT complain about patch1
-
-  $ hg qpush
-  applying patch2
-  unable to read patch2
-  now at: patch1
-  [1]
-
-preparing qpush of missing patch with no patch applied
-
-  $ hg qpop -a
-  popping patch1
-  patch queue now empty
-  $ rm .hg/patches/patch1
-
-qpush should fail the same way as below
-
-  $ hg qpush
-  applying patch1
-  unable to read patch1
-  [1]
-
-Test qpush to a patch below the currently applied patch.
-
-  $ hg qq -c guardedseriesorder
-  $ hg qnew a
-  $ hg qguard +block
-  $ hg qnew b
-  $ hg qnew c
-
-  $ hg qpop -a
-  popping c
-  popping b
-  popping a
-  patch queue now empty
-
-try to push and pop while a is guarded
-
-  $ hg qpush a
-  cannot push 'a' - guarded by '+block'
-  [1]
-  $ hg qpush -a
-  applying b
-  patch b is empty
-  applying c
-  patch c is empty
-  now at: c
-
-now try it when a is unguarded, and we're at the top of the queue
-  $ hg qsel block
-  number of guarded, applied patches has changed from 1 to 0
-  $ hg qpush b
-  abort: cannot push to a previous patch: b
-  [255]
-  $ hg qpush a
-  abort: cannot push to a previous patch: a
-  [255]
-
-and now we try it one more time with a unguarded, while we're not at the top of the queue
-
-  $ hg qpop b
-  popping c
-  now at: b
-  $ hg qpush a
-  abort: cannot push to a previous patch: a
-  [255]
-
-test qpop --force and backup files
-
-  $ hg qpop -a
-  popping b
-  patch queue now empty
-  $ hg qq --create force
-  $ echo a > a
-  $ echo b > b
-  $ echo c > c
-  $ hg ci -Am add a b c
-  $ echo a >> a
-  $ hg rm b
-  $ hg rm c
-  $ hg qnew p1
-  $ echo a >> a
-  $ echo bb > b
-  $ hg add b
-  $ echo cc > c
-  $ hg add c
-  $ hg qpop --force --verbose
-  saving current version of a as a.orig
-  saving current version of b as b.orig
-  saving current version of c as c.orig
-  popping p1
-  patch queue now empty
-  $ hg st
-  ? a.orig
-  ? b.orig
-  ? c.orig
-  ? untracked-file
-  $ cat a.orig
-  a
-  a
-  a
-  $ cat b.orig
-  bb
-  $ cat c.orig
-  cc
-
-test qpop --force --no-backup
-
-  $ hg qpush
-  applying p1
-  now at: p1
-  $ rm a.orig
-  $ echo a >> a
-  $ hg qpop --force --no-backup --verbose
-  popping p1
-  patch queue now empty
-  $ test -f a.orig && echo 'error: backup with --no-backup'
-  [1]
-
-test qpop --keep-changes
-
-  $ hg qpush
-  applying p1
-  now at: p1
-  $ hg qpop --keep-changes --force
-  abort: cannot use both --force and --keep-changes
-  [255]
-  $ echo a >> a
-  $ hg qpop --keep-changes
-  abort: local changes found, refresh first
-  [255]
-  $ hg revert -qa a
-  $ rm a
-  $ hg qpop --keep-changes
-  abort: local changes found, refresh first
-  [255]
-  $ hg rm -A a
-  $ hg qpop --keep-changes
-  abort: local changes found, refresh first
-  [255]
-  $ hg revert -qa a
-  $ echo b > b
-  $ hg add b
-  $ hg qpop --keep-changes
-  abort: local changes found, refresh first
-  [255]
-  $ hg forget b
-  $ echo d > d
-  $ hg add d
-  $ hg qpop --keep-changes
-  popping p1
-  patch queue now empty
-  $ hg forget d
-  $ rm d
-
-test qpush --force and backup files
-
-  $ echo a >> a
-  $ hg qnew p2
-  $ echo b >> b
-  $ echo d > d
-  $ echo e > e
-  $ hg add d e
-  $ hg rm c
-  $ hg qnew p3
-  $ hg qpop -a
-  popping p3
-  popping p2
-  patch queue now empty
-  $ echo a >> a
-  $ echo b1 >> b
-  $ echo d1 > d
-  $ hg add d
-  $ echo e1 > e
-  $ hg qpush -a --force --verbose
-  applying p2
-  saving current version of a as a.orig
-  patching file a
-  a
-  applying p3
-  saving current version of b as b.orig
-  saving current version of d as d.orig
-  patching file b
-  patching file c
-  patching file d
-  file d already exists
-  1 out of 1 hunks FAILED -- saving rejects to file d.rej
-  patching file e
-  file e already exists
-  1 out of 1 hunks FAILED -- saving rejects to file e.rej
-  patch failed to apply
-  b
-  patch failed, rejects left in working dir
-  errors during apply, please fix and refresh p3
-  [2]
-  $ cat a.orig
-  a
-  a
-  $ cat b.orig
-  b
-  b1
-  $ cat d.orig
-  d1
-
-test qpush --force --no-backup
-
-  $ hg revert -qa
-  $ hg qpop -a
-  popping p3
-  popping p2
-  patch queue now empty
-  $ echo a >> a
-  $ rm a.orig
-  $ hg qpush --force --no-backup --verbose
-  applying p2
-  patching file a
-  a
-  now at: p2
-  $ test -f a.orig && echo 'error: backup with --no-backup'
-  [1]
-
-test qgoto --force --no-backup
-
-  $ hg qpop
-  popping p2
-  patch queue now empty
-  $ echo a >> a
-  $ hg qgoto --force --no-backup p2 --verbose
-  applying p2
-  patching file a
-  a
-  now at: p2
-  $ test -f a.orig && echo 'error: backup with --no-backup'
-  [1]
-
-test qpush --keep-changes
-
-  $ hg qpush --keep-changes --force
-  abort: cannot use both --force and --keep-changes
-  [255]
-  $ hg qpush --keep-changes --exact
-  abort: cannot use --exact and --keep-changes together
-  [255]
-  $ echo b >> b
-  $ hg qpush --keep-changes
-  applying p3
-  errors during apply, please fix and refresh p2
-  [2]
-  $ rm b
-  $ hg qpush --keep-changes
-  applying p3
-  errors during apply, please fix and refresh p2
-  [2]
-  $ hg rm -A b
-  $ hg qpush --keep-changes
-  applying p3
-  errors during apply, please fix and refresh p2
-  [2]
-  $ hg revert -aq b
-  $ echo d > d
-  $ hg add d
-  $ hg qpush --keep-changes
-  applying p3
-  errors during apply, please fix and refresh p2
-  [2]
-  $ hg forget d
-  $ rm d
-  $ hg qpop
-  popping p2
-  patch queue now empty
-  $ echo b >> b
-  $ hg qpush -a --keep-changes
-  applying p2
-  applying p3
-  errors during apply, please fix and refresh p2
-  [2]
-  $ hg qtop
-  p2
-  $ hg parents --template "{rev} {desc}\n"
-  2 imported patch p2
-  $ hg st b
-  M b
-  $ cat b
-  b
-  b
-
-test qgoto --keep-changes
-
-  $ hg revert -aq b
-  $ rm e
-  $ hg qgoto --keep-changes --force p3
-  abort: cannot use both --force and --keep-changes
-  [255]
-  $ echo a >> a
-  $ hg qgoto --keep-changes p3
-  applying p3
-  now at: p3
-  $ hg st a
-  M a
-  $ hg qgoto --keep-changes p2
-  popping p3
-  now at: p2
-  $ hg st a
-  M a
-
-test mq.keepchanges setting
-
-  $ hg --config mq.keepchanges=1 qpush
-  applying p3
-  now at: p3
-  $ hg st a
-  M a
-  $ hg --config mq.keepchanges=1 qpop
-  popping p3
-  now at: p2
-  $ hg st a
-  M a
-  $ hg --config mq.keepchanges=1 qgoto p3
-  applying p3
-  now at: p3
-  $ hg st a
-  M a
-  $ echo b >> b
-  $ hg --config mq.keepchanges=1 qpop --force
-  popping p3
-  now at: p2
-  $ hg st b
-  $ hg --config mq.keepchanges=1 qpush --exact
-  abort: local changes found, refresh first
-  [255]
-  $ hg revert -qa a
-  $ hg qpop
-  popping p2
-  patch queue now empty
-  $ echo a >> a
-  $ hg --config mq.keepchanges=1 qpush --force
-  applying p2
-  now at: p2
-  $ hg st a
-
-  $ cd ..
diff --git a/tests/test-mq-qqueue.t b/tests/test-mq-qqueue.t
deleted file mode 100644
--- a/tests/test-mq-qqueue.t
+++ /dev/null
@@ -1,188 +0,0 @@ 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "mq=" >> $HGRCPATH
-
-  $ hg init foo
-  $ cd foo
-  $ echo a > a
-  $ hg ci -qAm a
-
-Default queue:
-
-  $ hg qqueue
-  patches (active)
-
-  $ echo b > a
-  $ hg qnew -fgDU somestuff
-
-Applied patches in default queue:
-
-  $ hg qap
-  somestuff
-
-Try to change patch (create succeeds, switch fails):
-
-  $ hg qqueue foo --create
-  abort: new queue created, but cannot make active as patches are applied
-  [255]
-
-  $ hg qqueue
-  foo
-  patches (active)
-
-Empty default queue:
-
-  $ hg qpop
-  popping somestuff
-  patch queue now empty
-
-Switch queue:
-
-  $ hg qqueue foo
-  $ hg qqueue
-  foo (active)
-  patches
-
-List queues, quiet:
-
-  $ hg qqueue --quiet
-  foo
-  patches
-
-Fail creating queue with already existing name:
-
-  $ hg qqueue --create foo
-  abort: queue "foo" already exists
-  [255]
-
-  $ hg qqueue
-  foo (active)
-  patches
-
-Create new queue for rename:
-
-  $ hg qqueue --create bar
-
-  $ hg qqueue
-  bar (active)
-  foo
-  patches
-
-Rename queue, same name:
-
-  $ hg qqueue --rename bar
-  abort: can't rename "bar" to its current name
-  [255]
-
-Rename queue to existing:
-
-  $ hg qqueue --rename foo
-  abort: queue "foo" already exists
-  [255]
-
-Rename queue:
-
-  $ hg qqueue --rename buz
-
-  $ hg qqueue
-  buz (active)
-  foo
-  patches
-
-Switch back to previous queue:
-
-  $ hg qqueue foo
-  $ hg qqueue --delete buz
-
-  $ hg qqueue
-  foo (active)
-  patches
-
-Create queue for purge:
-
-  $ hg qqueue --create purge-me
-
-  $ hg qqueue
-  foo
-  patches
-  purge-me (active)
-
-Create patch for purge:
-
-  $ hg qnew patch-purge-me
-
-  $ ls -1d .hg/patches-purge-me 2>/dev/null || true
-  .hg/patches-purge-me
-
-  $ hg qpop -a
-  popping patch-purge-me
-  patch queue now empty
-
-Purge queue:
-
-  $ hg qqueue foo
-  $ hg qqueue --purge purge-me
-
-  $ hg qqueue
-  foo (active)
-  patches
-
-  $ ls -1d .hg/patches-purge-me 2>/dev/null || true
-
-Unapplied patches:
-
-  $ hg qun
-  $ echo c > a
-  $ hg qnew -fgDU otherstuff
-
-Fail switching back:
-
-  $ hg qqueue patches
-  abort: new queue created, but cannot make active as patches are applied
-  [255]
-
-Fail deleting current:
-
-  $ hg qqueue foo --delete
-  abort: cannot delete currently active queue
-  [255]
-
-Switch back and delete foo:
-
-  $ hg qpop -a
-  popping otherstuff
-  patch queue now empty
-
-  $ hg qqueue patches
-  $ hg qqueue foo --delete
-  $ hg qqueue
-  patches (active)
-
-Tricky cases:
-
-  $ hg qqueue store --create
-  $ hg qnew journal
-
-  $ hg qqueue
-  patches
-  store (active)
-
-  $ hg qpop -a
-  popping journal
-  patch queue now empty
-
-  $ hg qqueue patches
-  $ hg qun
-  somestuff
-
-Invalid names:
-
-  $ hg qqueue test/../../bar --create
-  abort: invalid queue name, may not contain the characters ":\/."
-  [255]
-
-  $ hg qqueue . --create
-  abort: invalid queue name, may not contain the characters ":\/."
-  [255]
-
-  $ cd ..
-
diff --git a/tests/test-mq-qrefresh-interactive.t b/tests/test-mq-qrefresh-interactive.t
deleted file mode 100644
--- a/tests/test-mq-qrefresh-interactive.t
+++ /dev/null
@@ -1,350 +0,0 @@ 
-Create configuration
-
-  $ echo "[ui]" >> $HGRCPATH
-  $ echo "interactive=true" >> $HGRCPATH
-
-help qrefresh (no record)
-
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "mq=" >> $HGRCPATH
-  $ hg help qrefresh
-  hg qrefresh [-I] [-X] [-e] [-m TEXT] [-l FILE] [-s] [FILE]...
-  
-  update the current patch
-  
-      If any file patterns are provided, the refreshed patch will contain only
-      the modifications that match those patterns; the remaining modifications
-      will remain in the working directory.
-  
-      If -s/--short is specified, files currently included in the patch will be
-      refreshed just like matched files and remain in the patch.
-  
-      If -e/--edit is specified, Mercurial will start your configured editor for
-      you to enter a message. In case qrefresh fails, you will find a backup of
-      your message in ".hg/last-message.txt".
-  
-      hg add/remove/copy/rename work as usual, though you might want to use git-
-      style patches (-g/--git or [diff] git=1) to track copies and renames. See
-      the diffs help topic for more information on the git diff format.
-  
-      Returns 0 on success.
-  
-  options:
-  
-   -e --edit                edit commit message
-   -g --git                 use git extended diff format
-   -s --short               refresh only files already in the patch and
-                            specified files
-   -U --currentuser         add/update author field in patch with current user
-   -u --user USER           add/update author field in patch with given user
-   -D --currentdate         add/update date field in patch with current date
-   -d --date DATE           add/update date field in patch with given date
-   -I --include PATTERN [+] include names matching the given patterns
-   -X --exclude PATTERN [+] exclude names matching the given patterns
-   -m --message TEXT        use text as commit message
-   -l --logfile FILE        read commit message from file
-  
-  [+] marked option can be specified multiple times
-  
-  use "hg -v help qrefresh" to show the global options
-
-help qrefresh (record)
-
-  $ echo "record=" >> $HGRCPATH
-  $ hg help qrefresh
-  hg qrefresh [-I] [-X] [-e] [-m TEXT] [-l FILE] [-s] [FILE]...
-  
-  update the current patch
-  
-      If any file patterns are provided, the refreshed patch will contain only
-      the modifications that match those patterns; the remaining modifications
-      will remain in the working directory.
-  
-      If -s/--short is specified, files currently included in the patch will be
-      refreshed just like matched files and remain in the patch.
-  
-      If -e/--edit is specified, Mercurial will start your configured editor for
-      you to enter a message. In case qrefresh fails, you will find a backup of
-      your message in ".hg/last-message.txt".
-  
-      hg add/remove/copy/rename work as usual, though you might want to use git-
-      style patches (-g/--git or [diff] git=1) to track copies and renames. See
-      the diffs help topic for more information on the git diff format.
-  
-      Returns 0 on success.
-  
-  options:
-  
-   -e --edit                edit commit message
-   -g --git                 use git extended diff format
-   -s --short               refresh only files already in the patch and
-                            specified files
-   -U --currentuser         add/update author field in patch with current user
-   -u --user USER           add/update author field in patch with given user
-   -D --currentdate         add/update date field in patch with current date
-   -d --date DATE           add/update date field in patch with given date
-   -I --include PATTERN [+] include names matching the given patterns
-   -X --exclude PATTERN [+] exclude names matching the given patterns
-   -m --message TEXT        use text as commit message
-   -l --logfile FILE        read commit message from file
-   -i --interactive         interactively select changes to refresh
-  
-  [+] marked option can be specified multiple times
-  
-  use "hg -v help qrefresh" to show the global options
-
-  $ hg init a
-  $ cd a
-
-Base commit
-
-  $ cat > 1.txt <<EOF
-  > 1
-  > 2
-  > 3
-  > 4
-  > 5
-  > EOF
-  $ cat > 2.txt <<EOF
-  > a
-  > b
-  > c
-  > d
-  > e
-  > f
-  > EOF
-
-  $ mkdir dir
-  $ cat > dir/a.txt <<EOF
-  > hello world
-  > 
-  > someone
-  > up
-  > there
-  > loves
-  > me
-  > EOF
-
-  $ hg add 1.txt 2.txt dir/a.txt
-  $ hg commit -m aaa
-  $ hg qnew -d '0 0' patch
-
-Changing files
-
-  $ sed -e 's/2/2 2/;s/4/4 4/' 1.txt > 1.txt.new
-  $ sed -e 's/b/b b/' 2.txt > 2.txt.new
-  $ sed -e 's/hello world/hello world!/' dir/a.txt > dir/a.txt.new
-
-  $ mv -f 1.txt.new 1.txt
-  $ mv -f 2.txt.new 2.txt
-  $ mv -f dir/a.txt.new dir/a.txt
-
-Whole diff
-
-  $ hg diff --nodates
-  diff -r ed27675cb5df 1.txt
-  --- a/1.txt
-  +++ b/1.txt
-  @@ -1,5 +1,5 @@
-   1
-  -2
-  +2 2
-   3
-  -4
-  +4 4
-   5
-  diff -r ed27675cb5df 2.txt
-  --- a/2.txt
-  +++ b/2.txt
-  @@ -1,5 +1,5 @@
-   a
-  -b
-  +b b
-   c
-   d
-   e
-  diff -r ed27675cb5df dir/a.txt
-  --- a/dir/a.txt
-  +++ b/dir/a.txt
-  @@ -1,4 +1,4 @@
-  -hello world
-  +hello world!
-   
-   someone
-   up
-
-partial qrefresh
-
-  $ hg qrefresh -i -d '0 0' <<EOF
-  > y
-  > y
-  > n
-  > y
-  > y
-  > n
-  > EOF
-  diff --git a/1.txt b/1.txt
-  2 hunks, 2 lines changed
-  examine changes to '1.txt'? [Ynesfdaq?] 
-  @@ -1,3 +1,3 @@
-   1
-  -2
-  +2 2
-   3
-  record change 1/4 to '1.txt'? [Ynesfdaq?] 
-  @@ -3,3 +3,3 @@
-   3
-  -4
-  +4 4
-   5
-  record change 2/4 to '1.txt'? [Ynesfdaq?] 
-  diff --git a/2.txt b/2.txt
-  1 hunks, 1 lines changed
-  examine changes to '2.txt'? [Ynesfdaq?] 
-  @@ -1,5 +1,5 @@
-   a
-  -b
-  +b b
-   c
-   d
-   e
-  record change 3/4 to '2.txt'? [Ynesfdaq?] 
-  diff --git a/dir/a.txt b/dir/a.txt
-  1 hunks, 1 lines changed
-  examine changes to 'dir/a.txt'? [Ynesfdaq?] 
-
-After partial qrefresh 'tip'
-
-  $ hg tip -p
-  changeset:   1:0738af1a8211
-  tag:         patch
-  tag:         qbase
-  tag:         qtip
-  tag:         tip
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     [mq]: patch
-  
-  diff -r 1fd39ab63a33 -r 0738af1a8211 1.txt
-  --- a/1.txt	Thu Jan 01 00:00:00 1970 +0000
-  +++ b/1.txt	Thu Jan 01 00:00:00 1970 +0000
-  @@ -1,5 +1,5 @@
-   1
-  -2
-  +2 2
-   3
-   4
-   5
-  diff -r 1fd39ab63a33 -r 0738af1a8211 2.txt
-  --- a/2.txt	Thu Jan 01 00:00:00 1970 +0000
-  +++ b/2.txt	Thu Jan 01 00:00:00 1970 +0000
-  @@ -1,5 +1,5 @@
-   a
-  -b
-  +b b
-   c
-   d
-   e
-  
-After partial qrefresh 'diff'
-
-  $ hg diff --nodates
-  diff -r 0738af1a8211 1.txt
-  --- a/1.txt
-  +++ b/1.txt
-  @@ -1,5 +1,5 @@
-   1
-   2 2
-   3
-  -4
-  +4 4
-   5
-  diff -r 0738af1a8211 dir/a.txt
-  --- a/dir/a.txt
-  +++ b/dir/a.txt
-  @@ -1,4 +1,4 @@
-  -hello world
-  +hello world!
-   
-   someone
-   up
-
-qrefresh interactively everything else
-
-  $ hg qrefresh -i -d '0 0' <<EOF
-  > y
-  > y
-  > y
-  > y
-  > EOF
-  diff --git a/1.txt b/1.txt
-  1 hunks, 1 lines changed
-  examine changes to '1.txt'? [Ynesfdaq?] 
-  @@ -1,5 +1,5 @@
-   1
-   2 2
-   3
-  -4
-  +4 4
-   5
-  record change 1/2 to '1.txt'? [Ynesfdaq?] 
-  diff --git a/dir/a.txt b/dir/a.txt
-  1 hunks, 1 lines changed
-  examine changes to 'dir/a.txt'? [Ynesfdaq?] 
-  @@ -1,4 +1,4 @@
-  -hello world
-  +hello world!
-   
-   someone
-   up
-  record change 2/2 to 'dir/a.txt'? [Ynesfdaq?] 
-
-After final qrefresh 'tip'
-
-  $ hg tip -p
-  changeset:   1:2c3f66afeed9
-  tag:         patch
-  tag:         qbase
-  tag:         qtip
-  tag:         tip
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     [mq]: patch
-  
-  diff -r 1fd39ab63a33 -r 2c3f66afeed9 1.txt
-  --- a/1.txt	Thu Jan 01 00:00:00 1970 +0000
-  +++ b/1.txt	Thu Jan 01 00:00:00 1970 +0000
-  @@ -1,5 +1,5 @@
-   1
-  -2
-  +2 2
-   3
-  -4
-  +4 4
-   5
-  diff -r 1fd39ab63a33 -r 2c3f66afeed9 2.txt
-  --- a/2.txt	Thu Jan 01 00:00:00 1970 +0000
-  +++ b/2.txt	Thu Jan 01 00:00:00 1970 +0000
-  @@ -1,5 +1,5 @@
-   a
-  -b
-  +b b
-   c
-   d
-   e
-  diff -r 1fd39ab63a33 -r 2c3f66afeed9 dir/a.txt
-  --- a/dir/a.txt	Thu Jan 01 00:00:00 1970 +0000
-  +++ b/dir/a.txt	Thu Jan 01 00:00:00 1970 +0000
-  @@ -1,4 +1,4 @@
-  -hello world
-  +hello world!
-   
-   someone
-   up
-  
-
-After qrefresh 'diff'
-
-  $ hg diff --nodates
-
-  $ cd ..
diff --git a/tests/test-mq-qrefresh-replace-log-message.t b/tests/test-mq-qrefresh-replace-log-message.t
deleted file mode 100644
--- a/tests/test-mq-qrefresh-replace-log-message.t
+++ /dev/null
@@ -1,61 +0,0 @@ 
-Environment setup for MQ
-
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "mq=" >> $HGRCPATH
-  $ hg init
-  $ hg qinit
-
-Should fail if no patches applied
-
-  $ hg qrefresh
-  no patches applied
-  [1]
-  $ hg qrefresh -e
-  no patches applied
-  [1]
-  $ hg qnew -m "First commit message" first-patch
-  $ echo aaaa > file
-  $ hg add file
-  $ hg qrefresh
-
-Should display 'First commit message'
-
-  $ hg log -l1 --template "{desc}\n"
-  First commit message
-
-Testing changing message with -m
-
-  $ echo bbbb > file
-  $ hg qrefresh -m "Second commit message"
-
-Should display 'Second commit message'
-
-  $ hg log -l1 --template "{desc}\n"
-  Second commit message
-
-Testing changing message with -l
-
-  $ echo "Third commit message" > logfile
-  $ echo " This is the 3rd log message" >> logfile
-  $ echo bbbb > file
-  $ hg qrefresh -l logfile
-
-Should display 'Third commit message\\\n This is the 3rd log message'
-
-  $ hg log -l1 --template "{desc}\n"
-  Third commit message
-   This is the 3rd log message
-
-Testing changing message with -l-
-
-  $ hg qnew -m "First commit message" second-patch
-  $ echo aaaa > file2
-  $ hg add file2
-  $ echo bbbb > file2
-  $ (echo "Fifth commit message"; echo " This is the 5th log message") | hg qrefresh -l-
-
-Should display 'Fifth commit message\\\n This is the 5th log message'
-
-  $ hg log -l1 --template "{desc}\n"
-  Fifth commit message
-   This is the 5th log message
diff --git a/tests/test-mq-qrefresh.t b/tests/test-mq-qrefresh.t
deleted file mode 100644
--- a/tests/test-mq-qrefresh.t
+++ /dev/null
@@ -1,548 +0,0 @@ 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "mq=" >> $HGRCPATH
-  $ echo "[diff]" >> $HGRCPATH
-  $ echo "nodates=1" >> $HGRCPATH
-
-  $ hg init a
-  $ cd a
-
-  $ mkdir 1 2
-  $ echo 'base' > 1/base
-  $ echo 'base' > 2/base
-  $ hg ci -Ambase
-  adding 1/base
-  adding 2/base
-
-  $ hg qnew -mmqbase mqbase
-
-  $ echo 'patched' > 1/base
-  $ echo 'patched' > 2/base
-  $ hg qrefresh
-
-  $ hg qdiff
-  diff -r e7af5904b465 1/base
-  --- a/1/base
-  +++ b/1/base
-  @@ -1,1 +1,1 @@
-  -base
-  +patched
-  diff -r e7af5904b465 2/base
-  --- a/2/base
-  +++ b/2/base
-  @@ -1,1 +1,1 @@
-  -base
-  +patched
-
-  $ hg qdiff .
-  diff -r e7af5904b465 1/base
-  --- a/1/base
-  +++ b/1/base
-  @@ -1,1 +1,1 @@
-  -base
-  +patched
-  diff -r e7af5904b465 2/base
-  --- a/2/base
-  +++ b/2/base
-  @@ -1,1 +1,1 @@
-  -base
-  +patched
-
-  $ cat .hg/patches/mqbase
-  # HG changeset patch
-  # Parent e7af5904b465cd1f4f3cf6b26fe14e8db6f63eaa
-  mqbase
-  
-  diff -r e7af5904b465 1/base
-  --- a/1/base
-  +++ b/1/base
-  @@ -1,1 +1,1 @@
-  -base
-  +patched
-  diff -r e7af5904b465 2/base
-  --- a/2/base
-  +++ b/2/base
-  @@ -1,1 +1,1 @@
-  -base
-  +patched
-
-  $ echo 'patched again' > base
-  $ hg qrefresh 1
-
-  $ hg qdiff
-  diff -r e7af5904b465 1/base
-  --- a/1/base
-  +++ b/1/base
-  @@ -1,1 +1,1 @@
-  -base
-  +patched
-  diff -r e7af5904b465 2/base
-  --- a/2/base
-  +++ b/2/base
-  @@ -1,1 +1,1 @@
-  -base
-  +patched
-
-  $ hg qdiff .
-  diff -r e7af5904b465 1/base
-  --- a/1/base
-  +++ b/1/base
-  @@ -1,1 +1,1 @@
-  -base
-  +patched
-  diff -r e7af5904b465 2/base
-  --- a/2/base
-  +++ b/2/base
-  @@ -1,1 +1,1 @@
-  -base
-  +patched
-
-  $ cat .hg/patches/mqbase
-  # HG changeset patch
-  # Parent e7af5904b465cd1f4f3cf6b26fe14e8db6f63eaa
-  mqbase
-  
-  diff -r e7af5904b465 1/base
-  --- a/1/base
-  +++ b/1/base
-  @@ -1,1 +1,1 @@
-  -base
-  +patched
-
-qrefresh . in subdir:
-
-  $ ( cd 1 ; hg qrefresh . )
-
-  $ hg qdiff
-  diff -r e7af5904b465 1/base
-  --- a/1/base
-  +++ b/1/base
-  @@ -1,1 +1,1 @@
-  -base
-  +patched
-  diff -r e7af5904b465 2/base
-  --- a/2/base
-  +++ b/2/base
-  @@ -1,1 +1,1 @@
-  -base
-  +patched
-
-  $ hg qdiff .
-  diff -r e7af5904b465 1/base
-  --- a/1/base
-  +++ b/1/base
-  @@ -1,1 +1,1 @@
-  -base
-  +patched
-  diff -r e7af5904b465 2/base
-  --- a/2/base
-  +++ b/2/base
-  @@ -1,1 +1,1 @@
-  -base
-  +patched
-
-  $ cat .hg/patches/mqbase
-  # HG changeset patch
-  # Parent e7af5904b465cd1f4f3cf6b26fe14e8db6f63eaa
-  mqbase
-  
-  diff -r e7af5904b465 1/base
-  --- a/1/base
-  +++ b/1/base
-  @@ -1,1 +1,1 @@
-  -base
-  +patched
-
-qrefresh in hg-root again:
-
-  $ hg qrefresh
-
-  $ hg qdiff
-  diff -r e7af5904b465 1/base
-  --- a/1/base
-  +++ b/1/base
-  @@ -1,1 +1,1 @@
-  -base
-  +patched
-  diff -r e7af5904b465 2/base
-  --- a/2/base
-  +++ b/2/base
-  @@ -1,1 +1,1 @@
-  -base
-  +patched
-
-  $ hg qdiff .
-  diff -r e7af5904b465 1/base
-  --- a/1/base
-  +++ b/1/base
-  @@ -1,1 +1,1 @@
-  -base
-  +patched
-  diff -r e7af5904b465 2/base
-  --- a/2/base
-  +++ b/2/base
-  @@ -1,1 +1,1 @@
-  -base
-  +patched
-
-  $ cat .hg/patches/mqbase
-  # HG changeset patch
-  # Parent e7af5904b465cd1f4f3cf6b26fe14e8db6f63eaa
-  mqbase
-  
-  diff -r e7af5904b465 1/base
-  --- a/1/base
-  +++ b/1/base
-  @@ -1,1 +1,1 @@
-  -base
-  +patched
-  diff -r e7af5904b465 2/base
-  --- a/2/base
-  +++ b/2/base
-  @@ -1,1 +1,1 @@
-  -base
-  +patched
-
-
-qrefresh --short tests:
-
-  $ echo 'orphan' > orphanchild
-  $ hg add orphanchild
-  $ hg qrefresh nonexistentfilename # clear patch
-  nonexistentfilename: * (glob)
-  $ hg diff -c qtip
-  $ hg qrefresh --short 1/base
-  $ hg qrefresh --short 2/base
-
-  $ hg qdiff
-  diff -r e7af5904b465 1/base
-  --- a/1/base
-  +++ b/1/base
-  @@ -1,1 +1,1 @@
-  -base
-  +patched
-  diff -r e7af5904b465 2/base
-  --- a/2/base
-  +++ b/2/base
-  @@ -1,1 +1,1 @@
-  -base
-  +patched
-  diff -r e7af5904b465 orphanchild
-  --- /dev/null
-  +++ b/orphanchild
-  @@ -0,0 +1,1 @@
-  +orphan
-
-  $ cat .hg/patches/mqbase
-  # HG changeset patch
-  # Parent e7af5904b465cd1f4f3cf6b26fe14e8db6f63eaa
-  mqbase
-  
-  diff -r e7af5904b465 1/base
-  --- a/1/base
-  +++ b/1/base
-  @@ -1,1 +1,1 @@
-  -base
-  +patched
-  diff -r e7af5904b465 2/base
-  --- a/2/base
-  +++ b/2/base
-  @@ -1,1 +1,1 @@
-  -base
-  +patched
-
-  $ hg st
-  A orphanchild
-  ? base
-
-diff shows what is not in patch:
-
-  $ hg diff
-  diff -r ???????????? orphanchild (glob)
-  --- /dev/null
-  +++ b/orphanchild
-  @@ -0,0 +1,1 @@
-  +orphan
-
-Before starting exclusive tests:
-
-  $ cat .hg/patches/mqbase
-  # HG changeset patch
-  # Parent e7af5904b465cd1f4f3cf6b26fe14e8db6f63eaa
-  mqbase
-  
-  diff -r e7af5904b465 1/base
-  --- a/1/base
-  +++ b/1/base
-  @@ -1,1 +1,1 @@
-  -base
-  +patched
-  diff -r e7af5904b465 2/base
-  --- a/2/base
-  +++ b/2/base
-  @@ -1,1 +1,1 @@
-  -base
-  +patched
-
-Exclude 2/base:
-
-  $ hg qref -s -X 2/base
-
-  $ cat .hg/patches/mqbase
-  # HG changeset patch
-  # Parent e7af5904b465cd1f4f3cf6b26fe14e8db6f63eaa
-  mqbase
-  
-  diff -r e7af5904b465 1/base
-  --- a/1/base
-  +++ b/1/base
-  @@ -1,1 +1,1 @@
-  -base
-  +patched
-
-status shows 2/base as dirty:
-
-  $ hg status
-  M 2/base
-  A orphanchild
-  ? base
-
-Remove 1/base and add 2/base again but not orphanchild:
-
-  $ hg qref -s -X orphanchild -X 1/base 2/base orphanchild
-
-  $ cat .hg/patches/mqbase
-  # HG changeset patch
-  # Parent e7af5904b465cd1f4f3cf6b26fe14e8db6f63eaa
-  mqbase
-  
-  diff -r e7af5904b465 2/base
-  --- a/2/base
-  +++ b/2/base
-  @@ -1,1 +1,1 @@
-  -base
-  +patched
-
-Add 1/base with include filter - and thus remove 2/base from patch:
-
-  $ hg qref -s -I 1/ o* */*
-
-  $ cat .hg/patches/mqbase
-  # HG changeset patch
-  # Parent e7af5904b465cd1f4f3cf6b26fe14e8db6f63eaa
-  mqbase
-  
-  diff -r e7af5904b465 1/base
-  --- a/1/base
-  +++ b/1/base
-  @@ -1,1 +1,1 @@
-  -base
-  +patched
-
-  $ cd ..
-
-
-Test qrefresh --git losing copy metadata:
-
-  $ hg init repo
-  $ cd repo
-
-  $ echo "[diff]" >> .hg/hgrc
-  $ echo "git=True" >> .hg/hgrc
-  $ echo a > a
-
-  $ hg ci -Am adda
-  adding a
-  $ hg copy a ab
-  $ echo b >> ab
-  $ hg copy a ac
-  $ echo c >> ac
-
-Capture changes:
-
-  $ hg qnew -f p1
-
-  $ hg qdiff
-  diff --git a/a b/ab
-  copy from a
-  copy to ab
-  --- a/a
-  +++ b/ab
-  @@ -1,1 +1,2 @@
-   a
-  +b
-  diff --git a/a b/ac
-  copy from a
-  copy to ac
-  --- a/a
-  +++ b/ac
-  @@ -1,1 +1,2 @@
-   a
-  +c
-
-Refresh and check changes again:
-
-  $ hg qrefresh
-
-  $ hg qdiff
-  diff --git a/a b/ab
-  copy from a
-  copy to ab
-  --- a/a
-  +++ b/ab
-  @@ -1,1 +1,2 @@
-   a
-  +b
-  diff --git a/a b/ac
-  copy from a
-  copy to ac
-  --- a/a
-  +++ b/ac
-  @@ -1,1 +1,2 @@
-   a
-  +c
-
-  $ cd ..
-
-
-Issue1441: qrefresh confused after hg rename:
-
-  $ hg init repo-1441
-  $ cd repo-1441
-  $ echo a > a
-  $ hg add a
-  $ hg qnew -f p
-  $ hg mv a b
-  $ hg qrefresh
-
-  $ hg qdiff
-  diff -r 000000000000 b
-  --- /dev/null
-  +++ b/b
-  @@ -0,0 +1,1 @@
-  +a
-
-  $ cd ..
-
-
-Issue2025: qrefresh does not honor filtering options when tip !=
-qtip:
-
-  $ hg init repo-2025
-  $ cd repo-2025
-  $ echo a > a
-  $ echo b > b
-  $ hg ci -qAm addab
-  $ echo a >> a
-  $ echo b >> b
-  $ hg qnew -f patch
-  $ hg up -qC 0
-  $ echo c > c
-  $ hg ci -qAm addc
-  $ hg up -qC 1
-
-refresh with tip != qtip:
-
-  $ hg --config diff.nodates=1 qrefresh -I b
-
-  $ hg st
-  M a
-
-  $ cat b
-  b
-  b
-
-  $ cat .hg/patches/patch
-  # HG changeset patch
-  # Parent 1a60229be7ac3e4a7f647508e99b87bef1f03593
-  
-  diff -r 1a60229be7ac b
-  --- a/b
-  +++ b/b
-  @@ -1,1 +1,2 @@
-   b
-  +b
-
-  $ cd ..
-
-
-Issue1441 with git patches:
-
-  $ hg init repo-1441-git
-  $ cd repo-1441-git
-
-  $ echo "[diff]" >> .hg/hgrc
-  $ echo "git=True" >> .hg/hgrc
-
-  $ echo a > a
-  $ hg add a
-  $ hg qnew -f p
-  $ hg mv a b
-  $ hg qrefresh
-
-  $ hg qdiff --nodates
-  diff --git a/b b/b
-  new file mode 100644
-  --- /dev/null
-  +++ b/b
-  @@ -0,0 +1,1 @@
-  +a
-
-  $ cd ..
-
-Refresh with bad usernames. Mercurial used to abort on bad usernames,
-but only after writing the bad name into the patch.
-
-  $ hg init bad-usernames
-  $ cd bad-usernames
-  $ touch a
-  $ hg add a
-  $ hg qnew a
-  $ hg qrefresh -u 'foo
-  > bar'
-  transaction abort!
-  rollback completed
-  refresh interrupted while patch was popped! (revert --all, qpush to recover)
-  abort: username 'foo\nbar' contains a newline!
-  [255]
-  $ rm a
-  $ cat .hg/patches/a
-  # HG changeset patch
-  # Parent 0000000000000000000000000000000000000000
-  diff --git a/a b/a
-  new file mode 100644
-  $ hg qpush
-  applying a
-  now at: a
-  $ hg qrefresh -u ' '
-  transaction abort!
-  rollback completed
-  refresh interrupted while patch was popped! (revert --all, qpush to recover)
-  abort: empty username!
-  [255]
-  $ cat .hg/patches/a
-  # HG changeset patch
-  # Parent 0000000000000000000000000000000000000000
-  diff --git a/a b/a
-  new file mode 100644
-  $ cd ..
-
-Refresh with phase data:
-
-
-
-  $ cd repo
-  $ echo 'babar' >> a
-  $ hg qnew -m 'update a' p2.diff
-  $ hg phase p2.diff
-  2: draft
-  $ echo 'beber' >> a
-  $ hg qref
-  $ hg phase p2.diff
-  2: draft
-  $ hg phase --force --secret p2.diff
-  $ echo 'bibir' >> a
-  $ hg qref
-  $ hg phase p2.diff
-  2: secret
-
-  $ cd ..
diff --git a/tests/test-mq-qrename.t b/tests/test-mq-qrename.t
deleted file mode 100644
--- a/tests/test-mq-qrename.t
+++ /dev/null
@@ -1,125 +0,0 @@ 
-
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "mq=" >> $HGRCPATH
-
-  $ hg init a
-  $ cd a
-
-  $ echo 'base' > base
-  $ hg ci -Ambase
-  adding base
-
-  $ hg qnew -mmqbase mqbase
-
-  $ hg qrename mqbase renamed
-  $ mkdir .hg/patches/foo
-  $ hg qrename renamed foo
-
-  $ hg qseries
-  foo/renamed
-
-  $ ls .hg/patches/foo
-  renamed
-
-  $ mkdir .hg/patches/bar
-  $ hg qrename foo/renamed bar
-
-  $ hg qseries
-  bar/renamed
-
-  $ ls .hg/patches/bar
-  renamed
-
-  $ hg qrename bar/renamed baz
-
-  $ hg qseries
-  baz
-
-  $ ls .hg/patches/baz
-  .hg/patches/baz
-
-  $ hg qrename baz new/dir
-
-  $ hg qseries
-  new/dir
-
-  $ ls .hg/patches/new/dir
-  .hg/patches/new/dir
-
-  $ cd ..
-
-Test patch being renamed before committed:
-
-  $ hg init b
-  $ cd b
-  $ hg qinit -c
-  $ hg qnew x
-  $ hg qrename y
-  $ hg qcommit -m rename
-
-  $ cd ..
-
-Test overlapping renames (issue2388)
-
-  $ hg init c
-  $ cd c
-  $ hg qinit -c
-  $ echo a > a
-  $ hg add
-  adding a
-  $ hg qnew patcha
-  $ echo b > b
-  $ hg add
-  adding b
-  $ hg qnew patchb
-  $ hg ci --mq -m c1
-  $ hg qrename patchb patchc
-  $ hg qrename patcha patchb
-  $ hg st --mq
-  M series
-  A patchb
-  A patchc
-  R patcha
-  $ cd ..
-
-Test renames with mq repo (issue2097)
-
-  $ hg init issue2097
-  $ cd issue2097
-  $ hg qnew p0
-  $ (cd .hg/patches && hg init)
-  $ hg qren p0 p1
-  $ hg debugstate --mq
-  $ hg ci --mq -mq0
-  nothing changed
-  [1]
-  $ cd ..
-
-Test renaming to a folded patch (issue3058)
-
-  $ hg init issue3058
-  $ cd issue3058
-  $ hg init --mq
-  $ echo a > a
-  $ hg add a
-  $ hg qnew adda
-  $ echo b >> a
-  $ hg qnew addb
-  $ hg qpop
-  popping addb
-  now at: adda
-  $ hg ci --mq -m "save mq"
-  $ hg qfold addb
-  $ hg qmv addb
-  $ cat .hg/patches/addb
-  # HG changeset patch
-  # Parent 0000000000000000000000000000000000000000
-  
-  diff -r 000000000000 a
-  --- /dev/null	* (glob)
-  +++ b/a	* (glob)
-  @@ -0,0 +1,2 @@
-  +a
-  +b
-  $ cd ..
-
diff --git a/tests/test-mq-qsave.t b/tests/test-mq-qsave.t
deleted file mode 100644
--- a/tests/test-mq-qsave.t
+++ /dev/null
@@ -1,15 +0,0 @@ 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "mq=" >> $HGRCPATH
-
-  $ hg init
-
-  $ echo 'base' > base
-  $ hg ci -Ambase
-  adding base
-
-  $ hg qnew -mmqbase mqbase
-
-  $ hg qsave
-  $ hg qrestore 2
-  restoring status: hg patches saved state
-
diff --git a/tests/test-mq-safety.t b/tests/test-mq-safety.t
deleted file mode 100644
--- a/tests/test-mq-safety.t
+++ /dev/null
@@ -1,216 +0,0 @@ 
-  $ echo '[extensions]' >> $HGRCPATH
-  $ echo 'hgext.mq =' >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
-  $ hg init repo
-  $ cd repo
-
-  $ echo foo > foo
-  $ hg ci -qAm 'add a file'
-
-  $ hg qinit
-
-  $ hg qnew foo
-  $ echo foo >> foo
-  $ hg qrefresh -m 'append foo'
-
-  $ hg qnew bar
-  $ echo bar >> foo
-  $ hg qrefresh -m 'append bar'
-
-Try to operate on public mq changeset
-
-  $ hg qpop
-  popping bar
-  now at: foo
-  $ hg phase --public qbase
-  $ echo babar >> foo
-  $ hg qref
-  abort: cannot refresh immutable revision
-  (see "hg help phases" for details)
-  [255]
-  $ hg revert -a
-  reverting foo
-  $ hg qpop
-  abort: popping would remove an immutable revision
-  (see "hg help phases" for details)
-  [255]
-  $ hg qfold bar
-  abort: cannot refresh immutable revision
-  (see "hg help phases" for details)
-  [255]
-  $ hg revert -a
-  reverting foo
-
-restore state for remaining test
-
-  $ hg qpush
-  applying bar
-  now at: bar
-
-try to commit on top of a patch
-
-  $ echo quux >> foo
-  $ hg ci -m 'append quux'
-  abort: cannot commit over an applied mq patch
-  [255]
-
-
-cheat a bit...
-
-  $ mv .hg/patches .hg/patches2
-  $ hg ci -m 'append quux'
-  $ mv .hg/patches2 .hg/patches
-
-
-qpop/qrefresh on the wrong revision
-
-  $ hg qpop
-  abort: popping would remove a revision not managed by this patch queue
-  [255]
-  $ hg qpop -n patches
-  using patch queue: $TESTTMP/repo/.hg/patches (glob)
-  abort: popping would remove a revision not managed by this patch queue
-  [255]
-  $ hg qrefresh
-  abort: working directory revision is not qtip
-  [255]
-
-  $ hg up -C qtip
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hg qpop
-  abort: popping would remove a revision not managed by this patch queue
-  [255]
-  $ hg qrefresh
-  abort: cannot refresh a revision with children
-  [255]
-  $ hg tip --template '{rev} {desc}\n'
-  3 append quux
-
-
-qpush warning branchheads
-
-  $ cd ..
-  $ hg init branchy
-  $ cd branchy
-  $ echo q > q
-  $ hg add q
-  $ hg qnew -f qp
-  $ hg qpop
-  popping qp
-  patch queue now empty
-  $ echo a > a
-  $ hg ci -Ama
-  adding a
-  $ hg up null
-  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  $ hg branch b
-  marked working directory as branch b
-  (branches are permanent and global, did you want a bookmark?)
-  $ echo c > c
-  $ hg ci -Amc
-  adding c
-  $ hg merge default
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  (branch merge, don't forget to commit)
-  $ hg ci -mmerge
-  $ hg up default
-  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  $ hg log
-  changeset:   2:65309210bf4e
-  branch:      b
-  tag:         tip
-  parent:      1:707adb4c8ae1
-  parent:      0:cb9a9f314b8b
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     merge
-  
-  changeset:   1:707adb4c8ae1
-  branch:      b
-  parent:      -1:000000000000
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     c
-  
-  changeset:   0:cb9a9f314b8b
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     a
-  
-  $ hg qpush
-  applying qp
-  now at: qp
-
-Testing applied patches, push and --force
-
-  $ cd ..
-  $ hg init forcepush
-  $ cd forcepush
-  $ echo a > a
-  $ hg ci -Am adda
-  adding a
-  $ echo a >> a
-  $ hg ci -m changea
-  $ hg up 0
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hg branch branch
-  marked working directory as branch branch
-  (branches are permanent and global, did you want a bookmark?)
-  $ echo b > b
-  $ hg ci -Am addb
-  adding b
-  $ hg up 0
-  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  $ hg --cwd .. clone -r 0 forcepush forcepush2
-  adding changesets
-  adding manifests
-  adding file changes
-  added 1 changesets with 1 changes to 1 files
-  updating to branch default
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ echo a >> a
-  $ hg qnew patch
-
-Pushing applied patch with --rev without --force
-
-  $ hg push -r . ../forcepush2
-  pushing to ../forcepush2
-  abort: source has mq patches applied
-  [255]
-
-Pushing applied patch with branchhash, without --force
-
-  $ hg push ../forcepush2#default
-  pushing to ../forcepush2
-  abort: source has mq patches applied
-  [255]
-
-Pushing revs excluding applied patch
-
-  $ hg push --new-branch -r 'branch(branch)' -r 2 ../forcepush2
-  pushing to ../forcepush2
-  searching for changes
-  adding changesets
-  adding manifests
-  adding file changes
-  added 1 changesets with 1 changes to 1 files
-
-Pushing applied patch with --force
-
-  $ hg phase --force --secret 'mq()'
-  $ hg push --force -r default ../forcepush2
-  pushing to ../forcepush2
-  searching for changes
-  no changes found (ignored 1 secret changesets)
-  [1]
-  $ hg phase --draft 'mq()'
-  $ hg push --force -r default ../forcepush2
-  pushing to ../forcepush2
-  searching for changes
-  adding changesets
-  adding manifests
-  adding file changes
-  added 1 changesets with 1 changes to 1 files (+1 heads)
-
-  $ cd ..
diff --git a/tests/test-mq-strip.t b/tests/test-mq-strip.t
deleted file mode 100644
--- a/tests/test-mq-strip.t
+++ /dev/null
@@ -1,487 +0,0 @@ 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "mq=" >> $HGRCPATH
-  $ echo "graphlog=" >> $HGRCPATH
-
-  $ restore() {
-  >     hg unbundle -q .hg/strip-backup/*
-  >     rm .hg/strip-backup/*
-  > }
-  $ teststrip() {
-  >     hg up -C $1
-  >     echo % before update $1, strip $2
-  >     hg parents
-  >     hg --traceback strip $2
-  >     echo % after update $1, strip $2
-  >     hg parents
-  >     restore
-  > }
-
-  $ hg init test
-  $ cd test
-
-  $ echo foo > bar
-  $ hg ci -Ama
-  adding bar
-
-  $ echo more >> bar
-  $ hg ci -Amb
-
-  $ echo blah >> bar
-  $ hg ci -Amc
-
-  $ hg up 1
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ echo blah >> bar
-  $ hg ci -Amd
-  created new head
-
-  $ echo final >> bar
-  $ hg ci -Ame
-
-  $ hg log
-  changeset:   4:443431ffac4f
-  tag:         tip
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     e
-  
-  changeset:   3:65bd5f99a4a3
-  parent:      1:ef3a871183d7
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     d
-  
-  changeset:   2:264128213d29
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     c
-  
-  changeset:   1:ef3a871183d7
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     b
-  
-  changeset:   0:9ab35a2d17cb
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     a
-  
-
-  $ teststrip 4 4
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  % before update 4, strip 4
-  changeset:   4:443431ffac4f
-  tag:         tip
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     e
-  
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
-  % after update 4, strip 4
-  changeset:   3:65bd5f99a4a3
-  tag:         tip
-  parent:      1:ef3a871183d7
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     d
-  
-  $ teststrip 4 3
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  % before update 4, strip 3
-  changeset:   4:443431ffac4f
-  tag:         tip
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     e
-  
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
-  % after update 4, strip 3
-  changeset:   1:ef3a871183d7
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     b
-  
-  $ teststrip 1 4
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  % before update 1, strip 4
-  changeset:   1:ef3a871183d7
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     b
-  
-  saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
-  % after update 1, strip 4
-  changeset:   1:ef3a871183d7
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     b
-  
-  $ teststrip 4 2
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  % before update 4, strip 2
-  changeset:   4:443431ffac4f
-  tag:         tip
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     e
-  
-  saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
-  % after update 4, strip 2
-  changeset:   3:443431ffac4f
-  tag:         tip
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     e
-  
-  $ teststrip 4 1
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  % before update 4, strip 1
-  changeset:   4:264128213d29
-  tag:         tip
-  parent:      1:ef3a871183d7
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     c
-  
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
-  % after update 4, strip 1
-  changeset:   0:9ab35a2d17cb
-  tag:         tip
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     a
-  
-  $ teststrip null 4
-  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  % before update null, strip 4
-  saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
-  % after update null, strip 4
-
-  $ hg log
-  changeset:   4:264128213d29
-  tag:         tip
-  parent:      1:ef3a871183d7
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     c
-  
-  changeset:   3:443431ffac4f
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     e
-  
-  changeset:   2:65bd5f99a4a3
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     d
-  
-  changeset:   1:ef3a871183d7
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     b
-  
-  changeset:   0:9ab35a2d17cb
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     a
-  
-
-  $ hg up -C 2
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hg merge 4
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  (branch merge, don't forget to commit)
-
-before strip of merge parent
-
-  $ hg parents
-  changeset:   2:65bd5f99a4a3
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     d
-  
-  changeset:   4:264128213d29
-  tag:         tip
-  parent:      1:ef3a871183d7
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     c
-  
-  $ hg strip 4
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
-
-after strip of merge parent
-
-  $ hg parents
-  changeset:   1:ef3a871183d7
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     b
-  
-  $ restore
-
-  $ hg up
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hg glog
-  @  changeset:   4:264128213d29
-  |  tag:         tip
-  |  parent:      1:ef3a871183d7
-  |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
-  |  summary:     c
-  |
-  | o  changeset:   3:443431ffac4f
-  | |  user:        test
-  | |  date:        Thu Jan 01 00:00:00 1970 +0000
-  | |  summary:     e
-  | |
-  | o  changeset:   2:65bd5f99a4a3
-  |/   user:        test
-  |    date:        Thu Jan 01 00:00:00 1970 +0000
-  |    summary:     d
-  |
-  o  changeset:   1:ef3a871183d7
-  |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
-  |  summary:     b
-  |
-  o  changeset:   0:9ab35a2d17cb
-     user:        test
-     date:        Thu Jan 01 00:00:00 1970 +0000
-     summary:     a
-  
-
-2 is parent of 3, only one strip should happen
-
-  $ hg strip "roots(2)" 3
-  saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
-  $ hg glog
-  @  changeset:   2:264128213d29
-  |  tag:         tip
-  |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
-  |  summary:     c
-  |
-  o  changeset:   1:ef3a871183d7
-  |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
-  |  summary:     b
-  |
-  o  changeset:   0:9ab35a2d17cb
-     user:        test
-     date:        Thu Jan 01 00:00:00 1970 +0000
-     summary:     a
-  
-  $ restore
-  $ hg glog
-  o  changeset:   4:443431ffac4f
-  |  tag:         tip
-  |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
-  |  summary:     e
-  |
-  o  changeset:   3:65bd5f99a4a3
-  |  parent:      1:ef3a871183d7
-  |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
-  |  summary:     d
-  |
-  | @  changeset:   2:264128213d29
-  |/   user:        test
-  |    date:        Thu Jan 01 00:00:00 1970 +0000
-  |    summary:     c
-  |
-  o  changeset:   1:ef3a871183d7
-  |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
-  |  summary:     b
-  |
-  o  changeset:   0:9ab35a2d17cb
-     user:        test
-     date:        Thu Jan 01 00:00:00 1970 +0000
-     summary:     a
-  
-
-2 different branches: 2 strips
-
-  $ hg strip 2 4
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
-  $ hg glog
-  o  changeset:   2:65bd5f99a4a3
-  |  tag:         tip
-  |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
-  |  summary:     d
-  |
-  @  changeset:   1:ef3a871183d7
-  |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
-  |  summary:     b
-  |
-  o  changeset:   0:9ab35a2d17cb
-     user:        test
-     date:        Thu Jan 01 00:00:00 1970 +0000
-     summary:     a
-  
-  $ restore
-
-2 different branches and a common ancestor: 1 strip
-
-  $ hg strip 1 "2|4"
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
-  $ restore
-
-stripping an empty revset
-
-  $ hg strip "1 and not 1"
-  abort: empty revision set
-  [255]
-
-remove branchy history for qimport tests
-
-  $ hg strip 3
-  saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
-
-
-strip of applied mq should cleanup status file
-
-  $ hg up -C 3
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ echo fooagain >> bar
-  $ hg ci -mf
-  $ hg qimport -r tip:2
-
-applied patches before strip
-
-  $ hg qapplied
-  2.diff
-  3.diff
-  4.diff
-
-stripping revision in queue
-
-  $ hg strip 3
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
-
-applied patches after stripping rev in queue
-
-  $ hg qapplied
-  2.diff
-
-stripping ancestor of queue
-
-  $ hg strip 1
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
-
-applied patches after stripping ancestor of queue
-
-  $ hg qapplied
-
-Verify strip protects against stripping wc parent when there are uncommited mods
-
-  $ echo b > b
-  $ hg add b
-  $ hg ci -m 'b'
-  $ hg log --graph
-  @  changeset:   1:7519abd79d14
-  |  tag:         tip
-  |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
-  |  summary:     b
-  |
-  o  changeset:   0:9ab35a2d17cb
-     user:        test
-     date:        Thu Jan 01 00:00:00 1970 +0000
-     summary:     a
-  
-
-  $ echo c > b
-  $ echo c > bar
-  $ hg strip tip
-  abort: local changes found
-  [255]
-  $ hg strip tip --keep
-  saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
-  $ hg log --graph
-  @  changeset:   0:9ab35a2d17cb
-     tag:         tip
-     user:        test
-     date:        Thu Jan 01 00:00:00 1970 +0000
-     summary:     a
-  
-  $ hg status
-  M bar
-  ? b
-
-Strip adds, removes, modifies with --keep
-
-  $ touch b
-  $ hg add b
-  $ hg commit -mb
-  $ touch c
-  $ hg add c
-  $ hg rm bar
-  $ hg commit -mc
-  $ echo b > b
-  $ echo d > d
-  $ hg strip --keep tip
-  saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
-  $ hg status
-  M b
-  ! bar
-  ? c
-  ? d
-  $ cd ..
-
-stripping many nodes on a complex graph (issue3299)
-
-  $ hg init issue3299
-  $ cd issue3299
-  $ hg debugbuilddag '@a.:a@b.:b.:x<a@a.:a<b@b.:b<a@a.:a'
-  $ hg strip 'not ancestors(x)'
-  saved backup bundle to $TESTTMP/issue3299/.hg/strip-backup/*-backup.hg (glob)
-
-test hg strip -B bookmark
-
-  $ cd ..
-  $ hg init bookmarks
-  $ cd bookmarks
-  $ hg debugbuilddag '..<2.*1/2:m<2+3:c<m+3:a<2.:b'
-  $ hg bookmark -r 'a' 'todelete'
-  $ hg bookmark -r 'b' 'B'
-  $ hg bookmark -r 'b' 'nostrip'
-  $ hg bookmark -r 'c' 'delete'
-  $ hg up -C todelete
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hg strip -B nostrip
-  bookmark 'nostrip' deleted
-  abort: empty revision set
-  [255]
-  $ hg strip -B todelete
-  bookmark 'todelete' deleted
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/*-backup.hg (glob)
-  $ hg id -ir dcbb326fdec2
-  abort: unknown revision 'dcbb326fdec2'!
-  [255]
-  $ hg id -ir d62d843c9a01
-  d62d843c9a01
-  $ hg bookmarks
-     B                         9:ff43616e5d0f
-     delete                    6:2702dd0c91e7
-  $ hg strip -B delete
-  bookmark 'delete' deleted
-  saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/*-backup.hg (glob)
-  $ hg id -ir 6:2702dd0c91e7
-  abort: unknown revision '2702dd0c91e7'!
-  [255]
-
-  $ cd ..
diff --git a/tests/test-mq-subrepo-svn.t b/tests/test-mq-subrepo-svn.t
deleted file mode 100644
--- a/tests/test-mq-subrepo-svn.t
+++ /dev/null
@@ -1,54 +0,0 @@ 
-  $ "$TESTDIR/hghave" svn13 || exit 80
-
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "mq=" >> $HGRCPATH
-  $ echo "[diff]" >> $HGRCPATH
-  $ echo "nodates=1" >> $HGRCPATH
-
-fn to create new repository, and cd into it
-  $ mkrepo() {
-  >     hg init $1
-  >     cd $1
-  >     hg qinit
-  > }
-
-
-handle svn subrepos safely
-
-  $ svnadmin create svn-repo-2499
-
-  $ SVNREPOPATH=`pwd`/svn-repo-2499/project
-#if windows
-  $ SVNREPOURL=file:///`python -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"`
-#else
-  $ SVNREPOURL=file://`python -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"`
-#endif
-
-  $ mkdir -p svn-project-2499/trunk
-  $ svn import -m 'init project' svn-project-2499 "$SVNREPOURL"
-  Adding         svn-project-2499/trunk (glob)
-  
-  Committed revision 1.
-
-qnew on repo w/svn subrepo
-  $ mkrepo repo-2499-svn-subrepo
-  $ svn co "$SVNREPOURL"/trunk sub
-  Checked out revision 1.
-  $ echo 'sub = [svn]sub' >> .hgsub
-  $ hg add .hgsub
-  $ hg status -S -X '**/format'
-  A .hgsub
-  $ hg qnew -m0 0.diff
-  $ cd sub
-  $ echo a > a
-  $ svn add a
-  A         a
-  $ svn st
-  A*    a (glob)
-  $ cd ..
-  $ hg status -S        # doesn't show status for svn subrepos (yet)
-  $ hg qnew -m1 1.diff
-  abort: uncommitted changes in subrepository sub
-  [255]
-
-  $ cd ..
diff --git a/tests/test-mq-subrepo.t b/tests/test-mq-subrepo.t
deleted file mode 100644
--- a/tests/test-mq-subrepo.t
+++ /dev/null
@@ -1,514 +0,0 @@ 
-  $ echo "[ui]" >> $HGRCPATH
-  $ echo "commitsubrepos = Yes" >> $HGRCPATH
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "mq=" >> $HGRCPATH
-  $ echo "record=" >> $HGRCPATH
-  $ echo "[diff]" >> $HGRCPATH
-  $ echo "nodates=1" >> $HGRCPATH
-
-  $ stdin=`pwd`/stdin.tmp
-
-fn to create new repository w/dirty subrepo, and cd into it
-  $ mkrepo() {
-  >     hg init $1
-  >     cd $1
-  >     hg qinit
-  > }
-
-fn to create dirty subrepo
-  $ mksubrepo() {
-  >     hg init $1
-  >     cd $1
-  >     echo a > a
-  >     hg add
-  >     cd ..
-  > }
-
-  $ testadd() {
-  >     cat - > "$stdin"
-  >     mksubrepo sub
-  >     echo sub = sub >> .hgsub
-  >     hg add .hgsub
-  >     echo % abort when adding .hgsub w/dirty subrepo
-  >     hg status -S
-  >     echo '%' $*
-  >     cat "$stdin" | hg $*
-  >     echo [$?]
-  >     hg -R sub ci -m0sub
-  >     echo % update substate when adding .hgsub w/clean updated subrepo
-  >     hg status -S
-  >     echo '%' $*
-  >     cat "$stdin" | hg $*
-  >     hg debugsub
-  > }
-
-  $ testmod() {
-  >     cat - > "$stdin"
-  >     mksubrepo sub2
-  >     echo sub2 = sub2 >> .hgsub
-  >     echo % abort when modifying .hgsub w/dirty subrepo
-  >     hg status -S
-  >     echo '%' $*
-  >     cat "$stdin" | hg $*
-  >     echo [$?]
-  >     hg -R sub2 ci -m0sub2
-  >     echo % update substate when modifying .hgsub w/clean updated subrepo
-  >     hg status -S
-  >     echo '%' $*
-  >     cat "$stdin" | hg $*
-  >     hg debugsub
-  > }
-
-  $ testrm1() {
-  >     cat - > "$stdin"
-  >     mksubrepo sub3
-  >     echo sub3 = sub3 >> .hgsub
-  >     hg ci -Aqmsub3
-  >     $EXTRA
-  >     echo b >> sub3/a
-  >     hg rm .hgsub
-  >     echo % update substate when removing .hgsub w/dirty subrepo
-  >     hg status -S
-  >     echo '%' $*
-  >     cat "$stdin" | hg $*
-  >     echo % debugsub should be empty
-  >     hg debugsub
-  > }
-
-  $ testrm2() {
-  >     cat - > "$stdin"
-  >     mksubrepo sub4
-  >     echo sub4 = sub4 >> .hgsub
-  >     hg ci -Aqmsub4
-  >     $EXTRA
-  >     hg rm .hgsub
-  >     echo % update substate when removing .hgsub w/clean updated subrepo
-  >     hg status -S
-  >     echo '%' $*
-  >     cat "$stdin" | hg $*
-  >     echo % debugsub should be empty
-  >     hg debugsub
-  > }
-
-
-handle subrepos safely on qnew
-
-  $ mkrepo repo-2499-qnew
-  $ testadd qnew -m0 0.diff
-  adding a
-  % abort when adding .hgsub w/dirty subrepo
-  A .hgsub
-  A sub/a
-  % qnew -m0 0.diff
-  abort: uncommitted changes in subrepository sub
-  [255]
-  % update substate when adding .hgsub w/clean updated subrepo
-  A .hgsub
-  % qnew -m0 0.diff
-  path sub
-   source   sub
-   revision b2fdb12cd82b021c3b7053d67802e77b6eeaee31
-
-  $ testmod qnew -m1 1.diff
-  adding a
-  % abort when modifying .hgsub w/dirty subrepo
-  M .hgsub
-  A sub2/a
-  % qnew -m1 1.diff
-  abort: uncommitted changes in subrepository sub2
-  [255]
-  % update substate when modifying .hgsub w/clean updated subrepo
-  M .hgsub
-  % qnew -m1 1.diff
-  path sub
-   source   sub
-   revision b2fdb12cd82b021c3b7053d67802e77b6eeaee31
-  path sub2
-   source   sub2
-   revision 1f94c7611cc6b74f5a17b16121a1170d44776845
-
-  $ hg qpop -qa
-  patch queue now empty
-  $ testrm1 qnew -m2 2.diff
-  adding a
-  % update substate when removing .hgsub w/dirty subrepo
-  M sub3/a
-  R .hgsub
-  % qnew -m2 2.diff
-  % debugsub should be empty
-
-  $ hg qpop -qa
-  patch queue now empty
-  $ testrm2 qnew -m3 3.diff
-  adding a
-  % update substate when removing .hgsub w/clean updated subrepo
-  R .hgsub
-  % qnew -m3 3.diff
-  % debugsub should be empty
-
-  $ cd ..
-
-
-handle subrepos safely on qrefresh
-
-  $ mkrepo repo-2499-qrefresh
-  $ hg qnew -m0 0.diff
-  $ testadd qrefresh
-  adding a
-  % abort when adding .hgsub w/dirty subrepo
-  A .hgsub
-  A sub/a
-  % qrefresh
-  abort: uncommitted changes in subrepository sub
-  [255]
-  % update substate when adding .hgsub w/clean updated subrepo
-  A .hgsub
-  % qrefresh
-  path sub
-   source   sub
-   revision b2fdb12cd82b021c3b7053d67802e77b6eeaee31
-
-  $ hg qnew -m1 1.diff
-  $ testmod qrefresh
-  adding a
-  % abort when modifying .hgsub w/dirty subrepo
-  M .hgsub
-  A sub2/a
-  % qrefresh
-  abort: uncommitted changes in subrepository sub2
-  [255]
-  % update substate when modifying .hgsub w/clean updated subrepo
-  M .hgsub
-  % qrefresh
-  path sub
-   source   sub
-   revision b2fdb12cd82b021c3b7053d67802e77b6eeaee31
-  path sub2
-   source   sub2
-   revision 1f94c7611cc6b74f5a17b16121a1170d44776845
-
-  $ hg qpop -qa
-  patch queue now empty
-  $ EXTRA='hg qnew -m2 2.diff'
-  $ testrm1 qrefresh
-  adding a
-  % update substate when removing .hgsub w/dirty subrepo
-  M sub3/a
-  R .hgsub
-  % qrefresh
-  % debugsub should be empty
-
-  $ hg qpop -qa
-  patch queue now empty
-  $ EXTRA='hg qnew -m3 3.diff'
-  $ testrm2 qrefresh
-  adding a
-  % update substate when removing .hgsub w/clean updated subrepo
-  R .hgsub
-  % qrefresh
-  % debugsub should be empty
-  $ EXTRA=
-
-  $ cd ..
-
-
-handle subrepos safely on qpush/qpop
-
-  $ mkrepo repo-2499-qpush
-  $ mksubrepo sub
-  adding a
-  $ hg -R sub ci -m0sub
-  $ echo sub = sub > .hgsub
-  $ hg add .hgsub
-  $ hg qnew -m0 0.diff
-  $ hg debugsub
-  path sub
-   source   sub
-   revision b2fdb12cd82b021c3b7053d67802e77b6eeaee31
-
-qpop
-  $ hg qpop
-  popping 0.diff
-  patch queue now empty
-  $ hg status -AS
-  $ hg debugsub
-
-qpush
-  $ hg qpush
-  applying 0.diff
-  now at: 0.diff
-  $ hg status -AS
-  C .hgsub
-  C .hgsubstate
-  C sub/a
-  $ hg debugsub
-  path sub
-   source   sub
-   revision b2fdb12cd82b021c3b7053d67802e77b6eeaee31
-
-  $ cd ..
-
-
-handle subrepos safely on qrecord
-
-  $ mkrepo repo-2499-qrecord
-  $ testadd qrecord --config ui.interactive=1 -m0 0.diff <<EOF
-  > y
-  > y
-  > EOF
-  adding a
-  % abort when adding .hgsub w/dirty subrepo
-  A .hgsub
-  A sub/a
-  % qrecord --config ui.interactive=1 -m0 0.diff
-  diff --git a/.hgsub b/.hgsub
-  new file mode 100644
-  examine changes to '.hgsub'? [Ynesfdaq?] 
-  abort: uncommitted changes in subrepository sub
-  [255]
-  % update substate when adding .hgsub w/clean updated subrepo
-  A .hgsub
-  % qrecord --config ui.interactive=1 -m0 0.diff
-  diff --git a/.hgsub b/.hgsub
-  new file mode 100644
-  examine changes to '.hgsub'? [Ynesfdaq?] 
-  path sub
-   source   sub
-   revision b2fdb12cd82b021c3b7053d67802e77b6eeaee31
-
-  $ testmod qrecord --config ui.interactive=1 -m1 1.diff <<EOF
-  > y
-  > y
-  > EOF
-  adding a
-  % abort when modifying .hgsub w/dirty subrepo
-  M .hgsub
-  A sub2/a
-  % qrecord --config ui.interactive=1 -m1 1.diff
-  diff --git a/.hgsub b/.hgsub
-  1 hunks, 1 lines changed
-  examine changes to '.hgsub'? [Ynesfdaq?] 
-  @@ -1,1 +1,2 @@
-   sub = sub
-  +sub2 = sub2
-  record this change to '.hgsub'? [Ynesfdaq?] 
-  abort: uncommitted changes in subrepository sub2
-  [255]
-  % update substate when modifying .hgsub w/clean updated subrepo
-  M .hgsub
-  % qrecord --config ui.interactive=1 -m1 1.diff
-  diff --git a/.hgsub b/.hgsub
-  1 hunks, 1 lines changed
-  examine changes to '.hgsub'? [Ynesfdaq?] 
-  @@ -1,1 +1,2 @@
-   sub = sub
-  +sub2 = sub2
-  record this change to '.hgsub'? [Ynesfdaq?] 
-  path sub
-   source   sub
-   revision b2fdb12cd82b021c3b7053d67802e77b6eeaee31
-  path sub2
-   source   sub2
-   revision 1f94c7611cc6b74f5a17b16121a1170d44776845
-
-  $ hg qpop -qa
-  patch queue now empty
-  $ testrm1 qrecord --config ui.interactive=1 -m2 2.diff <<EOF
-  > y
-  > y
-  > EOF
-  adding a
-  % update substate when removing .hgsub w/dirty subrepo
-  M sub3/a
-  R .hgsub
-  % qrecord --config ui.interactive=1 -m2 2.diff
-  diff --git a/.hgsub b/.hgsub
-  deleted file mode 100644
-  examine changes to '.hgsub'? [Ynesfdaq?] 
-  % debugsub should be empty
-
-  $ hg qpop -qa
-  patch queue now empty
-  $ testrm2 qrecord --config ui.interactive=1 -m3 3.diff <<EOF
-  > y
-  > y
-  > EOF
-  adding a
-  % update substate when removing .hgsub w/clean updated subrepo
-  R .hgsub
-  % qrecord --config ui.interactive=1 -m3 3.diff
-  diff --git a/.hgsub b/.hgsub
-  deleted file mode 100644
-  examine changes to '.hgsub'? [Ynesfdaq?] 
-  % debugsub should be empty
-
-  $ cd ..
-
-
-correctly handle subrepos with patch queues
-  $ mkrepo repo-subrepo-with-queue
-  $ mksubrepo sub
-  adding a
-  $ hg -R sub qnew sub0.diff
-  $ echo sub = sub >> .hgsub
-  $ hg add .hgsub
-  $ hg qnew 0.diff
-
-  $ cd ..
-
-check whether MQ operations can import updated .hgsubstate correctly
-both into 'revision' and 'patch file under .hg/patches':
-
-  $ hg init importing-hgsubstate
-  $ cd importing-hgsubstate
-
-  $ echo a > a
-  $ hg commit -u test -d '0 0' -Am '#0 in parent'
-  adding a
-  $ hg init sub
-  $ echo sa > sub/sa
-  $ hg -R sub commit -u test -d '0 0' -Am '#0 in sub'
-  adding sa
-  $ echo 'sub = sub' > .hgsub
-  $ touch .hgsubstate
-  $ hg add .hgsub .hgsubstate
-
-  $ hg qnew -u test -d '0 0' import-at-qnew
-  $ hg -R sub parents --template '{node} sub\n'
-  b6f6e9c41f3dfd374a6d2ed4535c87951cf979cf sub
-  $ cat .hgsubstate
-  b6f6e9c41f3dfd374a6d2ed4535c87951cf979cf sub
-  $ hg diff -c tip
-  diff -r f499373e340c -r b20ffac88564 .hgsub
-  --- /dev/null
-  +++ b/.hgsub
-  @@ -0,0 +1,1 @@
-  +sub = sub
-  diff -r f499373e340c -r b20ffac88564 .hgsubstate
-  --- /dev/null
-  +++ b/.hgsubstate
-  @@ -0,0 +1,1 @@
-  +b6f6e9c41f3dfd374a6d2ed4535c87951cf979cf sub
-  $ cat .hg/patches/import-at-qnew
-  # HG changeset patch
-  # Parent f499373e340cdca5d01dee904aeb42dd2a325e71
-  # User test
-  # Date 0 0
-  
-  diff -r f499373e340c -r b20ffac88564 .hgsub
-  --- /dev/null
-  +++ b/.hgsub
-  @@ -0,0 +1,1 @@
-  +sub = sub
-  diff -r f499373e340c -r b20ffac88564 .hgsubstate
-  --- /dev/null
-  +++ b/.hgsubstate
-  @@ -0,0 +1,1 @@
-  +b6f6e9c41f3dfd374a6d2ed4535c87951cf979cf sub
-  $ hg qpop
-  popping import-at-qnew
-  patch queue now empty
-  $ hg qpush
-  applying import-at-qnew
-  now at: import-at-qnew
-
-  $ hg qnew import-at-qrefresh
-  $ echo sb > sub/sb
-  $ hg -R sub commit -u test -d '0 0' -Am '#1 in sub'
-  adding sb
-  $ hg qrefresh -u test -d '0 0'
-  $ hg -R sub parents --template '{node} sub\n'
-  88ac1bef5ed43b689d1d200b59886b675dec474b sub
-  $ cat .hgsubstate
-  88ac1bef5ed43b689d1d200b59886b675dec474b sub
-  $ hg diff -c tip
-  diff -r 44f846335325 -r b3e8c5fa3aaa .hgsubstate
-  --- a/.hgsubstate
-  +++ b/.hgsubstate
-  @@ -1,1 +1,1 @@
-  -b6f6e9c41f3dfd374a6d2ed4535c87951cf979cf sub
-  +88ac1bef5ed43b689d1d200b59886b675dec474b sub
-  $ cat .hg/patches/import-at-qrefresh
-  # HG changeset patch
-  # Date 0 0
-  # User test
-  # Parent 44f846335325209be6be35dc2c9a4be107278c09
-  
-  diff -r 44f846335325 .hgsubstate
-  --- a/.hgsubstate
-  +++ b/.hgsubstate
-  @@ -1,1 +1,1 @@
-  -b6f6e9c41f3dfd374a6d2ed4535c87951cf979cf sub
-  +88ac1bef5ed43b689d1d200b59886b675dec474b sub
-
-  $ hg qrefresh -u test -d '0 0'
-  $ cat .hgsubstate
-  88ac1bef5ed43b689d1d200b59886b675dec474b sub
-  $ hg diff -c tip
-  diff -r 44f846335325 -r b3e8c5fa3aaa .hgsubstate
-  --- a/.hgsubstate
-  +++ b/.hgsubstate
-  @@ -1,1 +1,1 @@
-  -b6f6e9c41f3dfd374a6d2ed4535c87951cf979cf sub
-  +88ac1bef5ed43b689d1d200b59886b675dec474b sub
-  $ cat .hg/patches/import-at-qrefresh
-  # HG changeset patch
-  # Date 0 0
-  # User test
-  # Parent 44f846335325209be6be35dc2c9a4be107278c09
-  
-  diff -r 44f846335325 .hgsubstate
-  --- a/.hgsubstate
-  +++ b/.hgsubstate
-  @@ -1,1 +1,1 @@
-  -b6f6e9c41f3dfd374a6d2ed4535c87951cf979cf sub
-  +88ac1bef5ed43b689d1d200b59886b675dec474b sub
-
-  $ hg update -C tip
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hg qpop -a
-  popping import-at-qrefresh
-  popping import-at-qnew
-  patch queue now empty
-
-  $ hg -R sub update -C 0
-  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  $ echo 'sub = sub' > .hgsub
-  $ hg commit -Am '#1 in parent'
-  adding .hgsub
-  $ hg -R sub update -C 1
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hg commit -Am '#2 in parent (but will be rolled back soon)'
-  $ hg rollback
-  repository tip rolled back to revision 1 (undo commit)
-  working directory now based on revision 1
-  $ hg status
-  M .hgsubstate
-  $ hg qnew -u test -d '0 0' checkstate-at-qnew
-  $ hg -R sub parents --template '{node} sub\n'
-  88ac1bef5ed43b689d1d200b59886b675dec474b sub
-  $ cat .hgsubstate
-  88ac1bef5ed43b689d1d200b59886b675dec474b sub
-  $ hg diff -c tip
-  diff -r 4d91eb2fa1d1 -r 1259c112d884 .hgsubstate
-  --- a/.hgsubstate
-  +++ b/.hgsubstate
-  @@ -1,1 +1,1 @@
-  -b6f6e9c41f3dfd374a6d2ed4535c87951cf979cf sub
-  +88ac1bef5ed43b689d1d200b59886b675dec474b sub
-  $ cat .hg/patches/checkstate-at-qnew
-  # HG changeset patch
-  # Parent 4d91eb2fa1d1b22ec513347b9cd06f6b49d470fa
-  # User test
-  # Date 0 0
-  
-  diff -r 4d91eb2fa1d1 -r 1259c112d884 .hgsubstate
-  --- a/.hgsubstate
-  +++ b/.hgsubstate
-  @@ -1,1 +1,1 @@
-  -b6f6e9c41f3dfd374a6d2ed4535c87951cf979cf sub
-  +88ac1bef5ed43b689d1d200b59886b675dec474b sub
-
-  $ cd ..
-
-  $ cd ..
diff --git a/tests/test-mq-symlinks.t b/tests/test-mq-symlinks.t
deleted file mode 100644
--- a/tests/test-mq-symlinks.t
+++ /dev/null
@@ -1,108 +0,0 @@ 
-  $ "$TESTDIR/hghave" symlink || exit 80
-
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "mq=" >> $HGRCPATH
-
-  $ hg init
-  $ hg qinit
-  $ hg qnew base.patch
-  $ echo aaa > a
-  $ echo bbb > b
-  $ echo ccc > c
-  $ hg add a b c
-  $ hg qrefresh
-  $ "$TESTDIR/readlink.py" a
-  a -> a not a symlink
-
-
-test replacing a file with a symlink
-
-  $ hg qnew symlink.patch
-  $ rm a
-  $ ln -s b a
-  $ hg qrefresh --git
-  $ "$TESTDIR/readlink.py" a
-  a -> b
-
-  $ hg qpop
-  popping symlink.patch
-  now at: base.patch
-  $ hg qpush
-  applying symlink.patch
-  now at: symlink.patch
-  $ "$TESTDIR/readlink.py" a
-  a -> b
-
-
-test updating a symlink
-
-  $ rm a
-  $ ln -s c a
-  $ hg qnew --git -f updatelink
-  $ "$TESTDIR/readlink.py" a
-  a -> c
-  $ hg qpop
-  popping updatelink
-  now at: symlink.patch
-  $ hg qpush --debug
-  applying updatelink
-  patching file a
-  a
-  now at: updatelink
-  $ "$TESTDIR/readlink.py" a
-  a -> c
-  $ hg st
-
-
-test replacing a symlink with a file
-
-  $ ln -s c s
-  $ hg add s
-  $ hg qnew --git -f addlink
-  $ rm s
-  $ echo sss > s
-  $ hg qnew --git -f replacelinkwithfile
-  $ hg qpop
-  popping replacelinkwithfile
-  now at: addlink
-  $ hg qpush
-  applying replacelinkwithfile
-  now at: replacelinkwithfile
-  $ cat s
-  sss
-  $ hg st
-
-
-test symlink removal
-
-  $ hg qnew removesl.patch
-  $ hg rm a
-  $ hg qrefresh --git
-  $ hg qpop
-  popping removesl.patch
-  now at: replacelinkwithfile
-  $ hg qpush
-  applying removesl.patch
-  now at: removesl.patch
-  $ hg st -c
-  C b
-  C c
-  C s
-
-replace broken symlink with another broken symlink
-
-  $ ln -s linka linka
-  $ hg add linka
-  $ hg qnew link
-  $ hg mv linka linkb
-  $ rm linkb
-  $ ln -s linkb linkb
-  $ hg qnew movelink
-  $ hg qpop
-  popping movelink
-  now at: link
-  $ hg qpush
-  applying movelink
-  now at: movelink
-  $ "$TESTDIR/readlink.py" linkb
-  linkb -> linkb
diff --git a/tests/test-mq.t b/tests/test-mq.t
deleted file mode 100644
--- a/tests/test-mq.t
+++ /dev/null
@@ -1,1579 +0,0 @@ 
-  $ checkundo()
-  > {
-  >     if [ -f .hg/store/undo ]; then
-  >     echo ".hg/store/undo still exists after $1"
-  >     fi
-  > }
-
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "mq=" >> $HGRCPATH
-
-  $ echo "[mq]" >> $HGRCPATH
-  $ echo "plain=true" >> $HGRCPATH
-
-
-help
-
-  $ hg help mq
-  mq extension - manage a stack of patches
-  
-  This extension lets you work with a stack of patches in a Mercurial
-  repository. It manages two stacks of patches - all known patches, and applied
-  patches (subset of known patches).
-  
-  Known patches are represented as patch files in the .hg/patches directory.
-  Applied patches are both patch files and changesets.
-  
-  Common tasks (use "hg help command" for more details):
-  
-    create new patch                          qnew
-    import existing patch                     qimport
-  
-    print patch series                        qseries
-    print applied patches                     qapplied
-  
-    add known patch to applied stack          qpush
-    remove patch from applied stack           qpop
-    refresh contents of top applied patch     qrefresh
-  
-  By default, mq will automatically use git patches when required to avoid
-  losing file mode changes, copy records, binary files or empty files creations
-  or deletions. This behaviour can be configured with:
-  
-    [mq]
-    git = auto/keep/yes/no
-  
-  If set to 'keep', mq will obey the [diff] section configuration while
-  preserving existing git patches upon qrefresh. If set to 'yes' or 'no', mq
-  will override the [diff] section and always generate git or regular patches,
-  possibly losing data in the second case.
-  
-  It may be desirable for mq changesets to be kept in the secret phase (see "hg
-  help phases"), which can be enabled with the following setting:
-  
-    [mq]
-    secret = True
-  
-  You will by default be managing a patch queue named "patches". You can create
-  other, independent patch queues with the "hg qqueue" command.
-  
-  If the working directory contains uncommitted files, qpush, qpop and qgoto
-  abort immediately. If -f/--force is used, the changes are discarded. Setting:
-  
-    [mq]
-    keepchanges = True
-  
-  make them behave as if --keep-changes were passed, and non-conflicting local
-  changes will be tolerated and preserved. If incompatible options such as
-  -f/--force or --exact are passed, this setting is ignored.
-  
-  list of commands:
-  
-   qapplied      print the patches already applied
-   qclone        clone main and patch repository at same time
-   qdelete       remove patches from queue
-   qdiff         diff of the current patch and subsequent modifications
-   qfinish       move applied patches into repository history
-   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 or existing changeset
-   qnew          create a new patch
-   qnext         print the name of the next pushable patch
-   qpop          pop the current patch off the stack
-   qprev         print the name of the preceding applied patch
-   qpush         push the next patch onto the stack
-   qqueue        manage multiple patch queues
-   qrefresh      update the current patch
-   qrename       rename a patch
-   qselect       set or print guarded patches to push
-   qseries       print the entire series file
-   qtop          print the name of the current patch
-   qunapplied    print the patches not yet applied
-   strip         strip changesets and all their descendants from the repository
-  
-  use "hg -v help mq" to show builtin aliases and global options
-
-  $ hg init a
-  $ cd a
-  $ echo a > a
-  $ hg ci -Ama
-  adding a
-
-  $ hg clone . ../k
-  updating to branch default
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-
-  $ mkdir b
-  $ echo z > b/z
-  $ hg ci -Ama
-  adding b/z
-
-
-qinit
-
-  $ hg qinit
-
-  $ cd ..
-  $ hg init b
-
-
--R qinit
-
-  $ hg -R b qinit
-
-  $ hg init c
-
-
-qinit -c
-
-  $ hg --cwd c qinit -c
-  $ hg -R c/.hg/patches st
-  A .hgignore
-  A series
-
-
-qinit; qinit -c
-
-  $ hg init d
-  $ cd d
-  $ hg qinit
-  $ hg qinit -c
-
-qinit -c should create both files if they don't exist
-
-  $ cat .hg/patches/.hgignore
-  ^\.hg
-  ^\.mq
-  syntax: glob
-  status
-  guards
-  $ cat .hg/patches/series
-  $ hg qinit -c
-  abort: repository $TESTTMP/d/.hg/patches already exists! (glob)
-  [255]
-  $ cd ..
-
-  $ echo '% qinit; <stuff>; qinit -c'
-  % qinit; <stuff>; qinit -c
-  $ hg init e
-  $ cd e
-  $ hg qnew A
-  $ checkundo qnew
-  $ echo foo > foo
-  $ hg phase -r qbase
-  0: draft
-  $ hg add foo
-  $ hg qrefresh
-  $ hg phase -r qbase
-  0: draft
-  $ hg qnew B
-  $ echo >> foo
-  $ hg qrefresh
-  $ echo status >> .hg/patches/.hgignore
-  $ echo bleh >> .hg/patches/.hgignore
-  $ hg qinit -c
-  adding .hg/patches/A (glob)
-  adding .hg/patches/B (glob)
-  $ hg -R .hg/patches status
-  A .hgignore
-  A A
-  A B
-  A series
-
-qinit -c shouldn't touch these files if they already exist
-
-  $ cat .hg/patches/.hgignore
-  status
-  bleh
-  $ cat .hg/patches/series
-  A
-  B
-
-add an untracked file
-
-  $ echo >> .hg/patches/flaf
-
-status --mq with color (issue2096)
-
-  $ hg status --mq --config extensions.color= --config color.mode=ansi --color=always
-  \x1b[0;32;1mA \x1b[0m\x1b[0;32;1m.hgignore\x1b[0m (esc)
-  \x1b[0;32;1mA \x1b[0m\x1b[0;32;1mA\x1b[0m (esc)
-  \x1b[0;32;1mA \x1b[0m\x1b[0;32;1mB\x1b[0m (esc)
-  \x1b[0;32;1mA \x1b[0m\x1b[0;32;1mseries\x1b[0m (esc)
-  \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4mflaf\x1b[0m (esc)
-
-try the --mq option on a command provided by an extension
-
-  $ hg purge --mq --verbose --config extensions.purge=
-  removing file flaf
-
-  $ cd ..
-
-#if no-outer-repo
-
-init --mq without repo
-
-  $ mkdir f
-  $ cd f
-  $ hg init --mq
-  abort: there is no Mercurial repository here (.hg not found)
-  [255]
-  $ cd ..
-
-#endif
-
-init --mq with repo path
-
-  $ hg init g
-  $ hg init --mq g
-  $ test -d g/.hg/patches/.hg
-
-init --mq with nonexistent directory
-
-  $ hg init --mq nonexistentdir
-  abort: repository nonexistentdir not found!
-  [255]
-
-
-init --mq with bundle (non "local")
-
-  $ hg -R a bundle --all a.bundle >/dev/null
-  $ hg init --mq a.bundle
-  abort: only a local queue repository may be initialized
-  [255]
-
-  $ cd a
-
-  $ hg qnew -m 'foo bar' test.patch
-
-  $ echo '# comment' > .hg/patches/series.tmp
-  $ echo >> .hg/patches/series.tmp # empty line
-  $ cat .hg/patches/series >> .hg/patches/series.tmp
-  $ mv .hg/patches/series.tmp .hg/patches/series
-
-
-qrefresh
-
-  $ echo a >> a
-  $ hg qrefresh
-  $ cat .hg/patches/test.patch
-  foo bar
-  
-  diff -r [a-f0-9]* a (re)
-  --- a/a\t(?P<date>.*) (re)
-  \+\+\+ b/a\t(?P<date2>.*) (re)
-  @@ -1,1 +1,2 @@
-   a
-  +a
-
-empty qrefresh
-
-  $ hg qrefresh -X a
-
-revision:
-
-  $ hg diff -r -2 -r -1
-
-patch:
-
-  $ cat .hg/patches/test.patch
-  foo bar
-  
-
-working dir diff:
-
-  $ hg diff --nodates -q
-  --- a/a
-  +++ b/a
-  @@ -1,1 +1,2 @@
-   a
-  +a
-
-restore things
-
-  $ hg qrefresh
-  $ checkundo qrefresh
-
-
-qpop
-
-  $ hg qpop
-  popping test.patch
-  patch queue now empty
-  $ checkundo qpop
-
-
-qpush with dump of tag cache
-Dump the tag cache to ensure that it has exactly one head after qpush.
-
-  $ rm -f .hg/cache/tags
-  $ hg tags > /dev/null
-
-.hg/cache/tags (pre qpush):
-
-  $ cat .hg/cache/tags
-  1 [\da-f]{40} (re)
-  
-  $ hg qpush
-  applying test.patch
-  now at: test.patch
-  $ hg phase -r qbase
-  2: draft
-  $ hg tags > /dev/null
-
-.hg/cache/tags (post qpush):
-
-  $ cat .hg/cache/tags
-  2 [\da-f]{40} (re)
-  
-  $ checkundo qpush
-  $ cd ..
-
-
-pop/push outside repo
-  $ hg -R a qpop
-  popping test.patch
-  patch queue now empty
-  $ hg -R a qpush
-  applying test.patch
-  now at: test.patch
-
-  $ cd a
-  $ hg qnew test2.patch
-
-qrefresh in subdir
-
-  $ cd b
-  $ echo a > a
-  $ hg add a
-  $ hg qrefresh
-
-pop/push -a in subdir
-
-  $ hg qpop -a
-  popping test2.patch
-  popping test.patch
-  patch queue now empty
-  $ hg --traceback qpush -a
-  applying test.patch
-  applying test2.patch
-  now at: test2.patch
-
-
-setting columns & formatted tests truncating (issue1912)
-
-  $ COLUMNS=4 hg qseries --config ui.formatted=true
-  test.patch
-  test2.patch
-  $ COLUMNS=20 hg qseries --config ui.formatted=true -vs
-  0 A test.patch: f...
-  1 A test2.patch: 
-  $ hg qpop
-  popping test2.patch
-  now at: test.patch
-  $ hg qseries -vs
-  0 A test.patch: foo bar
-  1 U test2.patch: 
-  $ hg sum | grep mq
-  mq:     1 applied, 1 unapplied
-  $ hg qpush
-  applying test2.patch
-  now at: test2.patch
-  $ hg sum | grep mq
-  mq:     2 applied
-  $ hg qapplied
-  test.patch
-  test2.patch
-  $ hg qtop
-  test2.patch
-
-
-prev
-
-  $ hg qapp -1
-  test.patch
-
-next
-
-  $ hg qunapp -1
-  all patches applied
-  [1]
-
-  $ hg qpop
-  popping test2.patch
-  now at: test.patch
-
-commit should fail
-
-  $ hg commit
-  abort: cannot commit over an applied mq patch
-  [255]
-
-push should fail if draft
-
-  $ hg push ../../k
-  pushing to ../../k
-  abort: source has mq patches applied
-  [255]
-
-
-import should fail
-
-  $ hg st .
-  $ echo foo >> ../a
-  $ hg diff > ../../import.diff
-  $ hg revert --no-backup ../a
-  $ hg import ../../import.diff
-  abort: cannot import over an applied patch
-  [255]
-  $ hg st
-
-import --no-commit should succeed
-
-  $ hg import --no-commit ../../import.diff
-  applying ../../import.diff
-  $ hg st
-  M a
-  $ hg revert --no-backup ../a
-
-
-qunapplied
-
-  $ hg qunapplied
-  test2.patch
-
-
-qpush/qpop with index
-
-  $ hg qnew test1b.patch
-  $ echo 1b > 1b
-  $ hg add 1b
-  $ hg qrefresh
-  $ hg qpush 2
-  applying test2.patch
-  now at: test2.patch
-  $ hg qpop 0
-  popping test2.patch
-  popping test1b.patch
-  now at: test.patch
-  $ hg qpush test.patch+1
-  applying test1b.patch
-  now at: test1b.patch
-  $ hg qpush test.patch+2
-  applying test2.patch
-  now at: test2.patch
-  $ hg qpop test2.patch-1
-  popping test2.patch
-  now at: test1b.patch
-  $ hg qpop test2.patch-2
-  popping test1b.patch
-  now at: test.patch
-  $ hg qpush test1b.patch+1
-  applying test1b.patch
-  applying test2.patch
-  now at: test2.patch
-
-
-qpush --move
-
-  $ hg qpop -a
-  popping test2.patch
-  popping test1b.patch
-  popping test.patch
-  patch queue now empty
-  $ hg qguard test1b.patch -- -negguard
-  $ hg qguard test2.patch -- +posguard
-  $ hg qpush --move test2.patch # can't move guarded patch
-  cannot push 'test2.patch' - guarded by '+posguard'
-  [1]
-  $ hg qselect posguard
-  number of unguarded, unapplied patches has changed from 2 to 3
-  $ hg qpush --move test2.patch # move to front
-  applying test2.patch
-  now at: test2.patch
-  $ hg qpush --move test1b.patch # negative guard unselected
-  applying test1b.patch
-  now at: test1b.patch
-  $ hg qpush --move test.patch # noop move
-  applying test.patch
-  now at: test.patch
-  $ hg qseries -v
-  0 A test2.patch
-  1 A test1b.patch
-  2 A test.patch
-  $ hg qpop -a
-  popping test.patch
-  popping test1b.patch
-  popping test2.patch
-  patch queue now empty
-
-cleaning up
-
-  $ hg qselect --none
-  guards deactivated
-  number of unguarded, unapplied patches has changed from 3 to 2
-  $ hg qguard --none test1b.patch
-  $ hg qguard --none test2.patch
-  $ hg qpush --move test.patch
-  applying test.patch
-  now at: test.patch
-  $ hg qpush --move test1b.patch
-  applying test1b.patch
-  now at: test1b.patch
-  $ hg qpush --move bogus # nonexistent patch
-  abort: patch bogus not in series
-  [255]
-  $ hg qpush --move # no patch
-  abort: please specify the patch to move
-  [255]
-  $ hg qpush --move test.patch # already applied
-  abort: cannot push to a previous patch: test.patch
-  [255]
-  $ sed '2i\
-  > # make qtip index different in series and fullseries
-  > ' `hg root`/.hg/patches/series > $TESTTMP/sedtmp
-  $ cp $TESTTMP/sedtmp `hg root`/.hg/patches/series
-  $ cat `hg root`/.hg/patches/series
-  # comment
-  # make qtip index different in series and fullseries
-  
-  test.patch
-  test1b.patch
-  test2.patch
-  $ hg qpush --move test2.patch
-  applying test2.patch
-  now at: test2.patch
-
-
-series after move
-
-  $ cat `hg root`/.hg/patches/series
-  # comment
-  # make qtip index different in series and fullseries
-  
-  test.patch
-  test1b.patch
-  test2.patch
-
-
-pop, qapplied, qunapplied
-
-  $ hg qseries -v
-  0 A test.patch
-  1 A test1b.patch
-  2 A test2.patch
-
-qapplied -1 test.patch
-
-  $ hg qapplied -1 test.patch
-  only one patch applied
-  [1]
-
-qapplied -1 test1b.patch
-
-  $ hg qapplied -1 test1b.patch
-  test.patch
-
-qapplied -1 test2.patch
-
-  $ hg qapplied -1 test2.patch
-  test1b.patch
-
-qapplied -1
-
-  $ hg qapplied -1
-  test1b.patch
-
-qapplied
-
-  $ hg qapplied
-  test.patch
-  test1b.patch
-  test2.patch
-
-qapplied test1b.patch
-
-  $ hg qapplied test1b.patch
-  test.patch
-  test1b.patch
-
-qunapplied -1
-
-  $ hg qunapplied -1
-  all patches applied
-  [1]
-
-qunapplied
-
-  $ hg qunapplied
-
-popping
-
-  $ hg qpop
-  popping test2.patch
-  now at: test1b.patch
-
-qunapplied -1
-
-  $ hg qunapplied -1
-  test2.patch
-
-qunapplied
-
-  $ hg qunapplied
-  test2.patch
-
-qunapplied test2.patch
-
-  $ hg qunapplied test2.patch
-
-qunapplied -1 test2.patch
-
-  $ hg qunapplied -1 test2.patch
-  all patches applied
-  [1]
-
-popping -a
-
-  $ hg qpop -a
-  popping test1b.patch
-  popping test.patch
-  patch queue now empty
-
-qapplied
-
-  $ hg qapplied
-
-qapplied -1
-
-  $ hg qapplied -1
-  no patches applied
-  [1]
-  $ hg qpush
-  applying test.patch
-  now at: test.patch
-
-
-push should succeed
-
-  $ hg qpop -a
-  popping test.patch
-  patch queue now empty
-  $ hg push ../../k
-  pushing to ../../k
-  searching for changes
-  adding changesets
-  adding manifests
-  adding file changes
-  added 1 changesets with 1 changes to 1 files
-
-
-we want to start with some patches applied
-
-  $ hg qpush -a
-  applying test.patch
-  applying test1b.patch
-  applying test2.patch
-  now at: test2.patch
-
-% pops all patches and succeeds
-
-  $ hg qpop -a
-  popping test2.patch
-  popping test1b.patch
-  popping test.patch
-  patch queue now empty
-
-% does nothing and succeeds
-
-  $ hg qpop -a
-  no patches applied
-
-% fails - nothing else to pop
-
-  $ hg qpop
-  no patches applied
-  [1]
-
-% pushes a patch and succeeds
-
-  $ hg qpush
-  applying test.patch
-  now at: test.patch
-
-% pops a patch and succeeds
-
-  $ hg qpop
-  popping test.patch
-  patch queue now empty
-
-% pushes up to test1b.patch and succeeds
-
-  $ hg qpush test1b.patch
-  applying test.patch
-  applying test1b.patch
-  now at: test1b.patch
-
-% does nothing and succeeds
-
-  $ hg qpush test1b.patch
-  qpush: test1b.patch is already at the top
-
-% does nothing and succeeds
-
-  $ hg qpop test1b.patch
-  qpop: test1b.patch is already at the top
-
-% fails - can't push to this patch
-
-  $ hg qpush test.patch
-  abort: cannot push to a previous patch: test.patch
-  [255]
-
-% fails - can't pop to this patch
-
-  $ hg qpop test2.patch
-  abort: patch test2.patch is not applied
-  [255]
-
-% pops up to test.patch and succeeds
-
-  $ hg qpop test.patch
-  popping test1b.patch
-  now at: test.patch
-
-% pushes all patches and succeeds
-
-  $ hg qpush -a
-  applying test1b.patch
-  applying test2.patch
-  now at: test2.patch
-
-% does nothing and succeeds
-
-  $ hg qpush -a
-  all patches are currently applied
-
-% fails - nothing else to push
-
-  $ hg qpush
-  patch series already fully applied
-  [1]
-
-% does nothing and succeeds
-
-  $ hg qpush test2.patch
-  qpush: test2.patch is already at the top
-
-strip
-
-  $ cd ../../b
-  $ echo x>x
-  $ hg ci -Ama
-  adding x
-  $ hg strip tip
-  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  saved backup bundle to $TESTTMP/b/.hg/strip-backup/*-backup.hg (glob)
-  $ hg unbundle .hg/strip-backup/*
-  adding changesets
-  adding manifests
-  adding file changes
-  added 1 changesets with 1 changes to 1 files
-  (run 'hg update' to get a working copy)
-
-
-strip with local changes, should complain
-
-  $ hg up
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ echo y>y
-  $ hg add y
-  $ hg strip tip
-  abort: local changes found
-  [255]
-
---force strip with local changes
-
-  $ hg strip -f tip
-  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  saved backup bundle to $TESTTMP/b/.hg/strip-backup/*-backup.hg (glob)
-  $ cd ..
-
-
-cd b; hg qrefresh
-
-  $ hg init refresh
-  $ cd refresh
-  $ echo a > a
-  $ hg ci -Ama
-  adding a
-  $ hg qnew -mfoo foo
-  $ echo a >> a
-  $ hg qrefresh
-  $ mkdir b
-  $ cd b
-  $ echo f > f
-  $ hg add f
-  $ hg qrefresh
-  $ cat ../.hg/patches/foo
-  foo
-  
-  diff -r cb9a9f314b8b a
-  --- a/a\t(?P<date>.*) (re)
-  \+\+\+ b/a\t(?P<date>.*) (re)
-  @@ -1,1 +1,2 @@
-   a
-  +a
-  diff -r cb9a9f314b8b b/f
-  --- /dev/null\t(?P<date>.*) (re)
-  \+\+\+ b/b/f\t(?P<date>.*) (re)
-  @@ -0,0 +1,1 @@
-  +f
-
-hg qrefresh .
-
-  $ hg qrefresh .
-  $ cat ../.hg/patches/foo
-  foo
-  
-  diff -r cb9a9f314b8b b/f
-  --- /dev/null\t(?P<date>.*) (re)
-  \+\+\+ b/b/f\t(?P<date>.*) (re)
-  @@ -0,0 +1,1 @@
-  +f
-  $ hg status
-  M a
-
-
-qpush failure
-
-  $ cd ..
-  $ hg qrefresh
-  $ hg qnew -mbar bar
-  $ echo foo > foo
-  $ echo bar > bar
-  $ hg add foo bar
-  $ hg qrefresh
-  $ hg qpop -a
-  popping bar
-  popping foo
-  patch queue now empty
-  $ echo bar > foo
-  $ hg qpush -a
-  applying foo
-  applying bar
-  file foo already exists
-  1 out of 1 hunks FAILED -- saving rejects to file foo.rej
-  patch failed, unable to continue (try -v)
-  patch failed, rejects left in working dir
-  errors during apply, please fix and refresh bar
-  [2]
-  $ hg st
-  ? foo
-  ? foo.rej
-
-
-mq tags
-
-  $ hg log --template '{rev} {tags}\n' -r qparent:qtip
-  0 qparent
-  1 foo qbase
-  2 bar qtip tip
-
-mq revset
-
-  $ hg log -r 'mq()' --template '{rev}\n'
-  1
-  2
-  $ hg help revsets | grep -i mq
-      "mq()"
-        Changesets managed by MQ.
-
-bad node in status
-
-  $ hg qpop
-  popping bar
-  now at: foo
-  $ hg strip -qn tip
-  $ hg tip
-  changeset:   0:cb9a9f314b8b
-  tag:         tip
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     a
-  
-  $ hg branches
-  default                        0:cb9a9f314b8b
-  $ hg qpop
-  no patches applied
-  [1]
-
-  $ cd ..
-
-
-git patches
-
-  $ cat >>$HGRCPATH <<EOF
-  > [diff]
-  > git = True
-  > EOF
-  $ hg init git
-  $ cd git
-  $ hg qinit
-
-  $ hg qnew -m'new file' new
-  $ echo foo > new
-#if execbit
-  $ chmod +x new
-#endif
-  $ hg add new
-  $ hg qrefresh
-#if execbit
-  $ cat .hg/patches/new
-  new file
-  
-  diff --git a/new b/new
-  new file mode 100755
-  --- /dev/null
-  +++ b/new
-  @@ -0,0 +1,1 @@
-  +foo
-#else
-  $ cat .hg/patches/new
-  new file
-  
-  diff --git a/new b/new
-  new file mode 100644
-  --- /dev/null
-  +++ b/new
-  @@ -0,0 +1,1 @@
-  +foo
-#endif
-
-  $ hg qnew -m'copy file' copy
-  $ hg cp new copy
-  $ hg qrefresh
-  $ cat .hg/patches/copy
-  copy file
-  
-  diff --git a/new b/copy
-  copy from new
-  copy to copy
-
-  $ hg qpop
-  popping copy
-  now at: new
-  $ hg qpush
-  applying copy
-  now at: copy
-  $ hg qdiff
-  diff --git a/new b/copy
-  copy from new
-  copy to copy
-  $ cat >>$HGRCPATH <<EOF
-  > [diff]
-  > git = False
-  > EOF
-  $ hg qdiff --git
-  diff --git a/new b/copy
-  copy from new
-  copy to copy
-  $ cd ..
-
-empty lines in status
-
-  $ hg init emptystatus
-  $ cd emptystatus
-  $ hg qinit
-  $ printf '\n\n' > .hg/patches/status
-  $ hg qser
-  $ cd ..
-
-bad line in status (without ":")
-
-  $ hg init badstatus
-  $ cd badstatus
-  $ hg qinit
-  $ printf 'babar has no colon in this line\n' > .hg/patches/status
-  $ hg qser
-  malformated mq status line: ['babar has no colon in this line']
-  $ cd ..
-
-
-test file addition in slow path
-
-  $ hg init slow
-  $ cd slow
-  $ hg qinit
-  $ echo foo > foo
-  $ hg add foo
-  $ hg ci -m 'add foo'
-  $ hg qnew bar
-  $ echo bar > bar
-  $ hg add bar
-  $ hg mv foo baz
-  $ hg qrefresh --git
-  $ hg up -C 0
-  1 files updated, 0 files merged, 2 files removed, 0 files unresolved
-  $ echo >> foo
-  $ hg ci -m 'change foo'
-  created new head
-  $ hg up -C 1
-  2 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  $ hg qrefresh --git
-  $ cat .hg/patches/bar
-  diff --git a/bar b/bar
-  new file mode 100644
-  --- /dev/null
-  +++ b/bar
-  @@ -0,0 +1,1 @@
-  +bar
-  diff --git a/foo b/baz
-  rename from foo
-  rename to baz
-  $ hg log -v --template '{rev} {file_copies}\n' -r .
-  2 baz (foo)
-  $ hg qrefresh --git
-  $ cat .hg/patches/bar
-  diff --git a/bar b/bar
-  new file mode 100644
-  --- /dev/null
-  +++ b/bar
-  @@ -0,0 +1,1 @@
-  +bar
-  diff --git a/foo b/baz
-  rename from foo
-  rename to baz
-  $ hg log -v --template '{rev} {file_copies}\n' -r .
-  2 baz (foo)
-  $ hg qrefresh
-  $ grep 'diff --git' .hg/patches/bar
-  diff --git a/bar b/bar
-  diff --git a/foo b/baz
-
-
-test file move chains in the slow path
-
-  $ hg up -C 1
-  1 files updated, 0 files merged, 2 files removed, 0 files unresolved
-  $ echo >> foo
-  $ hg ci -m 'change foo again'
-  $ hg up -C 2
-  2 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  $ hg mv bar quux
-  $ hg mv baz bleh
-  $ hg qrefresh --git
-  $ cat .hg/patches/bar
-  diff --git a/foo b/bleh
-  rename from foo
-  rename to bleh
-  diff --git a/quux b/quux
-  new file mode 100644
-  --- /dev/null
-  +++ b/quux
-  @@ -0,0 +1,1 @@
-  +bar
-  $ hg log -v --template '{rev} {file_copies}\n' -r .
-  3 bleh (foo)
-  $ hg mv quux fred
-  $ hg mv bleh barney
-  $ hg qrefresh --git
-  $ cat .hg/patches/bar
-  diff --git a/foo b/barney
-  rename from foo
-  rename to barney
-  diff --git a/fred b/fred
-  new file mode 100644
-  --- /dev/null
-  +++ b/fred
-  @@ -0,0 +1,1 @@
-  +bar
-  $ hg log -v --template '{rev} {file_copies}\n' -r .
-  3 barney (foo)
-
-
-refresh omitting an added file
-
-  $ hg qnew baz
-  $ echo newfile > newfile
-  $ hg add newfile
-  $ hg qrefresh
-  $ hg st -A newfile
-  C newfile
-  $ hg qrefresh -X newfile
-  $ hg st -A newfile
-  A newfile
-  $ hg revert newfile
-  $ rm newfile
-  $ hg qpop
-  popping baz
-  now at: bar
-
-test qdel/qrm
-
-  $ hg qdel baz
-  $ echo p >> .hg/patches/series
-  $ hg qrm p
-  $ hg qser
-  bar
-
-create a git patch
-
-  $ echo a > alexander
-  $ hg add alexander
-  $ hg qnew -f --git addalexander
-  $ grep diff .hg/patches/addalexander
-  diff --git a/alexander b/alexander
-
-
-create a git binary patch
-
-  $ cat > writebin.py <<EOF
-  > import sys
-  > path = sys.argv[1]
-  > open(path, 'wb').write('BIN\x00ARY')
-  > EOF
-  $ python writebin.py bucephalus
-
-  $ python "$TESTDIR/md5sum.py" bucephalus
-  8ba2a2f3e77b55d03051ff9c24ad65e7  bucephalus
-  $ hg add bucephalus
-  $ hg qnew -f --git addbucephalus
-  $ grep diff .hg/patches/addbucephalus
-  diff --git a/bucephalus b/bucephalus
-
-
-check binary patches can be popped and pushed
-
-  $ hg qpop
-  popping addbucephalus
-  now at: addalexander
-  $ test -f bucephalus && echo % bucephalus should not be there
-  [1]
-  $ hg qpush
-  applying addbucephalus
-  now at: addbucephalus
-  $ test -f bucephalus
-  $ python "$TESTDIR/md5sum.py" bucephalus
-  8ba2a2f3e77b55d03051ff9c24ad65e7  bucephalus
-
-
-
-strip again
-
-  $ cd ..
-  $ hg init strip
-  $ cd strip
-  $ touch foo
-  $ hg add foo
-  $ hg ci -m 'add foo'
-  $ echo >> foo
-  $ hg ci -m 'change foo 1'
-  $ hg up -C 0
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ echo 1 >> foo
-  $ hg ci -m 'change foo 2'
-  created new head
-  $ HGMERGE=true hg merge
-  merging foo
-  0 files updated, 1 files merged, 0 files removed, 0 files unresolved
-  (branch merge, don't forget to commit)
-  $ hg ci -m merge
-  $ hg log
-  changeset:   3:99615015637b
-  tag:         tip
-  parent:      2:20cbbe65cff7
-  parent:      1:d2871fc282d4
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     merge
-  
-  changeset:   2:20cbbe65cff7
-  parent:      0:53245c60e682
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     change foo 2
-  
-  changeset:   1:d2871fc282d4
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     change foo 1
-  
-  changeset:   0:53245c60e682
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     add foo
-  
-  $ hg strip 1
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  saved backup bundle to $TESTTMP/strip/.hg/strip-backup/*-backup.hg (glob)
-  $ checkundo strip
-  $ hg log
-  changeset:   1:20cbbe65cff7
-  tag:         tip
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     change foo 2
-  
-  changeset:   0:53245c60e682
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     add foo
-  
-  $ cd ..
-
-
-qclone
-
-  $ qlog()
-  > {
-  >     echo 'main repo:'
-  >     hg log --template '    rev {rev}: {desc}\n'
-  >     echo 'patch repo:'
-  >     hg -R .hg/patches log --template '    rev {rev}: {desc}\n'
-  > }
-  $ hg init qclonesource
-  $ cd qclonesource
-  $ echo foo > foo
-  $ hg add foo
-  $ hg ci -m 'add foo'
-  $ hg qinit
-  $ hg qnew patch1
-  $ echo bar >> foo
-  $ hg qrefresh -m 'change foo'
-  $ cd ..
-
-
-repo with unversioned patch dir
-
-  $ hg qclone qclonesource failure
-  abort: versioned patch repository not found (see init --mq)
-  [255]
-
-  $ cd qclonesource
-  $ hg qinit -c
-  adding .hg/patches/patch1 (glob)
-  $ hg qci -m checkpoint
-  $ qlog
-  main repo:
-      rev 1: change foo
-      rev 0: add foo
-  patch repo:
-      rev 0: checkpoint
-  $ cd ..
-
-
-repo with patches applied
-
-  $ hg qclone qclonesource qclonedest
-  updating to branch default
-  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ cd qclonedest
-  $ qlog
-  main repo:
-      rev 0: add foo
-  patch repo:
-      rev 0: checkpoint
-  $ cd ..
-
-
-repo with patches unapplied
-
-  $ cd qclonesource
-  $ hg qpop -a
-  popping patch1
-  patch queue now empty
-  $ qlog
-  main repo:
-      rev 0: add foo
-  patch repo:
-      rev 0: checkpoint
-  $ cd ..
-  $ hg qclone qclonesource qclonedest2
-  updating to branch default
-  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ cd qclonedest2
-  $ qlog
-  main repo:
-      rev 0: add foo
-  patch repo:
-      rev 0: checkpoint
-  $ cd ..
-
-
-Issue1033: test applying on an empty file
-
-  $ hg init empty
-  $ cd empty
-  $ touch a
-  $ hg ci -Am addempty
-  adding a
-  $ echo a > a
-  $ hg qnew -f -e changea
-  $ hg qpop
-  popping changea
-  patch queue now empty
-  $ hg qpush
-  applying changea
-  now at: changea
-  $ cd ..
-
-test qpush with --force, issue1087
-
-  $ hg init forcepush
-  $ cd forcepush
-  $ echo hello > hello.txt
-  $ echo bye > bye.txt
-  $ hg ci -Ama
-  adding bye.txt
-  adding hello.txt
-  $ hg qnew -d '0 0' empty
-  $ hg qpop
-  popping empty
-  patch queue now empty
-  $ echo world >> hello.txt
-
-
-qpush should fail, local changes
-
-  $ hg qpush
-  abort: local changes found
-  [255]
-
-
-apply force, should not discard changes with empty patch
-
-  $ hg qpush -f
-  applying empty
-  patch empty is empty
-  now at: empty
-  $ hg diff --config diff.nodates=True
-  diff -r d58265112590 hello.txt
-  --- a/hello.txt
-  +++ b/hello.txt
-  @@ -1,1 +1,2 @@
-   hello
-  +world
-  $ hg qdiff --config diff.nodates=True
-  diff -r 9ecee4f634e3 hello.txt
-  --- a/hello.txt
-  +++ b/hello.txt
-  @@ -1,1 +1,2 @@
-   hello
-  +world
-  $ hg log -l1 -p
-  changeset:   1:d58265112590
-  tag:         empty
-  tag:         qbase
-  tag:         qtip
-  tag:         tip
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     imported patch empty
-  
-  
-  $ hg qref -d '0 0'
-  $ hg qpop
-  popping empty
-  patch queue now empty
-  $ echo universe >> hello.txt
-  $ echo universe >> bye.txt
-
-
-qpush should fail, local changes
-
-  $ hg qpush
-  abort: local changes found
-  [255]
-
-
-apply force, should discard changes in hello, but not bye
-
-  $ hg qpush -f --verbose
-  applying empty
-  saving current version of hello.txt as hello.txt.orig
-  patching file hello.txt
-  hello.txt
-  now at: empty
-  $ hg st
-  M bye.txt
-  ? hello.txt.orig
-  $ hg diff --config diff.nodates=True
-  diff -r ba252371dbc1 bye.txt
-  --- a/bye.txt
-  +++ b/bye.txt
-  @@ -1,1 +1,2 @@
-   bye
-  +universe
-  $ hg qdiff --config diff.nodates=True
-  diff -r 9ecee4f634e3 bye.txt
-  --- a/bye.txt
-  +++ b/bye.txt
-  @@ -1,1 +1,2 @@
-   bye
-  +universe
-  diff -r 9ecee4f634e3 hello.txt
-  --- a/hello.txt
-  +++ b/hello.txt
-  @@ -1,1 +1,3 @@
-   hello
-  +world
-  +universe
-
-
-test popping revisions not in working dir ancestry
-
-  $ hg qseries -v
-  0 A empty
-  $ hg up qparent
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hg qpop
-  popping empty
-  patch queue now empty
-
-  $ cd ..
-  $ hg init deletion-order
-  $ cd deletion-order
-
-  $ touch a
-  $ hg ci -Aqm0
-
-  $ hg qnew rename-dir
-  $ hg rm a
-  $ hg qrefresh
-
-  $ mkdir a b
-  $ touch a/a b/b
-  $ hg add -q a b
-  $ hg qrefresh
-
-
-test popping must remove files added in subdirectories first
-
-  $ hg qpop
-  popping rename-dir
-  patch queue now empty
-  $ cd ..
-
-
-test case preservation through patch pushing especially on case
-insensitive filesystem
-
-  $ hg init casepreserve
-  $ cd casepreserve
-
-  $ hg qnew add-file1
-  $ echo a > TeXtFiLe.TxT
-  $ hg add TeXtFiLe.TxT
-  $ hg qrefresh
-
-  $ hg qnew add-file2
-  $ echo b > AnOtHeRFiLe.TxT
-  $ hg add AnOtHeRFiLe.TxT
-  $ hg qrefresh
-
-  $ hg qnew modify-file
-  $ echo c >> AnOtHeRFiLe.TxT
-  $ hg qrefresh
-
-  $ hg qapplied
-  add-file1
-  add-file2
-  modify-file
-  $ hg qpop -a
-  popping modify-file
-  popping add-file2
-  popping add-file1
-  patch queue now empty
-
-this qpush causes problems below, if case preservation on case
-insensitive filesystem is not enough:
-(1) unexpected "adding ..." messages are shown
-(2) patching fails in modification of (1) files
-
-  $ hg qpush -a
-  applying add-file1
-  applying add-file2
-  applying modify-file
-  now at: modify-file
-
-Proper phase default with mq:
-
-1. mq.secret=false
-
-  $ rm .hg/store/phaseroots
-  $ hg phase 'qparent::'
-  0: draft
-  1: draft
-  2: draft
-  $ echo '[mq]' >> $HGRCPATH
-  $ echo 'secret=true' >> $HGRCPATH
-  $ rm -f .hg/store/phaseroots
-  $ hg phase 'qparent::'
-  0: secret
-  1: secret
-  2: secret
-
-Test that qfinish change phase when mq.secret=true
-
-  $ hg qfinish qbase
-  patch add-file1 finalized without changeset message
-  $ hg phase 'all()'
-  0: draft
-  1: secret
-  2: secret
-
-Test that qfinish respect phases.new-commit setting
-
-  $ echo '[phases]' >> $HGRCPATH
-  $ echo 'new-commit=secret' >> $HGRCPATH
-  $ hg qfinish qbase
-  patch add-file2 finalized without changeset message
-  $ hg phase 'all()'
-  0: draft
-  1: secret
-  2: secret
-
-(restore env for next test)
-
-  $ sed -e 's/new-commit=secret//' $HGRCPATH > $TESTTMP/sedtmp
-  $ cp $TESTTMP/sedtmp $HGRCPATH
-  $ hg qimport -r 1 --name  add-file2
-
-Test that qfinish preserve phase when mq.secret=false
-
-  $ sed -e 's/secret=true/secret=false/' $HGRCPATH > $TESTTMP/sedtmp
-  $ cp $TESTTMP/sedtmp $HGRCPATH
-  $ hg qfinish qbase
-  patch add-file2 finalized without changeset message
-  $ hg phase 'all()'
-  0: draft
-  1: secret
-  2: secret
-
-Test that secret mq patch does not break hgweb
-
-  $ cat > hgweb.cgi <<HGWEB
-  > from mercurial import demandimport; demandimport.enable()
-  > from mercurial.hgweb import hgweb
-  > from mercurial.hgweb import wsgicgi
-  > import cgitb
-  > cgitb.enable()
-  > app = hgweb('.', 'test')
-  > wsgicgi.launch(app)
-  > HGWEB
-  $ . "$TESTDIR/cgienv"
-#if msys
-  $ PATH_INFO=//tags; export PATH_INFO
-#else
-  $ PATH_INFO=/tags; export PATH_INFO
-#endif
-  $ QUERY_STRING='style=raw'
-  $ python hgweb.cgi | grep '^tip'
-  tip	[0-9a-f]{40} (re)
-
-  $ cd ..
diff --git a/tests/test-rebase-mq-skip.t b/tests/test-rebase-mq-skip.t
deleted file mode 100644
--- a/tests/test-rebase-mq-skip.t
+++ /dev/null
@@ -1,139 +0,0 @@ 
-This emulates the effects of an hg pull --rebase in which the remote repo
-already has one local mq patch
-
-  $ cat >> $HGRCPATH <<EOF
-  > [extensions]
-  > graphlog=
-  > rebase=
-  > mq=
-  > 
-  > [phases]
-  > publish=False
-  > 
-  > [alias]
-  > tglog = log -G --template "{rev}: '{desc}' tags: {tags}\n"
-  > EOF
-
-
-  $ hg init a
-  $ cd a
-  $ hg qinit -c
-
-  $ echo c1 > c1
-  $ hg add c1
-  $ hg ci -m C1
-
-  $ echo r1 > r1
-  $ hg add r1
-  $ hg ci -m R1
-
-  $ hg up -q 0
-
-  $ hg qnew p0.patch
-  $ echo p0 > p0
-  $ hg add p0
-  $ hg qref -m P0
-
-  $ hg qnew p1.patch
-  $ echo p1 > p1
-  $ hg add p1
-  $ hg qref -m P1
-
-  $ hg export qtip > p1.patch
-
-  $ hg up -q -C 1
-
-  $ hg import p1.patch
-  applying p1.patch
-
-  $ rm p1.patch
-
-  $ hg up -q -C qtip
-
-  $ hg rebase
-  saved backup bundle to $TESTTMP/a/.hg/strip-backup/*-backup.hg (glob)
-
-  $ hg tglog
-  @  3: 'P0' tags: p0.patch qbase qtip tip
-  |
-  o  2: 'P1' tags: qparent
-  |
-  o  1: 'R1' tags:
-  |
-  o  0: 'C1' tags:
-  
-  $ cd ..
-
-
-  $ hg init b
-  $ cd b
-  $ hg qinit -c
-
-  $ for i in r0 r1 r2 r3 r4 r5 r6;
-  > do
-  >     echo $i > $i
-  >     hg ci -Am $i
-  > done
-  adding r0
-  adding r1
-  adding r2
-  adding r3
-  adding r4
-  adding r5
-  adding r6
-
-  $ hg qimport -r 1:tip
-
-  $ hg up -q 0
-
-  $ for i in r1 r3 r7 r8;
-  > do
-  >     echo $i > $i
-  >     hg ci -Am branch2-$i
-  > done
-  adding r1
-  created new head
-  adding r3
-  adding r7
-  adding r8
-
-  $ echo somethingelse > r4
-  $ hg ci -Am branch2-r4
-  adding r4
-
-  $ echo r6 > r6
-  $ hg ci -Am branch2-r6
-  adding r6
-
-  $ hg up -q qtip
-
-  $ HGMERGE=internal:fail hg rebase
-  abort: unresolved conflicts (see hg resolve, then hg rebase --continue)
-  [255]
-
-  $ HGMERGE=internal:local hg resolve --all
-
-  $ hg rebase --continue
-  saved backup bundle to $TESTTMP/b/.hg/strip-backup/*-backup.hg (glob)
-
-  $ hg tglog
-  @  8: 'r5' tags: 5.diff qtip tip
-  |
-  o  7: 'r2' tags: 2.diff qbase
-  |
-  o  6: 'branch2-r6' tags: qparent
-  |
-  o  5: 'branch2-r4' tags:
-  |
-  o  4: 'branch2-r8' tags:
-  |
-  o  3: 'branch2-r7' tags:
-  |
-  o  2: 'branch2-r3' tags:
-  |
-  o  1: 'branch2-r1' tags:
-  |
-  o  0: 'r0' tags:
-  
-
-  $ cd ..
diff --git a/tests/test-rebase-mq.t b/tests/test-rebase-mq.t
deleted file mode 100644
--- a/tests/test-rebase-mq.t
+++ /dev/null
@@ -1,347 +0,0 @@ 
-  $ cat >> $HGRCPATH <<EOF
-  > [extensions]
-  > graphlog=
-  > rebase=
-  > mq=
-  > 
-  > [mq]
-  > plain=true
-  > 
-  > [alias]
-  > tglog = log -G --template "{rev}: '{desc}' tags: {tags}\n"
-  > EOF
-
-
-  $ hg init a
-  $ cd a
-  $ hg qinit -c
-
-  $ echo c1 > f
-  $ hg add f
-  $ hg ci -m C1
-
-  $ echo r1 > f
-  $ hg ci -m R1
-
-  $ hg up -q 0
-
-  $ hg qnew f.patch
-  $ echo mq1 > f
-  $ hg qref -m P0
-
-  $ hg qnew f2.patch
-  $ echo mq2 > f
-  $ hg qref -m P1
-
-  $ hg tglog
-  @  3: 'P1' tags: f2.patch qtip tip
-  |
-  o  2: 'P0' tags: f.patch qbase
-  |
-  | o  1: 'R1' tags:
-  |/
-  o  0: 'C1' tags: qparent
-  
-
-Rebase - try to rebase on an applied mq patch:
-
-  $ hg rebase -s 1 -d 3
-  abort: cannot rebase onto an applied mq patch
-  [255]
-
-Rebase - same thing, but mq patch is default dest:
-
-  $ hg up -q 1
-  $ hg rebase
-  abort: cannot rebase onto an applied mq patch
-  [255]
-  $ hg up -q qtip
-
-Rebase - generate a conflict:
-
-  $ hg rebase -s 2 -d 1
-  merging f
-  warning: conflicts during merge.
-  merging f incomplete! (edit conflicts, then use 'hg resolve --mark')
-  abort: unresolved conflicts (see hg resolve, then hg rebase --continue)
-  [255]
-
-Fix the 1st conflict:
-
-  $ echo mq1r1 > f
-  $ hg resolve -m f
-  $ hg rebase -c
-  merging f
-  warning: conflicts during merge.
-  merging f incomplete! (edit conflicts, then use 'hg resolve --mark')
-  abort: unresolved conflicts (see hg resolve, then hg rebase --continue)
-  [255]
-
-Fix the 2nd conflict:
-
-  $ echo mq1r1mq2 > f
-  $ hg resolve -m f
-  $ hg rebase -c
-  saved backup bundle to $TESTTMP/a/.hg/strip-backup/*-backup.hg (glob)
-
-  $ hg tglog
-  @  3: 'P1' tags: f2.patch qtip tip
-  |
-  o  2: 'P0' tags: f.patch qbase
-  |
-  o  1: 'R1' tags: qparent
-  |
-  o  0: 'C1' tags:
-  
-  $ hg up -q qbase
-
-  $ cat f
-  mq1r1
-
-  $ cat .hg/patches/f.patch
-  # HG changeset patch
-  # User test
-  # Date ?????????? ? (glob)
-  #      * (glob)
-  # Node ID ???????????????????????????????????????? (glob)
-  # Parent  bac9ed9960d8992bcad75864a879fa76cadaf1b0
-  P0
-  
-  diff -r bac9ed9960d8 -r ???????????? f (glob)
-  --- a/f	Thu Jan 01 00:00:00 1970 +0000
-  +++ b/f	??? ??? ?? ??:??:?? ???? ????? (glob)
-  @@ -1,1 +1,1 @@
-  -r1
-  +mq1r1
-
-Update to qtip:
-
-  $ hg up -q qtip
-
-  $ cat f
-  mq1r1mq2
-
-  $ cat .hg/patches/f2.patch
-  # HG changeset patch
-  # User test
-  # Date ?????????? ? (glob)
-  #      * (glob)
-  # Node ID ???????????????????????????????????????? (glob)
-  # Parent  ???????????????????????????????????????? (glob)
-  P1
-  
-  diff -r ???????????? -r ???????????? f (glob)
-  --- a/f	??? ??? ?? ??:??:?? ???? ????? (glob)
-  +++ b/f	??? ??? ?? ??:??:?? ???? ????? (glob)
-  @@ -1,1 +1,1 @@
-  -mq1r1
-  +mq1r1mq2
-
-Adding one git-style patch and one normal:
-
-  $ hg qpop -a
-  popping f2.patch
-  popping f.patch
-  patch queue now empty
-
-  $ rm -fr .hg/patches
-  $ hg qinit -c
-
-  $ hg up -q 0
-
-  $ hg qnew --git f_git.patch
-  $ echo mq1 > p
-  $ hg add p
-  $ hg qref --git -m 'P0 (git)'
-
-  $ hg qnew f.patch
-  $ echo mq2 > p
-  $ hg qref -m P1
-  $ hg qci -m 'save patch state'
-
-  $ hg qseries -s
-  f_git.patch: P0 (git)
-  f.patch: P1
-
-  $ hg -R .hg/patches manifest
-  .hgignore
-  f.patch
-  f_git.patch
-  series
-
-  $ cat .hg/patches/f_git.patch
-  P0 (git)
-  
-  diff --git a/p b/p
-  new file mode 100644
-  --- /dev/null
-  +++ b/p
-  @@ -0,0 +1,1 @@
-  +mq1
-
-  $ cat .hg/patches/f.patch
-  P1
-  
-  diff -r ???????????? p (glob)
-  --- a/p	??? ??? ?? ??:??:?? ???? ????? (glob)
-  +++ b/p	??? ??? ?? ??:??:?? ???? ????? (glob)
-  @@ -1,1 +1,1 @@
-  -mq1
-  +mq2
-
-
-Rebase the applied mq patches:
-
-  $ hg rebase -s 2 -d 1
-  saved backup bundle to $TESTTMP/a/.hg/strip-backup/*-backup.hg (glob)
-
-  $ hg qci -m 'save patch state'
-
-  $ hg qseries -s
-  f_git.patch: P0 (git)
-  f.patch: P1
-
-  $ hg -R .hg/patches manifest
-  .hgignore
-  f.patch
-  f_git.patch
-  series
-
-  $ cat .hg/patches/f_git.patch
-  # HG changeset patch
-  # User test
-  # Date ?????????? ? (glob)
-  #      * (glob)
-  # Node ID ???????????????????????????????????????? (glob)
-  # Parent  bac9ed9960d8992bcad75864a879fa76cadaf1b0
-  P0 (git)
-  
-  diff --git a/p b/p
-  new file mode 100644
-  --- /dev/null
-  +++ b/p
-  @@ -0,0 +1,1 @@
-  +mq1
-
-  $ cat .hg/patches/f.patch
-  # HG changeset patch
-  # User test
-  # Date ?????????? ? (glob)
-  #      * (glob)
-  # Node ID ???????????????????????????????????????? (glob)
-  # Parent  ???????????????????????????????????????? (glob)
-  P1
-  
-  diff -r ???????????? -r ???????????? p (glob)
-  --- a/p	??? ??? ?? ??:??:?? ???? ????? (glob)
-  +++ b/p	??? ??? ?? ??:??:?? ???? ????? (glob)
-  @@ -1,1 +1,1 @@
-  -mq1
-  +mq2
-
-  $ cd ..
-
-Rebase with guards
-
-  $ hg init foo
-  $ cd foo
-  $ echo a > a
-  $ hg ci -Am a
-  adding a
-
-Create mq repo with guarded patches foo and bar and empty patch:
-
-  $ hg qinit
-  $ echo guarded > guarded
-  $ hg add guarded
-  $ hg qnew guarded
-  $ hg qnew empty-important -m 'important commit message'
-  $ echo bar > bar
-  $ hg add bar
-  $ hg qnew bar
-  $ echo foo > foo
-  $ hg add foo
-  $ hg qnew foo
-  $ hg qpop -a
-  popping foo
-  popping bar
-  popping empty-important
-  popping guarded
-  patch queue now empty
-  $ hg qguard guarded +guarded
-  $ hg qguard bar +baz
-  $ hg qguard foo +baz
-  $ hg qselect baz
-  number of unguarded, unapplied patches has changed from 1 to 3
-  $ hg qpush bar
-  applying empty-important
-  patch empty-important is empty
-  applying bar
-  now at: bar
-
-  $ hg qguard -l
-  guarded: +guarded
-  empty-important: unguarded
-  bar: +baz
-  foo: +baz
-
-  $ hg tglog
-  @  2: 'imported patch bar' tags: bar qtip tip
-  |
-  o  1: 'important commit message' tags: empty-important qbase
-  |
-  o  0: 'a' tags: qparent
-  
-Create new head to rebase bar onto:
-
-  $ hg up -C 0
-  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  $ echo b > b
-  $ hg add b
-  $ hg ci -m b
-  created new head
-  $ hg up -C 2
-  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  $ echo a >> a
-  $ hg qref
-
-  $ hg tglog
-  @  3: '[mq]: bar' tags: bar qtip tip
-  |
-  | o  2: 'b' tags:
-  | |
-  o |  1: 'important commit message' tags: empty-important qbase
-  |/
-  o  0: 'a' tags: qparent
-  
-
-Rebase bar (make sure series order is preserved and empty-important also is
-removed from the series):
-
-  $ hg qseries
-  guarded
-  empty-important
-  bar
-  foo
-  $ [ -f .hg/patches/empty-important ]
-  $ hg -q rebase -d 2
-  $ hg qseries
-  guarded
-  bar
-  foo
-  $ [ -f .hg/patches/empty-important ]
-  [1]
-
-  $ hg qguard -l
-  guarded: +guarded
-  bar: +baz
-  foo: +baz
-
-  $ hg tglog
-  @  2:* '[mq]: bar' tags: bar qbase qtip tip (glob)
-  |
-  o  1:* 'b' tags: qparent (glob)
-  |
-  o  0:* 'a' tags: (glob)
-  
-  $ cd ..