changeset 13008:ac627ab0b3a5

merge with stable
author Martin Geisler <mg@aragost.com>
date Wed, 17 Nov 2010 09:17:55 +0100
parents cffa35529706 (diff) e98bf6948092 (current diff)
children 54be08fa4d1d
files
diffstat 29 files changed, 933 insertions(+), 408 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/check-code.py	Tue Nov 16 21:35:58 2010 +0100
+++ b/contrib/check-code.py	Wed Nov 17 09:17:55 2010 +0100
@@ -118,6 +118,9 @@
      "linebreak after :"),
     (r'class\s[^(]:', "old-style class, use class foo(object)"),
     (r'^\s+del\(', "del isn't a function"),
+    (r'\band\(', "and isn't a function"),
+    (r'\bor\(', "or isn't a function"),
+    (r'\bnot\(', "not isn't a function"),
     (r'^\s+except\(', "except isn't a function"),
     (r',]', "unneeded trailing ',' in list"),
 #    (r'class\s[A-Z][^\(]*\((?!Exception)',
--- a/doc/Makefile	Tue Nov 16 21:35:58 2010 +0100
+++ b/doc/Makefile	Wed Nov 17 09:17:55 2010 +0100
@@ -1,7 +1,8 @@
 SOURCES=$(wildcard *.[0-9].txt)
 MAN=$(SOURCES:%.txt=%)
 HTML=$(SOURCES:%.txt=%.html)
-GENDOC=gendoc.py ../mercurial/commands.py ../mercurial/help.py ../mercurial/help/*.txt
+GENDOC=gendoc.py ../mercurial/commands.py ../mercurial/help.py \
+	../mercurial/help/*.txt ../hgext/*.py ../hgext/*/__init__.py
 PREFIX=/usr/local
 MANDIR=$(PREFIX)/share/man
 INSTALL=install -c -m 644
--- a/hgext/convert/__init__.py	Tue Nov 16 21:35:58 2010 +0100
+++ b/hgext/convert/__init__.py	Wed Nov 17 09:17:55 2010 +0100
@@ -59,10 +59,10 @@
     --sourcesort  try to preserve source revisions order, only
                   supported by Mercurial sources.
 
-    If <REVMAP> isn't given, it will be put in a default location
-    (<dest>/.hg/shamap by default). The <REVMAP> is a simple text file
-    that maps each source commit ID to the destination ID for that
-    revision, like so::
+    If ``REVMAP`` isn't given, it will be put in a default location
+    (``<dest>/.hg/shamap`` by default). The ``REVMAP`` is a simple
+    text file that maps each source commit ID to the destination ID
+    for that revision, like so::
 
       <source ID> <destination ID>
 
@@ -138,15 +138,19 @@
     Mercurial Source
     ''''''''''''''''
 
-    --config convert.hg.ignoreerrors=False    (boolean)
-        ignore integrity errors when reading. Use it to fix Mercurial
-        repositories with missing revlogs, by converting from and to
-        Mercurial.
-    --config convert.hg.saverev=False         (boolean)
-        store original revision ID in changeset (forces target IDs to
-        change)
-    --config convert.hg.startrev=0            (hg revision identifier)
-        convert start revision and its descendants
+    The Mercurial source recognizes the following configuration
+    options, which you can set on the command line with ``--config``:
+
+    :convert.hg.ignoreerrors: ignore integrity errors when reading.
+        Use it to fix Mercurial repositories with missing revlogs, by
+        converting from and to Mercurial. Default is False.
+
+    :convert.hg.saverev: store original. revision ID in changeset
+        (forces target IDs to change). It takes and boolean argument
+        and defaults to False.
+
+    :convert.hg.startrev: convert start revision and its descendants.
+        It takes a hg revision identifier and defaults to 0.
 
     CVS Source
     ''''''''''
@@ -154,42 +158,46 @@
     CVS source will use a sandbox (i.e. a checked-out copy) from CVS
     to indicate the starting point of what will be converted. Direct
     access to the repository files is not needed, unless of course the
-    repository is :local:. The conversion uses the top level directory
-    in the sandbox to find the CVS repository, and then uses CVS rlog
-    commands to find files to convert. This means that unless a
-    filemap is given, all files under the starting directory will be
+    repository is ``:local:``. The conversion uses the top level
+    directory in the sandbox to find the CVS repository, and then uses
+    CVS rlog commands to find files to convert. This means that unless
+    a filemap is given, all files under the starting directory will be
     converted, and that any directory reorganization in the CVS
     sandbox is ignored.
 
-    The options shown are the defaults.
+    The following options can be used with ``--config``:
+
+    :convert.cvsps.cache: Set to False to disable remote log caching,
+        for testing and debugging purposes. Default is True.
+
+    :convert.cvsps.fuzz: Specify the maximum time (in seconds) that is
+        allowed between commits with identical user and log message in
+        a single changeset. When very large files were checked in as
+        part of a changeset then the default may not be long enough.
+        The default is 60.
 
-    --config convert.cvsps.cache=True         (boolean)
-        Set to False to disable remote log caching, for testing and
-        debugging purposes.
-    --config convert.cvsps.fuzz=60            (integer)
-        Specify the maximum time (in seconds) that is allowed between
-        commits with identical user and log message in a single
-        changeset. When very large files were checked in as part of a
-        changeset then the default may not be long enough.
-    --config convert.cvsps.mergeto='{{mergetobranch ([-\\w]+)}}'
-        Specify a regular expression to which commit log messages are
-        matched. If a match occurs, then the conversion process will
-        insert a dummy revision merging the branch on which this log
-        message occurs to the branch indicated in the regex.
-    --config convert.cvsps.mergefrom='{{mergefrombranch ([-\\w]+)}}'
-        Specify a regular expression to which commit log messages are
-        matched. If a match occurs, then the conversion process will
-        add the most recent revision on the branch indicated in the
-        regex as the second parent of the changeset.
-    --config hook.cvslog
-        Specify a Python function to be called at the end of gathering
-        the CVS log. The function is passed a list with the log entries,
-        and can modify the entries in-place, or add or delete them.
-    --config hook.cvschangesets
-        Specify a Python function to be called after the changesets
-        are calculated from the the CVS log. The function is passed
-        a list with the changeset entries, and can modify the changesets
-        in-place, or add or delete them.
+    :convert.cvsps.mergeto: Specify a regular expression to which
+        commit log messages are matched. If a match occurs, then the
+        conversion process will insert a dummy revision merging the
+        branch on which this log message occurs to the branch
+        indicated in the regex. Default is ``{{mergetobranch
+        ([-\\w]+)}}``
+
+    :convert.cvsps.mergefrom: Specify a regular expression to which
+        commit log messages are matched. If a match occurs, then the
+        conversion process will add the most recent revision on the
+        branch indicated in the regex as the second parent of the
+        changeset. Default is ``{{mergefrombranch ([-\\w]+)}}``
+
+    :hook.cvslog: Specify a Python function to be called at the end of
+        gathering the CVS log. The function is passed a list with the
+        log entries, and can modify the entries in-place, or add or
+        delete them.
+
+    :hook.cvschangesets: Specify a Python function to be called after
+        the changesets are calculated from the the CVS log. The
+        function is passed a list with the changeset entries, and can
+        modify the changesets in-place, or add or delete them.
 
     An additional "debugcvsps" Mercurial command allows the builtin
     changeset merging code to be run without doing a conversion. Its
@@ -200,29 +208,33 @@
     '''''''''''''''''
 
     Subversion source detects classical trunk/branches/tags layouts.
-    By default, the supplied "svn://repo/path/" source URL is
-    converted as a single branch. If "svn://repo/path/trunk" exists it
-    replaces the default branch. If "svn://repo/path/branches" exists,
-    its subdirectories are listed as possible branches. If
-    "svn://repo/path/tags" exists, it is looked for tags referencing
-    converted branches. Default "trunk", "branches" and "tags" values
-    can be overridden with following options. Set them to paths
+    By default, the supplied ``svn://repo/path/`` source URL is
+    converted as a single branch. If ``svn://repo/path/trunk`` exists
+    it replaces the default branch. If ``svn://repo/path/branches``
+    exists, its subdirectories are listed as possible branches. If
+    ``svn://repo/path/tags`` exists, it is looked for tags referencing
+    converted branches. Default ``trunk``, ``branches`` and ``tags``
+    values can be overridden with following options. Set them to paths
     relative to the source URL, or leave them blank to disable auto
     detection.
 
-    --config convert.svn.branches=branches    (directory name)
-        specify the directory containing branches
-    --config convert.svn.tags=tags            (directory name)
-        specify the directory containing tags
-    --config convert.svn.trunk=trunk          (directory name)
-        specify the name of the trunk branch
+    The following options can be set with ``--config``:
+
+    :convert.svn.branches: specify the directory containing branches.
+        The defaults is ``branches``.
+
+    :convert.svn.tags: specify the directory containing tags. The
+        default is ``tags``.
+
+    :convert.svn.trunk: specify the name of the trunk branch The
+        defauls is ``trunk``.
 
     Source history can be retrieved starting at a specific revision,
     instead of being integrally converted. Only single branch
     conversions are supported.
 
-    --config convert.svn.startrev=0           (svn revision number)
-        specify start Subversion revision.
+    :convert.svn.startrev: specify start Subversion revision number.
+        The default is 0.
 
     Perforce Source
     '''''''''''''''
@@ -232,24 +244,27 @@
     source to a flat Mercurial repository, ignoring labels, branches
     and integrations. Note that when a depot path is given you then
     usually should specify a target directory, because otherwise the
-    target may be named ...-hg.
+    target may be named ``...-hg``.
 
     It is possible to limit the amount of source history to be
-    converted by specifying an initial Perforce revision.
+    converted by specifying an initial Perforce revision:
 
