# HG changeset patch # User Matt Mackall # Date 1432037877 18000 # Node ID 472a685a49618c684ef7a03ce977bc442f7b6ce8 # Parent 08d1ef09ed371bfa6982ea67f6c92b495d42c520# Parent ef4538ba67ef0d63fe55d4defa7b5993f0d16b6f merge with stable diff -r ef4538ba67ef -r 472a685a4961 Makefile --- a/Makefile Sun May 17 22:09:37 2015 -0400 +++ b/Makefile Tue May 19 07:17:57 2015 -0500 @@ -157,6 +157,16 @@ N=`cd dist && echo mercurial-*.mpkg | sed 's,\.mpkg$$,,'` && hdiutil create -srcfolder dist/$$N.mpkg/ -scrub -volname "$$N" -ov packages/osx/$$N.dmg rm -rf dist/mercurial-*.mpkg +debian-jessie: + mkdir -p packages/debian-jessie + contrib/builddeb + mv debbuild/*.deb packages/debian-jessie + rm -rf debbuild + +docker-debian-jessie: + mkdir -p packages/debian/jessie + contrib/dockerdeb jessie + fedora20: mkdir -p packages/fedora20 contrib/buildrpm diff -r ef4538ba67ef -r 472a685a4961 contrib/builddeb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/contrib/builddeb Tue May 19 07:17:57 2015 -0500 @@ -0,0 +1,62 @@ +#!/bin/sh -e +# +# Build a Mercurial debian package from the current repo +# +# Tested on Jessie (stable as of original script authoring.) + +. $(dirname $0)/packagelib.sh + +BUILD=1 +DEBBUILDDIR="$PWD/debbuild" +while [ "$1" ]; do + case "$1" in + --prepare ) + shift + BUILD= + ;; + --debbuilddir ) + shift + DEBBUILDDIR="$1" + shift + ;; + * ) + echo "Invalid parameter $1!" 1>&2 + exit 1 + ;; + esac +done + +set -u + +rm -rf $DEBBUILDDIR +mkdir -p $DEBBUILDDIR + +if [ ! -d .hg ]; then + echo 'You are not inside a Mercurial repository!' 1>&2 + exit 1 +fi + +gethgversion + +cp -r $PWD/contrib/debian $DEBBUILDDIR/DEBIAN +chmod -R 0755 $DEBBUILDDIR/DEBIAN + +control=$DEBBUILDDIR/DEBIAN/control + +# This looks like sed -i, but sed -i behaves just differently enough +# between BSD and GNU sed that I gave up and did the dumb thing. +sed "s/__VERSION__/$version/" < $control > $control.tmp +mv $control.tmp $control + +if [ "$BUILD" ]; then + dpkg-deb --build $DEBBUILDDIR + mv $DEBBUILDDIR.deb $DEBBUILDDIR/mercurial-$version-$release.deb + if [ $? = 0 ]; then + echo + echo "Built packages for $version-$release:" + find $DEBBUILDDIR/ -type f -newer $control + fi +else + echo "Prepared sources for $version-$release $control are in $DEBBUILDDIR - use like:" + echo "dpkg-deb --build $DEBBUILDDIR" +fi diff -r ef4538ba67ef -r 472a685a4961 contrib/buildrpm --- a/contrib/buildrpm Sun May 17 22:09:37 2015 -0400 +++ b/contrib/buildrpm Tue May 19 07:17:57 2015 -0500 @@ -7,6 +7,8 @@ # - CentOS 5 # - centOS 6 +. $(dirname $0)/packagelib.sh + BUILD=1 RPMBUILDDIR="$PWD/rpmbuild" while [ "$1" ]; do @@ -45,25 +47,8 @@ exit 1 fi -# build local hg and use it -python setup.py build_py -c -d . -HG="$PWD/hg" -PYTHONPATH="$PWD/mercurial/pure" -export PYTHONPATH - -mkdir -p $RPMBUILDDIR/SOURCES $RPMBUILDDIR/SPECS $RPMBUILDDIR/RPMS $RPMBUILDDIR/SRPMS $RPMBUILDDIR/BUILD - -hgversion=`$HG version | sed -ne 's/.*(version \(.*\))$/\1/p'` +gethgversion -if echo $hgversion | grep -- '-' > /dev/null 2>&1; then - # nightly build case, version is like 1.3.1+250-20b91f91f9ca - version=`echo $hgversion | cut -d- -f1` - release=`echo $hgversion | cut -d- -f2 | sed -e 's/+.*//'` -else - # official tag, version is like 1.3.1 - version=`echo $hgversion | sed -e 's/+.*//'` - release='0' -fi if [ "$PYTHONVER" ]; then release=$release+$PYTHONVER RPMPYTHONVER=$PYTHONVER diff -r ef4538ba67ef -r 472a685a4961 contrib/check-code.py --- a/contrib/check-code.py Sun May 17 22:09:37 2015 -0400 +++ b/contrib/check-code.py Tue May 19 07:17:57 2015 -0500 @@ -217,14 +217,6 @@ (r'(\w|\)),\w', "missing whitespace after ,"), (r'(\w|\))[+/*\-<>]\w', "missing whitespace in expression"), (r'^\s+(\w|\.)+=\w[^,()\n]*$', "missing whitespace in assignment"), - (r'(\s+)try:\n((?:\n|\1\s.*\n)+?)(\1except.*?:\n' - r'((?:\n|\1\s.*\n)+?))+\1finally:', - 'no try/except/finally in Python 2.4'), - (r'(? +Description: Mercurial (probably nightly) package built by upstream. diff -r ef4538ba67ef -r 472a685a4961 contrib/docker/debian-jessie --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/contrib/docker/debian-jessie Tue May 19 07:17:57 2015 -0500 @@ -0,0 +1,11 @@ +FROM debian:jessie +RUN apt-get update && apt-get install -y \ + build-essential \ + debhelper \ + dh-python \ + devscripts \ + python \ + python-all-dev \ + python-docutils \ + zip \ + unzip diff -r ef4538ba67ef -r 472a685a4961 contrib/dockerdeb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/contrib/dockerdeb Tue May 19 07:17:57 2015 -0500 @@ -0,0 +1,39 @@ +#!/bin/bash -eu + +. $(dirname $0)/dockerlib.sh +. $(dirname $0)/packagelib.sh + +BUILDDIR=$(dirname $0) +export ROOTDIR=$(cd $BUILDDIR/..; pwd) + +checkdocker + +PLATFORM="debian-$1" +shift # extra params are passed to build process + +initcontainer $PLATFORM + +DEBBUILDDIR=$ROOTDIR/packages/$PLATFORM +contrib/builddeb --debbuilddir $DEBBUILDDIR/staged --prepare + +DSHARED=/mnt/shared/ +if [ $(uname) = "Darwin" ] ; then + $DOCKER run -u $DBUILDUSER --rm -v $DEBBUILDDIR:$DSHARED -v $PWD:/mnt/hg $CONTAINER \ + sh -c "cd /mnt/hg && make clean && make local" +fi +$DOCKER run -u $DBUILDUSER --rm -v $DEBBUILDDIR:$DSHARED -v $PWD:/mnt/hg $CONTAINER \ + sh -c "cd /mnt/hg && make PREFIX=$DSHARED/staged/usr install" +$DOCKER run -u $DBUILDUSER --rm -v $DEBBUILDDIR:$DSHARED $CONTAINER \ + dpkg-deb --build $DSHARED/staged +if [ $(uname) = "Darwin" ] ; then + $DOCKER run -u $DBUILDUSER --rm -v $DEBBUILDDIR:$DSHARED -v $PWD:/mnt/hg $CONTAINER \ + sh -c "cd /mnt/hg && make clean" +fi + +gethgversion + +rm -r $DEBBUILDDIR/staged +mv $DEBBUILDDIR/staged.deb $DEBBUILDDIR/mercurial-$version-$release.deb + +echo +echo "Build complete - results can be found in $DEBBUILDDIR" diff -r ef4538ba67ef -r 472a685a4961 contrib/dockerlib.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/contrib/dockerlib.sh Tue May 19 07:17:57 2015 -0500 @@ -0,0 +1,42 @@ +#!/bin/sh -eu + +# This function exists to set up the DOCKER variable and verify that +# it's the binary we expect. It also verifies that the docker service +# is running on the system and we can talk to it. +function checkdocker() { + if which docker.io >> /dev/null 2>&1 ; then + DOCKER=docker.io + elif which docker >> /dev/null 2>&1 ; then + DOCKER=docker + else + echo "Error: docker must be installed" + exit 1 + fi + + $DOCKER -h 2> /dev/null | grep -q Jansens && { echo "Error: $DOCKER is the Docking System Tray - install docker.io instead"; exit 1; } + $DOCKER version | grep -q "^Client version:" || { echo "Error: unexpected output from \"$DOCKER version\""; exit 1; } + $DOCKER version | grep -q "^Server version:" || { echo "Error: could not get docker server version - check it is running and your permissions"; exit 1; } +} + +# Construct a container and leave its name in $CONTAINER for future use. +function initcontainer() { + [ "$1" ] || { echo "Error: platform name must be specified"; exit 1; } + + DFILE="$ROOTDIR/contrib/docker/$1" + [ -f "$DFILE" ] || { echo "Error: docker file $DFILE not found"; exit 1; } + + CONTAINER="hg-dockerrpm-$1" + DBUILDUSER=build + ( + cat $DFILE + if [ $(uname) = "Darwin" ] ; then + # The builder is using boot2docker on OS X, so we're going to + # *guess* the uid of the user inside the VM that is actually + # running docker. This is *very likely* to fail at some point. + echo RUN useradd $DBUILDUSER -u 1000 + else + echo RUN groupadd $DBUILDUSER -g `id -g` + echo RUN useradd $DBUILDUSER -u `id -u` -g $DBUILDUSER + fi + ) | $DOCKER build --tag $CONTAINER - +} diff -r ef4538ba67ef -r 472a685a4961 contrib/dockerrpm --- a/contrib/dockerrpm Sun May 17 22:09:37 2015 -0400 +++ b/contrib/dockerrpm Tue May 19 07:17:57 2015 -0500 @@ -1,36 +1,16 @@ #!/bin/bash -e +. $(dirname $0)/dockerlib.sh + BUILDDIR=$(dirname $0) -ROOTDIR=$(cd $BUILDDIR/..; pwd) +export ROOTDIR=$(cd $BUILDDIR/..; pwd) -if which docker.io >> /dev/null 2>&1 ; then - DOCKER=docker.io -elif which docker >> /dev/null 2>&1 ; then - DOCKER=docker -else - echo "Error: docker must be installed" - exit 1 -fi - -$DOCKER -h 2> /dev/null | grep -q Jansens && { echo "Error: $DOCKER is the Docking System Tray - install docker.io instead"; exit 1; } -$DOCKER version | grep -q "^Client version:" || { echo "Error: unexpected output from \"$DOCKER version\""; exit 1; } -$DOCKER version | grep -q "^Server version:" || { echo "Error: could not get docker server version - check it is running and your permissions"; exit 1; } +checkdocker PLATFORM="$1" -[ "$PLATFORM" ] || { echo "Error: platform name must be specified"; exit 1; } shift # extra params are passed to buildrpm -DFILE="$ROOTDIR/contrib/docker/$PLATFORM" -[ -f "$DFILE" ] || { echo "Error: docker file $DFILE not found"; exit 1; } - -CONTAINER="hg-dockerrpm-$PLATFORM" - -DBUILDUSER=build -( -cat $DFILE -echo RUN groupadd $DBUILDUSER -g `id -g` -echo RUN useradd $DBUILDUSER -u `id -u` -g $DBUILDUSER -) | $DOCKER build --tag $CONTAINER - +initcontainer $PLATFORM RPMBUILDDIR=$ROOTDIR/packages/$PLATFORM contrib/buildrpm --rpmbuilddir $RPMBUILDDIR --prepare $* diff -r ef4538ba67ef -r 472a685a4961 contrib/hg-ssh --- a/contrib/hg-ssh Sun May 17 22:09:37 2015 -0400 +++ b/contrib/hg-ssh Tue May 19 07:17:57 2015 -0500 @@ -64,7 +64,7 @@ if readonly: cmd += [ '--config', - 'hooks.prechangegroup.hg-ssh=python:__main__.rejectpush', + 'hooks.pretxnopen.hg-ssh=python:__main__.rejectpush', '--config', 'hooks.prepushkey.hg-ssh=python:__main__.rejectpush' ] diff -r ef4538ba67ef -r 472a685a4961 contrib/import-checker.py --- a/contrib/import-checker.py Sun May 17 22:09:37 2015 -0400 +++ b/contrib/import-checker.py Tue May 19 07:17:57 2015 -0500 @@ -26,6 +26,72 @@ return '.'.join(p for p in parts if p != 'pure') return '.'.join(parts) +def fromlocalfunc(modulename, localmods): + """Get a function to examine which locally defined module the + target source imports via a specified name. + + `modulename` is an `dotted_name_of_path()`-ed source file path, + which may have `.__init__` at the end of it, of the target source. + + `localmods` is a dict (or set), of which key is an absolute + `dotted_name_of_path()`-ed source file path of locally defined (= + Mercurial specific) modules. + + This function assumes that module names not existing in + `localmods` are ones of Python standard libarary. + + This function returns the function, which takes `name` argument, + and returns `(absname, dottedpath, hassubmod)` tuple if `name` + matches against locally defined module. Otherwise, it returns + False. + + It is assumed that `name` doesn't have `.__init__`. + + `absname` is an absolute module name of specified `name` + (e.g. "hgext.convert"). This can be used to compose prefix for sub + modules or so. + + `dottedpath` is a `dotted_name_of_path()`-ed source file path + (e.g. "hgext.convert.__init__") of `name`. This is used to look + module up in `localmods` again. + + `hassubmod` is whether it may have sub modules under it (for + convenient, even though this is also equivalent to "absname != + dottednpath") + + >>> localmods = {'foo.__init__': True, 'foo.foo1': True, + ... 'foo.bar.__init__': True, 'foo.bar.bar1': True, + ... 'baz.__init__': True, 'baz.baz1': True } + >>> fromlocal = fromlocalfunc('foo.xxx', localmods) + >>> # relative + >>> fromlocal('foo1') + ('foo.foo1', 'foo.foo1', False) + >>> fromlocal('bar') + ('foo.bar', 'foo.bar.__init__', True) + >>> fromlocal('bar.bar1') + ('foo.bar.bar1', 'foo.bar.bar1', False) + >>> # absolute + >>> fromlocal('baz') + ('baz', 'baz.__init__', True) + >>> fromlocal('baz.baz1') + ('baz.baz1', 'baz.baz1', False) + >>> # unknown = maybe standard library + >>> fromlocal('os') + False + """ + prefix = '.'.join(modulename.split('.')[:-1]) + if prefix: + prefix += '.' + def fromlocal(name): + # check relative name at first + for n in prefix + name, name: + if n in localmods: + return (n, n, False) + dottedpath = n + '.__init__' + if dottedpath in localmods: + return (n, dottedpath, True) + return False + return fromlocal def list_stdlib_modules(): """List the modules present in the stdlib. @@ -104,38 +170,94 @@ stdlib_modules = set(list_stdlib_modules()) -def imported_modules(source, ignore_nested=False): +def imported_modules(source, modulename, localmods, ignore_nested=False): """Given the source of a file as a string, yield the names imported by that file. Args: source: The python source to examine as a string. + modulename: of specified python source (may have `__init__`) + localmods: dict of locally defined module names (may have `__init__`) ignore_nested: If true, import statements that do not start in column zero will be ignored. Returns: - A list of module names imported by the given source. + A list of absolute module names imported by the given source. + >>> modulename = 'foo.xxx' + >>> localmods = {'foo.__init__': True, + ... 'foo.foo1': True, 'foo.foo2': True, + ... 'foo.bar.__init__': True, 'foo.bar.bar1': True, + ... 'baz.__init__': True, 'baz.baz1': True } + >>> # standard library (= not locally defined ones) + >>> sorted(imported_modules( + ... 'from stdlib1 import foo, bar; import stdlib2', + ... modulename, localmods)) + [] + >>> # relative importing >>> sorted(imported_modules( - ... 'import foo ; from baz import bar; import foo.qux')) - ['baz.bar', 'foo', 'foo.qux'] + ... 'import foo1; from bar import bar1', + ... modulename, localmods)) + ['foo.bar.__init__', 'foo.bar.bar1', 'foo.foo1'] + >>> sorted(imported_modules( + ... 'from bar.bar1 import name1, name2, name3', + ... modulename, localmods)) + ['foo.bar.bar1'] + >>> # absolute importing + >>> sorted(imported_modules( + ... 'from baz import baz1, name1', + ... modulename, localmods)) + ['baz.__init__', 'baz.baz1'] + >>> # mixed importing, even though it shouldn't be recommended + >>> sorted(imported_modules( + ... 'import stdlib, foo1, baz', + ... modulename, localmods)) + ['baz.__init__', 'foo.foo1'] + >>> # ignore_nested >>> sorted(imported_modules( ... '''import foo ... def wat(): ... import bar - ... ''', ignore_nested=True)) - ['foo'] + ... ''', modulename, localmods)) + ['foo.__init__', 'foo.bar.__init__'] + >>> sorted(imported_modules( + ... '''import foo + ... def wat(): + ... import bar + ... ''', modulename, localmods, ignore_nested=True)) + ['foo.__init__'] """ + fromlocal = fromlocalfunc(modulename, localmods) for node in ast.walk(ast.parse(source)): if ignore_nested and getattr(node, 'col_offset', 0) > 0: continue if isinstance(node, ast.Import): for n in node.names: - yield n.name + found = fromlocal(n.name) + if not found: + # this should import standard library + continue + yield found[1] elif isinstance(node, ast.ImportFrom): - prefix = node.module + '.' + found = fromlocal(node.module) + if not found: + # this should import standard library + continue + + absname, dottedpath, hassubmod = found + yield dottedpath + if not hassubmod: + # examination of "node.names" should be redundant + # e.g.: from mercurial.node import nullid, nullrev + continue + + prefix = absname + '.' for n in node.names: - yield prefix + n.name + found = fromlocal(prefix + n.name) + if not found: + # this should be a function or a property of "node.module" + continue + yield found[1] def verify_stdlib_on_own_line(source): """Given some python source, verify that stdlib imports are done @@ -171,8 +293,6 @@ while visit: path = visit.pop(0) for i in sorted(imports.get(path[-1], [])): - if i not in stdlib_modules and not i.startswith('mercurial.'): - i = mod.rsplit('.', 1)[0] + '.' + i if len(path) < shortest.get(i, 1000): shortest[i] = len(path) if i in path: @@ -194,10 +314,12 @@ def find_cycles(imports): """Find cycles in an already-loaded import graph. - >>> imports = {'top.foo': ['bar', 'os.path', 'qux'], - ... 'top.bar': ['baz', 'sys'], - ... 'top.baz': ['foo'], - ... 'top.qux': ['foo']} + All module names recorded in `imports` should be absolute one. + + >>> imports = {'top.foo': ['top.bar', 'os.path', 'top.qux'], + ... 'top.bar': ['top.baz', 'sys'], + ... 'top.baz': ['top.foo'], + ... 'top.qux': ['top.foo']} >>> print '\\n'.join(sorted(find_cycles(imports))) top.bar -> top.baz -> top.foo -> top.bar top.foo -> top.qux -> top.foo @@ -215,17 +337,23 @@ return len(c), c def main(argv): - if len(argv) < 2: - print 'Usage: %s file [file] [file] ...' + if len(argv) < 2 or (argv[1] == '-' and len(argv) > 2): + print 'Usage: %s {-|file [file] [file] ...}' return 1 + if argv[1] == '-': + argv = argv[:1] + argv.extend(l.rstrip() for l in sys.stdin.readlines()) + localmods = {} used_imports = {} any_errors = False for source_path in argv[1:]: + modname = dotted_name_of_path(source_path, trimpure=True) + localmods[modname] = source_path + for modname, source_path in sorted(localmods.iteritems()): f = open(source_path) - modname = dotted_name_of_path(source_path, trimpure=True) src = f.read() used_imports[modname] = sorted( - imported_modules(src, ignore_nested=True)) + imported_modules(src, modname, localmods, ignore_nested=True)) for error in verify_stdlib_on_own_line(src): any_errors = True print source_path, error diff -r ef4538ba67ef -r 472a685a4961 contrib/mercurial.spec --- a/contrib/mercurial.spec Sun May 17 22:09:37 2015 -0400 +++ b/contrib/mercurial.spec Tue May 19 07:17:57 2015 -0500 @@ -37,8 +37,8 @@ %if "%{?withpython}" BuildRequires: readline-devel, openssl-devel, ncurses-devel, zlib-devel, bzip2-devel %else -BuildRequires: python >= 2.4, python-devel, python-docutils >= 0.5 -Requires: python >= 2.4 +BuildRequires: python >= 2.6, python-devel, python-docutils >= 0.5 +Requires: python >= 2.6 %endif # The hgk extension uses the wish tcl interpreter, but we don't enforce it #Requires: tk diff -r ef4538ba67ef -r 472a685a4961 contrib/packagelib.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/contrib/packagelib.sh Tue May 19 07:17:57 2015 -0500 @@ -0,0 +1,19 @@ +gethgversion() { + make clean + make local || make local PURE=--pure + HG="$PWD/hg" + + $HG version > /dev/null || { echo 'abort: hg version failed!'; exit 1 ; } + + hgversion=`$HG version | sed -ne 's/.*(version \(.*\))$/\1/p'` + + if echo $hgversion | grep -- '-' > /dev/null 2>&1; then + # nightly build case, version is like 1.3.1+250-20b91f91f9ca + version=`echo $hgversion | cut -d- -f1` + release=`echo $hgversion | cut -d- -f2 | sed -e 's/+.*//'` + else + # official tag, version is like 1.3.1 + version=`echo $hgversion | sed -e 's/+.*//'` + release='0' + fi +} diff -r ef4538ba67ef -r 472a685a4961 contrib/revsetbenchmarks.txt --- a/contrib/revsetbenchmarks.txt Sun May 17 22:09:37 2015 -0400 +++ b/contrib/revsetbenchmarks.txt Tue May 19 07:17:57 2015 -0500 @@ -17,6 +17,7 @@ # those two `roots(...)` inputs are close to what phase movement use. roots((tip~100::) - (tip~100::tip)) roots((0::) - (0::tip)) +42:68 and roots(42:tip) ::p1(p1(tip)):: public() :10000 and public() diff -r ef4538ba67ef -r 472a685a4961 contrib/synthrepo.py --- a/contrib/synthrepo.py Sun May 17 22:09:37 2015 -0400 +++ b/contrib/synthrepo.py Tue May 19 07:17:57 2015 -0500 @@ -41,6 +41,10 @@ from mercurial.i18n import _ from mercurial.node import nullrev, nullid, short +# Note for extension authors: ONLY specify testedwith = 'internal' for +# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should +# be specifying the version(s) of Mercurial they are tested with, or +# leave the attribute unspecified. testedwith = 'internal' cmdtable = {} diff -r ef4538ba67ef -r 472a685a4961 contrib/wix/guids.wxi --- a/contrib/wix/guids.wxi Sun May 17 22:09:37 2015 -0400 +++ b/contrib/wix/guids.wxi Tue May 19 07:17:57 2015 -0500 @@ -28,6 +28,7 @@ + diff -r ef4538ba67ef -r 472a685a4961 contrib/wix/templates.wxs --- a/contrib/wix/templates.wxs Sun May 17 22:09:37 2015 -0400 +++ b/contrib/wix/templates.wxs Tue May 19 07:17:57 2015 -0500 @@ -12,6 +12,7 @@ + @@ -36,6 +37,13 @@ + + + + + + + diff -r ef4538ba67ef -r 472a685a4961 hgext/acl.py --- a/hgext/acl.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/acl.py Tue May 19 07:17:57 2015 -0500 @@ -195,6 +195,10 @@ from mercurial import util, match import getpass, urllib +# Note for extension authors: ONLY specify testedwith = 'internal' for +# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should +# be specifying the version(s) of Mercurial they are tested with, or +# leave the attribute unspecified. testedwith = 'internal' def _getusers(ui, group): diff -r ef4538ba67ef -r 472a685a4961 hgext/blackbox.py --- a/hgext/blackbox.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/blackbox.py Tue May 19 07:17:57 2015 -0500 @@ -35,6 +35,10 @@ cmdtable = {} command = cmdutil.command(cmdtable) +# Note for extension authors: ONLY specify testedwith = 'internal' for +# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should +# be specifying the version(s) of Mercurial they are tested with, or +# leave the attribute unspecified. testedwith = 'internal' lastblackbox = None diff -r ef4538ba67ef -r 472a685a4961 hgext/bugzilla.py --- a/hgext/bugzilla.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/bugzilla.py Tue May 19 07:17:57 2015 -0500 @@ -279,9 +279,13 @@ from mercurial.i18n import _ from mercurial.node import short -from mercurial import cmdutil, mail, templater, util +from mercurial import cmdutil, mail, util import re, time, urlparse, xmlrpclib +# Note for extension authors: ONLY specify testedwith = 'internal' for +# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should +# be specifying the version(s) of Mercurial they are tested with, or +# leave the attribute unspecified. testedwith = 'internal' class bzaccess(object): @@ -876,8 +880,6 @@ if not mapfile and not tmpl: tmpl = _('changeset {node|short} in repo {root} refers ' 'to bug {bug}.\ndetails:\n\t{desc|tabindent}') - if tmpl: - tmpl = templater.parsestring(tmpl, quoted=False) t = cmdutil.changeset_templater(self.ui, self.repo, False, None, tmpl, mapfile, False) self.ui.pushbuffer() diff -r ef4538ba67ef -r 472a685a4961 hgext/censor.py --- a/hgext/censor.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/censor.py Tue May 19 07:17:57 2015 -0500 @@ -31,6 +31,10 @@ cmdtable = {} command = cmdutil.command(cmdtable) +# Note for extension authors: ONLY specify testedwith = 'internal' for +# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should +# be specifying the version(s) of Mercurial they are tested with, or +# leave the attribute unspecified. testedwith = 'internal' @command('censor', diff -r ef4538ba67ef -r 472a685a4961 hgext/children.py --- a/hgext/children.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/children.py Tue May 19 07:17:57 2015 -0500 @@ -20,6 +20,10 @@ cmdtable = {} command = cmdutil.command(cmdtable) +# Note for extension authors: ONLY specify testedwith = 'internal' for +# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should +# be specifying the version(s) of Mercurial they are tested with, or +# leave the attribute unspecified. testedwith = 'internal' @command('children', diff -r ef4538ba67ef -r 472a685a4961 hgext/churn.py --- a/hgext/churn.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/churn.py Tue May 19 07:17:57 2015 -0500 @@ -9,17 +9,20 @@ '''command to display statistics about repository history''' from mercurial.i18n import _ -from mercurial import patch, cmdutil, scmutil, util, templater, commands +from mercurial import patch, cmdutil, scmutil, util, commands from mercurial import encoding import os import time, datetime cmdtable = {} command = cmdutil.command(cmdtable) +# Note for extension authors: ONLY specify testedwith = 'internal' for +# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should +# be specifying the version(s) of Mercurial they are tested with, or +# leave the attribute unspecified. testedwith = 'internal' def maketemplater(ui, repo, tmpl): - tmpl = templater.parsestring(tmpl, quoted=False) try: t = cmdutil.changeset_templater(ui, repo, False, None, tmpl, None, False) diff -r ef4538ba67ef -r 472a685a4961 hgext/color.py --- a/hgext/color.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/color.py Tue May 19 07:17:57 2015 -0500 @@ -162,6 +162,10 @@ cmdtable = {} command = cmdutil.command(cmdtable) +# Note for extension authors: ONLY specify testedwith = 'internal' for +# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should +# be specifying the version(s) of Mercurial they are tested with, or +# leave the attribute unspecified. testedwith = 'internal' # start and stop parameters for effects diff -r ef4538ba67ef -r 472a685a4961 hgext/convert/__init__.py --- a/hgext/convert/__init__.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/convert/__init__.py Tue May 19 07:17:57 2015 -0500 @@ -15,6 +15,10 @@ cmdtable = {} command = cmdutil.command(cmdtable) +# Note for extension authors: ONLY specify testedwith = 'internal' for +# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should +# be specifying the version(s) of Mercurial they are tested with, or +# leave the attribute unspecified. testedwith = 'internal' # Commands definition was moved elsewhere to ease demandload job. diff -r ef4538ba67ef -r 472a685a4961 hgext/convert/filemap.py --- a/hgext/convert/filemap.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/convert/filemap.py Tue May 19 07:17:57 2015 -0500 @@ -332,7 +332,7 @@ mp1 = self.parentmap[p1] if mp1 == SKIPREV or mp1 in knownparents: continue - isancestor = util.any(p2 for p2 in parents + isancestor = any(p2 for p2 in parents if p1 != p2 and mp1 != self.parentmap[p2] and mp1 in self.wantedancestors[p2]) if not isancestor and not hasbranchparent and len(parents) > 1: diff -r ef4538ba67ef -r 472a685a4961 hgext/eol.py --- a/hgext/eol.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/eol.py Tue May 19 07:17:57 2015 -0500 @@ -95,6 +95,10 @@ from mercurial import util, config, extensions, match, error import re, os +# Note for extension authors: ONLY specify testedwith = 'internal' for +# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should +# be specifying the version(s) of Mercurial they are tested with, or +# leave the attribute unspecified. testedwith = 'internal' # Matches a lone LF, i.e., one that is not part of CRLF. diff -r ef4538ba67ef -r 472a685a4961 hgext/extdiff.py --- a/hgext/extdiff.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/extdiff.py Tue May 19 07:17:57 2015 -0500 @@ -67,6 +67,10 @@ cmdtable = {} command = cmdutil.command(cmdtable) +# Note for extension authors: ONLY specify testedwith = 'internal' for +# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should +# be specifying the version(s) of Mercurial they are tested with, or +# leave the attribute unspecified. testedwith = 'internal' def snapshot(ui, repo, files, node, tmproot): diff -r ef4538ba67ef -r 472a685a4961 hgext/factotum.py --- a/hgext/factotum.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/factotum.py Tue May 19 07:17:57 2015 -0500 @@ -67,21 +67,20 @@ while True: fd = os.open('%s/rpc' % _mountpoint, os.O_RDWR) try: - try: - os.write(fd, 'start %s' % params) - l = os.read(fd, ERRMAX).split() - if l[0] == 'ok': - os.write(fd, 'read') - status, user, passwd = os.read(fd, ERRMAX).split(None, 2) - if status == 'ok': - if passwd.startswith("'"): - if passwd.endswith("'"): - passwd = passwd[1:-1].replace("''", "'") - else: - raise util.Abort(_('malformed password string')) - return (user, passwd) - except (OSError, IOError): - raise util.Abort(_('factotum not responding')) + os.write(fd, 'start %s' % params) + l = os.read(fd, ERRMAX).split() + if l[0] == 'ok': + os.write(fd, 'read') + status, user, passwd = os.read(fd, ERRMAX).split(None, 2) + if status == 'ok': + if passwd.startswith("'"): + if passwd.endswith("'"): + passwd = passwd[1:-1].replace("''", "'") + else: + raise util.Abort(_('malformed password string')) + return (user, passwd) + except (OSError, IOError): + raise util.Abort(_('factotum not responding')) finally: os.close(fd) getkey(self, params) diff -r ef4538ba67ef -r 472a685a4961 hgext/fetch.py --- a/hgext/fetch.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/fetch.py Tue May 19 07:17:57 2015 -0500 @@ -15,6 +15,10 @@ cmdtable = {} command = cmdutil.command(cmdtable) +# Note for extension authors: ONLY specify testedwith = 'internal' for +# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should +# be specifying the version(s) of Mercurial they are tested with, or +# leave the attribute unspecified. testedwith = 'internal' @command('fetch', diff -r ef4538ba67ef -r 472a685a4961 hgext/gpg.py --- a/hgext/gpg.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/gpg.py Tue May 19 07:17:57 2015 -0500 @@ -12,6 +12,10 @@ cmdtable = {} command = cmdutil.command(cmdtable) +# Note for extension authors: ONLY specify testedwith = 'internal' for +# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should +# be specifying the version(s) of Mercurial they are tested with, or +# leave the attribute unspecified. testedwith = 'internal' class gpg(object): @@ -255,7 +259,7 @@ if not opts["force"]: msigs = match.exact(repo.root, '', ['.hgsigs']) - if util.any(repo.status(match=msigs, unknown=True, ignored=True)): + if any(repo.status(match=msigs, unknown=True, ignored=True)): raise util.Abort(_("working copy of .hgsigs is changed "), hint=_("please commit .hgsigs manually")) diff -r ef4538ba67ef -r 472a685a4961 hgext/graphlog.py --- a/hgext/graphlog.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/graphlog.py Tue May 19 07:17:57 2015 -0500 @@ -20,6 +20,10 @@ cmdtable = {} command = cmdutil.command(cmdtable) +# Note for extension authors: ONLY specify testedwith = 'internal' for +# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should +# be specifying the version(s) of Mercurial they are tested with, or +# leave the attribute unspecified. testedwith = 'internal' @command('glog', diff -r ef4538ba67ef -r 472a685a4961 hgext/hgcia.py --- a/hgext/hgcia.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/hgcia.py Tue May 19 07:17:57 2015 -0500 @@ -43,11 +43,15 @@ from mercurial.i18n import _ from mercurial.node import bin, short -from mercurial import cmdutil, patch, templater, util, mail +from mercurial import cmdutil, patch, util, mail import email.Parser import socket, xmlrpclib from xml.sax import saxutils +# Note for extension authors: ONLY specify testedwith = 'internal' for +# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should +# be specifying the version(s) of Mercurial they are tested with, or +# leave the attribute unspecified. testedwith = 'internal' socket_timeout = 30 # seconds @@ -206,7 +210,6 @@ template = self.dstemplate else: template = self.deftemplate - template = templater.parsestring(template, quoted=False) t = cmdutil.changeset_templater(self.ui, self.repo, False, None, template, style, False) self.templater = t diff -r ef4538ba67ef -r 472a685a4961 hgext/hgk.py --- a/hgext/hgk.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/hgk.py Tue May 19 07:17:57 2015 -0500 @@ -41,6 +41,10 @@ cmdtable = {} command = cmdutil.command(cmdtable) +# Note for extension authors: ONLY specify testedwith = 'internal' for +# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should +# be specifying the version(s) of Mercurial they are tested with, or +# leave the attribute unspecified. testedwith = 'internal' @command('debug-diff-tree', diff -r ef4538ba67ef -r 472a685a4961 hgext/highlight/__init__.py --- a/hgext/highlight/__init__.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/highlight/__init__.py Tue May 19 07:17:57 2015 -0500 @@ -24,6 +24,10 @@ import highlight from mercurial.hgweb import webcommands, webutil, common from mercurial import extensions, encoding +# Note for extension authors: ONLY specify testedwith = 'internal' for +# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should +# be specifying the version(s) of Mercurial they are tested with, or +# leave the attribute unspecified. testedwith = 'internal' def filerevision_highlight(orig, web, tmpl, fctx): diff -r ef4538ba67ef -r 472a685a4961 hgext/histedit.py --- a/hgext/histedit.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/histedit.py Tue May 19 07:17:57 2015 -0500 @@ -181,6 +181,10 @@ cmdtable = {} command = cmdutil.command(cmdtable) +# Note for extension authors: ONLY specify testedwith = 'internal' for +# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should +# be specifying the version(s) of Mercurial they are tested with, or +# leave the attribute unspecified. testedwith = 'internal' # i18n: command names and abbreviations must remain untranslated @@ -707,15 +711,15 @@ if force and not outg: raise util.Abort(_('--force only allowed with --outgoing')) if cont: - if util.any((outg, abort, revs, freeargs, rules, editplan)): + if any((outg, abort, revs, freeargs, rules, editplan)): raise util.Abort(_('no arguments allowed with --continue')) goal = 'continue' elif abort: - if util.any((outg, revs, freeargs, rules, editplan)): + if any((outg, revs, freeargs, rules, editplan)): raise util.Abort(_('no arguments allowed with --abort')) goal = 'abort' elif editplan: - if util.any((outg, revs, freeargs)): + if any((outg, revs, freeargs)): raise util.Abort(_('only --commands argument allowed with ' '--edit-plan')) goal = 'edit-plan' diff -r ef4538ba67ef -r 472a685a4961 hgext/keyword.py --- a/hgext/keyword.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/keyword.py Tue May 19 07:17:57 2015 -0500 @@ -83,7 +83,7 @@ ''' from mercurial import commands, context, cmdutil, dispatch, filelog, extensions -from mercurial import localrepo, match, patch, templatefilters, templater, util +from mercurial import localrepo, match, patch, templatefilters, util from mercurial import scmutil, pathutil from mercurial.hgweb import webcommands from mercurial.i18n import _ @@ -91,6 +91,10 @@ cmdtable = {} command = cmdutil.command(cmdtable) +# Note for extension authors: ONLY specify testedwith = 'internal' for +# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should +# be specifying the version(s) of Mercurial they are tested with, or +# leave the attribute unspecified. testedwith = 'internal' # hg commands that do not act on keywords @@ -191,8 +195,7 @@ kwmaps = self.ui.configitems('keywordmaps') if kwmaps: # override default templates - self.templates = dict((k, templater.parsestring(v, False)) - for k, v in kwmaps) + self.templates = dict(kwmaps) else: self.templates = _defaultkwmaps(self.ui) @@ -457,9 +460,7 @@ repo.commit(text=msg) ui.status(_('\n\tkeywords expanded\n')) ui.write(repo.wread(fn)) - for root, dirs, files in os.walk(tmpdir): - for f in files: - util.unlinkpath(repo.vfs.reljoin(root, f)) + repo.wvfs.rmtree(repo.root) @command('kwexpand', commands.walkopts, diff -r ef4538ba67ef -r 472a685a4961 hgext/largefiles/__init__.py --- a/hgext/largefiles/__init__.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/largefiles/__init__.py Tue May 19 07:17:57 2015 -0500 @@ -112,6 +112,10 @@ import reposetup import uisetup as uisetupmod +# Note for extension authors: ONLY specify testedwith = 'internal' for +# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should +# be specifying the version(s) of Mercurial they are tested with, or +# leave the attribute unspecified. testedwith = 'internal' reposetup = reposetup.reposetup diff -r ef4538ba67ef -r 472a685a4961 hgext/largefiles/lfutil.py --- a/hgext/largefiles/lfutil.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/largefiles/lfutil.py Tue May 19 07:17:57 2015 -0500 @@ -364,10 +364,10 @@ def islfilesrepo(repo): if ('largefiles' in repo.requirements and - util.any(shortnameslash in f[0] for f in repo.store.datafiles())): + any(shortnameslash in f[0] for f in repo.store.datafiles())): return True - return util.any(openlfdirstate(repo.ui, repo, False)) + return any(openlfdirstate(repo.ui, repo, False)) class storeprotonotcapable(Exception): def __init__(self, storetypes): diff -r ef4538ba67ef -r 472a685a4961 hgext/largefiles/overrides.py --- a/hgext/largefiles/overrides.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/largefiles/overrides.py Tue May 19 07:17:57 2015 -0500 @@ -27,7 +27,7 @@ m = copy.copy(match) lfile = lambda f: lfutil.standin(f) in manifest m._files = filter(lfile, m._files) - m._fmap = set(m._files) + m._fileroots = set(m._files) m._always = False origmatchfn = m.matchfn m.matchfn = lambda f: lfile(f) and origmatchfn(f) @@ -42,7 +42,7 @@ notlfile = lambda f: not (lfutil.isstandin(f) or lfutil.standin(f) in manifest or f in excluded) m._files = filter(notlfile, m._files) - m._fmap = set(m._files) + m._fileroots = set(m._files) m._always = False origmatchfn = m.matchfn m.matchfn = lambda f: notlfile(f) and origmatchfn(f) @@ -358,7 +358,7 @@ and repo.wvfs.isdir(standin): m._files.append(standin) - m._fmap = set(m._files) + m._fileroots = set(m._files) m._always = False origmatchfn = m.matchfn def lfmatchfn(f): @@ -578,14 +578,13 @@ nolfiles = False installnormalfilesmatchfn(repo[None].manifest()) try: - try: - result = orig(ui, repo, pats, opts, rename) - except util.Abort, e: - if str(e) != _('no files to copy'): - raise e - else: - nonormalfiles = True - result = 0 + result = orig(ui, repo, pats, opts, rename) + except util.Abort, e: + if str(e) != _('no files to copy'): + raise e + else: + nonormalfiles = True + result = 0 finally: restorematchfn() @@ -608,86 +607,85 @@ os.makedirs(makestandin(dest)) try: - try: - # When we call orig below it creates the standins but we don't add - # them to the dir state until later so lock during that time. - wlock = repo.wlock() + # When we call orig below it creates the standins but we don't add + # them to the dir state until later so lock during that time. + wlock = repo.wlock() - manifest = repo[None].manifest() - def overridematch(ctx, pats=[], opts={}, globbed=False, - default='relpath'): - newpats = [] - # The patterns were previously mangled to add the standin - # directory; we need to remove that now - for pat in pats: - if match_.patkind(pat) is None and lfutil.shortname in pat: - newpats.append(pat.replace(lfutil.shortname, '')) - else: - newpats.append(pat) - match = oldmatch(ctx, newpats, opts, globbed, default) - m = copy.copy(match) - lfile = lambda f: lfutil.standin(f) in manifest - m._files = [lfutil.standin(f) for f in m._files if lfile(f)] - m._fmap = set(m._files) - origmatchfn = m.matchfn - m.matchfn = lambda f: (lfutil.isstandin(f) and - (f in manifest) and - origmatchfn(lfutil.splitstandin(f)) or - None) - return m - oldmatch = installmatchfn(overridematch) - listpats = [] + manifest = repo[None].manifest() + def overridematch(ctx, pats=[], opts={}, globbed=False, + default='relpath'): + newpats = [] + # The patterns were previously mangled to add the standin + # directory; we need to remove that now for pat in pats: - if match_.patkind(pat) is not None: - listpats.append(pat) + if match_.patkind(pat) is None and lfutil.shortname in pat: + newpats.append(pat.replace(lfutil.shortname, '')) else: - listpats.append(makestandin(pat)) + newpats.append(pat) + match = oldmatch(ctx, newpats, opts, globbed, default) + m = copy.copy(match) + lfile = lambda f: lfutil.standin(f) in manifest + m._files = [lfutil.standin(f) for f in m._files if lfile(f)] + m._fileroots = set(m._files) + origmatchfn = m.matchfn + m.matchfn = lambda f: (lfutil.isstandin(f) and + (f in manifest) and + origmatchfn(lfutil.splitstandin(f)) or + None) + return m + oldmatch = installmatchfn(overridematch) + listpats = [] + for pat in pats: + if match_.patkind(pat) is not None: + listpats.append(pat) + else: + listpats.append(makestandin(pat)) - try: - origcopyfile = util.copyfile - copiedfiles = [] - def overridecopyfile(src, dest): - if (lfutil.shortname in src and - dest.startswith(repo.wjoin(lfutil.shortname))): - destlfile = dest.replace(lfutil.shortname, '') - if not opts['force'] and os.path.exists(destlfile): - raise IOError('', - _('destination largefile already exists')) - copiedfiles.append((src, dest)) - origcopyfile(src, dest) - - util.copyfile = overridecopyfile - result += orig(ui, repo, listpats, opts, rename) - finally: - util.copyfile = origcopyfile - - lfdirstate = lfutil.openlfdirstate(ui, repo) - for (src, dest) in copiedfiles: + try: + origcopyfile = util.copyfile + copiedfiles = [] + def overridecopyfile(src, dest): if (lfutil.shortname in src and dest.startswith(repo.wjoin(lfutil.shortname))): - srclfile = src.replace(repo.wjoin(lfutil.standin('')), '') - destlfile = dest.replace(repo.wjoin(lfutil.standin('')), '') - destlfiledir = os.path.dirname(repo.wjoin(destlfile)) or '.' - if not os.path.isdir(destlfiledir): - os.makedirs(destlfiledir) - if rename: - os.rename(repo.wjoin(srclfile), repo.wjoin(destlfile)) + destlfile = dest.replace(lfutil.shortname, '') + if not opts['force'] and os.path.exists(destlfile): + raise IOError('', + _('destination largefile already exists')) + copiedfiles.append((src, dest)) + origcopyfile(src, dest) + + util.copyfile = overridecopyfile + result += orig(ui, repo, listpats, opts, rename) + finally: + util.copyfile = origcopyfile - # The file is gone, but this deletes any empty parent - # directories as a side-effect. - util.unlinkpath(repo.wjoin(srclfile), True) - lfdirstate.remove(srclfile) - else: - util.copyfile(repo.wjoin(srclfile), - repo.wjoin(destlfile)) + lfdirstate = lfutil.openlfdirstate(ui, repo) + for (src, dest) in copiedfiles: + if (lfutil.shortname in src and + dest.startswith(repo.wjoin(lfutil.shortname))): + srclfile = src.replace(repo.wjoin(lfutil.standin('')), '') + destlfile = dest.replace(repo.wjoin(lfutil.standin('')), '') + destlfiledir = os.path.dirname(repo.wjoin(destlfile)) or '.' + if not os.path.isdir(destlfiledir): + os.makedirs(destlfiledir) + if rename: + os.rename(repo.wjoin(srclfile), repo.wjoin(destlfile)) - lfdirstate.add(destlfile) - lfdirstate.write() - except util.Abort, e: - if str(e) != _('no files to copy'): - raise e - else: - nolfiles = True + # The file is gone, but this deletes any empty parent + # directories as a side-effect. + util.unlinkpath(repo.wjoin(srclfile), True) + lfdirstate.remove(srclfile) + else: + util.copyfile(repo.wjoin(srclfile), + repo.wjoin(destlfile)) + + lfdirstate.add(destlfile) + lfdirstate.write() + except util.Abort, e: + if str(e) != _('no files to copy'): + raise e + else: + nolfiles = True finally: restorematchfn() wlock.release() @@ -744,7 +742,7 @@ return f m._files = [tostandin(f) for f in m._files] m._files = [f for f in m._files if f is not None] - m._fmap = set(m._files) + m._fileroots = set(m._files) origmatchfn = m.matchfn def matchfn(f): if lfutil.isstandin(f): @@ -985,7 +983,7 @@ for subpath in sorted(ctx.substate): sub = ctx.sub(subpath) submatch = match_.narrowmatcher(subpath, match) - sub.archive(archiver, os.path.join(prefix, repo._path) + '/', submatch) + sub.archive(archiver, prefix + repo._path + '/', submatch) # If a largefile is modified, the change is not reflected in its # standin until a commit. cmdutil.bailifchanged() raises an exception diff -r ef4538ba67ef -r 472a685a4961 hgext/largefiles/proto.py --- a/hgext/largefiles/proto.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/largefiles/proto.py Tue May 19 07:17:57 2015 -0500 @@ -31,17 +31,16 @@ tmpfp = util.atomictempfile(path, createmode=repo.store.createmode) try: - try: - proto.getfile(tmpfp) - tmpfp._fp.seek(0) - if sha != lfutil.hexsha1(tmpfp._fp): - raise IOError(0, _('largefile contents do not match hash')) - tmpfp.close() - lfutil.linktousercache(repo, sha) - except IOError, e: - repo.ui.warn(_('largefiles: failed to put %s into store: %s\n') % - (sha, e.strerror)) - return wireproto.pushres(1) + proto.getfile(tmpfp) + tmpfp._fp.seek(0) + if sha != lfutil.hexsha1(tmpfp._fp): + raise IOError(0, _('largefile contents do not match hash')) + tmpfp.close() + lfutil.linktousercache(repo, sha) + except IOError, e: + repo.ui.warn(_('largefiles: failed to put %s into store: %s\n') % + (sha, e.strerror)) + return wireproto.pushres(1) finally: tmpfp.discard() diff -r ef4538ba67ef -r 472a685a4961 hgext/largefiles/remotestore.py --- a/hgext/largefiles/remotestore.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/largefiles/remotestore.py Tue May 19 07:17:57 2015 -0500 @@ -36,13 +36,12 @@ self.ui.debug('remotestore: sendfile(%s, %s)\n' % (filename, hash)) fd = None try: - try: - fd = lfutil.httpsendfile(self.ui, filename) - except IOError, e: - raise util.Abort( - _('remotestore: could not open file %s: %s') - % (filename, str(e))) + fd = lfutil.httpsendfile(self.ui, filename) return self._put(hash, fd) + except IOError, e: + raise util.Abort( + _('remotestore: could not open file %s: %s') + % (filename, str(e))) finally: if fd: fd.close() diff -r ef4538ba67ef -r 472a685a4961 hgext/largefiles/reposetup.py --- a/hgext/largefiles/reposetup.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/largefiles/reposetup.py Tue May 19 07:17:57 2015 -0500 @@ -365,7 +365,7 @@ repo.prepushoutgoinghooks.add("largefiles", prepushoutgoinghook) def checkrequireslfiles(ui, repo, **kwargs): - if 'largefiles' not in repo.requirements and util.any( + if 'largefiles' not in repo.requirements and any( lfutil.shortname+'/' in f[0] for f in repo.store.datafiles()): repo.requirements.add('largefiles') repo._writerequirements() diff -r ef4538ba67ef -r 472a685a4961 hgext/mq.py --- a/hgext/mq.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/mq.py Tue May 19 07:17:57 2015 -0500 @@ -76,6 +76,10 @@ cmdtable = {} command = cmdutil.command(cmdtable) +# Note for extension authors: ONLY specify testedwith = 'internal' for +# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should +# be specifying the version(s) of Mercurial they are tested with, or +# leave the attribute unspecified. testedwith = 'internal' # force load strip extension formerly included in mq and import some utility @@ -298,7 +302,7 @@ self.haspatch = diffstart > 1 self.plainmode = (plainmode or '# HG changeset patch' not in self.comments and - util.any(c.startswith('Date: ') or + any(c.startswith('Date: ') or c.startswith('From: ') for c in self.comments)) @@ -376,14 +380,17 @@ if repo.ui.configbool('mq', 'secret', False): phase = phases.secret if phase is not None: - backup = repo.ui.backupconfig('phases', 'new-commit') + phasebackup = repo.ui.backupconfig('phases', 'new-commit') + allowemptybackup = repo.ui.backupconfig('ui', 'allowemptycommit') try: if phase is not None: repo.ui.setconfig('phases', 'new-commit', phase, 'mq') + repo.ui.setconfig('ui', 'allowemptycommit', True) return repo.commit(*args, **kwargs) finally: + repo.ui.restoreconfig(allowemptybackup) if phase is not None: - repo.ui.restoreconfig(backup) + repo.ui.restoreconfig(phasebackup) class AbortNoCleanup(error.Abort): pass @@ -807,9 +814,10 @@ 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 + wlock = dsguard = lock = tr = None try: wlock = repo.wlock() + dsguard = cmdutil.dirstateguard(repo, 'mq.apply') lock = repo.lock() tr = repo.transaction("qpush") try: @@ -818,21 +826,22 @@ tobackup=tobackup, keepchanges=keepchanges) tr.close() self.savedirty() + dsguard.close() return ret except AbortNoCleanup: tr.close() self.savedirty() + dsguard.close() raise except: # re-raises try: tr.abort() finally: repo.invalidate() - repo.dirstate.invalidate() self.invalidate() raise finally: - release(tr, lock, wlock) + release(tr, lock, dsguard, wlock) self.removeundo(repo) def _apply(self, repo, series, list=False, update_status=True, @@ -1681,8 +1690,9 @@ bmlist = repo[top].bookmarks() + dsguard = None try: - repo.dirstate.beginparentchange() + dsguard = cmdutil.dirstateguard(repo, 'mq.refresh') if diffopts.git or diffopts.upgrade: copies = {} for dst in a: @@ -1735,13 +1745,12 @@ # assumes strip can roll itself back if interrupted repo.setparents(*cparents) - repo.dirstate.endparentchange() self.applied.pop() self.applieddirty = True strip(self.ui, repo, [top], update=False, backup=False) - except: # re-raises - repo.dirstate.invalidate() - raise + dsguard.close() + finally: + release(dsguard) try: # might be nice to attempt to roll back strip after this diff -r ef4538ba67ef -r 472a685a4961 hgext/notify.py --- a/hgext/notify.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/notify.py Tue May 19 07:17:57 2015 -0500 @@ -138,9 +138,13 @@ # load. This was not a problem on Python 2.7. import email.Parser from mercurial.i18n import _ -from mercurial import patch, cmdutil, templater, util, mail +from mercurial import patch, cmdutil, util, mail import fnmatch +# Note for extension authors: ONLY specify testedwith = 'internal' for +# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should +# be specifying the version(s) of Mercurial they are tested with, or +# leave the attribute unspecified. testedwith = 'internal' # template for single changeset can include email headers. @@ -190,8 +194,6 @@ self.ui.config('notify', 'template')) if not mapfile and not template: template = deftemplates.get(hooktype) or single_template - if template: - template = templater.parsestring(template, quoted=False) self.t = cmdutil.changeset_templater(self.ui, self.repo, False, None, template, mapfile, False) diff -r ef4538ba67ef -r 472a685a4961 hgext/pager.py --- a/hgext/pager.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/pager.py Tue May 19 07:17:57 2015 -0500 @@ -59,6 +59,10 @@ from mercurial import commands, dispatch, util, extensions, cmdutil from mercurial.i18n import _ +# Note for extension authors: ONLY specify testedwith = 'internal' for +# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should +# be specifying the version(s) of Mercurial they are tested with, or +# leave the attribute unspecified. testedwith = 'internal' def _pagerfork(ui, p): diff -r ef4538ba67ef -r 472a685a4961 hgext/patchbomb.py --- a/hgext/patchbomb.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/patchbomb.py Tue May 19 07:17:57 2015 -0500 @@ -71,6 +71,10 @@ cmdtable = {} command = cmdutil.command(cmdtable) +# Note for extension authors: ONLY specify testedwith = 'internal' for +# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should +# be specifying the version(s) of Mercurial they are tested with, or +# leave the attribute unspecified. testedwith = 'internal' def prompt(ui, prompt, default=None, rest=':'): diff -r ef4538ba67ef -r 472a685a4961 hgext/progress.py --- a/hgext/progress.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/progress.py Tue May 19 07:17:57 2015 -0500 @@ -40,6 +40,10 @@ import threading from mercurial.i18n import _ +# Note for extension authors: ONLY specify testedwith = 'internal' for +# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should +# be specifying the version(s) of Mercurial they are tested with, or +# leave the attribute unspecified. testedwith = 'internal' from mercurial import encoding diff -r ef4538ba67ef -r 472a685a4961 hgext/purge.py --- a/hgext/purge.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/purge.py Tue May 19 07:17:57 2015 -0500 @@ -30,6 +30,10 @@ cmdtable = {} command = cmdutil.command(cmdtable) +# Note for extension authors: ONLY specify testedwith = 'internal' for +# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should +# be specifying the version(s) of Mercurial they are tested with, or +# leave the attribute unspecified. testedwith = 'internal' @command('purge|clean', diff -r ef4538ba67ef -r 472a685a4961 hgext/rebase.py --- a/hgext/rebase.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/rebase.py Tue May 19 07:17:57 2015 -0500 @@ -29,6 +29,10 @@ cmdtable = {} command = cmdutil.command(cmdtable) +# Note for extension authors: ONLY specify testedwith = 'internal' for +# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should +# be specifying the version(s) of Mercurial they are tested with, or +# leave the attribute unspecified. testedwith = 'internal' def _savegraft(ctx, extra): @@ -67,7 +71,7 @@ ('e', 'edit', False, _('invoke editor on commit messages')), ('l', 'logfile', '', _('read collapse commit message from file'), _('FILE')), - ('', 'keep', False, _('keep original changesets')), + ('k', 'keep', False, _('keep original changesets')), ('', 'keepbranches', False, _('keep original branch names')), ('D', 'detach', False, _('(DEPRECATED)')), ('i', 'interactive', False, _('(DEPRECATED)')), @@ -358,9 +362,9 @@ # Keep track of the current bookmarks in order to reset them later currentbookmarks = repo._bookmarks.copy() - activebookmark = activebookmark or repo._bookmarkcurrent + activebookmark = activebookmark or repo._activebookmark if activebookmark: - bookmarks.unsetcurrent(repo) + bookmarks.deactivate(repo) extrafn = _makeextrafn(extrafns) @@ -498,7 +502,7 @@ if (activebookmark and repo['.'].node() == repo._bookmarks[activebookmark]): - bookmarks.setcurrent(repo, activebookmark) + bookmarks.activate(repo, activebookmark) finally: release(lock, wlock) @@ -530,10 +534,9 @@ '''Commit the wd changes with parents p1 and p2. Reuse commit info from rev but also store useful information in extra. Return node of committed revision.''' + dsguard = cmdutil.dirstateguard(repo, 'rebase') try: - repo.dirstate.beginparentchange() repo.setparents(repo[p1].node(), repo[p2].node()) - repo.dirstate.endparentchange() ctx = repo[rev] if commitmsg is None: commitmsg = ctx.description() @@ -552,11 +555,10 @@ repo.ui.restoreconfig(backup) repo.dirstate.setbranch(repo[newnode].branch()) + dsguard.close() return newnode - except util.Abort: - # Invalidate the previous setparents - repo.dirstate.invalidate() - raise + finally: + release(dsguard) def rebasenode(repo, rev, p1, base, state, collapse, target): 'Rebase a single revision rev on top of p1 using base as merge ancestor' @@ -893,7 +895,7 @@ repair.strip(repo.ui, repo, strippoints) if activebookmark and activebookmark in repo._bookmarks: - bookmarks.setcurrent(repo, activebookmark) + bookmarks.activate(repo, activebookmark) clearstatus(repo) repo.ui.warn(_('rebase aborted\n')) @@ -1057,7 +1059,7 @@ hg.update(repo, dest) if bookmarks.update(repo, [movemarkfrom], repo['.'].node()): ui.status(_("updating bookmark %s\n") - % repo._bookmarkcurrent) + % repo._activebookmark) else: if opts.get('tool'): raise util.Abort(_('--tool can only be used with --rebase')) @@ -1118,4 +1120,3 @@ _("use 'hg rebase --continue' or 'hg rebase --abort'")]) # ensure rebased rev are not hidden extensions.wrapfunction(repoview, '_getdynamicblockers', _rebasedvisible) - diff -r ef4538ba67ef -r 472a685a4961 hgext/record.py --- a/hgext/record.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/record.py Tue May 19 07:17:57 2015 -0500 @@ -13,6 +13,10 @@ cmdtable = {} command = cmdutil.command(cmdtable) +# Note for extension authors: ONLY specify testedwith = 'internal' for +# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should +# be specifying the version(s) of Mercurial they are tested with, or +# leave the attribute unspecified. testedwith = 'internal' diff -r ef4538ba67ef -r 472a685a4961 hgext/relink.py --- a/hgext/relink.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/relink.py Tue May 19 07:17:57 2015 -0500 @@ -13,6 +13,10 @@ cmdtable = {} command = cmdutil.command(cmdtable) +# Note for extension authors: ONLY specify testedwith = 'internal' for +# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should +# be specifying the version(s) of Mercurial they are tested with, or +# leave the attribute unspecified. testedwith = 'internal' @command('relink', [], _('[ORIGIN]')) diff -r ef4538ba67ef -r 472a685a4961 hgext/schemes.py --- a/hgext/schemes.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/schemes.py Tue May 19 07:17:57 2015 -0500 @@ -44,6 +44,10 @@ from mercurial import extensions, hg, templater, util from mercurial.i18n import _ +# Note for extension authors: ONLY specify testedwith = 'internal' for +# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should +# be specifying the version(s) of Mercurial they are tested with, or +# leave the attribute unspecified. testedwith = 'internal' diff -r ef4538ba67ef -r 472a685a4961 hgext/share.py --- a/hgext/share.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/share.py Tue May 19 07:17:57 2015 -0500 @@ -12,6 +12,10 @@ cmdtable = {} command = cmdutil.command(cmdtable) +# Note for extension authors: ONLY specify testedwith = 'internal' for +# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should +# be specifying the version(s) of Mercurial they are tested with, or +# leave the attribute unspecified. testedwith = 'internal' @command('share', diff -r ef4538ba67ef -r 472a685a4961 hgext/shelve.py --- a/hgext/shelve.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/shelve.py Tue May 19 07:17:57 2015 -0500 @@ -21,6 +21,7 @@ shelve". """ +import collections from mercurial.i18n import _ from mercurial.node import nullid, nullrev, bin, hex from mercurial import changegroup, cmdutil, scmutil, phases, commands @@ -32,6 +33,10 @@ cmdtable = {} command = cmdutil.command(cmdtable) +# Note for extension authors: ONLY specify testedwith = 'internal' for +# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should +# be specifying the version(s) of Mercurial they are tested with, or +# leave the attribute unspecified. testedwith = 'internal' class shelvedfile(object): @@ -143,7 +148,7 @@ Much faster than the revset ancestors(ctx) & draft()""" seen = set([nullrev]) - visit = util.deque() + visit = collections.deque() visit.append(ctx) while visit: ctx = visit.popleft() @@ -163,7 +168,7 @@ # we never need the user, so we use a generic user for all shelve operations user = 'shelve@localhost' - label = repo._bookmarkcurrent or parent.branch() or 'default' + label = repo._activebookmark or parent.branch() or 'default' # slashes aren't allowed in filenames, therefore we rename it label = label.replace('/', '_') @@ -284,17 +289,15 @@ """subcommand that deletes a specific shelve""" if not pats: raise util.Abort(_('no shelved changes specified!')) - wlock = None + wlock = repo.wlock() try: - wlock = repo.wlock() - try: - for name in pats: - for suffix in 'hg patch'.split(): - shelvedfile(repo, name, suffix).unlink() - except OSError, err: - if err.errno != errno.ENOENT: - raise - raise util.Abort(_("shelved change '%s' not found") % name) + for name in pats: + for suffix in 'hg patch'.split(): + shelvedfile(repo, name, suffix).unlink() + except OSError, err: + if err.errno != errno.ENOENT: + raise + raise util.Abort(_("shelved change '%s' not found") % name) finally: lockmod.release(wlock) @@ -363,6 +366,17 @@ finally: fp.close() +def singlepatchcmds(ui, repo, pats, opts, subcommand): + """subcommand that displays a single shelf""" + if len(pats) != 1: + raise util.Abort(_("--%s expects a single shelf") % subcommand) + shelfname = pats[0] + + if not shelvedfile(repo, shelfname, 'patch').exists(): + raise util.Abort(_("cannot find shelf %s") % shelfname) + + listcmd(ui, repo, pats, opts) + def checkparents(repo, state): """check parent while resuming an unshelve""" if state.parents != repo.dirstate.parents(): @@ -693,21 +707,21 @@ cmdutil.checkunfinished(repo) allowables = [ - ('addremove', 'create'), # 'create' is pseudo action - ('cleanup', 'cleanup'), -# ('date', 'create'), # ignored for passing '--date "0 0"' in tests - ('delete', 'delete'), - ('edit', 'create'), - ('list', 'list'), - ('message', 'create'), - ('name', 'create'), - ('patch', 'list'), - ('stat', 'list'), + ('addremove', set(['create'])), # 'create' is pseudo action + ('cleanup', set(['cleanup'])), +# ('date', set(['create'])), # ignored for passing '--date "0 0"' in tests + ('delete', set(['delete'])), + ('edit', set(['create'])), + ('list', set(['list'])), + ('message', set(['create'])), + ('name', set(['create'])), + ('patch', set(['patch', 'list'])), + ('stat', set(['stat', 'list'])), ] def checkopt(opt): if opts[opt]: for i, allowable in allowables: - if opts[i] and opt != allowable: + if opts[i] and opt not in allowable: raise util.Abort(_("options '--%s' and '--%s' may not be " "used together") % (opt, i)) return True @@ -719,11 +733,11 @@ return deletecmd(ui, repo, pats) elif checkopt('list'): return listcmd(ui, repo, pats, opts) + elif checkopt('patch'): + return singlepatchcmds(ui, repo, pats, opts, subcommand='patch') + elif checkopt('stat'): + return singlepatchcmds(ui, repo, pats, opts, subcommand='stat') else: - for i in ('patch', 'stat'): - if opts[i]: - raise util.Abort(_("option '--%s' may not be " - "used when shelving a change") % (i,)) return createcmd(ui, repo, pats, opts) def extsetup(ui): diff -r ef4538ba67ef -r 472a685a4961 hgext/strip.py --- a/hgext/strip.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/strip.py Tue May 19 07:17:57 2015 -0500 @@ -11,6 +11,10 @@ cmdtable = {} command = cmdutil.command(cmdtable) +# Note for extension authors: ONLY specify testedwith = 'internal' for +# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should +# be specifying the version(s) of Mercurial they are tested with, or +# leave the attribute unspecified. testedwith = 'internal' def checksubstate(repo, baserev=None): @@ -60,8 +64,8 @@ marks = repo._bookmarks if bookmark: - if bookmark == repo._bookmarkcurrent: - bookmarks.unsetcurrent(repo) + if bookmark == repo._activebookmark: + bookmarks.deactivate(repo) del marks[bookmark] marks.write() ui.write(_("bookmark '%s' deleted\n") % bookmark) diff -r ef4538ba67ef -r 472a685a4961 hgext/transplant.py --- a/hgext/transplant.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/transplant.py Tue May 19 07:17:57 2015 -0500 @@ -26,6 +26,10 @@ cmdtable = {} command = cmdutil.command(cmdtable) +# Note for extension authors: ONLY specify testedwith = 'internal' for +# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should +# be specifying the version(s) of Mercurial they are tested with, or +# leave the attribute unspecified. testedwith = 'internal' class transplantentry(object): diff -r ef4538ba67ef -r 472a685a4961 hgext/win32mbcs.py --- a/hgext/win32mbcs.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/win32mbcs.py Tue May 19 07:17:57 2015 -0500 @@ -48,6 +48,10 @@ import os, sys from mercurial.i18n import _ from mercurial import util, encoding +# Note for extension authors: ONLY specify testedwith = 'internal' for +# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should +# be specifying the version(s) of Mercurial they are tested with, or +# leave the attribute unspecified. testedwith = 'internal' _encoding = None # see extsetup diff -r ef4538ba67ef -r 472a685a4961 hgext/win32text.py --- a/hgext/win32text.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/win32text.py Tue May 19 07:17:57 2015 -0500 @@ -46,6 +46,10 @@ from mercurial import util import re +# Note for extension authors: ONLY specify testedwith = 'internal' for +# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should +# be specifying the version(s) of Mercurial they are tested with, or +# leave the attribute unspecified. testedwith = 'internal' # regexp for single LF without CR preceding. diff -r ef4538ba67ef -r 472a685a4961 hgext/zeroconf/__init__.py --- a/hgext/zeroconf/__init__.py Sun May 17 22:09:37 2015 -0400 +++ b/hgext/zeroconf/__init__.py Tue May 19 07:17:57 2015 -0500 @@ -31,6 +31,10 @@ from mercurial import extensions from mercurial.hgweb import server as servermod +# Note for extension authors: ONLY specify testedwith = 'internal' for +# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should +# be specifying the version(s) of Mercurial they are tested with, or +# leave the attribute unspecified. testedwith = 'internal' # publish diff -r ef4538ba67ef -r 472a685a4961 mercurial/ancestor.py --- a/mercurial/ancestor.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/ancestor.py Tue May 19 07:17:57 2015 -0500 @@ -5,8 +5,8 @@ # This software may be used and distributed according to the terms of the # GNU General Public License version 2 or any later version. +import collections import heapq -import util from node import nullrev def commonancestorsheads(pfunc, *nodes): @@ -314,7 +314,7 @@ parentrevs = self._parentrevs stoprev = self._stoprev - visit = util.deque(revs) + visit = collections.deque(revs) while visit: for parent in parentrevs(visit.popleft()): diff -r ef4538ba67ef -r 472a685a4961 mercurial/archival.py --- a/mercurial/archival.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/archival.py Tue May 19 07:17:57 2015 -0500 @@ -37,6 +37,10 @@ prefix = util.pconvert(lpfx) if not prefix.endswith('/'): prefix += '/' + # Drop the leading '.' path component if present, so Windows can read the + # zip files (issue4634) + if prefix.startswith('./'): + prefix = prefix[2:] if prefix.startswith('../') or os.path.isabs(lpfx) or '/../' in prefix: raise util.Abort(_('archive prefix contains illegal components')) return prefix @@ -50,7 +54,7 @@ def guesskind(dest): for kind, extensions in exts.iteritems(): - if util.any(dest.endswith(ext) for ext in extensions): + if any(dest.endswith(ext) for ext in extensions): return kind return None diff -r ef4538ba67ef -r 472a685a4961 mercurial/bookmarks.py --- a/mercurial/bookmarks.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/bookmarks.py Tue May 19 07:17:57 2015 -0500 @@ -8,7 +8,7 @@ import os from mercurial.i18n import _ from mercurial.node import hex, bin -from mercurial import encoding, error, util, obsolete, lock as lockmod +from mercurial import encoding, util, obsolete, lock as lockmod import errno class bmstore(dict): @@ -22,7 +22,7 @@ {hash}\s{name}\n (the same format as localtags) in .hg/bookmarks. The mapping is stored as {name: nodeid}. - This class does NOT handle the "current" bookmark state at this + This class does NOT handle the "active" bookmark state at this time. """ @@ -83,8 +83,8 @@ def _writerepo(self, repo): """Factored out for extensibility""" - if repo._bookmarkcurrent not in self: - unsetcurrent(repo) + if repo._activebookmark not in self: + deactivate(repo) wlock = repo.wlock() try: @@ -106,13 +106,12 @@ for name, node in self.iteritems(): fp.write("%s %s\n" % (hex(node), encoding.fromlocal(name))) -def readcurrent(repo): - '''Get the current bookmark - - If we use gittish branches we have a current bookmark that - we are on. This function returns the name of the bookmark. It - is stored in .hg/bookmarks.current - ''' +def readactive(repo): + """ + Get the active bookmark. We can have an active bookmark that updates + itself as we commit. This function returns the name of that bookmark. + It is stored in .hg/bookmarks.current + """ mark = None try: file = repo.vfs('bookmarks.current') @@ -129,17 +128,17 @@ file.close() return mark -def setcurrent(repo, mark): - '''Set the name of the bookmark that we are currently on - - Set the name of the bookmark that we are on (hg update ). +def activate(repo, mark): + """ + Set the given bookmark to be 'active', meaning that this bookmark will + follow new commits that are made. The name is recorded in .hg/bookmarks.current - ''' + """ if mark not in repo._bookmarks: raise AssertionError('bookmark %s does not exist!' % mark) - current = repo._bookmarkcurrent - if current == mark: + active = repo._activebookmark + if active == mark: return wlock = repo.wlock() @@ -149,42 +148,36 @@ file.close() finally: wlock.release() - repo._bookmarkcurrent = mark + repo._activebookmark = mark -def unsetcurrent(repo): +def deactivate(repo): + """ + Unset the active bookmark in this reposiotry. + """ wlock = repo.wlock() try: - try: - repo.vfs.unlink('bookmarks.current') - repo._bookmarkcurrent = None - except OSError, inst: - if inst.errno != errno.ENOENT: - raise + repo.vfs.unlink('bookmarks.current') + repo._activebookmark = None + except OSError, inst: + if inst.errno != errno.ENOENT: + raise finally: wlock.release() -def iscurrent(repo, mark=None, parents=None): - '''Tell whether the current bookmark is also active +def isactivewdirparent(repo): + """ + Tell whether the 'active' bookmark (the one that follows new commits) + points to one of the parents of the current working directory (wdir). - I.e., the bookmark listed in .hg/bookmarks.current also points to a - parent of the working directory. - ''' - if not mark: - mark = repo._bookmarkcurrent - if not parents: - parents = [p.node() for p in repo[None].parents()] + While this is normally the case, it can on occasion be false; for example, + immediately after a pull, the active bookmark can be moved to point + to a place different than the wdir. This is solved by running `hg update`. + """ + mark = repo._activebookmark marks = repo._bookmarks + parents = [p.node() for p in repo[None].parents()] return (mark in marks and marks[mark] in parents) -def updatecurrentbookmark(repo, oldnode, curbranch): - try: - return update(repo, oldnode, repo.branchtip(curbranch)) - except error.RepoLookupError: - if curbranch == "default": # no default branch! - return update(repo, oldnode, repo.lookup("tip")) - else: - raise util.Abort(_("branch %s not found") % curbranch) - def deletedivergent(repo, deletefrom, bm): '''Delete divergent versions of bm on nodes in deletefrom. @@ -207,33 +200,33 @@ check out and where to move the active bookmark from, if needed.''' movemarkfrom = None if checkout is None: - curmark = repo._bookmarkcurrent - if iscurrent(repo): + activemark = repo._activebookmark + if isactivewdirparent(repo): movemarkfrom = repo['.'].node() - elif curmark: - ui.status(_("updating to active bookmark %s\n") % curmark) - checkout = curmark + elif activemark: + ui.status(_("updating to active bookmark %s\n") % activemark) + checkout = activemark return (checkout, movemarkfrom) def update(repo, parents, node): deletefrom = parents marks = repo._bookmarks update = False - cur = repo._bookmarkcurrent - if not cur: + active = repo._activebookmark + if not active: return False - if marks[cur] in parents: + if marks[active] in parents: new = repo[node] divs = [repo[b] for b in marks - if b.split('@', 1)[0] == cur.split('@', 1)[0]] + if b.split('@', 1)[0] == active.split('@', 1)[0]] anc = repo.changelog.ancestors([new.rev()]) deletefrom = [b.node() for b in divs if b.rev() in anc or b == new] - if validdest(repo, repo[marks[cur]], new): - marks[cur] = new.node() + if validdest(repo, repo[marks[active]], new): + marks[active] = new.node() update = True - if deletedivergent(repo, deletefrom, cur): + if deletedivergent(repo, deletefrom, active): update = True if update: diff -r ef4538ba67ef -r 472a685a4961 mercurial/bundle2.py --- a/mercurial/bundle2.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/bundle2.py Tue May 19 07:17:57 2015 -0500 @@ -315,7 +315,7 @@ try: for part in iterparts: _processpart(op, part) - except Exception, exc: + except BaseException, exc: for part in iterparts: # consume the bundle content part.seek(0, 2) @@ -762,7 +762,7 @@ for chunk in self._payloadchunks(): yield _pack(_fpayloadsize, len(chunk)) yield chunk - except Exception, exc: + except BaseException, exc: # backup exception data for later exc_info = sys.exc_info() msg = 'unexpected error: %s' % exc diff -r ef4538ba67ef -r 472a685a4961 mercurial/bundlerepo.py --- a/mercurial/bundlerepo.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/bundlerepo.py Tue May 19 07:17:57 2015 -0500 @@ -177,11 +177,10 @@ return manifest.manifest.revision(self, nodeorrev) class bundlefilelog(bundlerevlog, filelog.filelog): - def __init__(self, opener, path, bundle, linkmapper, repo): + def __init__(self, opener, path, bundle, linkmapper): filelog.filelog.__init__(self, opener, path) bundlerevlog.__init__(self, opener, self.indexfile, bundle, linkmapper) - self._repo = repo def baserevision(self, nodeorrev): return filelog.filelog.revision(self, nodeorrev) @@ -322,8 +321,7 @@ if f in self.bundlefilespos: self.bundle.seek(self.bundlefilespos[f]) - return bundlefilelog(self.svfs, f, self.bundle, - self.changelog.rev, self) + return bundlefilelog(self.svfs, f, self.bundle, self.changelog.rev) else: return filelog.filelog(self.svfs, f) diff -r ef4538ba67ef -r 472a685a4961 mercurial/changegroup.py --- a/mercurial/changegroup.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/changegroup.py Tue May 19 07:17:57 2015 -0500 @@ -283,8 +283,6 @@ if bundlecaps is None: bundlecaps = set() self._bundlecaps = bundlecaps - self._changelog = repo.changelog - self._manifest = repo.manifest reorder = repo.ui.config('bundle', 'reorder', 'auto') if reorder == 'auto': reorder = None @@ -304,7 +302,7 @@ def fileheader(self, fname): return chunkheader(len(fname)) + fname - def group(self, nodelist, revlog, lookup, units=None, reorder=None): + def group(self, nodelist, revlog, lookup, units=None): """Calculate a delta group, yielding a sequence of changegroup chunks (strings). @@ -325,7 +323,7 @@ # for generaldelta revlogs, we linearize the revs; this will both be # much quicker and generate a much smaller bundle - if (revlog._generaldelta and reorder is not False) or reorder: + if (revlog._generaldelta and self._reorder is None) or self._reorder: dag = dagutil.revlogdag(revlog) revs = set(revlog.rev(n) for n in nodelist) revs = dag.linearize(revs) @@ -347,23 +345,20 @@ for c in self.revchunk(revlog, curr, prev, linknode): yield c + if units is not None: + self._progress(msgbundling, None) yield self.close() # filter any nodes that claim to be part of the known set - def prune(self, revlog, missing, commonrevs, source): + def prune(self, revlog, missing, commonrevs): rr, rl = revlog.rev, revlog.linkrev return [n for n in missing if rl(rr(n)) not in commonrevs] def generate(self, commonrevs, clnodes, fastpathlinkrev, source): '''yield a sequence of changegroup chunks (strings)''' repo = self._repo - cl = self._changelog - mf = self._manifest - reorder = self._reorder - progress = self._progress - - # for progress output - msgbundling = _('bundling') + cl = repo.changelog + ml = repo.manifest clrevorder = {} mfs = {} # needed manifests @@ -383,20 +378,34 @@ self._verbosenote(_('uncompressed size of bundle content:\n')) size = 0 - for chunk in self.group(clnodes, cl, lookupcl, units=_('changesets'), - reorder=reorder): + for chunk in self.group(clnodes, cl, lookupcl, units=_('changesets')): size += len(chunk) yield chunk self._verbosenote(_('%8.i (changelog)\n') % size) - progress(msgbundling, None) + # We need to make sure that the linkrev in the changegroup refers to + # the first changeset that introduced the manifest or file revision. + # The fastpath is usually safer than the slowpath, because the filelogs + # are walked in revlog order. + # + # When taking the slowpath with reorder=None and the manifest revlog + # uses generaldelta, the manifest may be walked in the "wrong" order. + # Without 'clrevorder', we would get an incorrect linkrev (see fix in + # cc0ff93d0c0c). + # + # When taking the fastpath, we are only vulnerable to reordering + # of the changelog itself. The changelog never uses generaldelta, so + # it is only reordered when reorder=True. To handle this case, we + # simply take the slowpath, which already has the 'clrevorder' logic. + # This was also fixed in cc0ff93d0c0c. + fastpathlinkrev = fastpathlinkrev and not self._reorder # Callback for the manifest, used to collect linkrevs for filelog # revisions. # Returns the linkrev node (collected in lookupcl). def lookupmf(x): clnode = mfs[x] - if not fastpathlinkrev or reorder: - mdata = mf.readfast(x) + if not fastpathlinkrev: + mdata = ml.readfast(x) for f, n in mdata.iteritems(): if f in changedfiles: # record the first changeset introducing this filelog @@ -407,25 +416,23 @@ fclnodes[n] = clnode return clnode - mfnodes = self.prune(mf, mfs, commonrevs, source) + mfnodes = self.prune(ml, mfs, commonrevs) size = 0 - for chunk in self.group(mfnodes, mf, lookupmf, units=_('manifests'), - reorder=reorder): + for chunk in self.group(mfnodes, ml, lookupmf, units=_('manifests')): size += len(chunk) yield chunk self._verbosenote(_('%8.i (manifests)\n') % size) - progress(msgbundling, None) mfs.clear() - needed = set(cl.rev(x) for x in clnodes) + clrevs = set(cl.rev(x) for x in clnodes) def linknodes(filerevlog, fname): - if fastpathlinkrev and not reorder: + if fastpathlinkrev: llr = filerevlog.linkrev def genfilenodes(): for r in filerevlog: linkrev = llr(r) - if linkrev in needed: + if linkrev in clrevs: yield filerevlog.node(r), cl.node(linkrev) return dict(genfilenodes()) return fnodes.get(fname, {}) @@ -435,15 +442,14 @@ yield chunk yield self.close() - progress(msgbundling, None) if clnodes: repo.hook('outgoing', node=hex(clnodes[0]), source=source) + # The 'source' parameter is useful for extensions def generatefiles(self, changedfiles, linknodes, commonrevs, source): repo = self._repo progress = self._progress - reorder = self._reorder msgbundling = _('bundling') total = len(changedfiles) @@ -460,18 +466,18 @@ def lookupfilelog(x): return linkrevnodes[x] - filenodes = self.prune(filerevlog, linkrevnodes, commonrevs, source) + filenodes = self.prune(filerevlog, linkrevnodes, commonrevs) if filenodes: progress(msgbundling, i + 1, item=fname, unit=msgfiles, total=total) h = self.fileheader(fname) size = len(h) yield h - for chunk in self.group(filenodes, filerevlog, lookupfilelog, - reorder=reorder): + for chunk in self.group(filenodes, filerevlog, lookupfilelog): size += len(chunk) yield chunk self._verbosenote(_('%8.i %s\n') % (size, fname)) + progress(msgbundling, None) def deltaparent(self, revlog, rev, p1, p2, prev): return prev @@ -513,11 +519,13 @@ version = '02' deltaheader = _CHANGEGROUPV2_DELTA_HEADER - def group(self, nodelist, revlog, lookup, units=None, reorder=None): - if (revlog._generaldelta and reorder is not True): - reorder = False - return super(cg2packer, self).group(nodelist, revlog, lookup, - units=units, reorder=reorder) + def __init__(self, repo, bundlecaps=None): + super(cg2packer, self).__init__(repo, bundlecaps) + if self._reorder is None: + # Since generaldelta is directly supported by cg2, reordering + # generally doesn't help, so we disable it by default (treating + # bundle.reorder=auto just like bundle.reorder=False). + self._reorder = False def deltaparent(self, revlog, rev, p1, p2, prev): dp = revlog.deltaparent(rev) @@ -788,8 +796,8 @@ if repo.ui.configbool('server', 'validate', default=False): # validate incoming csets have their manifests for cset in xrange(clstart, clend): - mfest = repo.changelog.read(repo.changelog.node(cset))[0] - mfest = repo.manifest.readdelta(mfest) + mfnode = repo.changelog.read(repo.changelog.node(cset))[0] + mfest = repo.manifest.readdelta(mfnode) # store file nodes we must see for f, n in mfest.iteritems(): needfiles.setdefault(f, set()).add(n) diff -r ef4538ba67ef -r 472a685a4961 mercurial/changelog.py --- a/mercurial/changelog.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/changelog.py Tue May 19 07:17:57 2015 -0500 @@ -172,14 +172,6 @@ self.rev(self.node(0)) return self._nodecache - def hasnode(self, node): - """filtered version of revlog.hasnode""" - try: - i = self.rev(node) - return i not in self.filteredrevs - except KeyError: - return False - def headrevs(self): if self.filteredrevs: try: diff -r ef4538ba67ef -r 472a685a4961 mercurial/cmdutil.py --- a/mercurial/cmdutil.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/cmdutil.py Tue May 19 07:17:57 2015 -0500 @@ -450,14 +450,17 @@ """opens the changelog, manifest, a filelog or a given revlog""" cl = opts['changelog'] mf = opts['manifest'] + dir = opts['dir'] msg = None if cl and mf: msg = _('cannot specify --changelog and --manifest at the same time') + elif cl and dir: + msg = _('cannot specify --changelog and --dir at the same time') elif cl or mf: if file_: msg = _('cannot specify filename with --changelog or --manifest') elif not repo: - msg = _('cannot specify --changelog or --manifest ' + msg = _('cannot specify --changelog or --manifest or --dir ' 'without a repository') if msg: raise util.Abort(msg) @@ -466,6 +469,13 @@ if repo: if cl: r = repo.unfiltered().changelog + elif dir: + if 'treemanifest' not in repo.requirements: + raise util.Abort(_("--dir can only be used on repos with " + "treemanifest enabled")) + dirlog = repo.dirlog(file_) + if len(dirlog): + r = dirlog elif mf: r = repo.manifest elif file_: @@ -818,6 +828,7 @@ msg = _('applied to working directory') rejects = False + dsguard = None try: cmdline_message = logmessage(ui, opts) @@ -859,7 +870,7 @@ n = None if update: - repo.dirstate.beginparentchange() + dsguard = dirstateguard(repo, 'tryimportone') if p1 != parents[0]: updatefunc(repo, p1.node()) if p2 != parents[1]: @@ -896,10 +907,16 @@ editor = None else: editor = getcommiteditor(editform=editform, **opts) - n = repo.commit(message, opts.get('user') or user, - opts.get('date') or date, match=m, - editor=editor, force=partial) - repo.dirstate.endparentchange() + allowemptyback = repo.ui.backupconfig('ui', 'allowemptycommit') + try: + if partial: + repo.ui.setconfig('ui', 'allowemptycommit', True) + n = repo.commit(message, opts.get('user') or user, + opts.get('date') or date, match=m, + editor=editor) + finally: + repo.ui.restoreconfig(allowemptyback) + dsguard.close() else: if opts.get('exact') or opts.get('import_branch'): branch = branch or 'default' @@ -937,6 +954,7 @@ msg = _('created %s') % short(n) return (msg, n, rejects) finally: + lockmod.release(dsguard) os.unlink(tmpname) def export(repo, revs, template='hg-%h.patch', fp=None, switch_parent=False, @@ -1443,9 +1461,9 @@ tmpl = ui.config('ui', 'logtemplate') if tmpl: try: - tmpl = templater.parsestring(tmpl) + tmpl = templater.unquotestring(tmpl) except SyntaxError: - tmpl = templater.parsestring(tmpl, quoted=False) + pass return tmpl, None else: style = util.expandpath(ui.config('ui', 'style', '')) @@ -1477,9 +1495,9 @@ t = ui.config('templates', tmpl) if t: try: - tmpl = templater.parsestring(t) + tmpl = templater.unquotestring(t) except SyntaxError: - tmpl = templater.parsestring(t, quoted=False) + tmpl = t return tmpl, None if tmpl == 'list': @@ -1825,13 +1843,12 @@ for windowsize in increasingwindows(): nrevs = [] for i in xrange(windowsize): - try: - rev = it.next() - if want(rev): - nrevs.append(rev) - except (StopIteration): + rev = next(it, None) + if rev is None: stopiteration = True break + elif want(rev): + nrevs.append(rev) for rev in sorted(nrevs): fns = fncache.get(rev) ctx = change(rev) @@ -1916,10 +1933,7 @@ # --follow with FILE behaviour depends on revs... it = iter(revs) startrev = it.next() - try: - followdescendants = startrev < it.next() - except (StopIteration): - followdescendants = False + followdescendants = startrev < next(it, startrev) # branch and only_branch are really aliases and must be handled at # the same time @@ -2113,15 +2127,11 @@ if not opts.get('rev'): revs.sort(reverse=True) if limit is not None: - count = 0 limitedrevs = [] - it = iter(revs) - while count < limit: - try: - limitedrevs.append(it.next()) - except (StopIteration): + for idx, r in enumerate(revs): + if limit <= idx: break - count += 1 + limitedrevs.append(r) revs = revset.baseset(limitedrevs) return revs, expr, filematcher @@ -2336,7 +2346,7 @@ return True return False - isdir = f in deleteddirs or f in wctx.dirs() + isdir = f in deleteddirs or wctx.hasdir(f) if f in repo.dirstate or isdir or f == '.' or insubrepo(): continue @@ -2464,9 +2474,10 @@ ui.note(_('amending changeset %s\n') % old) base = old.p1() - wlock = lock = newid = None + wlock = dsguard = lock = newid = None try: wlock = repo.wlock() + dsguard = dirstateguard(repo, 'amend') lock = repo.lock() tr = repo.transaction('amend') try: @@ -2480,13 +2491,13 @@ # First, do a regular commit to record all changes in the working # directory (if there are any) ui.callhooks = False - currentbookmark = repo._bookmarkcurrent + activebookmark = repo._activebookmark try: - repo._bookmarkcurrent = None + repo._activebookmark = None opts['message'] = 'temporary amend commit for %s' % old node = commit(ui, repo, commitfunc, pats, opts) finally: - repo._bookmarkcurrent = currentbookmark + repo._activebookmark = activebookmark ui.callhooks = True ctx = repo[node] @@ -2637,6 +2648,7 @@ tr.close() finally: tr.release() + dsguard.close() if not createmarkers and newid != old.node(): # Strip the intermediate commit (if there was one) and the amended # commit @@ -2645,9 +2657,7 @@ ui.note(_('stripping amended changeset %s\n') % old) repair.strip(ui, repo, old.node(), topic='amend-backup') finally: - if newid is None: - repo.dirstate.invalidate() - lockmod.release(lock, wlock) + lockmod.release(lock, dsguard, wlock) return newid def commiteditor(repo, ctx, subs, editform=''): @@ -2721,8 +2731,8 @@ edittext.append(_("HG: branch merge")) if ctx.branch(): edittext.append(_("HG: branch '%s'") % ctx.branch()) - if bookmarks.iscurrent(repo): - edittext.append(_("HG: bookmark '%s'") % repo._bookmarkcurrent) + if bookmarks.isactivewdirparent(repo): + edittext.append(_("HG: bookmark '%s'") % repo._activebookmark) edittext.extend([_("HG: subrepo %s") % s for s in subs]) edittext.extend([_("HG: added %s") % f for f in added]) edittext.extend([_("HG: changed %s") % f for f in modified]) @@ -3259,3 +3269,59 @@ for f, clearable, allowcommit, msg, hint in unfinishedstates: if clearable and repo.vfs.exists(f): util.unlink(repo.join(f)) + +class dirstateguard(object): + '''Restore dirstate at unexpected failure. + + At the construction, this class does: + + - write current ``repo.dirstate`` out, and + - save ``.hg/dirstate`` into the backup file + + This restores ``.hg/dirstate`` from backup file, if ``release()`` + is invoked before ``close()``. + + This just removes the backup file at ``close()`` before ``release()``. + ''' + + def __init__(self, repo, name): + repo.dirstate.write() + self._repo = repo + self._filename = 'dirstate.backup.%s.%d' % (name, id(self)) + repo.vfs.write(self._filename, repo.vfs.tryread('dirstate')) + self._active = True + self._closed = False + + def __del__(self): + if self._active: # still active + # this may occur, even if this class is used correctly: + # for example, releasing other resources like transaction + # may raise exception before ``dirstateguard.release`` in + # ``release(tr, ....)``. + self._abort() + + def close(self): + if not self._active: # already inactivated + msg = (_("can't close already inactivated backup: %s") + % self._filename) + raise util.Abort(msg) + + self._repo.vfs.unlink(self._filename) + self._active = False + self._closed = True + + def _abort(self): + # this "invalidate()" prevents "wlock.release()" from writing + # changes of dirstate out after restoring to original status + self._repo.dirstate.invalidate() + + self._repo.vfs.rename(self._filename, 'dirstate') + self._active = False + + def release(self): + if not self._closed: + if not self._active: # already inactivated + msg = (_("can't release already inactivated backup: %s") + % self._filename) + raise util.Abort(msg) + self._abort() diff -r ef4538ba67ef -r 472a685a4961 mercurial/commands.py --- a/mercurial/commands.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/commands.py Tue May 19 07:17:57 2015 -0500 @@ -979,8 +979,8 @@ if mark not in marks: raise util.Abort(_("bookmark '%s' does not exist") % mark) - if mark == repo._bookmarkcurrent: - bookmarks.unsetcurrent(repo) + if mark == repo._activebookmark: + bookmarks.deactivate(repo) del marks[mark] marks.write() @@ -994,8 +994,8 @@ raise util.Abort(_("bookmark '%s' does not exist") % rename) checkconflict(repo, mark, cur, force) marks[mark] = marks[rename] - if repo._bookmarkcurrent == rename and not inactive: - bookmarks.setcurrent(repo, mark) + if repo._activebookmark == rename and not inactive: + bookmarks.activate(repo, mark) del marks[rename] marks.write() @@ -1005,8 +1005,8 @@ mark = checkformat(mark) if newact is None: newact = mark - if inactive and mark == repo._bookmarkcurrent: - bookmarks.unsetcurrent(repo) + if inactive and mark == repo._activebookmark: + bookmarks.deactivate(repo) return tgt = cur if rev: @@ -1014,18 +1014,18 @@ checkconflict(repo, mark, cur, force, tgt) marks[mark] = tgt if not inactive and cur == marks[newact] and not rev: - bookmarks.setcurrent(repo, newact) - elif cur != tgt and newact == repo._bookmarkcurrent: - bookmarks.unsetcurrent(repo) + bookmarks.activate(repo, newact) + elif cur != tgt and newact == repo._activebookmark: + bookmarks.deactivate(repo) marks.write() elif inactive: if len(marks) == 0: ui.status(_("no bookmarks set\n")) - elif not repo._bookmarkcurrent: + elif not repo._activebookmark: ui.status(_("no active bookmark\n")) else: - bookmarks.unsetcurrent(repo) + bookmarks.deactivate(repo) finally: wlock.release() else: # show bookmarks @@ -1035,7 +1035,7 @@ if len(marks) == 0 and not fm: ui.status(_("no bookmarks set\n")) for bmark, n in sorted(marks.iteritems()): - current = repo._bookmarkcurrent + current = repo._activebookmark if bmark == current: prefix, label = '*', 'bookmarks.current' else: @@ -1506,7 +1506,7 @@ match, extra=extra) - current = repo._bookmarkcurrent + current = repo._activebookmark marks = old.bookmarks() node = cmdutil.amend(ui, repo, commitfunc, old, extra, pats, opts) if node == old.node(): @@ -1519,7 +1519,7 @@ for bm in marks: newmarks[bm] = node if bm == current: - bookmarks.setcurrent(repo, bm) + bookmarks.activate(repo, bm) newmarks.write() else: def commitfunc(ui, repo, message, match, opts): @@ -2056,7 +2056,8 @@ @command('debugdata', [('c', 'changelog', False, _('open changelog')), - ('m', 'manifest', False, _('open manifest'))], + ('m', 'manifest', False, _('open manifest')), + ('', 'dir', False, _('open directory manifest'))], _('-c|-m|FILE REV')) def debugdata(ui, repo, file_, rev=None, **opts): """dump the contents of a data file revision""" @@ -2227,6 +2228,7 @@ @command('debugindex', [('c', 'changelog', False, _('open changelog')), ('m', 'manifest', False, _('open manifest')), + ('', 'dir', False, _('open directory manifest')), ('f', 'format', 0, _('revlog format'), _('FORMAT'))], _('[-f FORMAT] -c|-m|FILE'), optionalrepo=True) @@ -2545,26 +2547,25 @@ try: tr = repo.transaction('debugobsolete') try: - try: - date = opts.get('date') - if date: - date = util.parsedate(date) - else: - date = None - prec = parsenodeid(precursor) - parents = None - if opts['record_parents']: - if prec not in repo.unfiltered(): - raise util.Abort('cannot used --record-parents on ' - 'unknown changesets') - parents = repo.unfiltered()[prec].parents() - parents = tuple(p.node() for p in parents) - repo.obsstore.create(tr, prec, succs, opts['flags'], - parents=parents, date=date, - metadata=metadata) - tr.close() - except ValueError, exc: - raise util.Abort(_('bad obsmarker input: %s') % exc) + date = opts.get('date') + if date: + date = util.parsedate(date) + else: + date = None + prec = parsenodeid(precursor) + parents = None + if opts['record_parents']: + if prec not in repo.unfiltered(): + raise util.Abort('cannot used --record-parents on ' + 'unknown changesets') + parents = repo.unfiltered()[prec].parents() + parents = tuple(p.node() for p in parents) + repo.obsstore.create(tr, prec, succs, opts['flags'], + parents=parents, date=date, + metadata=metadata) + tr.close() + except ValueError, exc: + raise util.Abort(_('bad obsmarker input: %s') % exc) finally: tr.release() finally: @@ -2730,6 +2731,7 @@ @command('debugrevlog', [('c', 'changelog', False, _('open changelog')), ('m', 'manifest', False, _('open manifest')), + ('', 'dir', False, _('open directory manifest')), ('d', 'dump', False, _('dump index data'))], _('-c|-m|FILE'), optionalrepo=True) @@ -4045,8 +4047,8 @@ parents = ctx.parents() changed = "" if default or id or num: - if (util.any(repo.status()) - or util.any(ctx.sub(s).dirty() for s in ctx.substate)): + if (any(repo.status()) + or any(ctx.sub(s).dirty() for s in ctx.substate)): changed = '+' if default or id: output = ["%s%s" % @@ -4213,7 +4215,7 @@ cmdutil.bailifchanged(repo) base = opts["base"] - wlock = lock = tr = None + wlock = dsguard = lock = tr = None msgs = [] ret = 0 @@ -4221,7 +4223,7 @@ try: try: wlock = repo.wlock() - repo.dirstate.beginparentchange() + dsguard = cmdutil.dirstateguard(repo, 'import') if not opts.get('no_commit'): lock = repo.lock() tr = repo.transaction('import') @@ -4262,18 +4264,16 @@ tr.close() if msgs: repo.savecommitmessage('\n* * *\n'.join(msgs)) - repo.dirstate.endparentchange() + dsguard.close() return ret - except: # re-raises - # wlock.release() indirectly calls dirstate.write(): since - # we're crashing, we do not want to change the working dir - # parent after all, so make sure it writes nothing - repo.dirstate.invalidate() - raise + finally: + # TODO: get rid of this meaningless try/finally enclosing. + # this is kept only to reduce changes in a patch. + pass finally: if tr: tr.release() - release(lock, wlock) + release(lock, dsguard, wlock) @command('incoming|in', [('f', 'force', None, @@ -4702,9 +4702,9 @@ if node: node = scmutil.revsingle(repo, node).node() - if not node and repo._bookmarkcurrent: - bmheads = repo.bookmarkheads(repo._bookmarkcurrent) - curhead = repo[repo._bookmarkcurrent].node() + if not node and repo._activebookmark: + bmheads = repo.bookmarkheads(repo._activebookmark) + curhead = repo[repo._activebookmark].node() if len(bmheads) == 2: if curhead == bmheads[0]: node = bmheads[1] @@ -4719,7 +4719,7 @@ "please merge with an explicit rev or bookmark"), hint=_("run 'hg heads' to see all heads")) - if not node and not repo._bookmarkcurrent: + if not node and not repo._activebookmark: branch = repo[None].branch() bheads = repo.branchheads(branch) nbhs = [bh for bh in bheads if not repo[bh].bookmarks()] @@ -4952,11 +4952,11 @@ ('f', 'force', False, _('allow to move boundary backward')), ('r', 'rev', [], _('target revision'), _('REV')), ], - _('[-p|-d|-s] [-f] [-r] REV...')) + _('[-p|-d|-s] [-f] [-r] [REV...]')) def phase(ui, repo, *revs, **opts): """set or show the current phase name - With no argument, show the phase name of specified revisions. + With no argument, show the phase name of the current revision(s). With one of -p/--public, -d/--draft or -s/--secret, change the phase value of the specified revisions. @@ -4981,7 +4981,9 @@ revs = list(revs) revs.extend(opts['rev']) if not revs: - raise util.Abort(_('no revisions specified')) + # display both parents as the second parent phase can influence + # the phase of a merge commit + revs = [c.rev() for c in repo[None].parents()] revs = scmutil.revrange(repo, revs) @@ -5049,7 +5051,7 @@ return 0 if not ret and not checkout: if bookmarks.update(repo, [movemarkfrom], repo['.'].node()): - ui.status(_("updating bookmark %s\n") % repo._bookmarkcurrent) + ui.status(_("updating bookmark %s\n") % repo._activebookmark) return ret if modheads > 1: currentbranchheads = len(repo.branchheads()) @@ -5520,7 +5522,7 @@ hint = _("uncommitted merge, use --all to discard all changes," " or 'hg update -C .' to abort the merge") raise util.Abort(msg, hint=hint) - dirty = util.any(repo.status()) + dirty = any(repo.status()) node = ctx.node() if node != parent: if dirty: @@ -5872,7 +5874,7 @@ """summarize working directory state This generates a brief summary of the working directory state, - including parents, branch, commit status, and available updates. + including parents, branch, commit status, phase and available updates. With the --remote option, this will check the default paths for incoming and outgoing changes. This can be time-consuming. @@ -5914,7 +5916,7 @@ ui.status(m, label='log.branch') if marks: - current = repo._bookmarkcurrent + current = repo._activebookmark # i18n: column positioning for "hg summary" ui.write(_('bookmarks:'), label='log.bookmark') if current is not None: @@ -6000,6 +6002,25 @@ ui.write(_('update: %d new changesets, %d branch heads (merge)\n') % (new, len(bheads))) + t = [] + draft = len(repo.revs('draft()')) + if draft: + t.append(_('%d draft') % draft) + secret = len(repo.revs('secret()')) + if secret: + t.append(_('%d secret') % secret) + + if parents: + parentphase = max(p.phase() for p in parents) + else: + parentphase = phases.public + + if draft or secret: + ui.status(_('phases: %s (%s)\n') % (', '.join(t), + phases.phasenames[parentphase])) + else: + ui.note(_('phases: (%s)\n') % phases.phasenames[parentphase]) + cmdutil.summaryhooks(ui, repo) if opts.get('remote'): @@ -6405,15 +6426,15 @@ if not ret and movemarkfrom: if bookmarks.update(repo, [movemarkfrom], repo['.'].node()): - ui.status(_("updating bookmark %s\n") % repo._bookmarkcurrent) + ui.status(_("updating bookmark %s\n") % repo._activebookmark) elif brev in repo._bookmarks: - bookmarks.setcurrent(repo, brev) + bookmarks.activate(repo, brev) ui.status(_("(activating bookmark %s)\n") % brev) elif brev: - if repo._bookmarkcurrent: + if repo._activebookmark: ui.status(_("(leaving bookmark %s)\n") % - repo._bookmarkcurrent) - bookmarks.unsetcurrent(repo) + repo._activebookmark) + bookmarks.deactivate(repo) return ret diff -r ef4538ba67ef -r 472a685a4961 mercurial/config.py --- a/mercurial/config.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/config.py Tue May 19 07:17:57 2015 -0500 @@ -10,10 +10,11 @@ import os, errno class config(object): - def __init__(self, data=None): + def __init__(self, data=None, includepaths=[]): self._data = {} self._source = {} self._unset = [] + self._includepaths = includepaths if data: for k in data._data: self._data[k] = data[k].copy() @@ -110,13 +111,17 @@ item = None cont = False m = includere.match(l) - if m: - inc = util.expandpath(m.group(1)) - base = os.path.dirname(src) - inc = os.path.normpath(os.path.join(base, inc)) - if include: + + if m and include: + expanded = util.expandpath(m.group(1)) + includepaths = [os.path.dirname(src)] + self._includepaths + + for base in includepaths: + inc = os.path.normpath(os.path.join(base, expanded)) + try: include(inc, remap=remap, sections=sections) + break except IOError, inst: if inst.errno != errno.ENOENT: raise error.ParseError(_("cannot include %s (%s)") diff -r ef4538ba67ef -r 472a685a4961 mercurial/context.py --- a/mercurial/context.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/context.py Tue May 19 07:17:57 2015 -0500 @@ -251,11 +251,13 @@ def sub(self, path): return subrepo.subrepo(self, path) - def match(self, pats=[], include=None, exclude=None, default='glob'): + def match(self, pats=[], include=None, exclude=None, default='glob', + listsubrepos=False): r = self._repo return matchmod.match(r.root, r.getcwd(), pats, include, exclude, default, - auditor=r.auditor, ctx=self) + auditor=r.auditor, ctx=self, + listsubrepos=listsubrepos) def diff(self, ctx2=None, match=None, **opts): """Returns a diff generator for the given contexts and matcher""" @@ -459,7 +461,7 @@ pass except (error.FilteredIndexError, error.FilteredLookupError, error.FilteredRepoLookupError): - if repo.filtername == 'visible': + if repo.filtername.startswith('visible'): msg = _("hidden revision '%s'") % changeid hint = _('use --hidden to access hidden revisions') raise error.FilteredRepoLookupError(msg, hint=hint) @@ -595,8 +597,8 @@ def bad(fn, msg): # The manifest doesn't know about subrepos, so don't complain about # paths into valid subrepos. - if util.any(fn == s or fn.startswith(s + '/') - for s in self.substate): + if any(fn == s or fn.startswith(s + '/') + for s in self.substate): return oldbad(fn, _('no such file in rev %s') % self) match.bad = bad @@ -1443,17 +1445,20 @@ finally: wlock.release() - def match(self, pats=[], include=None, exclude=None, default='glob'): + def match(self, pats=[], include=None, exclude=None, default='glob', + listsubrepos=False): r = self._repo # Only a case insensitive filesystem needs magic to translate user input # to actual case in the filesystem. if not util.checkcase(r.root): return matchmod.icasefsmatcher(r.root, r.getcwd(), pats, include, - exclude, default, r.auditor, self) + exclude, default, r.auditor, self, + listsubrepos=listsubrepos) return matchmod.match(r.root, r.getcwd(), pats, include, exclude, default, - auditor=r.auditor, ctx=self) + auditor=r.auditor, ctx=self, + listsubrepos=listsubrepos) def _filtersuspectsymlink(self, files): if not files or self._repo.dirstate._checklink: diff -r ef4538ba67ef -r 472a685a4961 mercurial/crecord.py --- a/mercurial/crecord.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/crecord.py Tue May 19 07:17:57 2015 -0500 @@ -20,7 +20,8 @@ # os.name is one of: 'posix', 'nt', 'dos', 'os2', 'mac', or 'ce' if os.name == 'posix': - import curses, fcntl, termios + import curses + import fcntl, termios else: # I have no idea if wcurses works with crecord... try: diff -r ef4538ba67ef -r 472a685a4961 mercurial/dagparser.py --- a/mercurial/dagparser.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/dagparser.py Tue May 19 07:17:57 2015 -0500 @@ -176,10 +176,7 @@ chiter = (c for c in desc) def nextch(): - try: - return chiter.next() - except StopIteration: - return '\0' + return next(chiter, '\0') def nextrun(c, allow): s = '' diff -r ef4538ba67ef -r 472a685a4961 mercurial/dirs.c --- a/mercurial/dirs.c Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/dirs.c Tue May 19 07:17:57 2015 -0500 @@ -9,7 +9,6 @@ #define PY_SSIZE_T_CLEAN #include -#include #include "util.h" /* @@ -29,23 +28,25 @@ PyObject *dict; } dirsObject; -static inline Py_ssize_t _finddir(PyObject *path, Py_ssize_t pos) +static inline Py_ssize_t _finddir(const char *path, Py_ssize_t pos) { - const char *s = PyString_AS_STRING(path); + while (pos != -1) { + if (path[pos] == '/') + break; + pos -= 1; + } - const char *ret = strchr(s + pos, '/'); - return (ret != NULL) ? (ret - s) : -1; + return pos; } static int _addpath(PyObject *dirs, PyObject *path) { - char *cpath = PyString_AS_STRING(path); - Py_ssize_t len = PyString_GET_SIZE(path); - Py_ssize_t pos = -1; + const char *cpath = PyString_AS_STRING(path); + Py_ssize_t pos = PyString_GET_SIZE(path); PyObject *key = NULL; int ret = -1; - while ((pos = _finddir(path, pos + 1)) != -1) { + while ((pos = _finddir(cpath, pos - 1)) != -1) { PyObject *val; /* It's likely that every prefix already has an entry @@ -53,18 +54,10 @@ deallocating a string for each prefix we check. */ if (key != NULL) ((PyStringObject *)key)->ob_shash = -1; - else if (pos != 0) { - /* pos >= 1, which means that len >= 2. This is - guaranteed to produce a non-interned string. */ - key = PyString_FromStringAndSize(cpath, len); - if (key == NULL) - goto bail; - } else { - /* pos == 0, which means we need to increment the dir - count for the empty string. We need to make sure we - don't muck around with interned strings, so throw it - away later. */ - key = PyString_FromString(""); + else { + /* Force Python to not reuse a small shared string. */ + key = PyString_FromStringAndSize(cpath, + pos < 2 ? 2 : pos); if (key == NULL) goto bail; } @@ -74,11 +67,7 @@ val = PyDict_GetItem(dirs, key); if (val != NULL) { PyInt_AS_LONG(val) += 1; - if (pos != 0) - PyString_AS_STRING(key)[pos] = '/'; - else - key = NULL; - continue; + break; } /* Force Python to not reuse a small shared int. */ @@ -92,9 +81,6 @@ Py_DECREF(val); if (ret == -1) goto bail; - - /* Clear the key out since we've already exposed it to Python - and can't mutate it further. */ Py_CLEAR(key); } ret = 0; @@ -107,14 +93,15 @@ static int _delpath(PyObject *dirs, PyObject *path) { - Py_ssize_t pos = -1; + char *cpath = PyString_AS_STRING(path); + Py_ssize_t pos = PyString_GET_SIZE(path); PyObject *key = NULL; int ret = -1; - while ((pos = _finddir(path, pos + 1)) != -1) { + while ((pos = _finddir(cpath, pos - 1)) != -1) { PyObject *val; - key = PyString_FromStringAndSize(PyString_AS_STRING(path), pos); + key = PyString_FromStringAndSize(cpath, pos); if (key == NULL) goto bail; @@ -126,9 +113,11 @@ goto bail; } - if (--PyInt_AS_LONG(val) <= 0 && - PyDict_DelItem(dirs, key) == -1) - goto bail; + if (--PyInt_AS_LONG(val) <= 0) { + if (PyDict_DelItem(dirs, key) == -1) + goto bail; + } else + break; Py_CLEAR(key); } ret = 0; diff -r ef4538ba67ef -r 472a685a4961 mercurial/dirstate.py --- a/mercurial/dirstate.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/dirstate.py Tue May 19 07:17:57 2015 -0500 @@ -143,7 +143,9 @@ @rootcache('.hgignore') def _ignore(self): - files = [self._join('.hgignore')] + files = [] + if os.path.exists(self._join('.hgignore')): + files.append(self._join('.hgignore')) for name, path in self._ui.configitems("ui"): if name == 'ignore' or name.startswith('ignore.'): # we need to use os.path.join here rather than self._join @@ -972,7 +974,7 @@ # fast path -- filter the other way around, since typically files is # much smaller than dmap return [f for f in files if f in dmap] - if not match.anypats() and util.all(fn in dmap for fn in files): + if not match.anypats() and all(fn in dmap for fn in files): # fast path -- all the values are known to be files, so just return # that return list(files) diff -r ef4538ba67ef -r 472a685a4961 mercurial/dispatch.py --- a/mercurial/dispatch.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/dispatch.py Tue May 19 07:17:57 2015 -0500 @@ -921,6 +921,30 @@ stats.sort(field) stats.pprint(limit=limit, file=fp, climit=climit) +def flameprofile(ui, func, fp): + try: + from flamegraph import flamegraph + except ImportError: + raise util.Abort(_( + 'flamegraph not available - install from ' + 'https://github.com/evanhempel/python-flamegraph')) + freq = ui.configint('profiling', 'freq', default=1000) + filter_ = None + collapse_recursion = True + thread = flamegraph.ProfileThread(fp, 1.0 / freq, + filter_, collapse_recursion) + start_time = time.clock() + try: + thread.start() + func() + finally: + thread.stop() + thread.join() + print 'Collected %d stack frames (%d unique) in %2.2f seconds.' % ( + time.clock() - start_time, thread.num_frames(), + thread.num_frames(unique=True)) + + def statprofile(ui, func, fp): try: import statprof @@ -952,7 +976,7 @@ profiler = os.getenv('HGPROF') if profiler is None: profiler = ui.config('profiling', 'type', default='ls') - if profiler not in ('ls', 'stat'): + if profiler not in ('ls', 'stat', 'flame'): ui.warn(_("unrecognized profiler '%s' - ignored\n") % profiler) profiler = 'ls' @@ -967,6 +991,8 @@ try: if profiler == 'ls': return lsprofile(ui, checkargs, fp) + elif profiler == 'flame': + return flameprofile(ui, checkargs, fp) else: return statprofile(ui, checkargs, fp) finally: diff -r ef4538ba67ef -r 472a685a4961 mercurial/exchange.py --- a/mercurial/exchange.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/exchange.py Tue May 19 07:17:57 2015 -0500 @@ -536,7 +536,8 @@ return pushop.stepsdone.add('obsmarkers') if pushop.outobsmarkers: - buildobsmarkerspart(bundler, pushop.outobsmarkers) + markers = sorted(pushop.outobsmarkers) + buildobsmarkerspart(bundler, markers) @b2partsgenerator('bookmarks') def _pushb2bookmarks(pushop, bundler): @@ -751,7 +752,7 @@ pushop.stepsdone.add('obsmarkers') if pushop.outobsmarkers: rslts = [] - remotedata = obsolete._pushkeyescape(pushop.outobsmarkers) + remotedata = obsolete._pushkeyescape(sorted(pushop.outobsmarkers)) for key in sorted(remotedata, reverse=True): # reverse sort to ensure we end with dump0 data = remotedata[key] @@ -1180,7 +1181,7 @@ # bundle10 case usebundle2 = False if bundlecaps is not None: - usebundle2 = util.any((cap.startswith('HG2') for cap in bundlecaps)) + usebundle2 = any((cap.startswith('HG2') for cap in bundlecaps)) if not usebundle2: if bundlecaps and not kwargs.get('cg', True): raise ValueError(_('request for bundle10 must include changegroup')) @@ -1257,6 +1258,7 @@ heads = repo.heads() subset = [c.node() for c in repo.set('::%ln', heads)] markers = repo.obsstore.relevantmarkers(subset) + markers = sorted(markers) buildobsmarkerspart(bundler, markers) def check_heads(repo, their_heads, context): @@ -1313,7 +1315,7 @@ def recordout(output): r.newpart('output', data=output, mandatory=False) tr.close() - except Exception, exc: + except BaseException, exc: exc.duringunbundle2 = True if captureoutput and r is not None: parts = exc._bundle2salvagedoutput = r.salvageoutput() diff -r ef4538ba67ef -r 472a685a4961 mercurial/filemerge.py --- a/mercurial/filemerge.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/filemerge.py Tue May 19 07:17:57 2015 -0500 @@ -354,7 +354,6 @@ ui = repo.ui template = ui.config('ui', 'mergemarkertemplate', _defaultconflictmarker) - template = templater.parsestring(template, quoted=False) tmpl = templater.templater(None, cache={'conflictmarker': template}) pad = max(len(l) for l in labels) diff -r ef4538ba67ef -r 472a685a4961 mercurial/hbisect.py --- a/mercurial/hbisect.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/hbisect.py Tue May 19 07:17:57 2015 -0500 @@ -8,6 +8,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 collections import os import error from i18n import _ @@ -71,7 +72,7 @@ # build children dict children = {} - visit = util.deque([badrev]) + visit = collections.deque([badrev]) candidates = [] while visit: rev = visit.popleft() diff -r ef4538ba67ef -r 472a685a4961 mercurial/help/config.txt --- a/mercurial/help/config.txt Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/help/config.txt Tue May 19 07:17:57 2015 -0500 @@ -376,8 +376,8 @@ HG: -- HG: user: {author}\n{ifeq(p2rev, "-1", "", "HG: branch merge\n") - }HG: branch '{branch}'\n{if(currentbookmark, - "HG: bookmark '{currentbookmark}'\n") }{subrepos % + }HG: branch '{branch}'\n{if(activebookmark, + "HG: bookmark '{activebookmark}'\n") }{subrepos % "HG: subrepo {subrepo}\n" }{file_adds % "HG: added {file}\n" }{file_mods % "HG: changed {file}\n" }{file_dels % diff -r ef4538ba67ef -r 472a685a4961 mercurial/help/templates.txt --- a/mercurial/help/templates.txt Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/help/templates.txt Tue May 19 07:17:57 2015 -0500 @@ -67,7 +67,7 @@ - Output the description set to a fill-width of 30:: - $ hg log -r 0 --template "{fill(desc, '30')}" + $ hg log -r 0 --template "{fill(desc, 30)}" - Use a conditional to test for the default branch:: @@ -104,4 +104,4 @@ - Print the first word of each line of a commit message:: - $ hg log --template "{word(\"0\", desc)}\n" + $ hg log --template "{word(0, desc)}\n" diff -r ef4538ba67ef -r 472a685a4961 mercurial/hg.py --- a/mercurial/hg.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/hg.py Tue May 19 07:17:57 2015 -0500 @@ -497,7 +497,7 @@ destrepo.ui.status(status) _update(destrepo, uprev) if update in destrepo._bookmarks: - bookmarks.setcurrent(destrepo, update) + bookmarks.activate(destrepo, update) finally: release(srclock, destlock) if cleandir is not None: diff -r ef4538ba67ef -r 472a685a4961 mercurial/hgweb/hgwebdir_mod.py --- a/mercurial/hgweb/hgwebdir_mod.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/hgweb/hgwebdir_mod.py Tue May 19 07:17:57 2015 -0500 @@ -176,71 +176,70 @@ def run_wsgi(self, req): try: - try: - self.refresh() + self.refresh() - virtual = req.env.get("PATH_INFO", "").strip('/') - tmpl = self.templater(req) - ctype = tmpl('mimetype', encoding=encoding.encoding) - ctype = templater.stringify(ctype) + virtual = req.env.get("PATH_INFO", "").strip('/') + tmpl = self.templater(req) + ctype = tmpl('mimetype', encoding=encoding.encoding) + ctype = templater.stringify(ctype) - # a static file - if virtual.startswith('static/') or 'static' in req.form: - if virtual.startswith('static/'): - fname = virtual[7:] - else: - fname = req.form['static'][0] - static = self.ui.config("web", "static", None, - untrusted=False) - if not static: - tp = self.templatepath or templater.templatepaths() - if isinstance(tp, str): - tp = [tp] - static = [os.path.join(p, 'static') for p in tp] - staticfile(static, fname, req) - return [] + # a static file + if virtual.startswith('static/') or 'static' in req.form: + if virtual.startswith('static/'): + fname = virtual[7:] + else: + fname = req.form['static'][0] + static = self.ui.config("web", "static", None, + untrusted=False) + if not static: + tp = self.templatepath or templater.templatepaths() + if isinstance(tp, str): + tp = [tp] + static = [os.path.join(p, 'static') for p in tp] + staticfile(static, fname, req) + return [] - # top-level index - elif not virtual: - req.respond(HTTP_OK, ctype) - return self.makeindex(req, tmpl) + # top-level index + elif not virtual: + req.respond(HTTP_OK, ctype) + return self.makeindex(req, tmpl) - # nested indexes and hgwebs + # nested indexes and hgwebs - repos = dict(self.repos) - virtualrepo = virtual - while virtualrepo: - real = repos.get(virtualrepo) - if real: - req.env['REPO_NAME'] = virtualrepo - try: - # ensure caller gets private copy of ui - repo = hg.repository(self.ui.copy(), real) - return hgweb(repo).run_wsgi(req) - except IOError, inst: - msg = inst.strerror - raise ErrorResponse(HTTP_SERVER_ERROR, msg) - except error.RepoError, inst: - raise ErrorResponse(HTTP_SERVER_ERROR, str(inst)) + repos = dict(self.repos) + virtualrepo = virtual + while virtualrepo: + real = repos.get(virtualrepo) + if real: + req.env['REPO_NAME'] = virtualrepo + try: + # ensure caller gets private copy of ui + repo = hg.repository(self.ui.copy(), real) + return hgweb(repo).run_wsgi(req) + except IOError, inst: + msg = inst.strerror + raise ErrorResponse(HTTP_SERVER_ERROR, msg) + except error.RepoError, inst: + raise ErrorResponse(HTTP_SERVER_ERROR, str(inst)) - up = virtualrepo.rfind('/') - if up < 0: - break - virtualrepo = virtualrepo[:up] + up = virtualrepo.rfind('/') + if up < 0: + break + virtualrepo = virtualrepo[:up] - # browse subdirectories - subdir = virtual + '/' - if [r for r in repos if r.startswith(subdir)]: - req.respond(HTTP_OK, ctype) - return self.makeindex(req, tmpl, subdir) + # browse subdirectories + subdir = virtual + '/' + if [r for r in repos if r.startswith(subdir)]: + req.respond(HTTP_OK, ctype) + return self.makeindex(req, tmpl, subdir) - # prefixes not found - req.respond(HTTP_NOT_FOUND, ctype) - return tmpl("notfound", repo=virtual) + # prefixes not found + req.respond(HTTP_NOT_FOUND, ctype) + return tmpl("notfound", repo=virtual) - except ErrorResponse, err: - req.respond(err, ctype) - return tmpl('error', error=err.message or '') + except ErrorResponse, err: + req.respond(err, ctype) + return tmpl('error', error=err.message or '') finally: tmpl = None diff -r ef4538ba67ef -r 472a685a4961 mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/hgweb/webcommands.py Tue May 19 07:17:57 2015 -0500 @@ -130,6 +130,8 @@ parent=webutil.parents(fctx), child=webutil.children(fctx), rename=webutil.renamelink(fctx), + tags=webutil.nodetagsdict(web.repo, fctx.node()), + bookmarks=webutil.nodebookmarksdict(web.repo, fctx.node()), permissions=fctx.manifest().flags(f)) @webcommand('file') @@ -230,7 +232,7 @@ # no revset syntax used return MODE_KEYWORD, query - if util.any((token, (value or '')[:3]) == ('string', 're:') + if any((token, (value or '')[:3]) == ('string', 're:') for token, value, pos in revset.tokenize(revdef)): return MODE_KEYWORD, query @@ -546,6 +548,7 @@ archives=web.archivelist(hex(node)), tags=webutil.nodetagsdict(web.repo, node), bookmarks=webutil.nodebookmarksdict(web.repo, node), + branch=webutil.nodebranchnodefault(ctx), inbranch=webutil.nodeinbranch(web.repo, ctx), branches=webutil.nodebranchdict(web.repo, ctx)) @@ -808,6 +811,8 @@ branch=webutil.nodebranchnodefault(ctx), parent=webutil.parents(ctx), child=webutil.children(ctx), + tags=webutil.nodetagsdict(web.repo, n), + bookmarks=webutil.nodebookmarksdict(web.repo, n), diff=diffs) diff = webcommand('diff')(filediff) @@ -880,6 +885,8 @@ branch=webutil.nodebranchnodefault(ctx), parent=webutil.parents(fctx), child=webutil.children(fctx), + tags=webutil.nodetagsdict(web.repo, ctx.node()), + bookmarks=webutil.nodebookmarksdict(web.repo, ctx.node()), leftrev=leftrev, leftnode=hex(leftnode), rightrev=rightrev, @@ -946,6 +953,8 @@ branch=webutil.nodebranchnodefault(fctx), parent=webutil.parents(fctx), child=webutil.children(fctx), + tags=webutil.nodetagsdict(web.repo, fctx.node()), + bookmarks=webutil.nodebookmarksdict(web.repo, fctx.node()), permissions=fctx.manifest().flags(f)) @webcommand('filelog') diff -r ef4538ba67ef -r 472a685a4961 mercurial/hook.py --- a/mercurial/hook.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/hook.py Tue May 19 07:17:57 2015 -0500 @@ -39,26 +39,25 @@ if demandimportenabled: demandimport.disable() try: + obj = __import__(modname) + except ImportError: + e1 = sys.exc_type, sys.exc_value, sys.exc_traceback try: - obj = __import__(modname) + # extensions are loaded with hgext_ prefix + obj = __import__("hgext_%s" % modname) except ImportError: - e1 = sys.exc_type, sys.exc_value, sys.exc_traceback - try: - # extensions are loaded with hgext_ prefix - obj = __import__("hgext_%s" % modname) - except ImportError: - e2 = sys.exc_type, sys.exc_value, sys.exc_traceback - if ui.tracebackflag: - ui.warn(_('exception from first failed import ' - 'attempt:\n')) - ui.traceback(e1) - if ui.tracebackflag: - ui.warn(_('exception from second failed import ' - 'attempt:\n')) - ui.traceback(e2) - raise util.Abort(_('%s hook is invalid ' - '(import of "%s" failed)') % - (hname, modname)) + e2 = sys.exc_type, sys.exc_value, sys.exc_traceback + if ui.tracebackflag: + ui.warn(_('exception from first failed import ' + 'attempt:\n')) + ui.traceback(e1) + if ui.tracebackflag: + ui.warn(_('exception from second failed import ' + 'attempt:\n')) + ui.traceback(e2) + raise util.Abort(_('%s hook is invalid ' + '(import of "%s" failed)') % + (hname, modname)) finally: if demandimportenabled: demandimport.enable() @@ -79,27 +78,24 @@ starttime = time.time() try: - try: - # redirect IO descriptors to the ui descriptors so hooks - # that write directly to these don't mess up the command - # protocol when running through the command server - old = sys.stdout, sys.stderr, sys.stdin - sys.stdout, sys.stderr, sys.stdin = ui.fout, ui.ferr, ui.fin + # redirect IO descriptors to the ui descriptors so hooks + # that write directly to these don't mess up the command + # protocol when running through the command server + old = sys.stdout, sys.stderr, sys.stdin + sys.stdout, sys.stderr, sys.stdin = ui.fout, ui.ferr, ui.fin - r = obj(ui=ui, repo=repo, hooktype=name, **args) - except KeyboardInterrupt: + r = obj(ui=ui, repo=repo, hooktype=name, **args) + except Exception, exc: + if isinstance(exc, util.Abort): + ui.warn(_('error: %s hook failed: %s\n') % + (hname, exc.args[0])) + else: + ui.warn(_('error: %s hook raised an exception: ' + '%s\n') % (hname, exc)) + if throw: raise - except Exception, exc: - if isinstance(exc, util.Abort): - ui.warn(_('error: %s hook failed: %s\n') % - (hname, exc.args[0])) - else: - ui.warn(_('error: %s hook raised an exception: ' - '%s\n') % (hname, exc)) - if throw: - raise - ui.traceback() - return True + ui.traceback() + return True finally: sys.stdout, sys.stderr, sys.stdin = old duration = time.time() - starttime diff -r ef4538ba67ef -r 472a685a4961 mercurial/httppeer.py --- a/mercurial/httppeer.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/httppeer.py Tue May 19 07:17:57 2015 -0500 @@ -198,16 +198,15 @@ headers = {'Content-Type': 'application/mercurial-0.1'} try: - try: - r = self._call(cmd, data=fp, headers=headers, **args) - vals = r.split('\n', 1) - if len(vals) < 2: - raise error.ResponseError(_("unexpected response:"), r) - return vals - except socket.error, err: - if err.args[0] in (errno.ECONNRESET, errno.EPIPE): - raise util.Abort(_('push failed: %s') % err.args[1]) - raise util.Abort(err.args[1]) + r = self._call(cmd, data=fp, headers=headers, **args) + vals = r.split('\n', 1) + if len(vals) < 2: + raise error.ResponseError(_("unexpected response:"), r) + return vals + except socket.error, err: + if err.args[0] in (errno.ECONNRESET, errno.EPIPE): + raise util.Abort(_('push failed: %s') % err.args[1]) + raise util.Abort(err.args[1]) finally: fp.close() os.unlink(tempname) diff -r ef4538ba67ef -r 472a685a4961 mercurial/ignore.py --- a/mercurial/ignore.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/ignore.py Tue May 19 07:17:57 2015 -0500 @@ -7,50 +7,6 @@ from i18n import _ import util, match -import re - -_commentre = None - -def ignorepats(lines): - '''parse lines (iterable) of .hgignore text, returning a tuple of - (patterns, parse errors). These patterns should be given to compile() - to be validated and converted into a match function.''' - syntaxes = {'re': 'relre:', 'regexp': 'relre:', 'glob': 'relglob:'} - syntax = 'relre:' - patterns = [] - warnings = [] - - for line in lines: - if "#" in line: - global _commentre - if not _commentre: - _commentre = re.compile(r'((^|[^\\])(\\\\)*)#.*') - # remove comments prefixed by an even number of escapes - line = _commentre.sub(r'\1', line) - # fixup properly escaped comments that survived the above - line = line.replace("\\#", "#") - line = line.rstrip() - if not line: - continue - - if line.startswith('syntax:'): - s = line[7:].strip() - try: - syntax = syntaxes[s] - except KeyError: - warnings.append(_("ignoring invalid syntax '%s'") % s) - continue - pat = syntax + line - for s, rels in syntaxes.iteritems(): - if line.startswith(rels): - pat = line - break - elif line.startswith(s+':'): - pat = rels + line[len(s) + 1:] - break - patterns.append(pat) - - return patterns, warnings def readpats(root, files, warn): '''return a dict mapping ignore-file-name to list-of-patterns''' @@ -60,16 +16,11 @@ if f in pats: continue try: - pats[f] = [] - fp = open(f) - pats[f], warnings = ignorepats(fp) - fp.close() - for warning in warnings: - warn("%s: %s\n" % (f, warning)) + pats[f] = match.readpatternfile(f, warn) except IOError, inst: - if f != files[0]: - warn(_("skipping unreadable ignore file '%s': %s\n") % - (f, inst.strerror)) + warn(_("skipping unreadable ignore file '%s': %s\n") % + (f, inst.strerror)) + return [(f, pats[f]) for f in files if f in pats] def ignore(root, files, warn): diff -r ef4538ba67ef -r 472a685a4961 mercurial/localrepo.py --- a/mercurial/localrepo.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/localrepo.py Tue May 19 07:17:57 2015 -0500 @@ -192,11 +192,11 @@ class localrepository(object): - supportedformats = set(('revlogv1', 'generaldelta', 'manifestv2')) + supportedformats = set(('revlogv1', 'generaldelta', 'treemanifest', + 'manifestv2')) _basesupported = supportedformats | set(('store', 'fncache', 'shared', 'dotencode')) - openerreqs = set(('revlogv1', 'generaldelta', 'manifestv2')) - requirements = ['revlogv1'] + openerreqs = set(('revlogv1', 'generaldelta', 'treemanifest', 'manifestv2')) filtername = None # a list of (ui, featureset) functions. @@ -204,9 +204,10 @@ featuresetupfuncs = set() def _baserequirements(self, create): - return self.requirements[:] + return ['revlogv1'] def __init__(self, baseui, path=None, create=False): + self.requirements = set() self.wvfs = scmutil.vfs(path, expandpath=True, realpath=True) self.wopener = self.wvfs self.root = self.wvfs.base @@ -243,14 +244,14 @@ if not self.wvfs.exists(): self.wvfs.makedirs() self.vfs.makedir(notindexed=True) - requirements = self._baserequirements(create) + self.requirements.update(self._baserequirements(create)) if self.ui.configbool('format', 'usestore', True): self.vfs.mkdir("store") - requirements.append("store") + self.requirements.add("store") if self.ui.configbool('format', 'usefncache', True): - requirements.append("fncache") + self.requirements.add("fncache") if self.ui.configbool('format', 'dotencode', True): - requirements.append('dotencode') + self.requirements.add('dotencode') # create an invalid changelog self.vfs.append( "00changelog.i", @@ -258,21 +259,22 @@ ' dummy changelog to prevent using the old repo layout' ) if self.ui.configbool('format', 'generaldelta', False): - requirements.append("generaldelta") + self.requirements.add("generaldelta") + if self.ui.configbool('experimental', 'treemanifest', False): + self.requirements.add("treemanifest") if self.ui.configbool('experimental', 'manifestv2', False): - requirements.append("manifestv2") - requirements = set(requirements) + self.requirements.add("manifestv2") else: raise error.RepoError(_("repository %s not found") % path) elif create: raise error.RepoError(_("repository %s already exists") % path) else: try: - requirements = scmutil.readrequires(self.vfs, self.supported) + self.requirements = scmutil.readrequires( + self.vfs, self.supported) except IOError, inst: if inst.errno != errno.ENOENT: raise - requirements = set() self.sharedpath = self.path try: @@ -287,13 +289,14 @@ if inst.errno != errno.ENOENT: raise - self.store = store.store(requirements, self.sharedpath, scmutil.vfs) + self.store = store.store( + self.requirements, self.sharedpath, scmutil.vfs) self.spath = self.store.path self.svfs = self.store.vfs self.sopener = self.svfs self.sjoin = self.store.join self.vfs.createmode = self.store.createmode - self._applyrequirements(requirements) + self._applyopenerreqs() if create: self._writerequirements() @@ -336,9 +339,8 @@ caps.add('bundle2=' + urllib.quote(capsblob)) return caps - def _applyrequirements(self, requirements): - self.requirements = requirements - self.svfs.options = dict((r, 1) for r in requirements + def _applyopenerreqs(self): + self.svfs.options = dict((r, 1) for r in self.requirements if r in self.openerreqs) chunkcachesize = self.ui.configint('format', 'chunkcachesize') if chunkcachesize is not None: @@ -349,15 +351,9 @@ manifestcachesize = self.ui.configint('format', 'manifestcachesize') if manifestcachesize is not None: self.svfs.options['manifestcachesize'] = manifestcachesize - usetreemanifest = self.ui.configbool('experimental', 'treemanifest') - if usetreemanifest is not None: - self.svfs.options['usetreemanifest'] = usetreemanifest def _writerequirements(self): - reqfile = self.vfs("requires", "w") - for r in sorted(self.requirements): - reqfile.write("%s\n" % r) - reqfile.close() + scmutil.writerequires(self.vfs, self.requirements) def _checknested(self, path): """Determine if path is a legal nested repository.""" @@ -419,8 +415,8 @@ return bookmarks.bmstore(self) @repofilecache('bookmarks.current') - def _bookmarkcurrent(self): - return bookmarks.readcurrent(self) + def _activebookmark(self): + return bookmarks.readactive(self) def bookmarkheads(self, bookmark): name = bookmark.split('@', 1)[0] @@ -464,6 +460,9 @@ def manifest(self): return manifest.manifest(self.svfs) + def dirlog(self, dir): + return self.manifest.dirlog(dir) + @repofilecache('dirstate') def dirstate(self): warned = [0] @@ -628,7 +627,7 @@ if not local: m = matchmod.exact(self.root, '', ['.hgtags']) - if util.any(self.status(match=m, unknown=True, ignored=True)): + if any(self.status(match=m, unknown=True, ignored=True)): raise util.Abort(_('working copy of .hgtags is changed'), hint=_('please commit .hgtags manually')) @@ -1381,7 +1380,7 @@ wctx = self[None] merge = len(wctx.parents()) > 1 - if not force and merge and not match.always(): + if not force and merge and match.ispartial(): raise util.Abort(_('cannot partially commit a merge ' '(do not specify files or patterns)')) @@ -1466,9 +1465,10 @@ cctx = context.workingcommitctx(self, status, text, user, date, extra) - if (not force and not extra.get("close") and not merge - and not cctx.files() - and wctx.branch() == wctx.p1().branch()): + allowemptycommit = (wctx.branch() != wctx.p1().branch() + or extra.get('close') or merge or cctx.files() + or self.ui.configbool('ui', 'allowemptycommit')) + if not allowemptycommit: return None if merge and cctx.deleted(): @@ -1521,7 +1521,7 @@ def commithook(node=hex(ret), parent1=hookp1, parent2=hookp2): # hack for command that use a temporary commit (eg: histedit) # temporary commit got stripped before hook release - if node in self: + if self.changelog.hasnode(ret): self.hook("commit", node=node, parent1=parent1, parent2=parent2) self._afterlock(commithook) @@ -1754,7 +1754,7 @@ """ return util.hooks() - def stream_in(self, remote, requirements): + def stream_in(self, remote, remotereqs): lock = self.lock() try: # Save remote branchmap. We will use it later @@ -1827,10 +1827,11 @@ util.bytecount(total_bytes / elapsed))) # new requirements = old non-format requirements + - # new format-related + # new format-related remote requirements # requirements from the streamed-in repository - requirements.update(set(self.requirements) - self.supportedformats) - self._applyrequirements(requirements) + self.requirements = remotereqs | ( + self.requirements - self.supportedformats) + self._applyopenerreqs() self._writerequirements() if rbranchmap: diff -r ef4538ba67ef -r 472a685a4961 mercurial/manifest.c --- a/mercurial/manifest.c Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/manifest.c Tue May 19 07:17:57 2015 -0500 @@ -235,7 +235,7 @@ PyObject *ret = NULL, *path = NULL, *hash = NULL, *flags = NULL; l = lmiter_nextline((lmIter *)o); if (!l) { - goto bail; + goto done; } pl = pathlen(l); path = PyString_FromStringAndSize(l->start, pl); @@ -244,10 +244,10 @@ flags = PyString_FromStringAndSize(l->start + consumed, l->len - consumed - 1); if (!path || !hash || !flags) { - goto bail; + goto done; } ret = PyTuple_Pack(3, path, hash, flags); - bail: +done: Py_XDECREF(path); Py_XDECREF(hash); Py_XDECREF(flags); @@ -672,7 +672,7 @@ copy->pydata = self->pydata; Py_INCREF(copy->pydata); return copy; - nomem: +nomem: PyErr_NoMemory(); Py_XDECREF(copy); return NULL; @@ -724,7 +724,7 @@ } copy->livelines = copy->numlines; return copy; - nomem: +nomem: PyErr_NoMemory(); Py_XDECREF(copy); return NULL; @@ -845,7 +845,7 @@ } Py_DECREF(emptyTup); return ret; - nomem: +nomem: PyErr_NoMemory(); Py_XDECREF(ret); Py_XDECREF(emptyTup); diff -r ef4538ba67ef -r 472a685a4961 mercurial/manifest.py --- a/mercurial/manifest.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/manifest.py Tue May 19 07:17:57 2015 -0500 @@ -219,7 +219,7 @@ files instead of over manifest files.''' files = match.files() return (len(files) < 100 and (match.isexact() or - (not match.anypats() and util.all(fn in self for fn in files)))) + (not match.anypats() and all(fn in self for fn in files)))) def walk(self, match): '''Generates matching file names. @@ -444,11 +444,15 @@ class treemanifest(object): def __init__(self, dir='', text=''): self._dir = dir + self._node = revlog.nullid self._dirs = {} # Using _lazymanifest here is a little slower than plain old dicts self._files = {} self._flags = {} - self.parse(text) + def readsubtree(subdir, subm): + raise AssertionError('treemanifest constructor only accepts ' + 'flat manifests') + self.parse(text, readsubtree) def _subpath(self, path): return self._dir + path @@ -461,10 +465,25 @@ def _isempty(self): return (not self._files and (not self._dirs or - util.all(m._isempty() for m in self._dirs.values()))) + all(m._isempty() for m in self._dirs.values()))) def __str__(self): - return '' % self._dir + return ('' % + (self._dir, revlog.hex(self._node))) + + def dir(self): + '''The directory that this tree manifest represents, including a + trailing '/'. Empty string for the repo root directory.''' + return self._dir + + def node(self): + '''This node of this instance. nullid for unsaved instances. Should + be updated when the instance is read or written from a revlog. + ''' + return self._node + + def setnode(self, node): + self._node = node def iteritems(self): for p, n in sorted(self._dirs.items() + self._files.items()): @@ -557,6 +576,7 @@ def setflag(self, f, flags): """Set the flags (symlink, executable) for path f.""" + assert 'd' not in flags dir, subpath = _splittopdir(f) if dir: if dir not in self._dirs: @@ -567,6 +587,7 @@ def copy(self): copy = treemanifest(self._dir) + copy._node = self._node for d in self._dirs: copy._dirs[d] = self._dirs[d].copy() copy._files = dict.copy(self._files) @@ -635,18 +656,10 @@ if not self.hasdir(fn): match.bad(fn, None) - def _walk(self, match, alldirs=False): - '''Recursively generates matching file names for walk(). - - Will visit all subdirectories if alldirs is True, otherwise it will - only visit subdirectories for which match.visitdir is True.''' - - if not alldirs: - # substring to strip trailing slash - visit = match.visitdir(self._dir[:-1] or '.') - if not visit: - return - alldirs = (visit == 'all') + def _walk(self, match): + '''Recursively generates matching file names for walk().''' + if not match.visitdir(self._dir[:-1] or '.'): + return # yield this dir's files and walk its submanifests for p in sorted(self._dirs.keys() + self._files.keys()): @@ -655,7 +668,7 @@ if match(fullp): yield fullp else: - for f in self._dirs[p]._walk(match, alldirs): + for f in self._dirs[p]._walk(match): yield f def matches(self, match): @@ -665,19 +678,13 @@ return self._matches(match) - def _matches(self, match, alldirs=False): + def _matches(self, match): '''recursively generate a new manifest filtered by the match argument. - - Will visit all subdirectories if alldirs is True, otherwise it will - only visit subdirectories for which match.visitdir is True.''' - + ''' ret = treemanifest(self._dir) - if not alldirs: - # substring to strip trailing slash - visit = match.visitdir(self._dir[:-1] or '.') - if not visit: - return ret - alldirs = (visit == 'all') + + if not match.visitdir(self._dir[:-1] or '.'): + return ret for fn in self._files: fullp = self._subpath(fn) @@ -688,7 +695,7 @@ ret._flags[fn] = self._flags[fn] for dir, subm in self._dirs.iteritems(): - m = subm._matches(match, alldirs) + m = subm._matches(match) if not m._isempty(): ret._dirs[dir] = m @@ -737,11 +744,18 @@ _diff(self, m2) return result - def parse(self, text): + def parse(self, text, readsubtree): for f, n, fl in _parse(text): - self[f] = n - if fl: - self.setflag(f, fl) + if fl == 'd': + f = f + '/' + self._dirs[f] = readsubtree(self._subpath(f), n) + else: + # Use __setitem__ and setflag rather than assigning directly + # to _files and _flags, thereby letting us parse flat manifests + # as well as tree manifests. + self[f] = n + if fl: + self.setflag(f, fl) def text(self, usemanifestv2=False): """Get the full data of this manifest as a bytestring.""" @@ -749,8 +763,30 @@ return _text(((f, self[f], flags(f)) for f in self.keys()), usemanifestv2) + def dirtext(self, usemanifestv2=False): + """Get the full data of this directory as a bytestring. Make sure that + any submanifests have been written first, so their nodeids are correct. + """ + flags = self.flags + dirs = [(d[:-1], self._dirs[d]._node, 'd') for d in self._dirs] + files = [(f, self._files[f], flags(f)) for f in self._files] + return _text(sorted(dirs + files), usemanifestv2) + + def writesubtrees(self, m1, m2, writesubtree): + emptytree = treemanifest() + for d, subm in self._dirs.iteritems(): + subp1 = m1._dirs.get(d, emptytree)._node + subp2 = m2._dirs.get(d, emptytree)._node + if subp1 == revlog.nullid: + subp1, subp2 = subp2, subp1 + writesubtree(subm, subp1, subp2) + class manifest(revlog.revlog): - def __init__(self, opener): + def __init__(self, opener, dir='', dirlogcache=None): + '''The 'dir' and 'dirlogcache' arguments are for internal use by + manifest.manifest only. External users should create a root manifest + log with manifest.manifest(opener) and call dirlog() on it. + ''' # During normal operations, we expect to deal with not more than four # revs at a time (such as during commit --amend). When rebasing large # stacks of commits, the number can go up, hence the config knob below. @@ -760,19 +796,38 @@ opts = getattr(opener, 'options', None) if opts is not None: cachesize = opts.get('manifestcachesize', cachesize) - usetreemanifest = opts.get('usetreemanifest', usetreemanifest) + usetreemanifest = opts.get('treemanifest', usetreemanifest) usemanifestv2 = opts.get('manifestv2', usemanifestv2) self._mancache = util.lrucachedict(cachesize) - revlog.revlog.__init__(self, opener, "00manifest.i") self._treeinmem = usetreemanifest self._treeondisk = usetreemanifest self._usemanifestv2 = usemanifestv2 + indexfile = "00manifest.i" + if dir: + assert self._treeondisk + if not dir.endswith('/'): + dir = dir + '/' + indexfile = "meta/" + dir + "00manifest.i" + revlog.revlog.__init__(self, opener, indexfile) + self._dir = dir + # The dirlogcache is kept on the root manifest log + if dir: + self._dirlogcache = dirlogcache + else: + self._dirlogcache = {'': self} def _newmanifest(self, data=''): if self._treeinmem: - return treemanifest('', data) + return treemanifest(self._dir, data) return manifestdict(data) + def dirlog(self, dir): + assert self._treeondisk + if dir not in self._dirlogcache: + self._dirlogcache[dir] = manifest(self.opener, dir, + self._dirlogcache) + return self._dirlogcache[dir] + def _slowreaddelta(self, node): r0 = self.deltaparent(self.rev(node)) m0 = self.read(self.node(r0)) @@ -793,7 +848,13 @@ return self._newmanifest(d) def readfast(self, node): - '''use the faster of readdelta or read''' + '''use the faster of readdelta or read + + This will return a manifest which is either only the files + added/modified relative to p1, or all files in the + manifest. Which one is returned depends on the codepath used + to retrieve the data. + ''' r = self.rev(node) deltaparent = self.deltaparent(r) if deltaparent != revlog.nullrev and deltaparent in self.parentrevs(r): @@ -806,8 +867,16 @@ if node in self._mancache: return self._mancache[node][0] text = self.revision(node) - arraytext = array.array('c', text) - m = self._newmanifest(text) + if self._treeondisk: + def readsubtree(dir, subm): + return self.dirlog(dir).read(subm) + m = self._newmanifest() + m.parse(text, readsubtree) + m.setnode(node) + arraytext = None + else: + m = self._newmanifest(text) + arraytext = array.array('c', text) self._mancache[node] = (m, arraytext) return m @@ -845,10 +914,34 @@ # just encode a fulltext of the manifest and pass that # through to the revlog layer, and let it handle the delta # process. - text = m.text(self._usemanifestv2) - arraytext = array.array('c', text) - n = self.addrevision(text, transaction, link, p1, p2) + if self._treeondisk: + m1 = self.read(p1) + m2 = self.read(p2) + n = self._addtree(m, transaction, link, m1, m2) + arraytext = None + else: + text = m.text(self._usemanifestv2) + n = self.addrevision(text, transaction, link, p1, p2) + arraytext = array.array('c', text) self._mancache[n] = (m, arraytext) return n + + def _addtree(self, m, transaction, link, m1, m2): + def writesubtree(subm, subp1, subp2): + sublog = self.dirlog(subm.dir()) + sublog.add(subm, transaction, link, subp1, subp2, None, None) + m.writesubtrees(m1, m2, writesubtree) + text = m.dirtext(self._usemanifestv2) + # If the manifest is unchanged compared to one parent, + # don't write a new revision + if text == m1.dirtext(self._usemanifestv2): + n = m1.node() + elif text == m2.dirtext(self._usemanifestv2): + n = m2.node() + else: + n = self.addrevision(text, transaction, link, m1.node(), m2.node()) + # Save nodeid so parent manifest can calculate its nodeid + m.setnode(n) + return n diff -r ef4538ba67ef -r 472a685a4961 mercurial/match.py --- a/mercurial/match.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/match.py Tue May 19 07:17:57 2015 -0500 @@ -21,7 +21,7 @@ except AttributeError: return m.match -def _expandsets(kindpats, ctx): +def _expandsets(kindpats, ctx, listsubrepos): '''Returns the kindpats list with the 'set' patterns expanded.''' fset = set() other = [] @@ -32,6 +32,12 @@ raise util.Abort("fileset expression with no context") s = ctx.getfileset(pat) fset.update(s) + + if listsubrepos: + for subpath in ctx.substate: + s = ctx.sub(subpath).getfileset(pat) + fset.update(subpath + '/' + f for f in s) + continue other.append((kind, pat)) return fset, other @@ -47,7 +53,8 @@ class match(object): def __init__(self, root, cwd, patterns, include=[], exclude=[], - default='glob', exact=False, auditor=None, ctx=None): + default='glob', exact=False, auditor=None, ctx=None, + listsubrepos=False): """build an object to match a set of file patterns arguments: @@ -80,11 +87,13 @@ matchfns = [] if include: kindpats = self._normalize(include, 'glob', root, cwd, auditor) - self.includepat, im = _buildmatch(ctx, kindpats, '(?:/|$)') + self.includepat, im = _buildmatch(ctx, kindpats, '(?:/|$)', + listsubrepos) matchfns.append(im) if exclude: kindpats = self._normalize(exclude, 'glob', root, cwd, auditor) - self.excludepat, em = _buildmatch(ctx, kindpats, '(?:/|$)') + self.excludepat, em = _buildmatch(ctx, kindpats, '(?:/|$)', + listsubrepos) matchfns.append(lambda f: not em(f)) if exact: if isinstance(patterns, list): @@ -97,7 +106,8 @@ if not _kindpatsalwaysmatch(kindpats): self._files = _roots(kindpats) self._anypats = self._anypats or _anypats(kindpats) - self.patternspat, pm = _buildmatch(ctx, kindpats, '$') + self.patternspat, pm = _buildmatch(ctx, kindpats, '$', + listsubrepos) matchfns.append(pm) if not matchfns: @@ -113,7 +123,7 @@ return True self.matchfn = m - self._fmap = set(self._files) + self._fileroots = set(self._files) def __call__(self, fn): return self.matchfn(fn) @@ -161,21 +171,17 @@ @propertycache def _dirs(self): - return set(util.dirs(self._fmap)) | set(['.']) + return set(util.dirs(self._fileroots)) | set(['.']) def visitdir(self, dir): - '''Helps while traversing a directory tree. Returns the string 'all' if - the given directory and all subdirectories should be visited. Otherwise - returns True or False indicating whether the given directory should be - visited. If 'all' is returned, calling this method on a subdirectory - gives an undefined result.''' - if not self._fmap or self.exact(dir): - return 'all' - return dir in self._dirs + return (not self._fileroots or '.' in self._fileroots or + dir in self._fileroots or dir in self._dirs or + any(parentdir in self._fileroots + for parentdir in util.finddirs(dir))) def exact(self, f): '''Returns True if f is in .files().''' - return f in self._fmap + return f in self._fileroots def anypats(self): '''Matcher uses patterns or include/exclude.''' @@ -186,6 +192,14 @@ - optimization might be possible and necessary.''' return self._always + def ispartial(self): + '''True if the matcher won't always match. + + Although it's just the inverse of _always in this implementation, + an extenion such as narrowhg might make it return something + slightly different.''' + return not self._always + def isexact(self): return self.matchfn == self.exact @@ -264,11 +278,11 @@ # If the parent repo had a path to this subrepo and no patterns are # specified, this submatcher always matches. if not self._always and not matcher._anypats: - self._always = util.any(f == path for f in matcher._files) + self._always = any(f == path for f in matcher._files) self._anypats = matcher._anypats self.matchfn = lambda fn: matcher.matchfn(self._path + "/" + fn) - self._fmap = set(self._files) + self._fileroots = set(self._files) def abs(self, f): return self._matcher.abs(self._path + "/" + f) @@ -285,17 +299,17 @@ """ def __init__(self, root, cwd, patterns, include, exclude, default, auditor, - ctx): + ctx, listsubrepos=False): init = super(icasefsmatcher, self).__init__ self._dsnormalize = ctx.repo().dirstate.normalize init(root, cwd, patterns, include, exclude, default, auditor=auditor, - ctx=ctx) + ctx=ctx, listsubrepos=listsubrepos) # m.exact(file) must be based off of the actual user input, otherwise # inexact case matches are treated as exact, and not noted without -v. if self._files: - self._fmap = set(_roots(self._kp)) + self._fileroots = set(_roots(self._kp)) def _normalize(self, patterns, default, root, cwd, auditor): self._kp = super(icasefsmatcher, self)._normalize(patterns, default, @@ -418,10 +432,10 @@ return '.*' + pat return _globre(pat) + globsuffix -def _buildmatch(ctx, kindpats, globsuffix): +def _buildmatch(ctx, kindpats, globsuffix, listsubrepos): '''Return regexp string and a matcher function for kindpats. globsuffix is appended to the regexp of globs.''' - fset, kindpats = _expandsets(kindpats, ctx) + fset, kindpats = _expandsets(kindpats, ctx, listsubrepos) if not kindpats: return "", fset.__contains__ @@ -486,3 +500,49 @@ for kind, pat in kindpats: if kind in ('glob', 're', 'relglob', 'relre', 'set'): return True + +_commentre = None + +def readpatternfile(filepath, warn): + '''parse a pattern file, returning a list of + patterns. These patterns should be given to compile() + to be validated and converted into a match function.''' + syntaxes = {'re': 'relre:', 'regexp': 'relre:', 'glob': 'relglob:'} + syntax = 'relre:' + patterns = [] + + fp = open(filepath) + for line in fp: + if "#" in line: + global _commentre + if not _commentre: + _commentre = re.compile(r'((^|[^\\])(\\\\)*)#.*') + # remove comments prefixed by an even number of escapes + line = _commentre.sub(r'\1', line) + # fixup properly escaped comments that survived the above + line = line.replace("\\#", "#") + line = line.rstrip() + if not line: + continue + + if line.startswith('syntax:'): + s = line[7:].strip() + try: + syntax = syntaxes[s] + except KeyError: + warn(_("%s: ignoring invalid syntax '%s'\n") % (filepath, s)) + continue + + linesyntax = syntax + for s, rels in syntaxes.iteritems(): + if line.startswith(rels): + linesyntax = rels + line = line[len(rels):] + break + elif line.startswith(s+':'): + linesyntax = rels + line = line[len(s) + 1:] + break + patterns.append(linesyntax + line) + fp.close() + return patterns diff -r ef4538ba67ef -r 472a685a4961 mercurial/merge.py --- a/mercurial/merge.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/merge.py Tue May 19 07:17:57 2015 -0500 @@ -605,7 +605,7 @@ # Consensus? if len(bids) == 1: # all bids are the same kind of method m, l = bids.items()[0] - if util.all(a == l[0] for a in l[1:]): # len(bids) is > 1 + if all(a == l[0] for a in l[1:]): # len(bids) is > 1 repo.ui.note(" %s: consensus for %s\n" % (f, m)) actions[f] = l[0] continue @@ -617,7 +617,7 @@ # If there are gets and they all agree [how could they not?], do it. if 'g' in bids: ga0 = bids['g'][0] - if util.all(a == ga0 for a in bids['g'][1:]): + if all(a == ga0 for a in bids['g'][1:]): repo.ui.note(" %s: picking 'get' action\n" % f) actions[f] = ga0 continue diff -r ef4538ba67ef -r 472a685a4961 mercurial/obsolete.py --- a/mercurial/obsolete.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/obsolete.py Tue May 19 07:17:57 2015 -0500 @@ -718,7 +718,7 @@ """List markers over pushkey""" if not repo.obsstore: return {} - return _pushkeyescape(repo.obsstore) + return _pushkeyescape(sorted(repo.obsstore)) def pushmarker(repo, key, old, new): """Push markers over pushkey""" @@ -1110,13 +1110,17 @@ @cachefor('unstable') def _computeunstableset(repo): """the set of non obsolete revisions with obsolete parents""" - # revset is not efficient enough here - # we do (obsolete()::) - obsolete() by hand - obs = getrevs(repo, 'obsolete') - if not obs: - return set() - cl = repo.changelog - return set(r for r in cl.descendants(obs) if r not in obs) + revs = [(ctx.rev(), ctx) for ctx in + repo.set('(not public()) and (not obsolete())')] + revs.sort(key=lambda x:x[0]) + unstable = set() + for rev, ctx in revs: + # A rev is unstable if one of its parent is obsolete or unstable + # this works since we traverse following growing rev order + if any((x.obsolete() or (x.rev() in unstable)) + for x in ctx.parents()): + unstable.add(rev) + return unstable @cachefor('suspended') def _computesuspendedset(repo): @@ -1139,19 +1143,18 @@ public = phases.public cl = repo.changelog torev = cl.nodemap.get - obs = getrevs(repo, 'obsolete') - for rev in repo: + for ctx in repo.set('(not public()) and (not obsolete())'): + rev = ctx.rev() # We only evaluate mutable, non-obsolete revision - if (public < phase(repo, rev)) and (rev not in obs): - node = cl.node(rev) - # (future) A cache of precursors may worth if split is very common - for pnode in allprecursors(repo.obsstore, [node], - ignoreflags=bumpedfix): - prev = torev(pnode) # unfiltered! but so is phasecache - if (prev is not None) and (phase(repo, prev) <= public): - # we have a public precursors - bumped.add(rev) - break # Next draft! + node = ctx.node() + # (future) A cache of precursors may worth if split is very common + for pnode in allprecursors(repo.obsstore, [node], + ignoreflags=bumpedfix): + prev = torev(pnode) # unfiltered! but so is phasecache + if (prev is not None) and (phase(repo, prev) <= public): + # we have a public precursors + bumped.add(rev) + break # Next draft! return bumped @cachefor('divergent') diff -r ef4538ba67ef -r 472a685a4961 mercurial/parser.py --- a/mercurial/parser.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/parser.py Tue May 19 07:17:57 2015 -0500 @@ -27,10 +27,7 @@ def _advance(self): 'advance the tokenizer' t = self.current - try: - self.current = self._iter.next() - except StopIteration: - pass + self.current = next(self._iter, None) return t def _match(self, m, pos): 'make sure the tokenizer matches an end condition' diff -r ef4538ba67ef -r 472a685a4961 mercurial/parsers.c --- a/mercurial/parsers.c Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/parsers.c Tue May 19 07:17:57 2015 -0500 @@ -1071,14 +1071,17 @@ phases[i] = phases[parent_2]; } -static PyObject *compute_phases(indexObject *self, PyObject *args) +static PyObject *compute_phases_map_sets(indexObject *self, PyObject *args) { PyObject *roots = Py_None; + PyObject *ret = NULL; PyObject *phaseslist = NULL; PyObject *phaseroots = NULL; PyObject *rev = NULL; PyObject *p1 = NULL; PyObject *p2 = NULL; + PyObject *phaseset = NULL; + PyObject *phasessetlist = NULL; Py_ssize_t addlen = self->added ? PyList_GET_SIZE(self->added) : 0; Py_ssize_t len = index_length(self) - 1; Py_ssize_t numphase = 0; @@ -1088,6 +1091,7 @@ int parent_1, parent_2; char *phases = NULL; const char *data; + long phase; if (!PyArg_ParseTuple(args, "O", &roots)) goto release_none; @@ -1100,13 +1104,24 @@ /* Put the phase information of all the roots in phases */ numphase = PyList_GET_SIZE(roots)+1; minrevallphases = len + 1; + phasessetlist = PyList_New(numphase); + if (phasessetlist == NULL) + goto release_none; + + PyList_SET_ITEM(phasessetlist, 0, Py_None); + Py_INCREF(Py_None); + for (i = 0; i < numphase-1; i++) { phaseroots = PyList_GET_ITEM(roots, i); + phaseset = PySet_New(NULL); + if (phaseset == NULL) + goto release_phasesetlist; + PyList_SET_ITEM(phasessetlist, i+1, phaseset); if (!PyList_Check(phaseroots)) - goto release_phases; + goto release_phasesetlist; minrevphase = add_roots_get_min(self, phaseroots, i+1, phases); if (minrevphase == -2) /* Error from add_roots_get_min */ - goto release_phases; + goto release_phasesetlist; minrevallphases = MIN(minrevallphases, minrevphase); } /* Propagate the phase information from the roots to the revs */ @@ -1121,7 +1136,7 @@ p2 = PyTuple_GET_ITEM(rev, 6); if (!PyInt_Check(p1) || !PyInt_Check(p2)) { PyErr_SetString(PyExc_TypeError, "revlog parents are invalid"); - goto release_phases; + goto release_phasesetlist; } parent_1 = (int)PyInt_AS_LONG(p1); parent_2 = (int)PyInt_AS_LONG(p2); @@ -1131,14 +1146,35 @@ /* Transform phase list to a python list */ phaseslist = PyList_New(len); if (phaseslist == NULL) - goto release_phases; - for (i = 0; i < len; i++) - PyList_SET_ITEM(phaseslist, i, PyInt_FromLong(phases[i])); + goto release_phasesetlist; + for (i = 0; i < len; i++) { + phase = phases[i]; + /* We only store the sets of phase for non public phase, the public phase + * is computed as a difference */ + if (phase != 0) { + phaseset = PyList_GET_ITEM(phasessetlist, phase); + PySet_Add(phaseset, PyInt_FromLong(i)); + } + PyList_SET_ITEM(phaseslist, i, PyInt_FromLong(phase)); + } + ret = PyList_New(2); + if (ret == NULL) + goto release_phaseslist; + PyList_SET_ITEM(ret, 0, phaseslist); + PyList_SET_ITEM(ret, 1, phasessetlist); + /* We don't release phaseslist and phasessetlist as we return them to + * python */ + goto release_phases; + +release_phaseslist: + Py_XDECREF(phaseslist); +release_phasesetlist: + Py_XDECREF(phasessetlist); release_phases: free(phases); release_none: - return phaseslist; + return ret; } static PyObject *index_headrevs(indexObject *self, PyObject *args) @@ -2278,8 +2314,8 @@ "clear the index caches"}, {"get", (PyCFunction)index_m_get, METH_VARARGS, "get an index entry"}, - {"computephases", (PyCFunction)compute_phases, METH_VARARGS, - "compute phases"}, + {"computephasesmapsets", (PyCFunction)compute_phases_map_sets, + METH_VARARGS, "compute phases"}, {"headrevs", (PyCFunction)index_headrevs, METH_VARARGS, "get head revisions"}, /* Can do filtering since 3.2 */ {"headrevsfiltered", (PyCFunction)index_headrevs, METH_VARARGS, diff -r ef4538ba67ef -r 472a685a4961 mercurial/patch.py --- a/mercurial/patch.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/patch.py Tue May 19 07:17:57 2015 -0500 @@ -6,6 +6,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 collections import cStringIO, email, os, errno, re, posixpath, copy import tempfile, zlib, shutil # On python2.4 you have to import these by name or they fail to @@ -15,7 +16,6 @@ from i18n import _ from node import hex, short -import cStringIO import base85, mdiff, scmutil, util, diffhelpers, copies, encoding, error import pathutil @@ -830,7 +830,7 @@ self.hunks = [] def binary(self): - return util.any(h.startswith('index ') for h in self.header) + return any(h.startswith('index ') for h in self.header) def pretty(self, fp): for h in self.header: @@ -853,7 +853,7 @@ fp.write(''.join(self.header)) def allhunks(self): - return util.any(self.allhunks_re.match(h) for h in self.header) + return any(self.allhunks_re.match(h) for h in self.header) def files(self): match = self.diffgit_re.match(self.header[0]) @@ -872,7 +872,7 @@ return '
' % (' '.join(map(repr, self.files()))) def isnewfile(self): - return util.any(self.newfile_re.match(h) for h in self.header) + return any(self.newfile_re.match(h) for h in self.header) def special(self): # Special files are shown only at the header level and not at the hunk @@ -885,7 +885,7 @@ nocontent = len(self.header) == 2 emptynewfile = self.isnewfile() and nocontent return emptynewfile or \ - util.any(self.special_re.match(h) for h in self.header) + any(self.special_re.match(h) for h in self.header) class recordhunk(object): """patch hunk @@ -2102,7 +2102,7 @@ def lrugetfilectx(): cache = {} - order = util.deque() + order = collections.deque() def getfilectx(f, ctx): fctx = ctx.filectx(f, filelog=cache.get(f)) if f not in cache: diff -r ef4538ba67ef -r 472a685a4961 mercurial/pathutil.py --- a/mercurial/pathutil.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/pathutil.py Tue May 19 07:17:57 2015 -0500 @@ -152,7 +152,19 @@ break name = dirname - raise util.Abort(_("%s not under root '%s'") % (myname, root)) + # A common mistake is to use -R, but specify a file relative to the repo + # instead of cwd. Detect that case, and provide a hint to the user. + hint = None + try: + if cwd != root: + canonpath(root, root, myname, auditor) + hint = (_("consider using '--cwd %s'") + % os.path.relpath(root, cwd)) + except util.Abort: + pass + + raise util.Abort(_("%s not under root '%s'") % (myname, root), + hint=hint) def normasprefix(path): '''normalize the specified path as path prefix diff -r ef4538ba67ef -r 472a685a4961 mercurial/phases.py --- a/mercurial/phases.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/phases.py Tue May 19 07:17:57 2015 -0500 @@ -155,6 +155,7 @@ # Cheap trick to allow shallow-copy without copy module self.phaseroots, self.dirty = _readroots(repo, phasedefaults) self._phaserevs = None + self._phasesets = None self.filterunknown(repo) self.opener = repo.svfs @@ -177,7 +178,7 @@ nativeroots = [] for phase in trackedphases: nativeroots.append(map(repo.changelog.rev, self.phaseroots[phase])) - return repo.changelog.computephases(nativeroots) + return repo.changelog.computephasesmapsets(nativeroots) def _computephaserevspure(self, repo): repo = repo.unfiltered() @@ -199,7 +200,8 @@ 'nativephaseskillswitch'): self._computephaserevspure(repo) else: - self._phaserevs = self._getphaserevsnative(repo) + res = self._getphaserevsnative(repo) + self._phaserevs, self._phasesets = res except AttributeError: self._computephaserevspure(repo) return self._phaserevs diff -r ef4538ba67ef -r 472a685a4961 mercurial/repoview.py --- a/mercurial/repoview.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/repoview.py Tue May 19 07:17:57 2015 -0500 @@ -115,16 +115,15 @@ """ wlock = fh = None try: - try: - wlock = repo.wlock(wait=False) - # write cache to file - newhash = cachehash(repo, hideable) - fh = repo.vfs.open(cachefile, 'w+b', atomictemp=True) - _writehiddencache(fh, newhash, hidden) - except (IOError, OSError): - repo.ui.debug('error writing hidden changesets cache') - except error.LockHeld: - repo.ui.debug('cannot obtain lock to write hidden changesets cache') + wlock = repo.wlock(wait=False) + # write cache to file + newhash = cachehash(repo, hideable) + fh = repo.vfs.open(cachefile, 'w+b', atomictemp=True) + _writehiddencache(fh, newhash, hidden) + except (IOError, OSError): + repo.ui.debug('error writing hidden changesets cache') + except error.LockHeld: + repo.ui.debug('cannot obtain lock to write hidden changesets cache') finally: if fh: fh.close() @@ -197,7 +196,7 @@ Secret and hidden changeset should not pretend to be here.""" assert not repo.changelog.filteredrevs # fast check to avoid revset call on huge repo - if util.any(repo._phasecache.phaseroots[1:]): + if any(repo._phasecache.phaseroots[1:]): getphase = repo._phasecache.phase maymutable = filterrevs(repo, 'base') return frozenset(r for r in maymutable if getphase(repo, r)) diff -r ef4538ba67ef -r 472a685a4961 mercurial/revlog.py --- a/mercurial/revlog.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/revlog.py Tue May 19 07:17:57 2015 -0500 @@ -12,6 +12,7 @@ """ # import stuff from node for others to import from revlog +import collections from node import bin, hex, nullid, nullrev from i18n import _ import ancestor, mdiff, parsers, error, util, templatefilters @@ -485,7 +486,7 @@ # take all ancestors from heads that aren't in has missing = set() - visit = util.deque(r for r in heads if r not in has) + visit = collections.deque(r for r in heads if r not in has) while visit: r = visit.popleft() if r in missing: diff -r ef4538ba67ef -r 472a685a4961 mercurial/revset.py --- a/mercurial/revset.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/revset.py Tue May 19 07:17:57 2015 -0500 @@ -25,23 +25,22 @@ cl = repo.changelog def iterate(): - revqueue, revsnode = None, None + revs.sort(reverse=True) + irevs = iter(revs) h = [] - revs.sort(reverse=True) - revqueue = util.deque(revs) - if revqueue: - revsnode = revqueue.popleft() - heapq.heappush(h, -revsnode) + inputrev = next(irevs, None) + if inputrev is not None: + heapq.heappush(h, -inputrev) seen = set() while h: current = -heapq.heappop(h) + if current == inputrev: + inputrev = next(irevs, None) + if inputrev is not None: + heapq.heappush(h, -inputrev) if current not in seen: - if revsnode and current == revsnode: - if revqueue: - revsnode = revqueue.popleft() - heapq.heappush(h, -revsnode) seen.add(current) yield current for parent in cl.parentrevs(current)[:cut]: @@ -334,11 +333,6 @@ return baseset([x]) return baseset() -def symbolset(repo, subset, x): - if x in symbols: - raise error.ParseError(_("can't use %s here") % x) - return stringset(repo, subset, x) - def rangeset(repo, subset, x, y): m = getset(repo, fullreposet(repo), x) n = getset(repo, fullreposet(repo), y) @@ -363,7 +357,7 @@ def orset(repo, subset, x, y): xl = getset(repo, subset, x) - yl = getset(repo, subset - xl, y) + yl = getset(repo, subset, y) return xl + yl def notset(repo, subset, x): @@ -1127,7 +1121,7 @@ def matches(r): c = repo[r] - return util.any(kw in encoding.lower(t) for t in c.files() + [c.user(), + return any(kw in encoding.lower(t) for t in c.files() + [c.user(), c.description()]) return subset.filter(matches) @@ -1151,12 +1145,11 @@ result = [] it = iter(os) for x in xrange(lim): - try: - y = it.next() - if y in ss: - result.append(y) - except (StopIteration): + y = next(it, None) + if y is None: break + elif y in ss: + result.append(y) return baseset(result) def last(repo, subset, x): @@ -1179,12 +1172,11 @@ result = [] it = iter(os) for x in xrange(lim): - try: - y = it.next() - if y in ss: - result.append(y) - except (StopIteration): + y = next(it, None) + if y is None: break + elif y in ss: + result.append(y) return baseset(result) def maxrev(repo, subset, x): @@ -1486,6 +1478,22 @@ except error.RepoLookupError: return baseset() +def _notpublic(repo, subset, x): + """``_notpublic()`` + Changeset not in public phase.""" + # i18n: "public" is a keyword + getargs(x, 0, 0, _("_notpublic takes no arguments")) + if repo._phasecache._phasesets: + s = set() + for u in repo._phasecache._phasesets[1:]: + s.update(u) + return subset & s + else: + phase = repo._phasecache.phase + target = phases.public + condition = lambda r: phase(repo, r) != target + return subset.filter(condition, cache=False) + def public(repo, subset, x): """``public()`` Changeset in public phase.""" @@ -1684,7 +1692,7 @@ Changesets in set with no parent changeset in set. """ s = getset(repo, fullreposet(repo), x) - subset = baseset([r for r in s if r in subset]) + subset = subset & s# baseset([r for r in s if r in subset]) cs = _children(repo, subset, s) return subset - cs @@ -1787,7 +1795,7 @@ return s.added or s.modified or s.removed if s.added: - return util.any(submatches(c.substate.keys())) + return any(submatches(c.substate.keys())) if s.modified: subs = set(c.p1().substate.keys()) @@ -1798,7 +1806,7 @@ return True if s.removed: - return util.any(submatches(c.p1().substate.keys())) + return any(submatches(c.p1().substate.keys())) return False @@ -1992,6 +2000,7 @@ "parents": parents, "present": present, "public": public, + "_notpublic": _notpublic, "remote": remote, "removes": removes, "rev": rev, @@ -2066,6 +2075,7 @@ "parents", "present", "public", + "_notpublic", "remote", "removes", "rev", @@ -2088,7 +2098,7 @@ "range": rangeset, "dagrange": dagrange, "string": stringset, - "symbol": symbolset, + "symbol": stringset, "and": andset, "or": orset, "not": notset, @@ -2097,7 +2107,6 @@ "ancestor": ancestorspec, "parent": parentspec, "parentpost": p1, - "only": only, } def optimize(x, small): @@ -2158,8 +2167,14 @@ wb, wa = wa, wb return max(wa, wb), (op, ta, tb) elif op == 'not': - o = optimize(x[1], not small) - return o[0], (op, o[1]) + # Optimize not public() to _notpublic() because we have a fast version + if x[1] == ('func', ('symbol', 'public'), None): + newsym = ('func', ('symbol', '_notpublic'), None) + o = optimize(newsym, not small) + return o[0], o[1] + else: + o = optimize(x[1], not small) + return o[0], (op, o[1]) elif op == 'parentpost': o = optimize(x[1], small) return o[0], (op, o[1]) @@ -2939,6 +2954,42 @@ def __repr__(self): return '<%s %r>' % (type(self).__name__, self._subset) +def _iterordered(ascending, iter1, iter2): + """produce an ordered iteration from two iterators with the same order + + The ascending is used to indicated the iteration direction. + """ + choice = max + if ascending: + choice = min + + val1 = None + val2 = None + try: + # Consume both iterators in an ordered way until one is empty + while True: + if val1 is None: + val1 = iter1.next() + if val2 is None: + val2 = iter2.next() + next = choice(val1, val2) + yield next + if val1 == next: + val1 = None + if val2 == next: + val2 = None + except StopIteration: + # Flush any remaining values and consume the other one + it = iter2 + if val1 is not None: + yield val1 + it = iter1 + elif val2 is not None: + # might have been equality and both are empty + yield val2 + for val in it: + yield val + class addset(abstractsmartset): """Represent the addition of two sets @@ -2948,6 +2999,64 @@ If the ascending attribute is set, that means the two structures are ordered in either an ascending or descending way. Therefore, we can add them maintaining the order by iterating over both at the same time + + >>> xs = baseset([0, 3, 2]) + >>> ys = baseset([5, 2, 4]) + + >>> rs = addset(xs, ys) + >>> bool(rs), 0 in rs, 1 in rs, 5 in rs, rs.first(), rs.last() + (True, True, False, True, 0, 4) + >>> rs = addset(xs, baseset([])) + >>> bool(rs), 0 in rs, 1 in rs, rs.first(), rs.last() + (True, True, False, 0, 2) + >>> rs = addset(baseset([]), baseset([])) + >>> bool(rs), 0 in rs, rs.first(), rs.last() + (False, False, None, None) + + iterate unsorted: + >>> rs = addset(xs, ys) + >>> [x for x in rs] # without _genlist + [0, 3, 2, 5, 4] + >>> assert not rs._genlist + >>> len(rs) + 5 + >>> [x for x in rs] # with _genlist + [0, 3, 2, 5, 4] + >>> assert rs._genlist + + iterate ascending: + >>> rs = addset(xs, ys, ascending=True) + >>> [x for x in rs], [x for x in rs.fastasc()] # without _asclist + ([0, 2, 3, 4, 5], [0, 2, 3, 4, 5]) + >>> assert not rs._asclist + >>> len(rs) + 5 + >>> [x for x in rs], [x for x in rs.fastasc()] + ([0, 2, 3, 4, 5], [0, 2, 3, 4, 5]) + >>> assert rs._asclist + + iterate descending: + >>> rs = addset(xs, ys, ascending=False) + >>> [x for x in rs], [x for x in rs.fastdesc()] # without _asclist + ([5, 4, 3, 2, 0], [5, 4, 3, 2, 0]) + >>> assert not rs._asclist + >>> len(rs) + 5 + >>> [x for x in rs], [x for x in rs.fastdesc()] + ([5, 4, 3, 2, 0], [5, 4, 3, 2, 0]) + >>> assert rs._asclist + + iterate ascending without fastasc: + >>> rs = addset(xs, generatorset(ys), ascending=True) + >>> assert rs.fastasc is None + >>> [x for x in rs] + [0, 2, 3, 4, 5] + + iterate descending without fastdesc: + >>> rs = addset(generatorset(xs), ys, ascending=False) + >>> assert rs.fastdesc is None + >>> [x for x in rs] + [5, 4, 3, 2, 0] """ def __init__(self, revs1, revs2, ascending=None): self._r1 = revs1 @@ -2966,10 +3075,10 @@ @util.propertycache def _list(self): if not self._genlist: - self._genlist = baseset(self._iterator()) + self._genlist = baseset(iter(self)) return self._genlist - def _iterator(self): + def __iter__(self): """Iterate over both collections without repeating elements If the ascending attribute is not set, iterate over the first one and @@ -2980,35 +3089,41 @@ same time, yielding only one value at a time in the given order. """ if self._ascending is None: - def gen(): + if self._genlist: + return iter(self._genlist) + def arbitraryordergen(): for r in self._r1: yield r inr1 = self._r1.__contains__ for r in self._r2: if not inr1(r): yield r - gen = gen() - else: - iter1 = iter(self._r1) - iter2 = iter(self._r2) - gen = self._iterordered(self._ascending, iter1, iter2) - return gen - - def __iter__(self): - if self._ascending is None: - if self._genlist: - return iter(self._genlist) - return iter(self._iterator()) + return arbitraryordergen() + # try to use our own fast iterator if it exists self._trysetasclist() if self._ascending: - it = self.fastasc + attr = 'fastasc' else: - it = self.fastdesc - if it is None: - # consume the gen and try again - self._list - return iter(self) - return it() + attr = 'fastdesc' + it = getattr(self, attr) + if it is not None: + return it() + # maybe half of the component supports fast + # get iterator for _r1 + iter1 = getattr(self._r1, attr) + if iter1 is None: + # let's avoid side effect (not sure it matters) + iter1 = iter(sorted(self._r1, reverse=not self._ascending)) + else: + iter1 = iter1() + # get iterator for _r2 + iter2 = getattr(self._r2, attr) + if iter2 is None: + # let's avoid side effect (not sure it matters) + iter2 = iter(sorted(self._r2, reverse=not self._ascending)) + else: + iter2 = iter2() + return _iterordered(self._ascending, iter1, iter2) def _trysetasclist(self): """populate the _asclist attribute if possible and necessary""" @@ -3024,7 +3139,7 @@ iter2 = self._r2.fastasc if None in (iter1, iter2): return None - return lambda: self._iterordered(True, iter1(), iter2()) + return lambda: _iterordered(True, iter1(), iter2()) @property def fastdesc(self): @@ -3035,48 +3150,7 @@ iter2 = self._r2.fastdesc if None in (iter1, iter2): return None - return lambda: self._iterordered(False, iter1(), iter2()) - - def _iterordered(self, ascending, iter1, iter2): - """produce an ordered iteration from two iterators with the same order - - The ascending is used to indicated the iteration direction. - """ - choice = max - if ascending: - choice = min - - val1 = None - val2 = None - - choice = max - if ascending: - choice = min - try: - # Consume both iterators in an ordered way until one is - # empty - while True: - if val1 is None: - val1 = iter1.next() - if val2 is None: - val2 = iter2.next() - next = choice(val1, val2) - yield next - if val1 == next: - val1 = None - if val2 == next: - val2 = None - except StopIteration: - # Flush any remaining values and consume the other one - it = iter2 - if val1 is not None: - yield val1 - it = iter1 - elif val2 is not None: - # might have been equality and both are empty - yield val2 - for val in it: - yield val + return lambda: _iterordered(False, iter1(), iter2()) def __contains__(self, x): return x in self._r1 or x in self._r2 @@ -3143,7 +3217,12 @@ self.__contains__ = self._desccontains def __nonzero__(self): - for r in self: + # Do not use 'for r in self' because it will enforce the iteration + # order (default ascending), possibly unrolling a whole descending + # iterator. + if self._genlist: + return True + for r in self._consumegen(): return True return False @@ -3267,9 +3346,7 @@ for x in self._consumegen(): pass return self.first() - if self: - return it().next() - return None + return next(it(), None) def last(self): if self._ascending: @@ -3281,9 +3358,7 @@ for x in self._consumegen(): pass return self.first() - if self: - return it().next() - return None + return next(it(), None) def __repr__(self): d = {False: '-', True: '+'}[self._ascending] diff -r ef4538ba67ef -r 472a685a4961 mercurial/scmutil.py --- a/mercurial/scmutil.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/scmutil.py Tue May 19 07:17:57 2015 -0500 @@ -803,7 +803,7 @@ pats = expandpats(pats or []) m = ctx.match(pats, opts.get('include'), opts.get('exclude'), - default) + default, listsubrepos=opts.get('subrepos')) def badfn(f, msg): ctx.repo().ui.warn("%s: %s\n" % (m.rel(f), msg)) m.bad = badfn @@ -1011,6 +1011,12 @@ " for more information")) return requirements +def writerequires(opener, requirements): + reqfile = opener("requires", "w") + for r in sorted(requirements): + reqfile.write("%s\n" % r) + reqfile.close() + class filecachesubentry(object): def __init__(self, path, stat): self.path = path diff -r ef4538ba67ef -r 472a685a4961 mercurial/setdiscovery.py --- a/mercurial/setdiscovery.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/setdiscovery.py Tue May 19 07:17:57 2015 -0500 @@ -40,6 +40,7 @@ classified with it (since all ancestors or descendants will be marked as well). """ +import collections from node import nullid, nullrev from i18n import _ import random @@ -65,7 +66,7 @@ else: heads = dag.heads() dist = {} - visit = util.deque(heads) + visit = collections.deque(heads) seen = set() factor = 1 while visit: @@ -168,7 +169,7 @@ ui.debug("all remote heads known locally\n") return (srvheadhashes, False, srvheadhashes,) - if sample and len(ownheads) <= initialsamplesize and util.all(yesno): + if sample and len(ownheads) <= initialsamplesize and all(yesno): ui.note(_("all local heads known remotely\n")) ownheadhashes = dag.externalizeall(ownheads) return (ownheadhashes, True, srvheadhashes,) diff -r ef4538ba67ef -r 472a685a4961 mercurial/store.py --- a/mercurial/store.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/store.py Tue May 19 07:17:57 2015 -0500 @@ -187,7 +187,7 @@ def _hashencode(path, dotencode): digest = _sha(path).hexdigest() - le = lowerencode(path).split('/')[1:] + le = lowerencode(path[5:]).split('/') # skips prefix 'data/' or 'meta/' parts = _auxencode(le, dotencode) basename = parts[-1] _root, ext = os.path.splitext(basename) diff -r ef4538ba67ef -r 472a685a4961 mercurial/subrepo.py --- a/mercurial/subrepo.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/subrepo.py Tue May 19 07:17:57 2015 -0500 @@ -500,6 +500,10 @@ """return file flags""" return '' + def getfileset(self, expr): + """Resolve the fileset expression for this repo""" + return set() + def printfiles(self, ui, m, fm, fmt): """handle the files command for this subrepo""" return 1 @@ -592,21 +596,14 @@ def _storeclean(self, path): clean = True itercache = self._calcstorehash(path) - try: - for filehash in self._readstorehashcache(path): - if filehash != itercache.next(): - clean = False - break - except StopIteration: + for filehash in self._readstorehashcache(path): + if filehash != next(itercache, None): + clean = False + break + if clean: + # if not empty: # the cached and current pull states have a different size - clean = False - if clean: - try: - itercache.next() - # the cached and current pull states have a different size - clean = False - except StopIteration: - pass + clean = next(itercache, None) is None return clean def _calcstorehash(self, remotepath): @@ -917,6 +914,26 @@ ctx = self._repo[rev] return cmdutil.files(ui, ctx, m, fm, fmt, True) + @annotatesubrepoerror + def getfileset(self, expr): + if self._ctx.rev() is None: + ctx = self._repo[None] + else: + rev = self._state[1] + ctx = self._repo[rev] + + files = ctx.getfileset(expr) + + for subpath in ctx.substate: + sub = ctx.sub(subpath) + + try: + files.extend(subpath + '/' + f for f in sub.getfileset(expr)) + except error.LookupError: + self.ui.status(_("skipping missing subrepository: %s\n") + % self.wvfs.reljoin(reporelpath(self), subpath)) + return files + def walk(self, match): ctx = self._repo[None] return ctx.walk(match) @@ -1711,7 +1728,7 @@ modified, added, removed = [], [], [] self._gitupdatestat() if rev2: - command = ['diff-tree', rev1, rev2] + command = ['diff-tree', '-r', rev1, rev2] else: command = ['diff-index', rev1] out = self._gitcommand(command) diff -r ef4538ba67ef -r 472a685a4961 mercurial/tags.py --- a/mercurial/tags.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/tags.py Tue May 19 07:17:57 2015 -0500 @@ -509,26 +509,25 @@ return try: + f = repo.vfs.open(_fnodescachefile, 'ab') try: - f = repo.vfs.open(_fnodescachefile, 'ab') - try: - # if the file has been truncated - actualoffset = f.tell() - if actualoffset < self._dirtyoffset: - self._dirtyoffset = actualoffset - data = self._raw[self._dirtyoffset:] - f.seek(self._dirtyoffset) - f.truncate() - repo.ui.log('tagscache', - 'writing %d bytes to %s\n' % ( - len(data), _fnodescachefile)) - f.write(data) - self._dirtyoffset = None - finally: - f.close() - except (IOError, OSError), inst: + # if the file has been truncated + actualoffset = f.tell() + if actualoffset < self._dirtyoffset: + self._dirtyoffset = actualoffset + data = self._raw[self._dirtyoffset:] + f.seek(self._dirtyoffset) + f.truncate() repo.ui.log('tagscache', - "couldn't write %s: %s\n" % ( - _fnodescachefile, inst)) + 'writing %d bytes to %s\n' % ( + len(data), _fnodescachefile)) + f.write(data) + self._dirtyoffset = None + finally: + f.close() + except (IOError, OSError), inst: + repo.ui.log('tagscache', + "couldn't write %s: %s\n" % ( + _fnodescachefile, inst)) finally: lock.release() diff -r ef4538ba67ef -r 472a685a4961 mercurial/templatefilters.py --- a/mercurial/templatefilters.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/templatefilters.py Tue May 19 07:17:57 2015 -0500 @@ -326,6 +326,8 @@ """ if util.safehasattr(thing, '__iter__') and not isinstance(thing, str): return "".join([stringify(t) for t in thing if t is not None]) + if thing is None: + return "" return str(thing) def strip(text): diff -r ef4538ba67ef -r 472a685a4961 mercurial/templatekw.py --- a/mercurial/templatekw.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/templatekw.py Tue May 19 07:17:57 2015 -0500 @@ -210,7 +210,7 @@ """ repo = args['ctx']._repo bookmarks = args['ctx'].bookmarks() - current = repo._bookmarkcurrent + current = repo._activebookmark makemap = lambda v: {'bookmark': v, 'current': current} f = _showlist('bookmark', bookmarks, **args) return _hybrid(f, bookmarks, makemap, lambda x: x['bookmark']) @@ -221,15 +221,21 @@ childrevs = ['%d:%s' % (cctx, cctx) for cctx in ctx.children()] return showlist('children', childrevs, element='child', **args) +# Deprecated, but kept alive for help generation a purpose. def showcurrentbookmark(**args): """:currentbookmark: String. The active bookmark, if it is + associated with the changeset (DEPRECATED)""" + return showactivebookmark(**args) + +def showactivebookmark(**args): + """:activetbookmark: String. The active bookmark, if it is associated with the changeset""" import bookmarks as bookmarks # to avoid circular import issues repo = args['repo'] - if bookmarks.iscurrent(repo): - current = repo._bookmarkcurrent - if current in args['ctx'].bookmarks(): - return current + if bookmarks.isactivewdirparent(repo): + active = repo._activebookmark + if active in args['ctx'].bookmarks(): + return active return '' def showdate(repo, ctx, templ, **args): @@ -418,12 +424,14 @@ # cache - a cache dictionary for the whole templater run # revcache - a cache dictionary for the current revision keywords = { + 'activebookmark': showactivebookmark, 'author': showauthor, 'bisect': showbisect, 'branch': showbranch, 'branches': showbranches, 'bookmarks': showbookmarks, 'children': showchildren, + # currentbookmark is deprecated 'currentbookmark': showcurrentbookmark, 'date': showdate, 'desc': showdescription, diff -r ef4538ba67ef -r 472a685a4961 mercurial/templater.py --- a/mercurial/templater.py Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/templater.py Tue May 19 07:17:57 2015 -0500 @@ -20,6 +20,7 @@ "|": (5, None, ("|", 5)), "%": (6, None, ("%", 6)), ")": (0, None, None), + "integer": (0, ("integer",), None), "symbol": (0, ("symbol",), None), "string": (0, ("string",), None), "rawstring": (0, ("rawstring",), None), @@ -59,6 +60,20 @@ pos += 1 else: raise error.ParseError(_("unterminated string"), s) + elif c.isdigit() or c == '-': + s = pos + if c == '-': # simply take negate operator as part of integer + pos += 1 + if pos >= end or not program[pos].isdigit(): + raise error.ParseError(_("integer literal without digits"), s) + pos += 1 + while pos < end: + d = program[pos] + if not d.isdigit(): + break + pos += 1 + yield ('integer', program[s:pos], s) + pos -= 1 elif c.isalnum() or c in '_': s = pos pos += 1 @@ -100,12 +115,12 @@ parseres, pos = p.parse(pd) parsed.append(parseres) - return [compileexp(e, context) for e in parsed] + return [compileexp(e, context, methods) for e in parsed] -def compileexp(exp, context): +def compileexp(exp, context, curmethods): t = exp[0] - if t in methods: - return methods[t](exp, context) + if t in curmethods: + return curmethods[t](exp, context) raise error.ParseError(_("unknown method '%s'") % t) # template evaluation @@ -135,6 +150,9 @@ return context._load(exp[1]) raise error.ParseError(_("expected template specifier")) +def runinteger(context, mapping, data): + return int(data) + def runstring(context, mapping, data): return data.decode("string-escape") @@ -157,7 +175,7 @@ return v def buildfilter(exp, context): - func, data = compileexp(exp[1], context) + func, data = compileexp(exp[1], context, methods) filt = getfilter(exp[2], context) return (runfilter, (func, data, filt)) @@ -179,7 +197,7 @@ "keyword '%s'") % (filt.func_name, dt)) def buildmap(exp, context): - func, data = compileexp(exp[1], context) + func, data = compileexp(exp[1], context, methods) ctmpl = gettemplate(exp[2], context) return (runmap, (func, data, ctmpl)) @@ -208,7 +226,7 @@ def buildfunc(exp, context): n = getsymbol(exp[1]) - args = [compileexp(x, context) for x in getlist(exp[2])] + args = [compileexp(x, context, exprmethods) for x in getlist(exp[2])] if n in funcs: f = funcs[n] return (f, args) @@ -551,8 +569,7 @@ num = int(stringify(args[0][0](context, mapping, args[0][1]))) except ValueError: # i18n: "word" is a keyword - raise error.ParseError( - _("Use strings like '3' for numbers passed to word function")) + raise error.ParseError(_("word expects an integer index")) text = stringify(args[1][0](context, mapping, args[1][1])) if len(args) == 3: splitter = stringify(args[2][0](context, mapping, args[2][1])) @@ -565,17 +582,23 @@ else: return tokens[num] -methods = { +# methods to interpret function arguments or inner expressions (e.g. {_(x)}) +exprmethods = { + "integer": lambda e, c: (runinteger, e[1]), "string": lambda e, c: (runstring, e[1]), "rawstring": lambda e, c: (runrawstring, e[1]), "symbol": lambda e, c: (runsymbol, e[1]), - "group": lambda e, c: compileexp(e[1], c), + "group": lambda e, c: compileexp(e[1], c, exprmethods), # ".": buildmember, "|": buildfilter, "%": buildmap, "func": buildfunc, } +# methods to interpret top-level template (e.g. {x}, {x|_}, {x % "y"}) +methods = exprmethods.copy() +methods["integer"] = exprmethods["symbol"] # '{1}' as variable + funcs = { "date": date, "diff": diff, @@ -618,14 +641,25 @@ for j in _flatten(i): yield j -def parsestring(s, quoted=True): - '''unwrap quotes if quoted is True''' - if quoted: - if len(s) < 2 or s[0] != s[-1]: - raise SyntaxError(_('unmatched quotes')) - return s[1:-1] - - return s +def unquotestring(s): + '''unwrap quotes''' + if len(s) < 2 or s[0] != s[-1]: + raise SyntaxError(_('unmatched quotes')) + # de-backslash-ify only <\">. it is invalid syntax in non-string part of + # template, but we are likely to escape <"> in quoted string and it was + # accepted before, thanks to issue4290. <\\"> is unmodified because it + # is ambiguous and it was processed as such before 2.8.1. + # + # template result + # --------- ------------------------ + # {\"\"} parse error + # "{""}" {""} -> <> + # "{\"\"}" {""} -> <> + # {"\""} {"\""} -> <"> + # '{"\""}' {"\""} -> <"> + # "{"\""}" parse error (don't care) + q = s[0] + return s[1:-1].replace('\\\\' + q, '\\\\\\' + q).replace('\\' + q, q) class engine(object): '''template expansion engine. @@ -709,7 +743,7 @@ raise util.Abort(_("style '%s' not found") % mapfile, hint=_("available styles: %s") % stylelist()) - conf = config.config() + conf = config.config(includepaths=templatepaths()) conf.read(mapfile) for key, val in conf[''].items(): @@ -717,7 +751,7 @@ raise SyntaxError(_('%s: missing value') % conf.source('', key)) if val[0] in "'\"": try: - self.cache[key] = parsestring(val) + self.cache[key] = unquotestring(val) except SyntaxError, inst: raise SyntaxError('%s: %s' % (conf.source('', key), inst.args[0])) diff -r ef4538ba67ef -r 472a685a4961 mercurial/templates/gitweb/fileannotate.tmpl --- a/mercurial/templates/gitweb/fileannotate.tmpl Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/templates/gitweb/fileannotate.tmpl Tue May 19 07:17:57 2015 -0500 @@ -39,19 +39,23 @@ - + + - + + {branch%filerevbranch} - + + {parent%fileannotateparent} {child%fileannotatechild} - + +
author{author|obfuscate}
{author|obfuscate}
{date|rfc822date}
{date|rfc822date}
changeset {rev}{node|short}
{node|short}
permissions{permissions|permissions}
{permissions|permissions}
diff -r ef4538ba67ef -r 472a685a4961 mercurial/templates/gitweb/filecomparison.tmpl --- a/mercurial/templates/gitweb/filecomparison.tmpl Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/templates/gitweb/filecomparison.tmpl Tue May 19 07:17:57 2015 -0500 @@ -39,7 +39,8 @@ {branch%filerevbranch} changeset {rev} - {node|short} + {node|short} + {parent%filecompparent} {child%filecompchild} diff -r ef4538ba67ef -r 472a685a4961 mercurial/templates/gitweb/filediff.tmpl --- a/mercurial/templates/gitweb/filediff.tmpl Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/templates/gitweb/filediff.tmpl Tue May 19 07:17:57 2015 -0500 @@ -39,7 +39,8 @@ {branch%filerevbranch} changeset {rev} - {node|short} + {node|short} + {parent%filediffparent} {child%filediffchild} diff -r ef4538ba67ef -r 472a685a4961 mercurial/templates/gitweb/filerevision.tmpl --- a/mercurial/templates/gitweb/filerevision.tmpl Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/templates/gitweb/filerevision.tmpl Tue May 19 07:17:57 2015 -0500 @@ -39,19 +39,23 @@ - + + - + + {branch%filerevbranch} - + + {parent%filerevparent} {child%filerevchild} - + +
author{author|obfuscate}
{author|obfuscate}
{date|rfc822date}
{date|rfc822date}
changeset {rev}{node|short}
{node|short}
permissions{permissions|permissions}
{permissions|permissions}
diff -r ef4538ba67ef -r 472a685a4961 mercurial/templates/gitweb/map --- a/mercurial/templates/gitweb/map Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/templates/gitweb/map Tue May 19 07:17:57 2015 -0500 @@ -293,11 +293,16 @@ {desc|strip|firstline|escape|nonempty} + {inbranch%inbranchtag}{branches%branchtag}{tags%tagtag}{bookmarks%bookmarktag} - file | diff | annotate {rename%filelogrename} - ' + file | + diff | + annotate + {rename%filelogrename} + + ' archiveentry = ' | {type|escape} ' indexentry = ' diff -r ef4538ba67ef -r 472a685a4961 mercurial/templates/map-cmdline.bisect --- a/mercurial/templates/map-cmdline.bisect Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/templates/map-cmdline.bisect Tue May 19 07:17:57 2015 -0500 @@ -1,25 +1,14 @@ -changeset = 'changeset: {rev}:{node|short}\nbisect: {bisect}\n{branches}{bookmarks}{tags}{parents}user: {author}\ndate: {date|date}\nsummary: {desc|firstline}\n\n' -changeset_quiet = '{bisect|shortbisect} {rev}:{node|short}\n' -changeset_verbose = 'changeset: {rev}:{node|short}\nbisect: {bisect}\n{branches}{bookmarks}{tags}{parents}user: {author}\ndate: {date|date}\n{files}{file_copies_switch}description:\n{desc|strip}\n\n\n' -changeset_debug = 'changeset: {rev}:{node}\nbisect: {bisect}\n{branches}{bookmarks}{tags}{parents}{manifest}user: {author}\ndate: {date|date}\n{file_mods}{file_adds}{file_dels}{file_copies_switch}{extras}description:\n{desc|strip}\n\n\n' -start_files = 'files: ' -file = ' {file}' -end_files = '\n' -start_file_mods = 'files: ' -file_mod = ' {file_mod}' -end_file_mods = '\n' -start_file_adds = 'files+: ' -file_add = ' {file_add}' -end_file_adds = '\n' -start_file_dels = 'files-: ' -file_del = ' {file_del}' -end_file_dels = '\n' -start_file_copies = 'copies: ' -file_copy = ' {name} ({source})' -end_file_copies = '\n' -parent = 'parent: {rev}:{node|formatnode}\n' -manifest = 'manifest: {rev}:{node}\n' -branch = 'branch: {branch}\n' -tag = 'tag: {tag}\n' -bookmark = 'bookmark: {bookmark}\n' -extra = 'extra: {key}={value|stringescape}\n' +%include map-cmdline.default + +changeset = '{cset}{lbisect}{branches}{bookmarks}{tags}{parents}{user}{ldate}{summary}\n' +changeset_quiet = '{lshortbisect} {rev}:{node|short}\n' +changeset_verbose = '{cset}{lbisect}{branches}{bookmarks}{tags}{parents}{user}{ldate}{lfiles}{lfile_copies_switch}{description}\n' +changeset_debug = '{fullcset}{lbisect}{branches}{bookmarks}{tags}{lphase}{parents}{manifest}{user}{ldate}{lfile_mods}{lfile_adds}{lfile_dels}{lfile_copies_switch}{extras}{description}\n' + +# We take the zeroth word in order to omit "(implicit)" in the label +bisectlabel = ' bisect.{word('0', bisect)}' + +lbisect ='{label("log.bisect{if(bisect, bisectlabel)}", + "bisect: {bisect}\n")}' +lshortbisect ='{label("log.bisect{if(bisect, bisectlabel)}", + "{bisect|shortbisect}")}' diff -r ef4538ba67ef -r 472a685a4961 mercurial/templates/map-cmdline.phases --- a/mercurial/templates/map-cmdline.phases Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/templates/map-cmdline.phases Tue May 19 07:17:57 2015 -0500 @@ -1,73 +1,3 @@ -# Base templates. Due to name clashes with existing keywords, we have -# to replace some keywords with 'lkeyword', for 'labelled keyword' +%include map-cmdline.default changeset = '{cset}{branches}{bookmarks}{tags}{lphase}{parents}{user}{ldate}{summary}\n' -changeset_quiet = '{lnode}' changeset_verbose = '{cset}{branches}{bookmarks}{tags}{lphase}{parents}{user}{ldate}{lfiles}{lfile_copies_switch}{description}\n' -changeset_debug = '{fullcset}{branches}{bookmarks}{tags}{lphase}{parents}{manifest}{user}{ldate}{lfile_mods}{lfile_adds}{lfile_dels}{lfile_copies_switch}{extras}{description}\n' - -# File templates -lfiles = '{if(files, - label("ui.note log.files", - "files: {files}\n"))}' - -lfile_mods = '{if(file_mods, - label("ui.debug log.files", - "files: {file_mods}\n"))}' - -lfile_adds = '{if(file_adds, - label("ui.debug log.files", - "files+: {file_adds}\n"))}' - -lfile_dels = '{if(file_dels, - label("ui.debug log.files", - "files-: {file_dels}\n"))}' - -lfile_copies_switch = '{if(file_copies_switch, - label("ui.note log.copies", - "copies: {file_copies_switch - % ' {name} ({source})'}\n"))}' - -# General templates -cset = '{label("log.changeset changeset.{phase}", - "changeset: {rev}:{node|short}")}\n' - -lphase = '{label("log.phase", - "phase: {phase}")}\n' - -fullcset = '{label("log.changeset changeset.{phase}", - "changeset: {rev}:{node}")}\n' - -parent = '{label("log.parent changeset.{phase}", - "parent: {rev}:{node|formatnode}")}\n' - -lnode = '{label("log.node", - "{rev}:{node|short}")}\n' - -manifest = '{label("ui.debug log.manifest", - "manifest: {rev}:{node}")}\n' - -branch = '{label("log.branch", - "branch: {branch}")}\n' - -tag = '{label("log.tag", - "tag: {tag}")}\n' - -bookmark = '{label("log.bookmark", - "bookmark: {bookmark}")}\n' - -user = '{label("log.user", - "user: {author}")}\n' - -summary = '{if(desc|strip, "{label('log.summary', - 'summary: {desc|firstline}')}\n")}' - -ldate = '{label("log.date", - "date: {date|date}")}\n' - -extra = '{label("ui.debug log.extra", - "extra: {key}={value|stringescape}")}\n' - -description = '{if(desc|strip, "{label('ui.note log.description', - 'description:')} - {label('ui.note log.description', - '{desc|strip}')}\n\n")}' diff -r ef4538ba67ef -r 472a685a4961 mercurial/templates/map-cmdline.status --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial/templates/map-cmdline.status Tue May 19 07:17:57 2015 -0500 @@ -0,0 +1,25 @@ +%include map-cmdline.default + +# Override base templates +changeset = '{cset}{branches}{bookmarks}{tags}{parents}{user}{ldate}{summary}{lfiles}\n' +changeset_verbose = '{cset}{branches}{bookmarks}{tags}{parents}{user}{ldate}{description}{lfiles}\n' +changeset_debug = '{fullcset}{branches}{bookmarks}{tags}{lphase}{parents}{manifest}{user}{ldate}{extras}{description}{lfiles}\n' + +# Override the file templates +lfiles = '{if(files, + label('ui.note log.files', + 'files:\n'))}{lfile_mods}{lfile_adds}{lfile_copies_switch}{lfile_dels}' + +# Exclude copied files, will display those in lfile_copies_switch +lfile_adds = '{file_adds % "{ifcontains(file, file_copies_switch, + '', + '{lfile_add}')}"}' +lfile_add = '{label("status.added", "A {file}\n")}' + +lfile_copies_switch = '{file_copies_switch % "{lfile_copy_orig}{lfile_copy_dest}"' +lfile_copy_orig = '{label("status.added", "A {name}\n")}' +lfile_copy_dest = '{label("status.copied", " {source}\n")}' + +lfile_mods = '{file_mods % "{label('status.modified', 'M {file}\n')}"}' + +lfile_dels = '{file_dels % "{label('status.removed', 'R {file}\n')}"}' diff -r ef4538ba67ef -r 472a685a4961 mercurial/templates/monoblue/map --- a/mercurial/templates/monoblue/map Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/templates/monoblue/map Tue May 19 07:17:57 2015 -0500 @@ -244,7 +244,12 @@ filelogentry = ' {date|rfc822date} - {desc|strip|firstline|escape|nonempty} + + + {desc|strip|firstline|escape|nonempty} + {inbranch%inbranchtag}{branches%branchtag}{tags%tagtag}{bookmarks%bookmarktag} + + file | diff | annotate {rename%filelogrename} diff -r ef4538ba67ef -r 472a685a4961 mercurial/templates/paper/fileannotate.tmpl --- a/mercurial/templates/paper/fileannotate.tmpl Sun May 17 22:09:37 2015 -0400 +++ b/mercurial/templates/paper/fileannotate.tmpl Tue May 19 07:17:57 2015 -0500 @@ -37,7 +37,7 @@
-

annotate {file|escape} @ {rev}:{node|short}

+

annotate {file|escape} @ {rev}:{node|short} {branch%changelogbranchname}{tags%changelogtag}{bookmarks%changelogtag}