-    --config convert.p4.startrev=0            (perforce changelist number)
-        specify initial Perforce revision.
+    :convert.p4.startrev: specify initial Perforce revision, a
+        Perforce changelist number).
 
     Mercurial Destination
     '''''''''''''''''''''
 
-    --config convert.hg.clonebranches=False   (boolean)
-        dispatch source branches in separate clones.
-    --config convert.hg.tagsbranch=default    (branch name)
-        tag revisions branch name
-    --config convert.hg.usebranchnames=True   (boolean)
-        preserve branch names
+    The following options are supported:
+
+    :convert.hg.clonebranches: dispatch source branches in separate
+        clones. The default is False.
 
+    :convert.hg.tagsbranch: branch name for tag revisions, defaults to
+        ``default``.
+
+    :convert.hg.usebranchnames: preserve branch names. The default is
+        True
     """
     return convcmd.convert(ui, src, dest, revmapfile, **opts)
 
--- a/hgext/eol.py	Tue Nov 16 21:35:58 2010 +0100
+++ b/hgext/eol.py	Wed Nov 17 09:17:55 2010 +0100
@@ -61,6 +61,11 @@
   Such files are normally not touched under the assumption that they
   have mixed EOLs on purpose.
 
+The extension provides ``cleverencode:`` and ``cleverdecode:`` filters
+like the deprecated win32text extension does. This means that you can
+disable win32text and enable eol and your filters will still work. You
+only need to these filters until you have prepared a ``.hgeol`` file.
+
 The ``win32text.forbid*`` hooks provided by the win32text extension
 have been unified into a single hook named ``eol.hook``. The hook will
 lookup the expected line endings from the ``.hgeol`` file, which means
@@ -109,6 +114,9 @@
     'to-lf': tolf,
     'to-crlf': tocrlf,
     'is-binary': isbinary,
+    # The following provide backwards compatibility with win32text
+    'cleverencode:': tolf,
+    'cleverdecode:': tocrlf
 }
 
 
--- a/hgext/keyword.py	Tue Nov 16 21:35:58 2010 +0100
+++ b/hgext/keyword.py	Wed Nov 17 09:17:55 2010 +0100
@@ -170,14 +170,25 @@
                                   for k, v in kwmaps)
         else:
             self.templates = _defaultkwmaps(self.ui)
-        escaped = '|'.join(map(re.escape, self.templates.keys()))
-        self.re_kw = re.compile(r'\$(%s)\$' % escaped)
-        self.re_kwexp = re.compile(r'\$(%s): [^$\n\r]*? \$' % escaped)
-
         templatefilters.filters.update({'utcdate': utcdate,
                                         'svnisodate': svnisodate,
                                         'svnutcdate': svnutcdate})
 
+    @util.propertycache
+    def escape(self):
+        '''Returns bar-separated and escaped keywords.'''
+        return '|'.join(map(re.escape, self.templates.keys()))
+
+    @util.propertycache
+    def rekw(self):
+        '''Returns regex for unexpanded keywords.'''
+        return re.compile(r'\$(%s)\$' % self.escape)
+
+    @util.propertycache
+    def rekwexp(self):
+        '''Returns regex for expanded keywords.'''
+        return re.compile(r'\$(%s): [^$\n\r]*? \$' % self.escape)
+
     def substitute(self, data, path, ctx, subfunc):
         '''Replaces keywords in data with expanded template.'''
         def kwsub(mobj):
@@ -191,11 +202,15 @@
             return '$%s: %s $' % (kw, ekw)
         return subfunc(kwsub, data)
 
+    def linkctx(self, path, fileid):
+        '''Similar to filelog.linkrev, but returns a changectx.'''
+        return self.repo.filectx(path, fileid=fileid).changectx()
+
     def expand(self, path, node, data):
         '''Returns data with keywords expanded.'''
         if not self.restrict and self.match(path) and not util.binary(data):
-            ctx = self.repo.filectx(path, fileid=node).changectx()
-            return self.substitute(data, path, ctx, self.re_kw.sub)
+            ctx = self.linkctx(path, node)
+            return self.substitute(data, path, ctx, self.rekw.sub)
         return data
 
     def iskwfile(self, cand, ctx):
@@ -212,8 +227,8 @@
         kwcmd = self.restrict and lookup # kwexpand/kwshrink
         if self.restrict or expand and lookup:
             mf = ctx.manifest()
-        fctx = ctx
-        subn = (self.restrict or rekw) and self.re_kw.subn or self.re_kwexp.subn
+        lctx = ctx
+        re_kw = (self.restrict or rekw) and self.rekw or self.rekwexp
         msg = (expand and _('overwriting %s expanding keywords\n')
                or _('overwriting %s shrinking keywords\n'))
         for f in candidates:
@@ -225,12 +240,12 @@
                 continue
             if expand:
                 if lookup:
-                    fctx = self.repo.filectx(f, fileid=mf[f]).changectx()
-                data, found = self.substitute(data, f, fctx, subn)
+                    lctx = self.linkctx(f, mf[f])
+                data, found = self.substitute(data, f, lctx, re_kw.subn)
             elif self.restrict:
-                found = self.re_kw.search(data)
+                found = re_kw.search(data)
             else:
-                data, found = _shrinktext(data, subn)
+                data, found = _shrinktext(data, re_kw.subn)
             if found:
                 self.ui.note(msg % f)
                 self.repo.wwrite(f, data, ctx.flags(f))
@@ -242,7 +257,7 @@
     def shrink(self, fname, text):
         '''Returns text with all keyword substitutions removed.'''
         if self.match(fname) and not util.binary(text):
-            return _shrinktext(text, self.re_kwexp.sub)
+            return _shrinktext(text, self.rekwexp.sub)
         return text
 
     def shrinklines(self, fname, lines):
@@ -250,7 +265,7 @@
         if self.match(fname):
             text = ''.join(lines)
             if not util.binary(text):
-                return _shrinktext(text, self.re_kwexp.sub).splitlines(True)
+                return _shrinktext(text, self.rekwexp.sub).splitlines(True)
         return lines
 
     def wread(self, fname, data):
--- a/hgext/mq.py	Tue Nov 16 21:35:58 2010 +0100
+++ b/hgext/mq.py	Wed Nov 17 09:17:55 2010 +0100
@@ -1270,10 +1270,10 @@
             # and then commit.
             #
             # this should really read:
-            #   mm, dd, aa, aa2 = repo.status(tip, patchparent)[:4]
+            #   mm, dd, aa = repo.status(top, patchparent)[:3]
             # but we do it backwards to take advantage of manifest/chlog
             # caching against the next repo.status call
-            mm, aa, dd, aa2 = repo.status(patchparent, top)[:4]
+            mm, aa, dd = repo.status(patchparent, top)[:3]
             changes = repo.changelog.read(top)
             man = repo.manifest.read(changes[0])
             aaa = aa[:]
@@ -1289,6 +1289,9 @@
             else:
                 match = cmdutil.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
@@ -1296,31 +1299,31 @@
             # show up in the added section
             for x in m:
                 if x not in aa:
-                    mm.append(x)
+                    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:
-                    del dd[dd.index(x)]
-                    mm.append(x)
+                    dd.remove(x)
+                    mm.add(x)
                 else:
-                    aa.append(x)
+                    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:
-                    del aa[aa.index(x)]
+                    aa.remove(x)
                     forget.append(x)
                     continue
-                elif x in mm:
-                    del mm[mm.index(x)]
-                dd.append(x)
-
-            m = list(set(mm))
-            r = list(set(dd))
-            a = list(set(aa))
+                else:
+                    mm.discard(x)
+                dd.add(x)
+
+            m = list(mm)
+            r = list(dd)
+            a = list(aa)
             c = [filter(matchfn, l) for l in (m, a, r)]
             match = cmdutil.matchfiles(repo, set(c[0] + c[1] + c[2]))
             chunks = patch.diff(repo, patchparent, match=match,
--- a/i18n/da.po	Tue Nov 16 21:35:58 2010 +0100
+++ b/i18n/da.po	Wed Nov 17 09:17:55 2010 +0100
@@ -17,8 +17,8 @@
 msgstr ""
 "Project-Id-Version: Mercurial\n"
 "Report-Msgid-Bugs-To: <mercurial-devel@selenic.com>\n"
-"POT-Creation-Date: 2010-10-28 09:50+0200\n"
-"PO-Revision-Date: 2010-10-28 10:01+0200\n"
+"POT-Creation-Date: 2010-11-01 11:03+0100\n"
+"PO-Revision-Date: 2010-11-01 11:11+0100\n"
 "Last-Translator: <mg@lazybytes.net>\n"
 "Language-Team: Danish\n"
 "MIME-Version: 1.0\n"
@@ -3396,6 +3396,10 @@
 msgstr "\"%s\" kan ikke bruges som navnet på en rettelse"
 
 #, python-format
+msgid "\"%s\" already exists as a directory"
+msgstr "\"%s\" eksisterer allerede som et katalog"
+
+#, python-format
 msgid "patch \"%s\" already exists"
 msgstr "rettelsen \"%s\" findes allerede"
 
@@ -3403,6 +3407,10 @@
 msgstr "kan ikke håndtere sammenføjninger"
 
 #, python-format
+msgid "cannot write patch \"%s\": %s"
+msgstr "kan ikke skrive patch \"%s\": %s"
+
+#, python-format
 msgid "error unlinking %s\n"
 msgstr "fejl ved sletning af %s\n"
 
@@ -4723,10 +4731,10 @@
 
 msgid ""
 "  [pager]\n"
-"  pager = LESS='FSRX' less"
+"  pager = less -FRSX"
 msgstr ""
 "  [pager]\n"
-"  pager = LESS='FSRX' less"
+"  pager = less -FRSX"
 
 msgid ""
 "If no pager is set, the pager extensions uses the environment variable\n"
@@ -4734,18 +4742,6 @@
 msgstr ""
 
 msgid ""
-"By default, the pager is only executed if a command has output. To\n"
-"force the pager to run even if a command prints nothing, set::"
-msgstr ""
-
-msgid ""
-"  [pager]\n"
-"  force = True"
-msgstr ""
-"  [pager]\n"
-"  force = True"
-
-msgid ""
 "If you notice \"BROKEN PIPE\" error messages, you can disable them by\n"
 "setting::"
 msgstr ""
@@ -6225,6 +6221,12 @@
 msgstr "noterer fjernelse af %s som en omdøbning til %s (%d%% lighed)\n"
 
 #, python-format
+msgid "%s has not been committed yet, so no copy data will be stored for %s.\n"
+msgstr ""
+"%s er endnu ikke comitted, så der vil ikke blive gemt kopieringsdata for %"
+"s.\n"
+
+#, python-format
 msgid "%s: not copying - file is not managed\n"
 msgstr "%s: kopierer ikke - filen er ikke versionsstyret\n"
 
@@ -6264,12 +6266,6 @@
 msgid "copying %s to %s\n"
 msgstr "kopierer %s til %s\n"
 
-#, python-format
-msgid "%s has not been committed yet, so no copy data will be stored for %s.\n"
-msgstr ""
-"%s er endnu ikke comitted, så der vil ikke blive gemt kopieringsdata for %"
-"s.\n"
-
 msgid "no source or destination specified"
 msgstr "ingen kilde eller destination angivet"
 
@@ -9355,6 +9351,9 @@
 msgid "[PATH]"
 msgstr "[STI]"
 
+msgid "revlog format"
+msgstr ""
+
 msgid "REPO NAMESPACE [KEY OLD NEW]"
 msgstr ""
 
@@ -12984,10 +12983,10 @@
 
 #, python-format
 msgid "can't use %s here"
-msgstr ""
+msgstr "kan ikke bruge %s her"
 
 msgid "can't use a list in this context"
-msgstr ""
+msgstr "en liste kan ikke bruges i denne konteks"
 
 #, python-format
 msgid "not a function: %s"
@@ -13004,7 +13003,7 @@
 
 #. i18n: "id" is a keyword
 msgid "id requires a string"
-msgstr ""
+msgstr "id kræver en streng"
 
 msgid ""
 "``rev(number)``\n"
@@ -13013,11 +13012,11 @@
 
 #. i18n: "rev" is a keyword
 msgid "rev requires one argument"
-msgstr ""
+msgstr "rev kræver et argument"
 
 #. i18n: "rev" is a keyword
 msgid "rev requires a number"
-msgstr ""
+msgstr "rev kræver et tal"
 
 #. i18n: "rev" is a keyword
 msgid "rev expects a number"
@@ -13298,20 +13297,23 @@
 "``tag(name)``\n"
 "    The specified tag by name, or all tagged revisions if no name is given."
 msgstr ""
+"``tag(navn)``\n"
+"    Den navngivne mærkat eller alle revisioner med en mærkat hvis der\n"
+"    ikke angives noget navn."
 
 #. i18n: "tag" is a keyword
 msgid "tag takes one or no arguments"
-msgstr ""
+msgstr "tag tager et eller to argumenter"
 
 #. i18n: "tag" is a keyword
 msgid "the argument to tag must be a string"
-msgstr ""
+msgstr "argumentet til tag skal være en streng"
 
 msgid "can't negate that"
 msgstr ""
 
 msgid "not a symbol"
-msgstr ""
+msgstr "ikke et symbol"
 
 msgid "empty query"
 msgstr "tomt forespørgsel"
@@ -13560,11 +13562,11 @@
 msgstr "certifikatet er for %s"
 
 msgid "no commonName found in certificate"
-msgstr ""
+msgstr "fandt ikke noget commonName i certifikatet"
 
 #, python-format
 msgid "%s certificate error: %s"
-msgstr ""
+msgstr "%s certifikatfejl: %s"
 
 #, python-format
 msgid "command '%s' failed: %s"
@@ -13647,7 +13649,7 @@
 
 #, python-format
 msgid "no port number associated with service '%s'"
-msgstr ""
+msgstr "der er ikke knyttet noget portnummer til servicen '%s'"
 
 msgid "cannot verify bundle or remote repos"
 msgstr "kan ikke verificere bundt eller fjerndepoter"
@@ -13704,7 +13706,7 @@
 msgstr "duplikeret revision %d (%d)"
 
 msgid "abandoned transaction found - run hg recover\n"
-msgstr ""
+msgstr "fandt efterladt transaktion - kør hg recover\n"
 
 #, python-format
 msgid "repository uses revlog format %d\n"
@@ -13738,7 +13740,7 @@
 msgstr "krydstjekker filer i ændringer og manifester\n"
 
 msgid "crosschecking"
-msgstr ""
+msgstr "krydstjekker"
 
 #, python-format
 msgid "changeset refers to unknown manifest %s"
@@ -13766,7 +13768,7 @@
 
 #, python-format
 msgid "%s not in manifests"
-msgstr ""
+msgstr "%s findes ikke i manifestet"
 
 #, python-format
 msgid "unpacked size is %s, %s expected"
--- a/mercurial/cmdutil.py	Tue Nov 16 21:35:58 2010 +0100
+++ b/mercurial/cmdutil.py	Wed Nov 17 09:17:55 2010 +0100
@@ -147,6 +147,11 @@
         # attempt to parse old-style ranges first to deal with
         # things like old-tag which contain query metacharacters
         try:
+            if isinstance(spec, int):
+                seen.add(spec)
+                l.append(spec)
+                continue
+
             if revrangesep in spec:
                 start, end = spec.split(revrangesep, 1)
                 start = revfix(repo, start, 0)
--- a/mercurial/commands.py	Tue Nov 16 21:35:58 2010 +0100
+++ b/mercurial/commands.py	Wed Nov 17 09:17:55 2010 +0100
@@ -126,7 +126,7 @@
         lastfunc = funcmap[-1]
         funcmap[-1] = lambda x: "%s:%s" % (lastfunc(x), x[1])
 
-    ctx = repo[opts.get('rev')]
+    ctx = cmdutil.revsingle(repo, opts.get('rev'))
     m = cmdutil.match(repo, pats, opts)
     follow = not opts.get('no_follow')
     for abs in ctx.walk(m):
@@ -178,7 +178,7 @@
     Returns 0 on success.
     '''
 
-    ctx = repo[opts.get('rev')]
+    ctx = cmdutil.revsingle(repo, opts.get('rev'))
     if not ctx:
         raise util.Abort(_('no working directory: please specify a revision'))
     node = ctx.node()
@@ -243,7 +243,7 @@
         opts['date'] = util.parsedate(date)
 
     cmdutil.bail_if_changed(repo)
-    node = repo.lookup(rev)
+    node = cmdutil.revsingle(repo, rev).node()
 
     op1, op2 = repo.dirstate.parents()
     a = repo.changelog.ancestor(op1, node)
@@ -408,7 +408,8 @@
                     raise util.Abort(_("%s killed") % command)
                 else:
                     transition = "bad"
-                ctx = repo[rev or '.']
+                ctx = cmdutil.revsingle(repo, rev)
+                rev = None # clear for future iterations
                 state[transition].append(ctx.node())
                 ui.status(_('Changeset %d:%s: %s\n') % (ctx, ctx, transition))
                 check_state(state, interactive=False)
@@ -572,11 +573,14 @@
 
     Returns 0 on success, 1 if no changes found.
     """
-    revs = opts.get('rev') or None
+    revs = None
+    if 'rev' in opts:
+        revs = cmdutil.revrange(repo, opts['rev'])
+
     if opts.get('all'):
         base = ['null']
     else:
-        base = opts.get('base')
+        base = cmdutil.revrange(repo, opts.get('base'))
     if base:
         if dest:
             raise util.Abort(_("--base is incompatible with specifying "
@@ -1026,7 +1030,7 @@
 
 def debugrebuildstate(ui, repo, rev="tip"):
     """rebuild the dirstate as it would look like for the given revision"""
-    ctx = repo[rev]
+    ctx = cmdutil.revsingle(repo, rev)
     wlock = repo.wlock()
     try:
         repo.dirstate.rebuild(ctx.node(), ctx.manifest())
@@ -1116,7 +1120,7 @@
         key, old, new = keyinfo
         r = target.pushkey(namespace, key, old, new)
         ui.status(str(r) + '\n')
-        return not(r)
+        return not r
     else:
         for k, v in target.listkeys(namespace).iteritems():
             ui.write("%s\t%s\n" % (k.encode('string-escape'),
@@ -1140,12 +1144,12 @@
     Returns 0 on success.
     """
 
-    if not rev2:
-        rev2 = hex(nullid)
+    r1 = cmdutil.revsingle(repo, rev1).node()
+    r2 = cmdutil.revsingle(repo, rev2, 'null').node()
 
     wlock = repo.wlock()
     try:
-        repo.dirstate.setparents(repo.lookup(rev1), repo.lookup(rev2))
+        repo.dirstate.setparents(r1, r2)
     finally:
         wlock.release()
 
@@ -1174,9 +1178,8 @@
         ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
 
 def debugsub(ui, repo, rev=None):
-    if rev == '':
-        rev = None
-    for k, v in sorted(repo[rev].substate.items()):
+    ctx = cmdutil.revsingle(repo, rev, None)
+    for k, v in sorted(ctx.substate.items()):
         ui.write('path %s\n' % k)
         ui.write(' source   %s\n' % v[0])
         ui.write(' revision %s\n' % v[1])
@@ -1435,7 +1438,7 @@
 def debugrename(ui, repo, file1, *pats, **opts):
     """dump rename information"""
 
-    ctx = repo[opts.get('rev')]
+    ctx = cmdutil.revsingle(repo, opts.get('rev'))
     m = cmdutil.match(repo, (file1,) + pats, opts)
     for abs in ctx.walk(m):
         fctx = ctx[abs]
@@ -1808,10 +1811,9 @@
     Returns 0 if matching heads are found, 1 if not.
     """
 
-    if opts.get('rev'):
-        start = repo.lookup(opts['rev'])
-    else:
-        start = None
+    start = None
+    if 'rev' in opts:
+        start = cmdutil.revsingle(repo, opts['rev'], None).node()
 
     if opts.get('topo'):
         heads = [repo[h] for h in repo.heads(start)]
@@ -2200,7 +2202,7 @@
             output.append("%s%s" % ('+'.join([str(p.rev()) for p in parents]),
                                     (changed) and "+" or ""))
     else:
-        ctx = repo[rev]
+        ctx = cmdutil.revsingle(repo, rev)
         if default or id:
             output = [hexfunc(ctx.node())]
         if num:
@@ -2279,6 +2281,7 @@
     d = opts["base"]
     strip = opts["strip"]
     wlock = lock = None
+    msgs = []
 
     def tryone(ui, hunk):
         tmpname, message, user, date, branch, nodeid, p1, p2 = \
@@ -2329,7 +2332,10 @@
             finally:
                 files = cmdutil.updatedir(ui, repo, files,
                                           similarity=sim / 100.0)
-            if not opts.get('no_commit'):
+            if opts.get('no_commit'):
+                if message:
+                    msgs.append(message)
+            else:
                 if opts.get('exact'):
                     m = None
                 else:
@@ -2378,6 +2384,8 @@
             if not haspatch:
                 raise util.Abort(_('no diffs found'))
 
+        if msgs:
+            repo.opener('last-message.txt', 'wb').write('\n* * *\n'.join(msgs))
     finally:
         release(lock, wlock)
 
@@ -2437,7 +2445,7 @@
     Returns 0 if a match is found, 1 otherwise.
     """
     end = opts.get('print0') and '\0' or '\n'
-    rev = opts.get('rev') or None
+    rev = cmdutil.revsingle(repo, opts.get('rev'), None).node()
 
     ret = 1
     m = cmdutil.match(repo, pats, opts, default='relglob')
@@ -2572,7 +2580,7 @@
         node = rev
 
     decor = {'l':'644 @ ', 'x':'755 * ', '':'644   '}
-    ctx = repo[node]
+    ctx = cmdutil.revsingle(repo, node)
     for f in ctx:
         if ui.debugflag:
             ui.write("%40s " % hex(ctx.manifest()[f]))
@@ -2641,6 +2649,8 @@
             raise util.Abort(_('working dir not at a head rev - '
                                'use "hg update" or merge with an explicit rev'))
         node = parent == bheads[0] and bheads[-1] or bheads[0]
+    else:
+        node = cmdutil.revsingle(repo, node).node()
 
     if opts.get('preview'):
         # find nodes that are ancestors of p2 but not of p1
@@ -2686,11 +2696,8 @@
 
     Returns 0 on success.
     """
-    rev = opts.get('rev')
-    if rev:
-        ctx = repo[rev]
-    else:
-        ctx = repo[None]
+
+    ctx = cmdutil.revsingle(repo, opts.get('rev'), None)
 
     if file_:
         m = cmdutil.match(repo, (file_,), opts)
@@ -3106,7 +3113,7 @@
     if not opts.get('rev') and p2 != nullid:
         raise util.Abort(_('uncommitted merge - please provide a '
                            'specific revision'))
-    ctx = repo[opts.get('rev')]
+    ctx = cmdutil.revsingle(repo, opts.get('rev'))
     node = ctx.node()
     mf = ctx.manifest()
     if node == parent:
@@ -3715,7 +3722,7 @@
     if not rev_ and repo.dirstate.parents()[1] != nullid:
         raise util.Abort(_('uncommitted merge - please provide a '
                            'specific revision'))
-    r = repo[rev_].node()
+    r = cmdutil.revsingle(repo, rev_).node()
 
     if not message:
         # we don't translate commit messages
--- a/mercurial/context.py	Tue Nov 16 21:35:58 2010 +0100
+++ b/mercurial/context.py	Wed Nov 17 09:17:55 2010 +0100
@@ -603,6 +603,9 @@
     def __str__(self):
         return str(self._parents[0]) + "+"
 
+    def __repr__(self):
+        return "<workingctx %s>" % str(self)
+
     def __nonzero__(self):
         return True
 
@@ -902,6 +905,9 @@
     def __str__(self):
         return "%s@%s" % (self.path(), self._changectx)
 
+    def __repr__(self):
+        return "<workingfilectx %s>" % str(self)
+
     def data(self):
         return self._repo.wread(self._path)
     def renamed(self):
--- a/mercurial/demandimport.py	Tue Nov 16 21:35:58 2010 +0100
+++ b/mercurial/demandimport.py	Wed Nov 17 09:17:55 2010 +0100
@@ -111,7 +111,7 @@
             mod = getattr(mod, comp)
         for x in fromlist:
             # set requested submodules for demand load
-            if not(hasattr(mod, x)):
+            if not hasattr(mod, x):
                 setattr(mod, x, _demandmod(x, mod.__dict__, locals))
         return mod
 
--- a/mercurial/discovery.py	Tue Nov 16 21:35:58 2010 +0100
+++ b/mercurial/discovery.py	Wed Nov 17 09:17:55 2010 +0100
@@ -220,8 +220,6 @@
             # - a local outgoing head descended from update
             # - a remote head that's known locally and not
             #   ancestral to an outgoing head
-            #
-            # New named branches cannot be created without --force.
 
             # 1. Create set of branches involved in the push.
             branches = set(repo[n].branch() for n in outg)
@@ -280,20 +278,30 @@
 
         # 5. Check for new heads.
         # If there are more heads after the push than before, a suitable
-        # warning, depending on unsynced status, is displayed.
+        # error message, depending on unsynced status, is displayed.
+        error = None
         for branch in branches:
-            if len(newmap[branch]) > len(oldmap[branch]):
+            newhs = set(newmap[branch])
+            oldhs = set(oldmap[branch])
+            if len(newhs) > len(oldhs):
+                if error is None:
+                    if branch:
+                        error = _("push creates new remote heads "
+                                  "on branch '%s'!") % branch
+                    else:
+                        error = _("push creates new remote heads!")
+                    if branch in unsynced:
+                        hint = _("you should pull and merge or "
+                                 "use push -f to force")
+                    else:
+                        hint = _("did you forget to merge? "
+                                 "use push -f to force")
                 if branch:
-                    msg = _("push creates new remote heads "
-                            "on branch '%s'!") % branch
-                else:
-                    msg = _("push creates new remote heads!")
-
-                if branch in unsynced:
-                    hint = _("you should pull and merge or use push -f to force")
-                else:
-                    hint = _("did you forget to merge? use push -f to force")
-                raise util.Abort(msg, hint=hint)
+                    repo.ui.debug("new remote heads on branch '%s'\n" % branch)
+                for h in (newhs - oldhs):
+                    repo.ui.debug("new remote head %s\n" % short(h))
+        if error:
+            raise util.Abort(error, hint=hint)
 
         # 6. Check for unsynced changes on involved branches.
         if unsynced:
--- a/mercurial/localrepo.py	Tue Nov 16 21:35:58 2010 +0100
+++ b/mercurial/localrepo.py	Wed Nov 17 09:17:55 2010 +0100
@@ -1207,8 +1207,7 @@
     def heads(self, start=None):
         heads = self.changelog.heads(start)
         # sort the output in rev descending order
-        heads = [(-self.changelog.rev(h), h) for h in heads]
-        return [n for (r, n) in sorted(heads)]
+        return  sorted(heads, key=self.changelog.rev, reverse=True)
 
     def branchheads(self, branch=None, start=None, closed=False):
         '''return a (possibly filtered) list of heads for the given branch
--- a/mercurial/minirst.py	Tue Nov 16 21:35:58 2010 +0100
+++ b/mercurial/minirst.py	Wed Nov 17 09:17:55 2010 +0100
@@ -14,27 +14,8 @@
 are just indented blocks that look like they are nested. This relies
 on the user to keep the right indentation for the blocks.
 
-It only supports a small subset of reStructuredText:
-
-- sections
-
-- paragraphs
-
-- literal blocks
-
-- definition lists
-
-- specific admonitions
-
-- bullet lists (items must start with '-')
-
-- enumerated lists (no autonumbering)
-
-- field lists (colons cannot be escaped)
-
-- option lists (supports only long options without arguments)
-
-- inline literals (no other inline markup is not recognized)
+Remember to update http://mercurial.selenic.com/wiki/HelpStyleGuide
+when adding support for new constructs.
 """
 
 import re, sys
@@ -299,6 +280,8 @@
         b = blocks[i]
         if b['type'] == 'paragraph' and b['lines'][0].startswith('.. '):
             del blocks[i]
+            if i < len(blocks) and blocks[i]['type'] == 'margin':
+                del blocks[i]
         else:
             i += 1
     return blocks
@@ -416,8 +399,8 @@
     blocks = hgrole(blocks)
     blocks = splitparagraphs(blocks)
     blocks = updatefieldlists(blocks)
+    blocks = addmargins(blocks)
     blocks = prunecomments(blocks)
-    blocks = addmargins(blocks)
     blocks = findadmonitions(blocks)
     text = '\n'.join(formatblock(b, width) for b in blocks)
     if keep is None:
@@ -444,7 +427,7 @@
     blocks = debug(splitparagraphs, blocks)
     blocks = debug(updatefieldlists, blocks)
     blocks = debug(findsections, blocks)
+    blocks = debug(addmargins, blocks)
     blocks = debug(prunecomments, blocks)
-    blocks = debug(addmargins, blocks)
     blocks = debug(findadmonitions, blocks)
     print '\n'.join(formatblock(b, 30) for b in blocks)
--- a/mercurial/patch.py	Tue Nov 16 21:35:58 2010 +0100
+++ b/mercurial/patch.py	Wed Nov 17 09:17:55 2010 +0100
@@ -974,7 +974,7 @@
     fp.seek(pos)
     return gitpatches
 
-def iterhunks(ui, fp, sourcefile=None):
+def iterhunks(ui, fp):
     """Read a patch and yield the following events:
     - ("file", afile, bfile, firsthunk): select a new target file.
     - ("hunk", hunk): a new hunk is ready to be applied, follows a
@@ -995,10 +995,6 @@
     BFILE = 1
     context = None
     lr = linereader(fp)
-    # gitworkdone is True if a git operation (copy, rename, ...) was
-    # performed already for the current file. Useful when the file
-    # section may have no hunk.
-    gitworkdone = False
 
     while True:
         newfile = newgitfile = False
@@ -1010,7 +1006,7 @@
                 current_hunk.fix_newline()
             yield 'hunk', current_hunk
             current_hunk = None
-        if ((sourcefile or state == BFILE) and ((not context and x[0] == '@') or
+        if (state == BFILE and ((not context and x[0] == '@') or
             ((context is not False) and x.startswith('***************')))):
             if context is None and x.startswith('***************'):
                 context = True
@@ -1032,7 +1028,6 @@
         elif x.startswith('diff --git'):
             # check for git diff, scanning the whole patch file if needed
             m = gitre.match(x)
-            gitworkdone = False
             if m:
                 afile, bfile = m.group(1, 2)
                 if not git:
@@ -1047,7 +1042,6 @@
                 if gp and (gp.op in ('COPY', 'DELETE', 'RENAME', 'ADD')
                            or gp.mode):
                     afile = bfile
-                    gitworkdone = True
                 newgitfile = True
         elif x.startswith('---'):
             # check for a unified diff
@@ -1075,9 +1069,6 @@
             afile = parsefilename(x)
             bfile = parsefilename(l2)
 
-        if newfile:
-            gitworkdone = False
-
         if newgitfile or newfile:
             emitfile = True
             state = BFILE
@@ -1089,7 +1080,7 @@
             raise PatchError(_("malformed patch %s %s") % (afile,
                              current_hunk.desc))
 
-def applydiff(ui, fp, changed, strip=1, sourcefile=None, eolmode='strict'):
+def applydiff(ui, fp, changed, strip=1, eolmode='strict'):
     """Reads a patch from fp and tries to apply it.
 
     The dict 'changed' is filled in with all of the filenames changed
@@ -1103,13 +1094,10 @@
     Callers probably want to call 'cmdutil.updatedir' after this to
     apply certain categories of changes not done by this function.
     """
-    return _applydiff(
-        ui, fp, patchfile, copyfile,
-        changed, strip=strip, sourcefile=sourcefile, eolmode=eolmode)
+    return _applydiff(ui, fp, patchfile, copyfile, changed, strip=strip,
+                      eolmode=eolmode)
 
-
-def _applydiff(ui, fp, patcher, copyfn, changed, strip=1,
-               sourcefile=None, eolmode='strict'):
+def _applydiff(ui, fp, patcher, copyfn, changed, strip=1, eolmode='strict'):
     rejects = 0
     err = 0
     current_file = None
@@ -1124,7 +1112,7 @@
         current_file.write_rej()
         return len(current_file.rej)
 
-    for state, values in iterhunks(ui, fp, sourcefile):
+    for state, values in iterhunks(ui, fp):
         if state == 'hunk':
             if not current_file:
                 continue
@@ -1137,14 +1125,10 @@
             rejects += closefile()
             afile, bfile, first_hunk = values
             try:
-                if sourcefile:
-                    current_file = patcher(ui, sourcefile, opener,
-                                           eolmode=eolmode)
-                else:
-                    current_file, missing = selectfile(afile, bfile,
-                                                       first_hunk, strip)
-                    current_file = patcher(ui, current_file, opener,
-                                           missing=missing, eolmode=eolmode)
+                current_file, missing = selectfile(afile, bfile,
+                                                   first_hunk, strip)
+                current_file = patcher(ui, current_file, opener,
+                                       missing=missing, eolmode=eolmode)
             except PatchError, err:
                 ui.warn(str(err) + '\n')
                 current_file = None
--- a/mercurial/revset.py	Tue Nov 16 21:35:58 2010 +0100
+++ b/mercurial/revset.py	Wed Nov 17 09:17:55 2010 +0100
@@ -202,9 +202,13 @@
     return [r for r in subset if r == l]
 
 def p1(repo, subset, x):
-    """``p1(set)``
-    First parent of changesets in set.
+    """``p1([set])``
+    First parent of changesets in set, or the working directory.
     """
+    if x is None:
+        p = repo[x].parents()[0].rev()
+        return [r for r in subset if r == p]
+
     ps = set()
     cl = repo.changelog
     for r in getset(repo, range(len(repo)), x):
@@ -212,9 +216,17 @@
     return [r for r in subset if r in ps]
 
 def p2(repo, subset, x):
-    """``p2(set)``
-    Second parent of changesets in set.
+    """``p2([set])``
+    Second parent of changesets in set, or the working directory.
     """
+    if x is None:
+        ps = repo[x].parents()
+        try:
+            p = ps[1].rev()
+            return [r for r in subset if r == p]
+        except IndexError:
+            return []
+
     ps = set()
     cl = repo.changelog
     for r in getset(repo, range(len(repo)), x):
@@ -222,9 +234,13 @@
     return [r for r in subset if r in ps]
 
 def parents(repo, subset, x):
-    """``parents(set)``
-    The set of all parents for all changesets in set.
+    """``parents([set])``
+    The set of all parents for all changesets in set, or the working directory.
     """
+    if x is None:
+        ps = tuple(p.rev() for p in repo[x].parents())
+        return [r for r in subset if r in ps]
+
     ps = set()
     cl = repo.changelog
     for r in getset(repo, range(len(repo)), x):
--- a/mercurial/subrepo.py	Tue Nov 16 21:35:58 2010 +0100
+++ b/mercurial/subrepo.py	Wed Nov 17 09:17:55 2010 +0100
@@ -5,7 +5,7 @@
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
-import errno, os, re, xml.dom.minidom, shutil, urlparse, posixpath
+import errno, os, re, xml.dom.minidom, shutil, subprocess, urlparse, posixpath
 from i18n import _
 import config, util, node, error, cmdutil
 hg = None
@@ -576,7 +576,199 @@
         return self._svncommand(['cat'], name)
 
 
+class gitsubrepo(object):
+    def __init__(self, ctx, path, state):
+        # TODO add git version check.
+        self._state = state
+        self._ctx = ctx
+        self._relpath = path
+        self._path = ctx._repo.wjoin(path)
+        self._ui = ctx._repo.ui
+
+    def _gitcommand(self, commands):
+        return self._gitdir(commands)[0]
+
+    def _gitdir(self, commands):
+        commands = ['--no-pager', '--git-dir=%s/.git' % self._path,
+                    '--work-tree=%s' % self._path] + commands
+        return self._gitnodir(commands)
+
+    def _gitnodir(self, commands):
+        """Calls the git command
+
+        The methods tries to call the git command. versions previor to 1.6.0
+        are not supported and very probably fail.
+        """
+        cmd = ['git'] + commands
+        cmd = [util.shellquote(arg) for arg in cmd]
+        cmd = util.quotecommand(' '.join(cmd))
+
+        # print git's stderr, which is mostly progress and useful info
+        p = subprocess.Popen(cmd, shell=True, bufsize=-1,
+                             close_fds=(os.name == 'posix'),
+                             stdout=subprocess.PIPE)
+        retdata = p.stdout.read()
+        # wait for the child to exit to avoid race condition.
+        p.wait()
+
+        if p.returncode != 0:
+            # there are certain error codes that are ok
+            command = None
+            for arg in commands:
+                if not arg.startswith('-'):
+                    command = arg
+                    break
+            if command == 'cat-file':
+                return retdata, p.returncode
+            if command in ('commit', 'status') and p.returncode == 1:
+                return retdata, p.returncode
+            # for all others, abort
+            raise util.Abort('git %s error %d' % (command, p.returncode))
+
+        return retdata, p.returncode
+
+    def _gitstate(self):
+        return self._gitcommand(['rev-parse', 'HEAD']).strip()
+
+    def _githavelocally(self, revision):
+        out, code = self._gitdir(['cat-file', '-e', revision])
+        return code == 0
+
+    def _gitbranchmap(self):
+        'returns the current branch and a map from git revision to branch[es]'
+        bm = {}
+        redirects = {}
+        current = None
+        out = self._gitcommand(['branch', '-a', '--no-color',
+                                '--verbose', '--abbrev=40'])
+        for line in out.split('\n'):
+            if not line:
+                continue
+            if line[2:].startswith('(no branch)'):
+                continue
+            branch, revision = line[2:].split()[:2]
+            if revision == '->':
+                continue # ignore remote/HEAD redirects
+            if line[0] == '*':
+                current = branch
+            bm.setdefault(revision, []).append(branch)
+        return current, bm
+
+    def _fetch(self, source, revision):
+        if not os.path.exists('%s/.git' % self._path):
+            self._ui.status(_('cloning subrepo %s\n') % self._relpath)
+            self._gitnodir(['clone', source, self._path])
+        if self._githavelocally(revision):
+            return
+        self._ui.status(_('pulling subrepo %s\n') % self._relpath)
+        self._gitcommand(['fetch', '--all', '-q'])
+        if not self._githavelocally(revision):
+            raise util.Abort(_("revision %s does not exist in subrepo %s\n") %
+                               (revision, self._path))
+
+    def dirty(self):
+        if self._state[1] != self._gitstate(): # version checked out changed?
+            return True
+        # check for staged changes or modified files; ignore untracked files
+        # docs say --porcelain flag is future-proof format
+        changed = self._gitcommand(['status', '--porcelain',
+                                    '--untracked-files=no'])
+        return bool(changed.strip())
+
+    def get(self, state):
+        source, revision, kind = state
+        self._fetch(source, revision)
+        # if the repo was set to be bare, unbare it
+        if self._gitcommand(['config', '--get', 'core.bare']
+                            ).strip() == 'true':
+            self._gitcommand(['config', 'core.bare', 'false'])
+            if self._gitstate() == revision:
+                self._gitcommand(['reset', '--hard', 'HEAD'])
+                return
+        elif self._gitstate() == revision:
+            return
+        current, bm = self._gitbranchmap()
+        if revision not in bm:
+            # no branch to checkout, check it out with no branch
+            self._ui.warn(_('checking out detached HEAD in subrepo %s\n') %
+                          self._relpath)
+            self._ui.warn(_('check out a git branch if you intend '
+                            'to make changes\n'))
+            self._gitcommand(['checkout', '-q', revision])
+            return
+        branches = bm[revision]
+        firstlocalbranch = None
+        for b in branches:
+            if b == 'master':
+                # master trumps all other branches
+                self._gitcommand(['checkout', 'master'])
+                return
+            if not firstlocalbranch and not b.startswith('remotes/'):
+                firstlocalbranch = b
+        if firstlocalbranch:
+            self._gitcommand(['checkout', firstlocalbranch])
+        else:
+            remote = branches[0]
+            local = remote.split('/')[-1]
+            self._gitcommand(['checkout', '-b', local, remote])
+
+    def commit(self, text, user, date):
+        cmd = ['commit', '-a', '-m', text]
+        if user:
+            cmd += ['--author', user]
+        if date:
+            # git's date parser silently ignores when seconds < 1e9
+            # convert to ISO8601
+            cmd += ['--date', util.datestr(date, '%Y-%m-%dT%H:%M:%S %1%2')]
+        self._gitcommand(cmd)
+        # make sure commit works otherwise HEAD might not exist under certain
+        # circumstances
+        return self._gitstate()
+
+    def merge(self, state):
+        source, revision, kind = state
+        self._fetch(source, revision)
+        base = self._gitcommand(['merge-base', revision,
+                                 self._state[1]]).strip()
+        if base == revision:
+            self.get(state) # fast forward merge
+        elif base != self._state[1]:
+            self._gitcommand(['merge', '--no-commit', revision])
+
+    def push(self, force):
+        cmd = ['push']
+        if force:
+            cmd.append('--force')
+        # push the currently checked out branch
+        current, bm = self._gitbranchmap()
+        if current:
+            self._gitcommand(cmd + ['origin', current, '-q'])
+            return True
+        else:
+            self._ui.warn(_('no branch checked out in subrepo %s\n'
+                            'nothing to push') % self._relpath)
+            return False
+
+    def remove(self):
+        if self.dirty():
+            self._ui.warn(_('not removing repo %s because '
+                            'it has changes.\n') % self._path)
+            return
+        # we can't fully delete the repository as it may contain
+        # local-only history
+        self._ui.note(_('removing subrepo %s\n') % self._path)
+        self._gitcommand(['config', 'core.bare', 'true'])
+        for f in os.listdir(self._path):
+            if f == '.git':
+                continue
+            path = os.path.join(self._path, f)
+            if os.path.isdir(path) and not os.path.islink(path):
+                shutil.rmtree(path)
+            else:
+                os.remove(path)
+
 types = {
     'hg': hgsubrepo,
     'svn': svnsubrepo,
+    'git': gitsubrepo,
     }
--- a/mercurial/util.py	Tue Nov 16 21:35:58 2010 +0100
+++ b/mercurial/util.py	Wed Nov 17 09:17:55 2010 +0100
@@ -1328,15 +1328,26 @@
 #### naming convention of below implementation follows 'textwrap' module
 
 class MBTextWrapper(textwrap.TextWrapper):
+    """
+    Extend TextWrapper for double-width characters.
+
+    Some Asian characters use two terminal columns instead of one.
+    A good example of this behavior can be seen with u'\u65e5\u672c',
+    the two Japanese characters for "Japan":
+    len() returns 2, but when printed to a terminal, they eat 4 columns.
+
+    (Note that this has nothing to do whatsoever with unicode
+    representation, or encoding of the underlying string)
+    """
     def __init__(self, **kwargs):
         textwrap.TextWrapper.__init__(self, **kwargs)
 
     def _cutdown(self, str, space_left):
         l = 0
         ucstr = unicode(str, encoding.encoding)
-        w = unicodedata.east_asian_width
+        colwidth = unicodedata.east_asian_width
         for i in xrange(len(ucstr)):
-            l += w(ucstr[i]) in 'WFA' and 2 or 1
+            l += colwidth(ucstr[i]) in 'WFA' and 2 or 1
             if space_left < l:
                 return (ucstr[:i].encode(encoding.encoding),
                         ucstr[i:].encode(encoding.encoding))
--- a/tests/run-tests.py	Tue Nov 16 21:35:58 2010 +0100
+++ b/tests/run-tests.py	Wed Nov 17 09:17:55 2010 +0100
@@ -504,7 +504,8 @@
         vlog("# Running", cmd)
         exitcode, output = run(cmd, options, replacements)
         # do not merge output if skipped, return hghave message instead
-        if exitcode == SKIPPED_STATUS:
+        # similarly, with --debug, output is None
+        if exitcode == SKIPPED_STATUS or output is None:
             return exitcode, output
     finally:
         os.remove(name)
--- a/tests/test-convert.t	Tue Nov 16 21:35:58 2010 +0100
+++ b/tests/test-convert.t	Wed Nov 17 09:17:55 2010 +0100
@@ -48,8 +48,8 @@
       --sourcesort  try to preserve source revisions order, only supported by
                     Mercurial sources.
   
-      If <REVMAP> isn't given, it will be put in a default location
-      (<dest>/.hg/shamap by default). The <REVMAP> is a simple text file that
+      If "REVMAP" isn't given, it will be put in a default location
+      ("<dest>/.hg/shamap" by default). The "REVMAP" is a simple text file that
       maps each source commit ID to the destination ID for that revision, like
       so:
   
@@ -123,16 +123,19 @@
       Mercurial Source
       ''''''''''''''''
   
-      --config convert.hg.ignoreerrors=False    (boolean)
-          ignore integrity errors when reading. Use it to fix Mercurial
-          repositories with missing revlogs, by converting from and to
-          Mercurial.
+      The Mercurial source recognizes the following configuration options, which
+      you can set on the command line with "--config":
   
-      --config convert.hg.saverev=False         (boolean)
-          store original revision ID in changeset (forces target IDs to change)
-  
-      --config convert.hg.startrev=0            (hg revision identifier)
-          convert start revision and its descendants
+      convert.hg.ignoreerrors
+                  ignore integrity errors when reading. Use it to fix Mercurial
+                  repositories with missing revlogs, by converting from and to
+                  Mercurial. Default is False.
+      convert.hg.saverev
+                  store original. revision ID in changeset (forces target IDs to
+                  change). It takes and boolean argument and defaults to False.
+      convert.hg.startrev
+                  convert start revision and its descendants. It takes a hg
+                  revision identifier and defaults to 0.
   
       CVS Source
       ''''''''''
@@ -140,46 +143,45 @@
       CVS source will use a sandbox (i.e. a checked-out copy) from CVS to
       indicate the starting point of what will be converted. Direct access to
       the repository files is not needed, unless of course the repository is
-      :local:. The conversion uses the top level directory in the sandbox to
+      ":local:". The conversion uses the top level directory in the sandbox to
       find the CVS repository, and then uses CVS rlog commands to find files to
       convert. This means that unless a filemap is given, all files under the
       starting directory will be converted, and that any directory
       reorganization in the CVS sandbox is ignored.
   
-      The options shown are the defaults.
-  
-      --config convert.cvsps.cache=True         (boolean)
-          Set to False to disable remote log caching, for testing and debugging
-          purposes.
-  
-      --config convert.cvsps.fuzz=60            (integer)
-          Specify the maximum time (in seconds) that is allowed between commits
-          with identical user and log message in a single changeset. When very
-          large files were checked in as part of a changeset then the default
-          may not be long enough.
+      The following options can be used with "--config":
   
-      --config convert.cvsps.mergeto='{{mergetobranch ([-\w]+)}}'
-          Specify a regular expression to which commit log messages are matched.
-          If a match occurs, then the conversion process will insert a dummy
-          revision merging the branch on which this log message occurs to the
-          branch indicated in the regex.
-  
-      --config convert.cvsps.mergefrom='{{mergefrombranch ([-\w]+)}}'
-          Specify a regular expression to which commit log messages are matched.
-          If a match occurs, then the conversion process will add the most
-          recent revision on the branch indicated in the regex as the second
-          parent of the changeset.
-  
-      --config hook.cvslog
-          Specify a Python function to be called at the end of gathering the CVS
-          log. The function is passed a list with the log entries, and can
-          modify the entries in-place, or add or delete them.
-  
-      --config hook.cvschangesets
-          Specify a Python function to be called after the changesets are
-          calculated from the the CVS log. The function is passed a list with
-          the changeset entries, and can modify the changesets in-place, or add
-          or delete them.
+      convert.cvsps.cache
+                  Set to False to disable remote log caching, for testing and
+                  debugging purposes. Default is True.
+      convert.cvsps.fuzz
+                  Specify the maximum time (in seconds) that is allowed between
+                  commits with identical user and log message in a single
+                  changeset. When very large files were checked in as part of a
+                  changeset then the default may not be long enough. The default
+                  is 60.
+      convert.cvsps.mergeto
+                  Specify a regular expression to which commit log messages are
+                  matched. If a match occurs, then the conversion process will
+                  insert a dummy revision merging the branch on which this log
+                  message occurs to the branch indicated in the regex. Default
+                  is "{{mergetobranch ([-\w]+)}}"
+      convert.cvsps.mergefrom
+                  Specify a regular expression to which commit log messages are
+                  matched. If a match occurs, then the conversion process will
+                  add the most recent revision on the branch indicated in the
+                  regex as the second parent of the changeset. Default is
+                  "{{mergefrombranch ([-\w]+)}}"
+      hook.cvslog
+                  Specify a Python function to be called at the end of gathering
+                  the CVS log. The function is passed a list with the log
+                  entries, and can modify the entries in-place, or add or delete
+                  them.
+      hook.cvschangesets
+                  Specify a Python function to be called after the changesets
+                  are calculated from the the CVS log. The function is passed a
+                  list with the changeset entries, and can modify the changesets
+                  in-place, or add or delete them.
   
       An additional "debugcvsps" Mercurial command allows the builtin changeset
       merging code to be run without doing a conversion. Its parameters and
@@ -199,21 +201,22 @@
       them to paths relative to the source URL, or leave them blank to disable
       auto detection.
   
-      --config convert.svn.branches=branches    (directory name)
-          specify the directory containing branches
+      The following options can be set with "--config":
   
-      --config convert.svn.tags=tags            (directory name)
-          specify the directory containing tags
-  
-      --config convert.svn.trunk=trunk          (directory name)
-          specify the name of the trunk branch
+      convert.svn.branches
+                  specify the directory containing branches. The defaults is
+                  "branches".
+      convert.svn.tags
+                  specify the directory containing tags. The default is "tags".
+      convert.svn.trunk
+                  specify the name of the trunk branch The defauls is "trunk".
   
       Source history can be retrieved starting at a specific revision, instead
       of being integrally converted. Only single branch conversions are
       supported.
   
-      --config convert.svn.startrev=0           (svn revision number)
-          specify start Subversion revision.
+      convert.svn.startrev
+                  specify start Subversion revision number. The default is 0.
   
       Perforce Source
       '''''''''''''''
@@ -222,25 +225,27 @@
       specification as source. It will convert all files in the source to a flat
       Mercurial repository, ignoring labels, branches and integrations. Note
       that when a depot path is given you then usually should specify a target
-      directory, because otherwise the target may be named ...-hg.
+      directory, because otherwise the target may be named "...-hg".
   
       It is possible to limit the amount of source history to be converted by
-      specifying an initial Perforce revision.
+      specifying an initial Perforce revision:
   
-      --config convert.p4.startrev=0            (perforce changelist number)
-          specify initial Perforce revision.
+      convert.p4.startrev
+                  specify initial Perforce revision, a Perforce changelist
+                  number).
   
       Mercurial Destination
       '''''''''''''''''''''
   
-      --config convert.hg.clonebranches=False   (boolean)
-          dispatch source branches in separate clones.
+      The following options are supported:
   
-      --config convert.hg.tagsbranch=default    (branch name)
-          tag revisions branch name
-  
-      --config convert.hg.usebranchnames=True   (boolean)
-          preserve branch names
+      convert.hg.clonebranches
+                  dispatch source branches in separate clones. The default is
+                  False.
+      convert.hg.tagsbranch
+                  branch name for tag revisions, defaults to "default".
+      convert.hg.usebranchnames
+                  preserve branch names. The default is True
   
   options:
   
--- a/tests/test-import.t	Tue Nov 16 21:35:58 2010 +0100
+++ b/tests/test-import.t	Wed Nov 17 09:17:55 2010 +0100
@@ -437,6 +437,13 @@
   $ hg revert -a
   reverting a
 
+
+import with --no-commit should have written .hg/last-message.txt
+
+  $ cat .hg/last-message.txt
+  change (no-eol)
+
+
 test fuzziness with eol=auto
 
   $ hg --config patch.eol=auto import --no-commit -v tip.patch
--- a/tests/test-no-symlinks	Tue Nov 16 21:35:58 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-#!/bin/sh
-
-"$TESTDIR/hghave" no-symlink || exit 80
-
-# The following script was used to create the bundle:
-#
-# hg init symlinks
-# cd symlinks
-# echo a > a
-# mkdir d
-# echo b > d/b
-# ln -s a a.lnk
-# ln -s d/b d/b.lnk
-# hg ci -Am t
-# hg bundle --base null ../test-no-symlinks.hg
-
-# Extract a symlink on a platform not supporting them
-echo % unbundle
-hg init t
-cd t
-hg pull -q "$TESTDIR/test-no-symlinks.hg"
-hg update
-
-cat a.lnk && echo
-cat d/b.lnk && echo
-
-# Copy a symlink and move another
-echo % move and copy
-hg copy a.lnk d/a2.lnk
-hg mv d/b.lnk b2.lnk
-hg ci -Am copy
-cat d/a2.lnk && echo
-cat b2.lnk && echo
-
-# Bundle and extract again
-echo % bundle
-hg bundle --base null ../symlinks.hg
-cd ..
-
-hg init t2
-cd t2
-hg pull ../symlinks.hg
-hg update
-
-cat a.lnk && echo
-cat d/a2.lnk && echo
-cat b2.lnk && echo
--- a/tests/test-no-symlinks.out	Tue Nov 16 21:35:58 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-% unbundle
-4 files updated, 0 files merged, 0 files removed, 0 files unresolved
-a
-d/b
-% move and copy
-a
-d/b
-% bundle
-2 changesets found
-pulling from ../symlinks.hg
-requesting all changes
-adding changesets
-adding manifests
-adding file changes
-added 2 changesets with 6 changes to 6 files
-(run 'hg update' to get a working copy)
-5 files updated, 0 files merged, 0 files removed, 0 files unresolved
-a
-a
-d/b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-no-symlinks.t	Wed Nov 17 09:17:55 2010 +0100
@@ -0,0 +1,59 @@
+  $ "$TESTDIR/hghave" no-symlink || exit 80
+
+# The following script was used to create the bundle:
+#
+# hg init symlinks
+# cd symlinks
+# echo a > a
+# mkdir d
+# echo b > d/b
+# ln -s a a.lnk
+# ln -s d/b d/b.lnk
+# hg ci -Am t
+# hg bundle --base null ../test-no-symlinks.hg
+
+Extract a symlink on a platform not supporting them
+
+  $ hg init t
+  $ cd t
+  $ hg pull -q "$TESTDIR/test-no-symlinks.hg"
+  $ hg update
+  4 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cat a.lnk && echo
+  a
+  $ cat d/b.lnk && echo
+  d/b
+
+Copy a symlink and move another
+
+  $ hg copy a.lnk d/a2.lnk
+  $ hg mv d/b.lnk b2.lnk
+  $ hg ci -Am copy
+  $ cat d/a2.lnk && echo
+  a
+  $ cat b2.lnk && echo
+  d/b
+
+Bundle and extract again
+
+  $ hg bundle --base null ../symlinks.hg
+  2 changesets found
+  $ cd ..
+  $ hg init t2
+  $ cd t2
+  $ hg pull ../symlinks.hg
+  pulling from ../symlinks.hg
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 6 changes to 6 files
+  (run 'hg update' to get a working copy)
+  $ hg update
+  5 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cat a.lnk && echo
+  a
+  $ cat d/a2.lnk && echo
+  a
+  $ cat b2.lnk && echo
+  d/b
--- a/tests/test-parentrevspec.t	Tue Nov 16 21:35:58 2010 +0100
+++ b/tests/test-parentrevspec.t	Wed Nov 17 09:17:55 2010 +0100
@@ -69,12 +69,12 @@
   6^^^^^: 0
   6^^^^^^: -1
   6^1: 5
-  6^2: abort: unknown revision '6^2'!
+  6^2: hg: parse error at 1: syntax error
   6^^2: 4
   6^1^2: 4
-  6^^3: abort: unknown revision '6^^3'!
+  6^^3: hg: parse error at 1: syntax error
   $ lookup "6~" "6~1" "6~2" "6~3" "6~4" "6~5" "6~42" "6~1^2" "6~1^2~2"
-  6~: abort: unknown revision '6~'!
+  6~: hg: parse error at 1: syntax error
   6~1: 5
   6~2: 3
   6~3: 2
@@ -102,4 +102,4 @@
   $ hg tag -l -r 2 "foo^bar"
   $ lookup "foo^bar" "foo^bar^"
   foo^bar: 2
-  foo^bar^: abort: unknown revision 'foo^bar^'!
+  foo^bar^: hg: parse error at 3: syntax error
--- a/tests/test-push-warn.t	Tue Nov 16 21:35:58 2010 +0100
+++ b/tests/test-push-warn.t	Wed Nov 17 09:17:55 2010 +0100
@@ -30,6 +30,23 @@
   (you should pull and merge or use push -f to force)
   [255]
 
+  $ hg push --debug ../a
+  pushing to ../a
+  searching for changes
+  examining 1c9246a22a0a:d8d565842d04
+  found incomplete branch 1c9246a22a0a:d8d565842d04
+  searching: 1 queries
+  narrowing 1:1 d8d565842d04
+  found new branch changeset 1c9246a22a0a
+  found new changesets starting at 1c9246a22a0a
+  1 total queries
+  common changesets up to d8d565842d04
+  new remote heads on branch 'default'
+  new remote head 1e108cc5548c
+  abort: push creates new remote heads on branch 'default'!
+  (you should pull and merge or use push -f to force)
+  [255]
+
   $ hg pull ../a
   pulling from ../a
   searching for changes
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-revset-dirstate-parents.t	Wed Nov 17 09:17:55 2010 +0100
@@ -0,0 +1,52 @@
+  $ HGENCODING=utf-8
+  $ export HGENCODING
+
+  $ try() {
+  >   hg debugrevspec --debug $@
+  > }
+
+  $ log() {
+  >   hg log --template '{rev}\n' -r "$1"
+  > }
+
+  $ hg init repo
+  $ cd repo
+
+  $ try 'p1()'
+  ('func', ('symbol', 'p1'), None)
+  $ try 'p2()'
+  ('func', ('symbol', 'p2'), None)
+  $ try 'parents()'
+  ('func', ('symbol', 'parents'), None)
+
+null revision
+  $ log 'p1()'
+  $ log 'p2()'
+  $ log 'parents()'
+
+working dir with a single parent
+  $ echo a > a
+  $ hg ci -Aqm0
+  $ log 'p1()'
+  0
+  $ log 'tag() and p1()'
+  $ log 'p2()'
+  $ log 'parents()'
+  0
+  $ log 'tag() and parents()'
+
+merge in progress
+  $ echo b > b
+  $ hg ci -Aqm1
+  $ hg up -q 0
+  $ echo c > c
+  $ hg ci -Aqm2
+  $ hg merge -q
+  $ log 'p1()'
+  2
+  $ log 'p2()'
+  1
+  $ log 'tag() and p2()'
+  $ log 'parents()'
+  1
+  2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-subrepo-git.t	Wed Nov 17 09:17:55 2010 +0100
@@ -0,0 +1,195 @@
+  $ "$TESTDIR/hghave" git || exit 80
+
+make git commits repeatable
+
+  $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
+  $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
+  $ GIT_AUTHOR_DATE='1234567891 +0000'; export GIT_AUTHOR_DATE
+  $ GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
+  $ GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
+  $ GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
+
+root hg repo
+
+  $ hg init t
+  $ cd t
+  $ echo a > a
+  $ hg add a
+  $ hg commit -m a
+  $ cd ..
+
+new external git repo
+
+  $ mkdir gitroot
+  $ cd gitroot
+  $ git init -q
+  $ echo g > g
+  $ git add g
+  $ git commit -q -m g
+
+add subrepo clone
+
+  $ cd ../t
+  $ echo 's = [git]../gitroot' > .hgsub
+  $ git clone -q ../gitroot s
+  $ hg add .hgsub
+  $ hg commit -m 'new git subrepo'
+  committing subrepository $TESTTMP/t/s
+  $ hg debugsub
+  path s
+   source   ../gitroot
+   revision da5f5b1d8ffcf62fb8327bcd3c89a4367a6018e7
+
+record a new commit from upstream from a different branch
+
+  $ cd ../gitroot
+  $ git checkout -b testing
+  Switched to a new branch 'testing'
+  $ echo gg >> g
+  $ git commit -q -a -m gg
+
+  $ cd ../t/s
+  $ git pull -q
+  $ git checkout -b testing origin/testing
+  Switched to a new branch 'testing'
+  Branch testing set up to track remote branch testing from origin.
+
+  $ cd ..
+  $ hg commit -m 'update git subrepo'
+  committing subrepository $TESTTMP/t/s
+  $ hg debugsub
+  path s
+   source   ../gitroot
+   revision 126f2a14290cd5ce061fdedc430170e8d39e1c5a
+
+clone root
+
+  $ hg clone . ../tc
+  updating to branch default
+  cloning subrepo s
+  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cd ../tc
+  $ hg debugsub
+  path s
+   source   ../gitroot
+   revision 126f2a14290cd5ce061fdedc430170e8d39e1c5a
+
+update to previous substate
+
+  $ hg update 1
+  Switched to a new branch 'master'
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cat s/g
+  g
+  $ hg debugsub
+  path s
+   source   ../gitroot
+   revision da5f5b1d8ffcf62fb8327bcd3c89a4367a6018e7
+
+make $GITROOT pushable, by replacing it with a clone with nothing checked out
+
+  $ cd ..
+  $ git clone gitroot gitrootbare --bare -q
+  $ rm -rf gitroot
+  $ mv gitrootbare gitroot
+
+clone root, make local change
+
+  $ cd t
+  $ hg clone . ../ta
+  updating to branch default
+  cloning subrepo s
+  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+  $ cd ../ta
+  $ echo ggg >> s/g
+  $ hg commit -m ggg
+  committing subrepository $TESTTMP/ta/s
+  $ hg debugsub
+  path s
+   source   ../gitroot
+   revision 79695940086840c99328513acbe35f90fcd55e57
+
+clone root separately, make different local change
+
+  $ cd ../t
+  $ hg clone . ../tb
+  updating to branch default
+  cloning subrepo s
+  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+  $ cd ../tb/s
+  $ echo f > f
+  $ git add f
+  $ cd ..
+
+  $ hg commit -m f
+  committing subrepository $TESTTMP/tb/s
+  $ hg debugsub
+  path s
+   source   ../gitroot
+   revision aa84837ccfbdfedcdcdeeedc309d73e6eb069edc
+
+user b push changes
+
+  $ hg push
+  pushing to $TESTTMP/t
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+
+user a pulls, merges, commits
+
+  $ cd ../ta
+  $ hg pull
+  pulling from $TESTTMP/t
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files (+1 heads)
+  (run 'hg heads' to see heads, 'hg merge' to merge)
+  $ hg merge
+  Automatic merge went well; stopped before committing as requested
+  pulling subrepo s
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (branch merge, don't forget to commit)
+  $ cat s/f
+  f
+  $ cat s/g
+  g
+  gg
+  ggg
+  $ hg commit -m 'merge'
+  committing subrepository $TESTTMP/ta/s
+  $ hg debugsub
+  path s
+   source   ../gitroot
+   revision f47b465e1bce645dbf37232a00574aa1546ca8d3
+  $ hg push
+  pushing to $TESTTMP/t
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 2 changes to 1 files
+
+update to a revision without the subrepo, keeping the local git repository
+
+  $ cd ../t
+  $ hg up 0
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ ls s -a
+  .
+  ..
+  .git
+
+  $ hg up 2
+  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ ls s -a
+  .
+  ..
+  .git
+  g
--- a/tests/test-win32text.t	Tue Nov 16 21:35:58 2010 +0100
+++ b/tests/test-win32text.t	Wed Nov 17 09:17:55 2010 +0100
@@ -9,10 +9,6 @@
   >     data = data.replace('\n', '\r\n')
   >     file(path, 'wb').write(data)
   > EOF
-  $ cat > print.py <<EOF
-  > import sys
-  > print(sys.stdin.read().replace('\n', '<LF>').replace('\r', '<CR>').replace('\0', '<NUL>'))
-  > EOF
   $ echo '[hooks]' >> .hg/hgrc
   $ echo 'pretxncommit.crlf = python:hgext.win32text.forbidcrlf' >> .hg/hgrc
   $ echo 'pretxnchangegroup.crlf = python:hgext.win32text.forbidcrlf' >> .hg/hgrc
@@ -369,12 +365,13 @@
   $ python -c 'file("f4.bat", "wb").write("rem empty\x0D\x0A")'
   $ hg add f3 f4.bat
   $ hg ci -m 6
-  $ python print.py < bin
-  hello<NUL><CR><LF>
-  $ python print.py < f3
-  some<LF>text<LF>
-  $ python print.py < f4.bat
-  rem empty<CR><LF>
+  $ cat bin
+  hello\x00\r (esc)
+  $ cat f3
+  some
+  text
+  $ cat f4.bat
+  rem empty\r (esc)
   $ echo
   
   $ echo '[extensions]' >> .hg/hgrc
@@ -405,38 +402,39 @@
   tip
 
   $ rm f3 f4.bat bin
-  $ hg co -C 2>&1 | python -c 'import sys, os; sys.stdout.write(sys.stdin.read().replace(os.getcwd(), "...."))'
+  $ hg co -C
   WARNING: f4.bat already has CRLF line endings
   and does not need EOL conversion by the win32text plugin.
   Before your next commit, please reconsider your encode/decode settings in 
-  Mercurial.ini or ..../.hg/hgrc.
+  Mercurial.ini or $TESTTMP/t/.hg/hgrc.
   3 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ python print.py < bin
-  hello<NUL><CR><LF>
-  $ python print.py < f3
-  some<CR><LF>text<CR><LF>
-  $ python print.py < f4.bat
-  rem empty<CR><LF>
+  $ cat bin
+  hello\x00\r (esc)
+  $ cat f3
+  some\r (esc)
+  text\r (esc)
+  $ cat f4.bat
+  rem empty\r (esc)
   $ echo
   
   $ python -c 'file("f5.sh", "wb").write("# empty\x0D\x0A")'
   $ hg add f5.sh
   $ hg ci -m 7
-  $ python print.py < f5.sh
-  # empty<CR><LF>
-  $ hg cat f5.sh | python print.py
-  # empty<LF>
+  $ cat f5.sh
+  # empty\r (esc)
+  $ hg cat f5.sh
+  # empty
   $ echo '% just linefeed' > linefeed
   $ hg ci -qAm 8 linefeed
-  $ python print.py < linefeed
-  % just linefeed<LF>
-  $ hg cat linefeed | python print.py
-  % just linefeed<LF>
+  $ cat linefeed
+  % just linefeed
+  $ hg cat linefeed
+  % just linefeed
   $ hg st -q
   $ hg revert -a linefeed
   no changes needed to linefeed
-  $ python print.py < linefeed
-  % just linefeed<LF>
+  $ cat linefeed
+  % just linefeed
   $ hg st -q
   $ echo modified >> linefeed
   $ hg st -q
@@ -444,5 +442,5 @@
   $ hg revert -a
   reverting linefeed
   $ hg st -q
-  $ python print.py < linefeed
-  % just linefeed<CR><LF>
+  $ cat linefeed
+  % just linefeed\r (esc)