changeset 20209:174d9b8baf5d

merge with stable
author Augie Fackler <raf@durin42.com>
date Wed, 01 Jan 2014 18:28:40 -0500
parents cd62532c62a1 (diff) 61a47fd64f30 (current diff)
children bdd340d8a595
files mercurial/fileset.py
diffstat 166 files changed, 2226 insertions(+), 1150 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Sat Dec 21 12:44:19 2013 +0900
+++ b/.hgignore	Wed Jan 01 18:28:40 2014 -0500
@@ -1,6 +1,7 @@
 syntax: glob
 
 *.elc
+*.tmp
 *.orig
 *.rej
 *~
--- a/Makefile	Sat Dec 21 12:44:19 2013 +0900
+++ b/Makefile	Wed Jan 01 18:28:40 2014 -0500
@@ -53,7 +53,8 @@
 
 clean:
 	-$(PYTHON) setup.py clean --all # ignore errors from this command
-	find . \( -name '*.py[cdo]' -o -name '*.so' \) -exec rm -f '{}' ';'
+	find contrib doc hgext i18n mercurial tests \
+		\( -name '*.py[cdo]' -o -name '*.so' \) -exec rm -f '{}' ';'
 	rm -f $(addprefix mercurial/,$(notdir $(wildcard mercurial/pure/[a-z]*.py)))
 	rm -f MANIFEST MANIFEST.in mercurial/__version__.py tests/*.err
 	rm -rf build mercurial/locale
@@ -107,7 +108,7 @@
 	  mercurial/fileset.py mercurial/revset.py \
 	  mercurial/templatefilters.py mercurial/templatekw.py \
 	  mercurial/filemerge.py \
-	  $(DOCFILES) > i18n/hg.pot
+	  $(DOCFILES) > i18n/hg.pot.tmp
         # All strings marked for translation in Mercurial contain
         # ASCII characters only. But some files contain string
         # literals like this '\037\213'. xgettext thinks it has to
@@ -119,11 +120,17 @@
 	  --msgid-bugs-address "<mercurial-devel@selenic.com>" \
 	  --copyright-holder "Matt Mackall <mpm@selenic.com> and others" \
 	  --from-code ISO-8859-1 --join --sort-by-file --add-comments=i18n: \
-	  -d hg -p i18n -o hg.pot
-	$(PYTHON) i18n/posplit i18n/hg.pot
+	  -d hg -p i18n -o hg.pot.tmp
+	$(PYTHON) i18n/posplit i18n/hg.pot.tmp
+        # The target file is not created before the last step. So it never is in
+        # an intermediate state.
+	mv -f i18n/hg.pot.tmp i18n/hg.pot
 
 %.po: i18n/hg.pot
-	msgmerge --no-location --update $@ $^
+        # work on a temporary copy for never having a half completed target
+	cp $@ $@.tmp
+	msgmerge --no-location --update $@.tmp $^
+	mv -f $@.tmp $@
 
 .PHONY: help all local build doc clean install install-bin install-doc \
 	install-home install-home-bin install-home-doc dist dist-notests tests \
--- a/contrib/bash_completion	Sat Dec 21 12:44:19 2013 +0900
+++ b/contrib/bash_completion	Wed Jan 01 18:28:40 2014 -0500
@@ -76,7 +76,7 @@
 {
     local i
     for i in $(compgen -d -- "$cur"); do
-	test ! -d "$i"/.hg || COMPREPLY=(${COMPREPLY[@]:-} "$i")
+        test ! -d "$i"/.hg || COMPREPLY=(${COMPREPLY[@]:-} "$i")
     done
 }
 
@@ -84,7 +84,6 @@
 {
     local files="$(_hg_cmd debugpathcomplete $1 "$cur")"
     local IFS=$'\n'
-    compopt -o filenames 2>/dev/null
     COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$files' -- "$cur"))
 }
 
@@ -92,10 +91,16 @@
 {
     local files="$(_hg_cmd status -n$1 "glob:$cur**")"
     local IFS=$'\n'
-    compopt -o filenames 2>/dev/null
     COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$files' -- "$cur"))
 }
 
+_hg_branches()
+{
+    local branches="$(_hg_cmd branches -q)"
+    local IFS=$'\n'
+    COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$branches' -- "$cur"))
+}
+
 _hg_bookmarks()
 {
     local bookmarks="$(_hg_cmd bookmarks -q)"
@@ -117,25 +122,45 @@
     local filters="$1"
 
     for ((i=1; $i<=$COMP_CWORD; i++)); do
-	if [[ "${COMP_WORDS[i]}" != -* ]]; then
-	    if [[ ${COMP_WORDS[i-1]} == @($filters|$global_args) ]]; then
-		continue
-	    fi
-	    count=$(($count + 1))
-	fi
+        if [[ "${COMP_WORDS[i]}" != -* ]]; then
+            if [[ ${COMP_WORDS[i-1]} == @($filters|$global_args) ]]; then
+                continue
+            fi
+            count=$(($count + 1))
+        fi
     done
 
     echo $(($count - 1))
 }
 
+_hg_fix_wordlist()
+{
+    local LASTCHAR=' '
+    if [ ${#COMPREPLY[@]} = 1 ]; then
+        [ -d "$COMPREPLY" ] && LASTCHAR=/
+        COMPREPLY=$(printf %q%s "$COMPREPLY" "$LASTCHAR")
+    else
+        for ((i=0; i < ${#COMPREPLY[@]}; i++)); do
+            [ -d "${COMPREPLY[$i]}" ] && COMPREPLY[$i]=${COMPREPLY[$i]}/
+        done
+    fi
+}
+
 _hg()
 {
-    local cur prev cmd cmd_index opts i
+    local cur prev cmd cmd_index opts i aliashg
     # global options that receive an argument
     local global_args='--cwd|-R|--repository'
     local hg="$1"
     local canonical=0
 
+    aliashg=$(alias $hg 2>/dev/null)
+    if [[ -n "$aliashg" ]]; then
+      aliashg=${aliashg#"alias $hg='"}
+      aliashg=${aliashg%"'"}
+      hg=$aliashg
+    fi
+
     COMPREPLY=()
     cur="$2"
     prev="$3"
@@ -144,145 +169,169 @@
     # (first non-option argument that doesn't follow a global option that
     #  receives an argument)
     for ((i=1; $i<=$COMP_CWORD; i++)); do
-	if [[ ${COMP_WORDS[i]} != -* ]]; then
-	    if [[ ${COMP_WORDS[i-1]} != @($global_args) ]]; then
-		cmd="${COMP_WORDS[i]}"
-		cmd_index=$i
-		break
-	    fi
-	fi
+        if [[ ${COMP_WORDS[i]} != -* ]]; then
+            if [[ ${COMP_WORDS[i-1]} != @($global_args) ]]; then
+                cmd="${COMP_WORDS[i]}"
+                cmd_index=$i
+                break
+            fi
+        fi
     done
 
     if [[ "$cur" == -* ]]; then
-	if [ "$(type -t "_hg_opt_$cmd")" = function ] && "_hg_opt_$cmd"; then
-	    return
-	fi
+        if [ "$(type -t "_hg_opt_$cmd")" = function ] && "_hg_opt_$cmd"; then
+            _hg_fix_wordlist
+            return
+        fi
 
-	opts=$(_hg_cmd debugcomplete --options "$cmd")
+        opts=$(_hg_cmd debugcomplete --options "$cmd")
 
-	COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$opts' -- "$cur"))
-	return
+        COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$opts' -- "$cur"))
+        _hg_fix_wordlist
+        return
     fi
 
     # global options
     case "$prev" in
-	-R|--repository)
-	    _hg_paths
-	    _hg_repos
-	    return
-	;;
-	--cwd)
-	    # Stick with default bash completion
-	    return
-	;;
+        -R|--repository)
+            _hg_paths
+            _hg_repos
+            _hg_fix_wordlist
+            return
+        ;;
+        --cwd)
+            # Stick with default bash completion
+            _hg_fix_wordlist
+            return
+        ;;
     esac
 
     if [ -z "$cmd" ] || [ $COMP_CWORD -eq $i ]; then
-	_hg_commands
-	return
+        _hg_commands
+        _hg_fix_wordlist
+        return
     fi
 
     # try to generate completion candidates for whatever command the user typed
     local help
     if _hg_command_specific; then
-	return
+        _hg_fix_wordlist
+        return
     fi
 
     # canonicalize the command name and try again
     help=$(_hg_cmd help "$cmd")
     if [ $? -ne 0 ]; then
-	# Probably either the command doesn't exist or it's ambiguous
-	return
+        # Probably either the command doesn't exist or it's ambiguous
+        return
     fi
     cmd=${help#hg }
     cmd=${cmd%%[$' \n']*}
     canonical=1
     _hg_command_specific
+    _hg_fix_wordlist
 }
 
 _hg_command_specific()
 {
     if [ "$(type -t "_hg_cmd_$cmd")" = function ]; then
-	"_hg_cmd_$cmd"
-	return 0
+        "_hg_cmd_$cmd"
+        return 0
     fi
 
-    if [ "$cmd" != status ] && [ "$prev" = -r ] || [ "$prev" == --rev ]; then
-	if [ $canonical = 1 ]; then
-	    _hg_labels
-	    return 0
-	elif [[ status != "$cmd"* ]]; then
-            _hg_labels
-	    return 0
-	else
-	    return 1
-	fi
+    if [ "$cmd" != status ]; then
+        case "$prev" in
+            -r|--rev)
+                if [[ $canonical = 1 || status != "$cmd"* ]]; then
+                    _hg_labels
+                    return 0
+                fi
+                return 1
+            ;;
+            -B|--bookmark)
+                if [[ $canonical = 1 || status != "$cmd"* ]]; then
+                    _hg_bookmarks
+                    return 0
+                fi
+                return 1
+            ;;
+            -b|--branch)
+                if [[ $canonical = 1 || status != "$cmd"* ]]; then
+                    _hg_branches
+                    return 0
+                fi
+                return 1
+            ;;
+        esac
     fi
 
+    local aliascmd=$(_hg_cmd showconfig alias.$cmd | awk '{print $1}')
+    [ -n "$aliascmd" ] && cmd=$aliascmd
+
     case "$cmd" in
-	help)
-	    _hg_commands
-	;;
-	export)
-	    if _hg_ext_mq_patchlist qapplied && [ "${COMPREPLY[*]}" ]; then
-		return 0
-	    fi
-	    _hg_labels
-	;;
-	manifest|update|up|checkout|co)
-	    _hg_labels
-	;;
-	pull|push|outgoing|incoming)
-	    _hg_paths
-	    _hg_repos
-	;;
-	paths)
-	    _hg_paths
-	;;
-	add)
-	    _hg_status "u"
-	;;
-	merge)
-	    _hg_labels
-	;;
-	commit|ci|record)
-	    _hg_status "mar"
-	;;
-	remove|rm)
-	    _hg_debugpathcomplete -n
-	;;
-	forget)
-	    _hg_debugpathcomplete -fa
-	;;
-	diff)
-	    _hg_status "mar"
-	;;
-	revert)
-	    _hg_debugpathcomplete
-	;;
-	clone)
-	    local count=$(_hg_count_non_option)
-	    if [ $count = 1 ]; then
-		_hg_paths
-	    fi
-	    _hg_repos
-	;;
-	debugindex|debugindexdot)
-	    COMPREPLY=(${COMPREPLY[@]:-} $(compgen -f -X "!*.i" -- "$cur"))
-	;;
-	debugdata)
-	    COMPREPLY=(${COMPREPLY[@]:-} $(compgen -f -X "!*.d" -- "$cur"))
-	;;
-	*)
-	    return 1
-	;;
+        help)
+            _hg_commands
+        ;;
+        export)
+            if _hg_ext_mq_patchlist qapplied && [ "${COMPREPLY[*]}" ]; then
+                return 0
+            fi
+            _hg_labels
+        ;;
+        manifest|update|up|checkout|co)
+            _hg_labels
+        ;;
+        pull|push|outgoing|incoming)
+            _hg_paths
+            _hg_repos
+        ;;
+        paths)
+            _hg_paths
+        ;;
+        add)
+            _hg_status "u"
+        ;;
+        merge)
+            _hg_labels
+        ;;
+        commit|ci|record)
+            _hg_status "mar"
+        ;;
+        remove|rm)
+            _hg_debugpathcomplete -n
+        ;;
+        forget)
+            _hg_debugpathcomplete -fa
+        ;;
+        diff)
+            _hg_status "mar"
+        ;;
+        revert)
+            _hg_debugpathcomplete
+        ;;
+        clone)
+            local count=$(_hg_count_non_option)
+            if [ $count = 1 ]; then
+                _hg_paths
+            fi
+            _hg_repos
+        ;;
+        debugindex|debugindexdot)
+            COMPREPLY=(${COMPREPLY[@]:-} $(compgen -f -X "!*.i" -- "$cur"))
+        ;;
+        debugdata)
+            COMPREPLY=(${COMPREPLY[@]:-} $(compgen -f -X "!*.d" -- "$cur"))
+        ;;
+        *)
+            return 1
+        ;;
     esac
 
     return 0
 }
 
-complete -o bashdefault -o default -F _hg hg \
-    || complete -o default -F _hg hg
+complete -o bashdefault -o default -o nospace -F _hg hg \
+    || complete -o default -o nospace -F _hg hg
 
 
 # Completion for commands provided by extensions
@@ -290,10 +339,8 @@
 # bookmarks
 _hg_cmd_bookmarks()
 {
-    if [[ "$prev" = @(-d|--delete|-m|--rename) ]]; then
-        _hg_bookmarks
-        return
-    fi
+    _hg_bookmarks
+    return
 }
 
 # mq
@@ -302,8 +349,8 @@
     local patches
     patches=$(_hg_cmd $1)
     if [ $? -eq 0 ] && [ "$patches" ]; then
-	COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$patches' -- "$cur"))
-	return 0
+        COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$patches' -- "$cur"))
+        return 0
     fi
     return 1
 }
@@ -313,19 +360,19 @@
     local root=$(_hg_cmd root)
     local n
     for n in $(cd "$root"/.hg && compgen -d -- "$cur"); do
-	# I think we're usually not interested in the regular "patches" queue
-	# so just filter it.
-	if [ "$n" != patches ] && [ -e "$root/.hg/$n/series" ]; then
-	    COMPREPLY=(${COMPREPLY[@]:-} "$n")
-	fi
+        # I think we're usually not interested in the regular "patches" queue
+        # so just filter it.
+        if [ "$n" != patches ] && [ -e "$root/.hg/$n/series" ]; then
+            COMPREPLY=(${COMPREPLY[@]:-} "$n")
+        fi
     done
 }
 
 _hg_cmd_qpop()
 {
     if [[ "$prev" = @(-n|--name) ]]; then
-	_hg_ext_mq_queues
-	return
+        _hg_ext_mq_queues
+        return
     fi
     _hg_ext_mq_patchlist qapplied
 }
@@ -333,8 +380,8 @@
 _hg_cmd_qpush()
 {
     if [[ "$prev" = @(-n|--name) ]]; then
-	_hg_ext_mq_queues
-	return
+        _hg_ext_mq_queues
+        return
     fi
     _hg_ext_mq_patchlist qunapplied
 }
@@ -342,8 +389,8 @@
 _hg_cmd_qgoto()
 {
     if [[ "$prev" = @(-n|--name) ]]; then
-	_hg_ext_mq_queues
-	return
+        _hg_ext_mq_queues
+        return
     fi
     _hg_ext_mq_patchlist qseries
 }
@@ -352,7 +399,7 @@
 {
     local qcmd=qunapplied
     if [[ "$prev" = @(-r|--rev) ]]; then
-	qcmd=qapplied
+        qcmd=qapplied
     fi
     _hg_ext_mq_patchlist $qcmd
 }
@@ -360,7 +407,7 @@
 _hg_cmd_qfinish()
 {
     if [[ "$prev" = @(-a|--applied) ]]; then
-	return
+        return
     fi
     _hg_ext_mq_patchlist qapplied
 }
@@ -368,8 +415,8 @@
 _hg_cmd_qsave()
 {
     if [[ "$prev" = @(-n|--name) ]]; then
-	_hg_ext_mq_queues
-	return
+        _hg_ext_mq_queues
+        return
     fi
 }
 
@@ -382,6 +429,10 @@
 
 _hg_cmd_strip()
 {
+    if [[ "$prev" = @(-B|--bookmark) ]]; then
+        _hg_bookmarks
+        return
+    fi
     _hg_labels
 }
 
@@ -412,7 +463,7 @@
 {
     local count=$(_hg_count_non_option)
     if [ $count = 1 ]; then
-	_hg_paths
+        _hg_paths
     fi
     _hg_repos
 }
@@ -433,15 +484,15 @@
     local prefix=''
 
     if [[ "$cur" == +* ]]; then
-	prefix=+
+        prefix=+
     elif [[ "$cur" == -* ]]; then
-	prefix=-
+        prefix=-
     fi
     local ncur=${cur#[-+]}
 
     if ! [ "$prefix" ]; then
-	_hg_ext_mq_patchlist qseries
-	return
+        _hg_ext_mq_patchlist qseries
+        return
     fi
 
     local guards=$(_hg_ext_mq_guards)
@@ -452,15 +503,15 @@
 {
     local i
     for ((i=cmd_index+1; i<=COMP_CWORD; i++)); do
-	if [[ ${COMP_WORDS[i]} != -* ]]; then
-	    if [[ ${COMP_WORDS[i-1]} != @($global_args) ]]; then
-		_hg_cmd_qguard
-		return 0
-	    fi
-	elif [ "${COMP_WORDS[i]}" = -- ]; then
-	    _hg_cmd_qguard
-	    return 0
-	fi
+        if [[ ${COMP_WORDS[i]} != -* ]]; then
+            if [[ ${COMP_WORDS[i-1]} != @($global_args) ]]; then
+                _hg_cmd_qguard
+                return 0
+            fi
+        elif [ "${COMP_WORDS[i]}" = -- ]; then
+            _hg_cmd_qguard
+            return 0
+        fi
     done
     return 1
 }
@@ -484,24 +535,24 @@
 
     # find the sub-command
     for ((i=cmd_index+1; i<=COMP_CWORD; i++)); do
-	if [[ ${COMP_WORDS[i]} != -* ]]; then
-	    if [[ ${COMP_WORDS[i-1]} != @($global_args) ]]; then
-		subcmd="${COMP_WORDS[i]}"
-		break
-	    fi
-	fi
+        if [[ ${COMP_WORDS[i]} != -* ]]; then
+            if [[ ${COMP_WORDS[i-1]} != @($global_args) ]]; then
+                subcmd="${COMP_WORDS[i]}"
+                break
+            fi
+        fi
     done
 
     if [ -z "$subcmd" ] || [ $COMP_CWORD -eq $i ] || [ "$subcmd" = help ]; then
-	COMPREPLY=(${COMPREPLY[@]:-}
-		   $(compgen -W 'bad good help init next reset' -- "$cur"))
-	return
+        COMPREPLY=(${COMPREPLY[@]:-}
+                   $(compgen -W 'bad good help init next reset' -- "$cur"))
+        return
     fi
 
     case "$subcmd" in
-	good|bad)
-	    _hg_labels
-	    ;;
+        good|bad)
+            _hg_labels
+            ;;
     esac
 
     return
@@ -512,28 +563,28 @@
 _hg_cmd_email()
 {
     case "$prev" in
-	-c|--cc|-t|--to|-f|--from|--bcc)
-	    # we need an e-mail address. let the user provide a function
-	    # to get them
-	    if [ "$(type -t _hg_emails)" = function ]; then
-		local arg=to
-		if [[ "$prev" == @(-f|--from) ]]; then
-		    arg=from
-		fi
-		local addresses=$(_hg_emails $arg)
-		COMPREPLY=(${COMPREPLY[@]:-}
-			   $(compgen -W '$addresses' -- "$cur"))
-	    fi
-	    return
-	    ;;
-	-m|--mbox)
-	    # fallback to standard filename completion
-	    return
-	    ;;
-	-s|--subject)
-	    # free form string
-	    return
-	    ;;
+        -c|--cc|-t|--to|-f|--from|--bcc)
+            # we need an e-mail address. let the user provide a function
+            # to get them
+            if [ "$(type -t _hg_emails)" = function ]; then
+                local arg=to
+                if [[ "$prev" == @(-f|--from) ]]; then
+                    arg=from
+                fi
+                local addresses=$(_hg_emails $arg)
+                COMPREPLY=(${COMPREPLY[@]:-}
+                           $(compgen -W '$addresses' -- "$cur"))
+            fi
+            return
+            ;;
+        -m|--mbox)
+            # fallback to standard filename completion
+            return
+            ;;
+        -s|--subject)
+            # free form string
+            return
+            ;;
     esac
 
     _hg_labels
@@ -552,15 +603,15 @@
 _hg_cmd_transplant()
 {
     case "$prev" in
-	-s|--source)
-	    _hg_paths
-	    _hg_repos
-	    return
-	    ;;
-	--filter)
-	    # standard filename completion
-	    return
-	    ;;
+        -s|--source)
+            _hg_paths
+            _hg_repos
+            return
+            ;;
+        --filter)
+            # standard filename completion
+            return
+            ;;
     esac
 
     # all other transplant options values and command parameters are revisions
@@ -571,14 +622,18 @@
 # shelve
 _hg_shelves()
 {
-    local shelves="$(_hg_cmd unshelve -l .)"
+    local shelves="$(_hg_cmd shelve -ql)"
     local IFS=$'\n'
     COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$shelves' -- "$cur"))
 }
 
 _hg_cmd_shelve()
 {
-    _hg_status "mard"
+    if [[ "$prev" = @(-d|--delete) ]]; then
+        _hg_shelves
+    else
+        _hg_status "mard"
+    fi
 }
 
 _hg_cmd_unshelve()
--- a/contrib/check-code.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/contrib/check-code.py	Wed Jan 01 18:28:40 2014 -0500
@@ -141,17 +141,15 @@
     (r'^  saved backup bundle to \$TESTTMP.*\.hg$', winglobmsg),
     (r'^  changeset .* references (corrupted|missing) \$TESTTMP/.*[^)]$',
      winglobmsg),
-    (r'^  pulling from \$TESTTMP/.*[^)]$', winglobmsg, '\$TESTTMP/unix-repo$'),
-    (r'^  reverting .*/.*[^)]$', winglobmsg, '\$TESTTMP/unix-repo$'),
-    (r'^  cloning subrepo \S+/.*[^)]$', winglobmsg, '\$TESTTMP/unix-repo$'),
-    (r'^  pushing to \$TESTTMP/.*[^)]$', winglobmsg, '\$TESTTMP/unix-repo$'),
-    (r'^  pushing subrepo \S+/\S+ to.*[^)]$', winglobmsg,
-     '\$TESTTMP/unix-repo$'),
+    (r'^  pulling from \$TESTTMP/.*[^)]$', winglobmsg,
+     '\$TESTTMP/unix-repo$'), # in test-issue1802.t which skipped on windows
+    (r'^  reverting .*/.*[^)]$', winglobmsg),
+    (r'^  cloning subrepo \S+/.*[^)]$', winglobmsg),
+    (r'^  pushing to \$TESTTMP/.*[^)]$', winglobmsg),
+    (r'^  pushing subrepo \S+/\S+ to.*[^)]$', winglobmsg),
     (r'^  moving \S+/.*[^)]$', winglobmsg),
-    (r'^  no changes made to subrepo since.*/.*[^)]$',
-     winglobmsg, '\$TESTTMP/unix-repo$'),
-    (r'^  .*: largefile \S+ not available from file:.*/.*[^)]$',
-     winglobmsg, '\$TESTTMP/unix-repo$'),
+    (r'^  no changes made to subrepo since.*/.*[^)]$', winglobmsg),
+    (r'^  .*: largefile \S+ not available from file:.*/.*[^)]$', winglobmsg),
   ],
   # warnings
   [
@@ -264,7 +262,7 @@
     (r'[\s\(](open|file)\([^)]*\)\.read\(',
      "use util.readfile() instead"),
     (r'[\s\(](open|file)\([^)]*\)\.write\(',
-     "use util.readfile() instead"),
+     "use util.writefile() instead"),
     (r'^[\s\(]*(open(er)?|file)\([^)]*\)',
      "always assign an opened file to a variable, and close it afterwards"),
     (r'[\s\(](open|file)\([^)]*\)\.',
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contrib/editmerge	Wed Jan 01 18:28:40 2014 -0500
@@ -0,0 +1,58 @@
+#!/bin/bash
+# A simple script for opening merge conflicts in the editor.
+# Use the following Mercurial settings to enable it.
+#
+# [ui]
+# merge = editmerge
+#
+# [merge-tools]
+# editmerge.args=$output
+# editmerge.check=changed
+# editmerge.premerge=keep
+
+FILE=$1
+
+getlines() {
+  grep -n "<<<<<<" $FILE | cut -f1 -d:
+}
+
+# editor preference loosely based on http://mercurial.selenic.com/wiki/editor
+# hg showconfig is at the bottom though, since it's slow to run (0.15 seconds)
+ED=$HGEDITOR
+if [ "$ED" = "" ] ; then
+  ED=$VISUAL
+fi
+if [ "$ED" = "" ] ; then
+  ED=$EDITOR
+fi
+if [ "$ED" = "" ] ; then
+  ED=$(hg showconfig ui.editor)
+fi
+if [ "$ED" = "" ] ; then
+  echo "merge failed - unable to find editor"
+  exit 1
+fi
+
+if [ "$ED" = "emacs" ] || [ "$ED" = "nano" ] || [ "$ED" = "vim" ] ; then
+  FIRSTLINE=$(getlines | head -n 1)
+  PREVIOUSLINE=""
+
+  # open the editor to the first conflict until there are no more
+  # or the user stops editing the file
+  while [ ! "$FIRSTLINE" = "" ] && [ ! "$FIRSTLINE" = "$PREVIOUSLINE" ] ; do
+    $ED +$FIRSTLINE $FILE
+    PREVIOUSLINE=$FIRSTLINE
+    FIRSTLINE=$(getlines | head -n 1)
+  done
+else
+  $ED $FILE
+fi
+
+# get the line numbers of the remaining conflicts
+CONFLICTS=$(getlines | sed ':a;N;$!ba;s/\n/, /g')
+if [ ! "$CONFLICTS" = "" ] ; then
+  echo "merge failed - resolve the conflicts (line $CONFLICTS) then use 'hg resolve --mark'"
+  exit 1
+fi
+
+exit 0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contrib/import-checker.py	Wed Jan 01 18:28:40 2014 -0500
@@ -0,0 +1,244 @@
+import ast
+import os
+import sys
+
+# Import a minimal set of stdlib modules needed for list_stdlib_modules()
+# to work when run from a virtualenv.  The modules were chosen empirically
+# so that the return value matches the return value without virtualenv.
+import BaseHTTPServer
+import zlib
+
+def dotted_name_of_path(path):
+    """Given a relative path to a source file, return its dotted module name.
+
+
+    >>> dotted_name_of_path('mercurial/error.py')
+    'mercurial.error'
+    """
+    parts = path.split('/')
+    parts[-1] = parts[-1][:-3] # remove .py
+    return '.'.join(parts)
+
+
+def list_stdlib_modules():
+    """List the modules present in the stdlib.
+
+    >>> mods = set(list_stdlib_modules())
+    >>> 'BaseHTTPServer' in mods
+    True
+
+    os.path isn't really a module, so it's missing:
+
+    >>> 'os.path' in mods
+    False
+
+    sys requires special treatment, because it's baked into the
+    interpreter, but it should still appear:
+
+    >>> 'sys' in mods
+    True
+
+    >>> 'collections' in mods
+    True
+
+    >>> 'cStringIO' in mods
+    True
+    """
+    for m in sys.builtin_module_names:
+        yield m
+    # These modules only exist on windows, but we should always
+    # consider them stdlib.
+    for m in ['msvcrt', '_winreg']:
+        yield m
+    # These get missed too
+    for m in 'ctypes', 'email':
+        yield m
+    yield 'builtins' # python3 only
+    stdlib_prefixes = set([sys.prefix, sys.exec_prefix])
+    # We need to supplement the list of prefixes for the search to work
+    # when run from within a virtualenv.
+    for mod in (BaseHTTPServer, zlib):
+        try:
+            # Not all module objects have a __file__ attribute.
+            filename = mod.__file__
+        except AttributeError:
+            continue
+        dirname = os.path.dirname(filename)
+        for prefix in stdlib_prefixes:
+            if dirname.startswith(prefix):
+                # Then this directory is redundant.
+                break
+        else:
+            stdlib_prefixes.add(dirname)
+    for libpath in sys.path:
+        # We want to walk everything in sys.path that starts with
+        # something in stdlib_prefixes. check-code suppressed because
+        # the ast module used by this script implies the availability
+        # of any().
+        if not any(libpath.startswith(p) for p in stdlib_prefixes): # no-check-code
+            continue
+        if 'site-packages' in libpath:
+            continue
+        for top, dirs, files in os.walk(libpath):
+            for name in files:
+                if name == '__init__.py':
+                    continue
+                if not (name.endswith('.py') or name.endswith('.so')):
+                    continue
+                full_path = os.path.join(top, name)
+                if 'site-packages' in full_path:
+                    continue
+                rel_path = full_path[len(libpath) + 1:]
+                mod = dotted_name_of_path(rel_path)
+                yield mod
+
+stdlib_modules = set(list_stdlib_modules())
+
+def imported_modules(source, 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.
+      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.
+
+    >>> sorted(imported_modules(
+    ...         'import foo ; from baz import bar; import foo.qux'))
+    ['baz.bar', 'foo', 'foo.qux']
+    >>> sorted(imported_modules(
+    ... '''import foo
+    ... def wat():
+    ...     import bar
+    ... ''', ignore_nested=True))
+    ['foo']
+    """
+    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
+        elif isinstance(node, ast.ImportFrom):
+            prefix = node.module + '.'
+            for n in node.names:
+                yield prefix + n.name
+
+def verify_stdlib_on_own_line(source):
+    """Given some python source, verify that stdlib imports are done
+    in separate statements from relative local module imports.
+
+    Observing this limitation is important as it works around an
+    annoying lib2to3 bug in relative import rewrites:
+    http://bugs.python.org/issue19510.
+
+    >>> list(verify_stdlib_on_own_line('import sys, foo'))
+    ['mixed stdlib and relative imports:\\n   foo, sys']
+    >>> list(verify_stdlib_on_own_line('import sys, os'))
+    []
+    >>> list(verify_stdlib_on_own_line('import foo, bar'))
+    []
+    """
+    for node in ast.walk(ast.parse(source)):
+        if isinstance(node, ast.Import):
+            from_stdlib = {}
+            for n in node.names:
+                from_stdlib[n.name] = n.name in stdlib_modules
+            num_std = len([x for x in from_stdlib.values() if x])
+            if num_std not in (len(from_stdlib.values()), 0):
+                yield ('mixed stdlib and relative imports:\n   %s' %
+                       ', '.join(sorted(from_stdlib.iterkeys())))
+
+class CircularImport(Exception):
+    pass
+
+
+def cyclekey(names):
+    return tuple(sorted(set(names)))
+
+def check_one_mod(mod, imports, path=None, ignore=None):
+    if path is None:
+        path = []
+    if ignore is None:
+        ignore = []
+    path = path + [mod]
+    for i in sorted(imports.get(mod, [])):
+        if i not in stdlib_modules:
+            i = mod.rsplit('.', 1)[0] + '.' + i
+        if i in path:
+            firstspot = path.index(i)
+            cycle = path[firstspot:] + [i]
+            if cyclekey(cycle) not in ignore:
+                raise CircularImport(cycle)
+            continue
+        check_one_mod(i, imports, path=path, ignore=ignore)
+
+def rotatecycle(cycle):
+    """arrange a cycle so that the lexicographically first module listed first
+
+    >>> rotatecycle(['foo', 'bar', 'foo'])
+    ['bar', 'foo', 'bar']
+    """
+    lowest = min(cycle)
+    idx = cycle.index(lowest)
+    return cycle[idx:] + cycle[1:idx] + [lowest]
+
+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']}
+    >>> print '\\n'.join(sorted(find_cycles(imports)))
+    top.bar -> top.baz -> top.foo -> top.bar -> top.bar
+    top.foo -> top.qux -> top.foo -> top.foo
+    """
+    cycles = {}
+    for mod in sorted(imports.iterkeys()):
+        try:
+            check_one_mod(mod, imports, ignore=cycles)
+        except CircularImport, e:
+            cycle = e.args[0]
+            cycles[cyclekey(cycle)] = ' -> '.join(rotatecycle(cycle))
+    return cycles.values()
+
+def _cycle_sortkey(c):
+    return len(c), c
+
+def main(argv):
+    if len(argv) < 2:
+        print 'Usage: %s file [file] [file] ...'
+        return 1
+    used_imports = {}
+    any_errors = False
+    for source_path in argv[1:]:
+        f = open(source_path)
+        modname = dotted_name_of_path(source_path)
+        src = f.read()
+        used_imports[modname] = sorted(
+            imported_modules(src, ignore_nested=True))
+        for error in verify_stdlib_on_own_line(src):
+            any_errors = True
+            print source_path, error
+        f.close()
+    cycles = find_cycles(used_imports)
+    if cycles:
+        firstmods = set()
+        for c in sorted(cycles, key=_cycle_sortkey):
+            first = c.split()[0]
+            # As a rough cut, ignore any cycle that starts with the
+            # same module as some other cycle. Otherwise we see lots
+            # of cycles that are effectively duplicates.
+            if first in firstmods:
+                continue
+            print 'Import cycle:', c
+            firstmods.add(first)
+        any_errors = True
+    return not any_errors
+
+if __name__ == '__main__':
+    sys.exit(int(main(sys.argv)))
--- a/contrib/perf.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/contrib/perf.py	Wed Jan 01 18:28:40 2014 -0500
@@ -243,6 +243,18 @@
                                copies=opts.get('rename')))
     ui.popbuffer()
 
+@command('perfmoonwalk')
+def perfmoonwalk(ui, repo):
+    """benchmark walking the changelog backwards
+
+    This also loads the changelog data for each revision in the changelog.
+    """
+    def moonwalk():
+        for i in xrange(len(repo), -1, -1):
+            ctx = repo[i]
+            ctx.branch() # read changelog data (in addition to the index)
+    timer(moonwalk)
+
 @command('perftemplating')
 def perftemplating(ui, repo):
     ui.pushbuffer()
@@ -349,7 +361,7 @@
     def getfiltered(name):
         def d():
             repo.invalidatevolatilesets()
-            repoview.filteredrevs(repo, name)
+            repoview.filterrevs(repo, name)
         return d
 
     allfilter = sorted(repoview.filtertable)
@@ -386,7 +398,7 @@
     allfilters = []
     while possiblefilters:
         for name in possiblefilters:
-            subset = repoview.subsettable.get(name)
+            subset = branchmap.subsettable.get(name)
             if subset not in possiblefilters:
                 break
         else:
--- a/doc/gendoc.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/doc/gendoc.py	Wed Jan 01 18:28:40 2014 -0500
@@ -40,11 +40,16 @@
             shortopt, longopt, default, desc, optlabel = opt
         else:
             shortopt, longopt, default, desc = opt
+            optlabel = _("VALUE")
         allopts = []
         if shortopt:
             allopts.append("-%s" % shortopt)
         if longopt:
             allopts.append("--%s" % longopt)
+        if isinstance(default, list):
+            allopts[-1] += " <%s[+]>" % optlabel
+        elif (default is not None) and not isinstance(default, bool):
+            allopts[-1] += " <%s>" % optlabel
         desc += default and _(" (default: %s)") % default or ""
         yield (", ".join(allopts), desc)
 
@@ -71,8 +76,14 @@
 def showdoc(ui):
     # print options
     ui.write(minirst.section(_("Options")))
+    multioccur = False
     for optstr, desc in get_opts(globalopts):
         ui.write("%s\n    %s\n\n" % (optstr, desc))
+        if optstr.endswith("[+]>"):
+            multioccur = True
+    if multioccur:
+        ui.write(_("\n[+] marked option can be specified multiple times\n"))
+        ui.write("\n")
 
     # print cmds
     ui.write(minirst.section(_("Commands")))
@@ -157,12 +168,18 @@
         if opt_output:
             opts_len = max([len(line[0]) for line in opt_output])
             ui.write(_("Options:\n\n"))
+            multioccur = False
             for optstr, desc in opt_output:
                 if desc:
                     s = "%-*s  %s" % (opts_len, optstr, desc)
                 else:
                     s = optstr
                 ui.write("%s\n" % s)
+                if optstr.endswith("[+]>"):
+                    multioccur = True
+            if multioccur:
+                ui.write(_("\n[+] marked option can be specified"
+                           " multiple times\n"))
             ui.write("\n")
         # aliases
         if d['aliases']:
--- a/hgext/convert/filemap.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/hgext/convert/filemap.py	Wed Jan 01 18:28:40 2014 -0500
@@ -10,12 +10,20 @@
 from mercurial import util, error
 from common import SKIPREV, converter_source
 
-def rpairs(name):
-    e = len(name)
-    while e != -1:
-        yield name[:e], name[e + 1:]
-        e = name.rfind('/', 0, e)
-    yield '.', name
+def rpairs(path):
+    '''Yield tuples with path split at '/', starting with the full path.
+    No leading, trailing or double '/', please.
+    >>> for x in rpairs('foo/bar/baz'): print x
+    ('foo/bar/baz', '')
+    ('foo/bar', 'baz')
+    ('foo', 'bar/baz')
+    ('.', 'foo/bar/baz')
+    '''
+    i = len(path)
+    while i != -1:
+        yield path[:i], path[i + 1:]
+        i = path.rfind('/', 0, i)
+    yield '.', path
 
 def normalize(path):
     ''' We use posixpath.normpath to support cross-platform path format.
--- a/hgext/graphlog.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/hgext/graphlog.py	Wed Jan 01 18:28:40 2014 -0500
@@ -5,7 +5,10 @@
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
-'''command to view revision graphs from a shell
+'''command to view revision graphs from a shell (DEPRECATED)
+
+The functionality of this extension has been include in core Mercurial
+since version 2.3.
 
 This extension adds a --graph option to the incoming, outgoing and log
 commands. When this options is given, an ASCII representation of the
--- a/hgext/keyword.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/hgext/keyword.py	Wed Jan 01 18:28:40 2014 -0500
@@ -84,7 +84,7 @@
 
 from mercurial import commands, context, cmdutil, dispatch, filelog, extensions
 from mercurial import localrepo, match, patch, templatefilters, templater, util
-from mercurial import scmutil
+from mercurial import scmutil, pathutil
 from mercurial.hgweb import webcommands
 from mercurial.i18n import _
 import os, re, shutil, tempfile
@@ -439,7 +439,11 @@
     repo[None].add([fn])
     ui.note(_('\nkeywords written to %s:\n') % fn)
     ui.note(keywords)
-    repo.dirstate.setbranch('demobranch')
+    wlock = repo.wlock()
+    try:
+        repo.dirstate.setbranch('demobranch')
+    finally:
+        wlock.release()
     for name, cmd in ui.configitems('hooks'):
         if name.split('.', 1)[0].find('commit') > -1:
             repo.ui.setconfig('hooks', name, '')
@@ -673,7 +677,7 @@
                 expansion. '''
                 source = repo.dirstate.copied(dest)
                 if 'l' in wctx.flags(source):
-                    source = scmutil.canonpath(repo.root, cwd,
+                    source = pathutil.canonpath(repo.root, cwd,
                                                os.path.realpath(source))
                 return kwt.match(source)
 
--- a/hgext/largefiles/overrides.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/hgext/largefiles/overrides.py	Wed Jan 01 18:28:40 2014 -0500
@@ -12,7 +12,7 @@
 import copy
 
 from mercurial import hg, commands, util, cmdutil, scmutil, match as match_, \
-    node, archival, error, merge, discovery
+    node, archival, error, merge, discovery, pathutil
 from mercurial.i18n import _
 from mercurial.node import hex
 from hgext import rebase
@@ -469,7 +469,7 @@
         return orig(ui, repo, pats, opts, rename)
 
     def makestandin(relpath):
-        path = scmutil.canonpath(repo.root, repo.getcwd(), relpath)
+        path = pathutil.canonpath(repo.root, repo.getcwd(), relpath)
         return os.path.join(repo.wjoin(lfutil.standin(path)))
 
     fullpats = scmutil.expandpats(pats)
--- a/hgext/largefiles/reposetup.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/hgext/largefiles/reposetup.py	Wed Jan 01 18:28:40 2014 -0500
@@ -445,8 +445,8 @@
                              for f in files
                              if lfutil.isstandin(f) and f in ctx]))
                 lfcommands.uploadlfiles(ui, self, remote, toupload)
-            return super(lfilesrepo, self).push(remote, force, revs,
-                newbranch)
+            return super(lfilesrepo, self).push(remote, force=force, revs=revs,
+                newbranch=newbranch)
 
         def _subdirlfs(self, files, lfiles):
             '''
--- a/hgext/mq.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/hgext/mq.py	Wed Jan 01 18:28:40 2014 -0500
@@ -1204,7 +1204,9 @@
         diffopts = self.diffopts()
         wlock = repo.wlock()
         try:
-            heads = [h for hs in repo.branchmap().itervalues() for h in hs]
+            heads = []
+            for hs in repo.branchmap().itervalues():
+                heads.extend(hs)
             if not heads:
                 heads = [nullid]
             if repo.dirstate.p1() not in heads and not exact:
@@ -2565,8 +2567,10 @@
         ph = patchheader(q.join(parent), q.plainmode)
         message, user = ph.message, ph.user
         for msg in messages:
-            message.append('* * *')
-            message.extend(msg)
+            if msg:
+                if message:
+                    message.append('* * *')
+                message.extend(msg)
         message = '\n'.join(message)
 
     if opts.get('edit'):
--- a/hgext/record.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/hgext/record.py	Wed Jan 01 18:28:40 2014 -0500
@@ -502,7 +502,8 @@
                          cmdsuggest)
 
     # make sure username is set before going interactive
-    ui.username()
+    if not opts.get('user'):
+        ui.username() # raise exception, username not provided
 
     def recordfunc(ui, repo, message, match, opts):
         """This is generic record driver.
--- a/hgext/relink.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/hgext/relink.py	Wed Jan 01 18:28:40 2014 -0500
@@ -48,6 +48,10 @@
         ui.status(_('there is nothing to relink\n'))
         return
 
+    if not util.samedevice(src.store.path, repo.store.path):
+        # No point in continuing
+        raise util.Abort(_('source and destination are on different devices'))
+
     locallock = repo.lock()
     try:
         remotelock = src.lock()
--- a/hgext/strip.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/hgext/strip.py	Wed Jan 01 18:28:40 2014 -0500
@@ -182,37 +182,32 @@
 
         revs = sorted(rootnodes)
         if update and opts.get('keep'):
-            wlock = repo.wlock()
-            try:
-                urev, p2 = repo.changelog.parents(revs[0])
-                if (util.safehasattr(repo, 'mq') and p2 != nullid
-                    and p2 in [x.node for x in repo.mq.applied]):
-                    urev = p2
-                uctx = repo[urev]
+            urev, p2 = repo.changelog.parents(revs[0])
+            if (util.safehasattr(repo, 'mq') and p2 != nullid
+                and p2 in [x.node for x in repo.mq.applied]):
+                urev = p2
+            uctx = repo[urev]
 
-                # only reset the dirstate for files that would actually change
-                # between the working context and uctx
-                descendantrevs = repo.revs("%s::." % uctx.rev())
-                changedfiles = []
-                for rev in descendantrevs:
-                    # blindly reset the files, regardless of what actually
-                    # changed
-                    changedfiles.extend(repo[rev].files())
+            # only reset the dirstate for files that would actually change
+            # between the working context and uctx
+            descendantrevs = repo.revs("%s::." % uctx.rev())
+            changedfiles = []
+            for rev in descendantrevs:
+                # blindly reset the files, regardless of what actually changed
+                changedfiles.extend(repo[rev].files())
 
-                # reset files that only changed in the dirstate too
-                dirstate = repo.dirstate
-                dirchanges = [f for f in dirstate if dirstate[f] != 'n']
-                changedfiles.extend(dirchanges)
+            # reset files that only changed in the dirstate too
+            dirstate = repo.dirstate
+            dirchanges = [f for f in dirstate if dirstate[f] != 'n']
+            changedfiles.extend(dirchanges)
 
-                repo.dirstate.rebuild(urev, uctx.manifest(), changedfiles)
-                repo.dirstate.write()
-                update = False
-            finally:
-                wlock.release()
+            repo.dirstate.rebuild(urev, uctx.manifest(), changedfiles)
+            repo.dirstate.write()
+            update = False
 
         if opts.get('bookmark'):
             if mark == repo._bookmarkcurrent:
-                bookmarks.setcurrent(repo, None)
+                bookmarks.unsetcurrent(repo)
             del marks[mark]
             marks.write()
             ui.write(_("bookmark '%s' deleted\n") % mark)
--- a/hgext/transplant.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/hgext/transplant.py	Wed Jan 01 18:28:40 2014 -0500
@@ -154,7 +154,7 @@
                     # transplants before them fail.
                     domerge = True
                     if not hasnode(repo, node):
-                        repo.pull(source, heads=[node])
+                        repo.pull(source.peer(), heads=[node])
 
                 skipmerge = False
                 if parents[1] != revlog.nullid:
--- a/mercurial/ancestor.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/ancestor.py	Wed Jan 01 18:28:40 2014 -0500
@@ -5,7 +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 heapq, util
+import heapq
+import util
 from node import nullrev
 
 def ancestors(pfunc, *orignodes):
--- a/mercurial/bookmarks.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/bookmarks.py	Wed Jan 01 18:28:40 2014 -0500
@@ -6,7 +6,7 @@
 # GNU General Public License version 2 or any later version.
 
 from mercurial.i18n import _
-from mercurial.node import hex
+from mercurial.node import hex, bin
 from mercurial import encoding, error, util, obsolete
 import errno
 
@@ -58,7 +58,7 @@
         '''
         repo = self._repo
         if repo._bookmarkcurrent not in self:
-            setcurrent(repo, None)
+            unsetcurrent(repo)
 
         wlock = repo.wlock()
         try:
@@ -106,13 +106,13 @@
     Set the name of the bookmark that we are on (hg update <bookmark>).
     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:
         return
 
-    if mark not in repo._bookmarks:
-        mark = ''
-
     wlock = repo.wlock()
     try:
         file = repo.opener('bookmarks.current', 'w', atomictemp=True)
@@ -239,49 +239,176 @@
     finally:
         w.release()
 
+def compare(repo, srcmarks, dstmarks,
+            srchex=None, dsthex=None, targets=None):
+    '''Compare bookmarks between srcmarks and dstmarks
+
+    This returns tuple "(addsrc, adddst, advsrc, advdst, diverge,
+    differ, invalid)", each are list of bookmarks below:
+
+    :addsrc:  added on src side (removed on dst side, perhaps)
+    :adddst:  added on dst side (removed on src side, perhaps)
+    :advsrc:  advanced on src side
+    :advdst:  advanced on dst side
+    :diverge: diverge
+    :differ:  changed, but changeset referred on src is unknown on dst
+    :invalid: unknown on both side
+
+    Each elements of lists in result tuple is tuple "(bookmark name,
+    changeset ID on source side, changeset ID on destination
+    side)". Each changeset IDs are 40 hexadecimal digit string or
+    None.
+
+    Changeset IDs of tuples in "addsrc", "adddst", "differ" or
+     "invalid" list may be unknown for repo.
+
+    This function expects that "srcmarks" and "dstmarks" return
+    changeset ID in 40 hexadecimal digit string for specified
+    bookmark. If not so (e.g. bmstore "repo._bookmarks" returning
+    binary value), "srchex" or "dsthex" should be specified to convert
+    into such form.
+
+    If "targets" is specified, only bookmarks listed in it are
+    examined.
+    '''
+    if not srchex:
+        srchex = lambda x: x
+    if not dsthex:
+        dsthex = lambda x: x
+
+    if targets:
+        bset = set(targets)
+    else:
+        srcmarkset = set(srcmarks)
+        dstmarkset = set(dstmarks)
+        bset = srcmarkset ^ dstmarkset
+        for b in srcmarkset & dstmarkset:
+            if srchex(srcmarks[b]) != dsthex(dstmarks[b]):
+                bset.add(b)
+
+    results = ([], [], [], [], [], [], [])
+    addsrc = results[0].append
+    adddst = results[1].append
+    advsrc = results[2].append
+    advdst = results[3].append
+    diverge = results[4].append
+    differ = results[5].append
+    invalid = results[6].append
+
+    for b in sorted(bset):
+        if b not in srcmarks:
+            if b in dstmarks:
+                adddst((b, None, dsthex(dstmarks[b])))
+            else:
+                invalid((b, None, None))
+        elif b not in dstmarks:
+            addsrc((b, srchex(srcmarks[b]), None))
+        else:
+            scid = srchex(srcmarks[b])
+            dcid = dsthex(dstmarks[b])
+            if scid in repo and dcid in repo:
+                sctx = repo[scid]
+                dctx = repo[dcid]
+                if sctx.rev() < dctx.rev():
+                    if validdest(repo, sctx, dctx):
+                        advdst((b, scid, dcid))
+                    else:
+                        diverge((b, scid, dcid))
+                else:
+                    if validdest(repo, dctx, sctx):
+                        advsrc((b, scid, dcid))
+                    else:
+                        diverge((b, scid, dcid))
+            else:
+                # it is too expensive to examine in detail, in this case
+                differ((b, scid, dcid))
+
+    return results
+
+def _diverge(ui, b, path, localmarks):
+    if b == '@':
+        b = ''
+    # find a unique @ suffix
+    for x in range(1, 100):
+        n = '%s@%d' % (b, x)
+        if n not in localmarks:
+            break
+    # try to use an @pathalias suffix
+    # if an @pathalias already exists, we overwrite (update) it
+    for p, u in ui.configitems("paths"):
+        if path == u:
+            n = '%s@%s' % (b, p)
+    return n
+
 def updatefromremote(ui, repo, remotemarks, path):
     ui.debug("checking for updated bookmarks\n")
-    changed = False
     localmarks = repo._bookmarks
-    for k in sorted(remotemarks):
-        if k in localmarks:
-            nr, nl = remotemarks[k], localmarks[k]
-            if nr in repo:
-                cr = repo[nr]
-                cl = repo[nl]
-                if cl.rev() >= cr.rev():
-                    continue
-                if validdest(repo, cl, cr):
-                    localmarks[k] = cr.node()
-                    changed = True
-                    ui.status(_("updating bookmark %s\n") % k)
-                else:
-                    if k == '@':
-                        kd = ''
-                    else:
-                        kd = k
-                    # find a unique @ suffix
-                    for x in range(1, 100):
-                        n = '%s@%d' % (kd, x)
-                        if n not in localmarks:
-                            break
-                    # try to use an @pathalias suffix
-                    # if an @pathalias already exists, we overwrite (update) it
-                    for p, u in ui.configitems("paths"):
-                        if path == u:
-                            n = '%s@%s' % (kd, p)
+    (addsrc, adddst, advsrc, advdst, diverge, differ, invalid
+     ) = compare(repo, remotemarks, localmarks, dsthex=hex)
+
+    changed = []
+    for b, scid, dcid in addsrc:
+        if scid in repo: # add remote bookmarks for changes we already have
+            changed.append((b, bin(scid), ui.status,
+                            _("adding remote bookmark %s\n") % (b)))
+    for b, scid, dcid in advsrc:
+        changed.append((b, bin(scid), ui.status,
+                        _("updating bookmark %s\n") % (b)))
+    for b, scid, dcid in diverge:
+        db = _diverge(ui, b, path, localmarks)
+        changed.append((db, bin(scid), ui.warn,
+                        _("divergent bookmark %s stored as %s\n") % (b, db)))
+    if changed:
+        for b, node, writer, msg in sorted(changed):
+            localmarks[b] = node
+            writer(msg)
+        localmarks.write()
+
+def updateremote(ui, repo, remote, revs):
+    ui.debug("checking for updated bookmarks\n")
+    revnums = map(repo.changelog.rev, revs or [])
+    ancestors = [a for a in repo.changelog.ancestors(revnums, inclusive=True)]
+    (addsrc, adddst, advsrc, advdst, diverge, differ, invalid
+     ) = compare(repo, repo._bookmarks, remote.listkeys('bookmarks'),
+                 srchex=hex)
 
-                    localmarks[n] = cr.node()
-                    changed = True
-                    ui.warn(_("divergent bookmark %s stored as %s\n") % (k, n))
-        elif remotemarks[k] in repo:
-            # add remote bookmarks for changes we already have
-            localmarks[k] = repo[remotemarks[k]].node()
-            changed = True
-            ui.status(_("adding remote bookmark %s\n") % k)
+    for b, scid, dcid in advsrc:
+        if ancestors and repo[scid].rev() not in ancestors:
+            continue
+        if remote.pushkey('bookmarks', b, dcid, scid):
+            ui.status(_("updating bookmark %s\n") % b)
+        else:
+            ui.warn(_('updating bookmark %s failed!\n') % b)
+
+def pushtoremote(ui, repo, remote, targets):
+    (addsrc, adddst, advsrc, advdst, diverge, differ, invalid
+     ) = compare(repo, repo._bookmarks, remote.listkeys('bookmarks'),
+                 srchex=hex, targets=targets)
+    if invalid:
+        b, scid, dcid = invalid[0]
+        ui.warn(_('bookmark %s does not exist on the local '
+                  'or remote repository!\n') % b)
+        return 2
 
-    if changed:
-        localmarks.write()
+    def push(b, old, new):
+        r = remote.pushkey('bookmarks', b, old, new)
+        if not r:
+            ui.warn(_('updating bookmark %s failed!\n') % b)
+            return 1
+        return 0
+    failed = 0
+    for b, scid, dcid in sorted(addsrc + advsrc + advdst + diverge + differ):
+        ui.status(_("exporting bookmark %s\n") % b)
+        if dcid is None:
+            dcid = ''
+        failed += push(b, dcid, scid)
+    for b, scid, dcid in adddst:
+        # treat as "deleted locally"
+        ui.status(_("deleting remote bookmark %s\n") % b)
+        failed += push(b, dcid, '')
+
+    if failed:
+        return 1
 
 def diff(ui, dst, src):
     ui.status(_("searching for changed bookmarks\n"))
--- a/mercurial/branchmap.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/branchmap.py	Wed Jan 01 18:28:40 2014 -0500
@@ -7,11 +7,11 @@
 
 from node import bin, hex, nullid, nullrev
 import encoding
-import util, repoview
+import util
 
 def _filename(repo):
     """name of a branchcache file for a given repo or repoview"""
-    filename = "cache/branchheads"
+    filename = "cache/branch2"
     if repo.filtername:
         filename = '%s-%s' % (filename, repo.filtername)
     return filename
@@ -39,11 +39,16 @@
         for l in lines:
             if not l:
                 continue
-            node, label = l.split(" ", 1)
+            node, state, label = l.split(" ", 2)
+            if state not in 'oc':
+                raise ValueError('invalid branch state')
             label = encoding.tolocal(label.strip())
             if not node in repo:
                 raise ValueError('node %s does not exist' % node)
-            partial.setdefault(label, []).append(bin(node))
+            node = bin(node)
+            partial.setdefault(label, []).append(node)
+            if state == 'c':
+                partial._closednodes.add(node)
     except KeyboardInterrupt:
         raise
     except Exception, inst:
@@ -58,6 +63,17 @@
 
 
 
+### Nearest subset relation
+# Nearest subset of filter X is a filter Y so that:
+# * Y is included in X,
+# * X - Y is as small as possible.
+# This create and ordering used for branchmap purpose.
+# the ordering may be partial
+subsettable = {None: 'visible',
+               'visible': 'served',
+               'served': 'immutable',
+               'immutable': 'base'}
+
 def updatecache(repo):
     cl = repo.changelog
     filtername = repo.filtername
@@ -67,7 +83,7 @@
     if partial is None or not partial.validfor(repo):
         partial = read(repo)
         if partial is None:
-            subsetname = repoview.subsettable.get(filtername)
+            subsetname = subsettable.get(filtername)
             if subsetname is None:
                 partial = branchcache()
             else:
@@ -83,14 +99,40 @@
     repo._branchcaches[repo.filtername] = partial
 
 class branchcache(dict):
-    """A dict like object that hold branches heads cache"""
+    """A dict like object that hold branches heads cache.
+
+    This cache is used to avoid costly computations to determine all the
+    branch heads of a repo.
+
+    The cache is serialized on disk in the following format:
+
+    <tip hex node> <tip rev number> [optional filtered repo hex hash]
+    <branch head hex node> <open/closed state> <branch name>
+    <branch head hex node> <open/closed state> <branch name>
+    ...
+
+    The first line is used to check if the cache is still valid. If the
+    branch cache is for a filtered repo view, an optional third hash is
+    included that hashes the hashes of all filtered revisions.
+
+    The open/closed state is represented by a single letter 'o' or 'c'.
+    This field can be used to avoid changelog reads when determining if a
+    branch head closes a branch or not.
+    """
 
     def __init__(self, entries=(), tipnode=nullid, tiprev=nullrev,
-                 filteredhash=None):
+                 filteredhash=None, closednodes=None):
         super(branchcache, self).__init__(entries)
         self.tipnode = tipnode
         self.tiprev = tiprev
         self.filteredhash = filteredhash
+        # closednodes is a set of nodes that close their branch. If the branch
+        # cache has been updated, it may contain nodes that are no longer
+        # heads.
+        if closednodes is None:
+            self._closednodes = set()
+        else:
+            self._closednodes = closednodes
 
     def _hashfiltered(self, repo):
         """build hash of revision filtered in the current cache
@@ -124,9 +166,33 @@
         except IndexError:
             return False
 
+    def _branchtip(self, heads):
+        tip = heads[-1]
+        closed = True
+        for h in reversed(heads):
+            if h not in self._closednodes:
+                tip = h
+                closed = False
+                break
+        return tip, closed
+
+    def branchtip(self, branch):
+        return self._branchtip(self[branch])[0]
+
+    def branchheads(self, branch, closed=False):
+        heads = self[branch]
+        if not closed:
+            heads = [h for h in heads if h not in self._closednodes]
+        return heads
+
+    def iterbranches(self):
+        for bn, heads in self.iteritems():
+            yield (bn, heads) + self._branchtip(heads)
+
     def copy(self):
         """return an deep copy of the branchcache object"""
-        return branchcache(self, self.tipnode, self.tiprev, self.filteredhash)
+        return branchcache(self, self.tipnode, self.tiprev, self.filteredhash,
+                           self._closednodes)
 
     def write(self, repo):
         try:
@@ -137,7 +203,12 @@
             f.write(" ".join(cachekey) + '\n')
             for label, nodes in sorted(self.iteritems()):
                 for node in nodes:
-                    f.write("%s %s\n" % (hex(node), encoding.fromlocal(label)))
+                    if node in self._closednodes:
+                        state = 'c'
+                    else:
+                        state = 'o'
+                    f.write("%s %s %s\n" % (hex(node), state,
+                                            encoding.fromlocal(label)))
             f.close()
         except (IOError, OSError, util.Abort):
             # Abort may be raise by read only opener
@@ -151,9 +222,13 @@
         cl = repo.changelog
         # collect new branch entries
         newbranches = {}
-        getbranch = cl.branch
+        getbranchinfo = cl.branchinfo
         for r in revgen:
-            newbranches.setdefault(getbranch(r), []).append(cl.node(r))
+            branch, closesbranch = getbranchinfo(r)
+            node = cl.node(r)
+            newbranches.setdefault(branch, []).append(node)
+            if closesbranch:
+                self._closednodes.add(node)
         # if older branchheads are reachable from new ones, they aren't
         # really branchheads. Note checking parents is insufficient:
         # 1 (branch a) -> 2 (branch b) -> 3 (branch a)
--- a/mercurial/changelog.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/changelog.py	Wed Jan 01 18:28:40 2014 -0500
@@ -342,9 +342,10 @@
         text = "\n".join(l)
         return self.addrevision(text, transaction, len(self), p1, p2)
 
-    def branch(self, rev):
-        """return the branch of a revision
+    def branchinfo(self, rev):
+        """return the branch name and open/close state of a revision
 
         This function exists because creating a changectx object
         just to access this is costly."""
-        return encoding.tolocal(self.read(rev)[5].get("branch"))
+        extra = self.read(rev)[5]
+        return encoding.tolocal(extra.get("branch")), 'close' in extra
--- a/mercurial/cmdutil.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/cmdutil.py	Wed Jan 01 18:28:40 2014 -0500
@@ -10,7 +10,7 @@
 import os, sys, errno, re, tempfile
 import util, scmutil, templater, patch, error, templatekw, revlog, copies
 import match as matchmod
-import subrepo, context, repair, graphmod, revset, phases, obsolete
+import subrepo, context, repair, graphmod, revset, phases, obsolete, pathutil
 import changelog
 import bookmarks
 import lock as lockmod
@@ -274,7 +274,7 @@
     # relsrc: ossep
     # otarget: ossep
     def copyfile(abssrc, relsrc, otarget, exact):
-        abstarget = scmutil.canonpath(repo.root, cwd, otarget)
+        abstarget = pathutil.canonpath(repo.root, cwd, otarget)
         if '/' in abstarget:
             # We cannot normalize abstarget itself, this would prevent
             # case only renames, like a => A.
@@ -367,7 +367,7 @@
     # return: function that takes hgsep and returns ossep
     def targetpathfn(pat, dest, srcs):
         if os.path.isdir(pat):
-            abspfx = scmutil.canonpath(repo.root, cwd, pat)
+            abspfx = pathutil.canonpath(repo.root, cwd, pat)
             abspfx = util.localpath(abspfx)
             if destdirexists:
                 striplen = len(os.path.split(abspfx)[0])
@@ -393,7 +393,7 @@
             res = lambda p: os.path.join(dest,
                                          os.path.basename(util.localpath(p)))
         else:
-            abspfx = scmutil.canonpath(repo.root, cwd, pat)
+            abspfx = pathutil.canonpath(repo.root, cwd, pat)
             if len(abspfx) < len(srcs[0][0]):
                 # A directory. Either the target path contains the last
                 # component of the source path or it does not.
@@ -2063,7 +2063,7 @@
                 fc = ctx[f]
                 repo.wwrite(f, fc.data(), fc.flags())
 
-            audit_path = scmutil.pathauditor(repo.root)
+            audit_path = pathutil.pathauditor(repo.root)
             for f in remove[0]:
                 if repo.dirstate[f] == 'a':
                     repo.dirstate.drop(f)
--- a/mercurial/commands.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/commands.py	Wed Jan 01 18:28:40 2014 -0500
@@ -17,7 +17,8 @@
 import merge as mergemod
 import minirst, revset, fileset
 import dagparser, context, simplemerge, graphmod
-import random, setdiscovery, treediscovery, dagutil, pvec, localrepo
+import random
+import setdiscovery, treediscovery, dagutil, pvec, localrepo
 import phases, obsolete
 
 table = {}
@@ -700,7 +701,7 @@
                 ui.status(_('changeset %d:%s: %s\n') % (ctx, ctx, transition))
                 check_state(state, interactive=False)
                 # bisect
-                nodes, changesets, good = hbisect.bisect(repo.changelog, state)
+                nodes, changesets, bgood = hbisect.bisect(repo.changelog, state)
                 # update to next check
                 node = nodes[0]
                 if not noupdate:
@@ -709,7 +710,7 @@
         finally:
             state['current'] = [node]
             hbisect.save_state(repo, state)
-        print_result(nodes, good)
+        print_result(nodes, bgood)
         return
 
     # update state
@@ -866,7 +867,7 @@
             if mark not in marks:
                 raise util.Abort(_("bookmark '%s' does not exist") % mark)
             if mark == repo._bookmarkcurrent:
-                bookmarks.setcurrent(repo, None)
+                bookmarks.unsetcurrent(repo)
             del marks[mark]
         marks.write()
 
@@ -892,7 +893,7 @@
             if newact is None:
                 newact = mark
             if inactive and mark == repo._bookmarkcurrent:
-                bookmarks.setcurrent(repo, None)
+                bookmarks.unsetcurrent(repo)
                 return
             tgt = cur
             if rev:
@@ -902,7 +903,7 @@
         if not inactive and cur == marks[newact] and not rev:
             bookmarks.setcurrent(repo, newact)
         elif cur != tgt and newact == repo._bookmarkcurrent:
-            bookmarks.setcurrent(repo, None)
+            bookmarks.unsetcurrent(repo)
         marks.write()
 
     # Same message whether trying to deactivate the current bookmark (-i
@@ -914,7 +915,7 @@
         if not repo._bookmarkcurrent:
             ui.status(_("no active bookmark\n"))
         else:
-            bookmarks.setcurrent(repo, None)
+            bookmarks.unsetcurrent(repo)
 
     else: # show bookmarks
         for bmark, n in sorted(marks.iteritems()):
@@ -1012,23 +1013,15 @@
 
     hexfunc = ui.debugflag and hex or short
 
-    activebranches = set([repo[n].branch() for n in repo.heads()])
+    allheads = set(repo.heads())
     branches = []
-    for tag, heads in repo.branchmap().iteritems():
-        for h in reversed(heads):
-            ctx = repo[h]
-            isopen = not ctx.closesbranch()
-            if isopen:
-                tip = ctx
-                break
-        else:
-            tip = repo[heads[-1]]
-        isactive = tag in activebranches and isopen
-        branches.append((tip, isactive, isopen))
-    branches.sort(key=lambda i: (i[1], i[0].rev(), i[0].branch(), i[2]),
+    for tag, heads, tip, isclosed in repo.branchmap().iterbranches():
+        isactive = not isclosed and bool(set(heads) & allheads)
+        branches.append((tag, repo[tip], isactive, not isclosed))
+    branches.sort(key=lambda i: (i[2], i[1].rev(), i[0], i[3]),
                   reverse=True)
 
-    for ctx, isactive, isopen in branches:
+    for tag, ctx, isactive, isopen in branches:
         if (not active) or isactive:
             if isactive:
                 label = 'branches.active'
@@ -1041,16 +1034,16 @@
             else:
                 label = 'branches.inactive'
                 notice = _(' (inactive)')
-            if ctx.branch() == repo.dirstate.branch():
+            if tag == repo.dirstate.branch():
                 label = 'branches.current'
-            rev = str(ctx.rev()).rjust(31 - encoding.colwidth(ctx.branch()))
+            rev = str(ctx.rev()).rjust(31 - encoding.colwidth(tag))
             rev = ui.label('%s:%s' % (rev, hexfunc(ctx.node())),
                            'log.changeset changeset.%s' % ctx.phasestr())
-            tag = ui.label(ctx.branch(), label)
+            labeledtag = ui.label(tag, label)
             if ui.quiet:
-                ui.write("%s\n" % tag)
+                ui.write("%s\n" % labeledtag)
             else:
-                ui.write("%s %s%s\n" % (tag, rev, notice))
+                ui.write("%s %s%s\n" % (labeledtag, rev, notice))
 
 @command('bundle',
     [('f', 'force', None, _('run even when the destination is unrelated')),
@@ -2142,11 +2135,8 @@
     labels = set()
     labels.update(t[0] for t in repo.tagslist())
     labels.update(repo._bookmarks.keys())
-    for heads in repo.branchmap().itervalues():
-        for h in heads:
-            ctx = repo[h]
-            if not ctx.closesbranch():
-                labels.add(ctx.branch())
+    labels.update(tag for (tag, heads, tip, closed)
+                  in repo.branchmap().iterbranches() if not closed)
     completions = set()
     if not args:
         args = ['']
@@ -2244,7 +2234,7 @@
                     continue
                 s = f.find(os.sep, speclen)
                 if s >= 0:
-                    adddir(f[:s + 1])
+                    adddir(f[:s])
                 else:
                     addfile(f)
         return files, dirs
@@ -2265,10 +2255,6 @@
         f, d = complete(spec, acceptable or 'nmar')
         files.update(f)
         dirs.update(d)
-    if not files and len(dirs) == 1:
-        # force the shell to consider a completion that matches one
-        # directory and zero files to be ambiguous
-        dirs.add(iter(dirs).next() + '.')
     files.update(dirs)
     ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files)))
     ui.write('\n')
@@ -3762,12 +3748,12 @@
                                         files, eolmode=None)
                     except patch.PatchError, e:
                         raise util.Abort(str(e))
-                    memctx = patch.makememctx(repo, (p1.node(), p2.node()),
-                                              message,
-                                              opts.get('user') or user,
-                                              opts.get('date') or date,
-                                              branch, files, store,
-                                              editor=cmdutil.commiteditor)
+                    memctx = context.makememctx(repo, (p1.node(), p2.node()),
+                                                message,
+                                                opts.get('user') or user,
+                                                opts.get('date') or date,
+                                                branch, files, store,
+                                                editor=cmdutil.commiteditor)
                     repo.savecommitmessage(memctx.description())
                     n = memctx.commit()
                 finally:
@@ -4680,6 +4666,7 @@
     """
 
     if opts.get('bookmark'):
+        ui.setconfig('bookmarks', 'pushing', opts['bookmark'])
         for b in opts['bookmark']:
             # translate -B options to -r so changesets get pushed
             if b in repo._bookmarks:
@@ -4713,25 +4700,11 @@
     result = not result
 
     if opts.get('bookmark'):
-        rb = other.listkeys('bookmarks')
-        for b in opts['bookmark']:
-            # explicit push overrides remote bookmark if any
-            if b in repo._bookmarks:
-                ui.status(_("exporting bookmark %s\n") % b)
-                new = repo[b].hex()
-            elif b in rb:
-                ui.status(_("deleting remote bookmark %s\n") % b)
-                new = '' # delete
-            else:
-                ui.warn(_('bookmark %s does not exist on the local '
-                          'or remote repository!\n') % b)
-                return 2
-            old = rb.get(b, '')
-            r = other.pushkey('bookmarks', b, old, new)
-            if not r:
-                ui.warn(_('updating bookmark %s failed!\n') % b)
-                if not result:
-                    result = 2
+        bresult = bookmarks.pushtoremote(ui, repo, other, opts['bookmark'])
+        if bresult == 2:
+            return 2
+        if not result and bresult:
+            result = 2
 
     return result
 
--- a/mercurial/commandserver.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/commandserver.py	Wed Jan 01 18:28:40 2014 -0500
@@ -184,7 +184,10 @@
         # persist between requests
         copiedui = self.ui.copy()
         self.repo.baseui = copiedui
-        self.repo.ui = self.repo.dirstate._ui = self.repoui.copy()
+        # clone ui without using ui.copy because this is protected
+        repoui = self.repoui.__class__(self.repoui)
+        repoui.copy = copiedui.copy # redo copy protection
+        self.repo.ui = self.repo.dirstate._ui = repoui
         self.repo.invalidate()
         self.repo.invalidatedirstate()
 
--- a/mercurial/context.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/context.py	Wed Jan 01 18:28:40 2014 -0500
@@ -195,6 +195,21 @@
     def dirty(self):
         return False
 
+def makememctx(repo, parents, text, user, date, branch, files, store,
+               editor=None):
+    def getfilectx(repo, memctx, path):
+        data, (islink, isexec), copied = store.getfile(path)
+        return memfilectx(path, data, islink=islink, isexec=isexec,
+                                  copied=copied)
+    extra = {}
+    if branch:
+        extra['branch'] = encoding.fromlocal(branch)
+    ctx =  memctx(repo, parents, text, files, getfilectx, user,
+                          date, extra)
+    if editor:
+        ctx._text = editor(repo, ctx, [])
+    return ctx
+
 class changectx(basectx):
     """A changecontext object makes access to data related to a particular
     changeset convenient. It represents a read-only context already present in
--- a/mercurial/dirstate.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/dirstate.py	Wed Jan 01 18:28:40 2014 -0500
@@ -8,7 +8,7 @@
 
 from node import nullid
 from i18n import _
-import scmutil, util, ignore, osutil, parsers, encoding
+import scmutil, util, ignore, osutil, parsers, encoding, pathutil
 import os, stat, errno, gc
 
 propertycache = util.propertycache
@@ -736,7 +736,7 @@
                 # unknown == True means we walked the full directory tree above.
                 # So if a file is not seen it was either a) not matching matchfn
                 # b) ignored, c) missing, or d) under a symlink directory.
-                audit_path = scmutil.pathauditor(self._root)
+                audit_path = pathutil.pathauditor(self._root)
 
                 for nf in iter(visit):
                     # Report ignored items in the dmap as long as they are not
--- a/mercurial/discovery.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/discovery.py	Wed Jan 01 18:28:40 2014 -0500
@@ -219,7 +219,8 @@
     unsynced = inc and set([None]) or set()
     return {None: (oldheads, newheads, unsynced)}
 
-def checkheads(repo, remote, outgoing, remoteheads, newbranch=False, inc=False):
+def checkheads(repo, remote, outgoing, remoteheads, newbranch=False, inc=False,
+               newbookmarks=[]):
     """Check that a push won't add any outgoing head
 
     raise Abort error and display ui message as needed.
@@ -259,6 +260,9 @@
             lctx, rctx = repo[bm], repo[rnode]
             if bookmarks.validdest(repo, rctx, lctx):
                 bookmarkedheads.add(lctx.node())
+        else:
+            if bm in newbookmarks:
+                bookmarkedheads.add(repo[bm].node())
 
     # 3. Check for new heads.
     # If there are more heads after the push than before, a suitable
@@ -313,8 +317,8 @@
             if 1 < len(newhs):
                 dhs = list(newhs)
                 if error is None:
-                    error = (_("push creates multiple headed new branch '%s'")
-                             % (branch))
+                    error = (_("push creates new branch '%s' "
+                               "with multiple heads") % (branch))
                     hint = _("merge or"
                              " see \"hg help push\" for details about"
                              " pushing new heads")
@@ -337,10 +341,12 @@
                     hint = _("merge or"
                              " see \"hg help push\" for details about"
                              " pushing new heads")
-            if branch is not None:
-                repo.ui.note(_("new remote heads on branch '%s'\n") % branch)
+            if branch is None:
+                repo.ui.note(_("new remote heads:\n"))
+            else:
+                repo.ui.note(_("new remote heads on branch '%s':\n") % branch)
             for h in dhs:
-                repo.ui.note(_("new remote head %s\n") % short(h))
+                repo.ui.note((" %s\n") % short(h))
     if error:
         raise util.Abort(error, hint=hint)
 
--- a/mercurial/dispatch.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/dispatch.py	Wed Jan 01 18:28:40 2014 -0500
@@ -106,8 +106,9 @@
                 for cfg in cfgs:
                     req.repo.ui.setconfig(*cfg)
 
+            # if we are in HGPLAIN mode, then disable custom debugging
             debugger = ui.config("ui", "debugger")
-            if not debugger:
+            if not debugger or ui.plain():
                 debugger = 'pdb'
 
             try:
--- a/mercurial/fancyopts.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/fancyopts.py	Wed Jan 01 18:28:40 2014 -0500
@@ -5,7 +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 getopt, util
+import getopt
+import util
 from i18n import _
 
 def gnugetopt(args, options, longoptions):
--- a/mercurial/fileset.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/fileset.py	Wed Jan 01 18:28:40 2014 -0500
@@ -5,7 +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 parser, error, util, merge, re
+import re
+import parser, error, util, merge
 from i18n import _
 
 elements = {
--- a/mercurial/hbisect.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/hbisect.py	Wed Jan 01 18:28:40 2014 -0500
@@ -8,7 +8,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 os, error
+import os
+import error
 from i18n import _
 from node import short, hex
 import util
--- a/mercurial/help.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/help.py	Wed Jan 01 18:28:40 2014 -0500
@@ -6,7 +6,8 @@
 # GNU General Public License version 2 or any later version.
 
 from i18n import gettext, _
-import itertools, sys, os, error
+import itertools, sys, os
+import error
 import extensions, revset, fileset, templatekw, templatefilters, filemerge
 import encoding, util, minirst
 import cmdutil
--- a/mercurial/help/config.txt	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/help/config.txt	Wed Jan 01 18:28:40 2014 -0500
@@ -945,6 +945,15 @@
     Phase of newly-created commits.
     Default: draft
 
+``checksubrepos``
+
+    Check phase of state in each subrepositories, allowed values are
+    "ignore", "follow" or "abort". For settings other than "ignore",
+    the phase of each subrepository commit is checked before committing
+    in the parent repository. If there is any greater phase than the parent
+    ("secret" vs "draft", for example), the commit is either aborted
+    with "abort" or the higher phase is used with "follow". Default: "follow".
+
 ``profiling``
 -------------
 
--- a/mercurial/help/templates.txt	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/help/templates.txt	Wed Jan 01 18:28:40 2014 -0500
@@ -102,3 +102,7 @@
 - Invert the firstline filter, i.e. everything but the first line::
 
    $ hg log -r 0 --template "{sub(r'^.*\n?\n?', '', desc)}\n"
+
+- Display the contents of the 'extra' field, one per line::
+
+   $ hg log -r 0 --template "{join(extras, '\n')}\n"
--- a/mercurial/hg.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/hg.py	Wed Jan 01 18:28:40 2014 -0500
@@ -202,19 +202,20 @@
         hardlink = None
         num = 0
         srcpublishing = srcrepo.ui.configbool('phases', 'publish', True)
+        srcvfs = scmutil.vfs(srcrepo.sharedpath)
+        dstvfs = scmutil.vfs(destpath)
         for f in srcrepo.store.copylist():
             if srcpublishing and f.endswith('phaseroots'):
                 continue
-            src = os.path.join(srcrepo.sharedpath, f)
-            dst = os.path.join(destpath, f)
-            dstbase = os.path.dirname(dst)
-            if dstbase and not os.path.exists(dstbase):
-                os.mkdir(dstbase)
-            if os.path.exists(src):
-                if dst.endswith('data'):
+            dstbase = os.path.dirname(f)
+            if dstbase and not dstvfs.exists(dstbase):
+                dstvfs.mkdir(dstbase)
+            if srcvfs.exists(f):
+                if f.endswith('data'):
                     # lock to avoid premature writing to the target
-                    destlock = lock.lock(os.path.join(dstbase, "lock"))
-                hardlink, n = util.copyfiles(src, dst, hardlink)
+                    destlock = lock.lock(dstvfs, dstbase + "/lock")
+                hardlink, n = util.copyfiles(srcvfs.join(f), dstvfs.join(f),
+                                             hardlink)
                 num += n
         if hardlink:
             ui.debug("linked %d files\n" % num)
@@ -337,8 +338,8 @@
             # Recomputing branch cache might be slow on big repos,
             # so just copy it
             dstcachedir = os.path.join(destpath, 'cache')
-            srcbranchcache = srcrepo.sjoin('cache/branchheads')
-            dstbranchcache = os.path.join(dstcachedir, 'branchheads')
+            srcbranchcache = srcrepo.sjoin('cache/branch2')
+            dstbranchcache = os.path.join(dstcachedir, 'branch2')
             if os.path.exists(srcbranchcache):
                 if not os.path.exists(dstcachedir):
                     os.mkdir(dstcachedir)
@@ -511,11 +512,7 @@
             return subreporecurse()
 
         displayer = cmdutil.show_changeset(ui, other, opts, buffered)
-
-        # XXX once graphlog extension makes it into core,
-        # should be replaced by a if graph/else
         displaychlist(other, chlist, displayer)
-
         displayer.close()
     finally:
         cleanupfn()
--- a/mercurial/hgweb/hgweb_mod.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/hgweb/hgweb_mod.py	Wed Jan 01 18:28:40 2014 -0500
@@ -6,7 +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 os
+import os, re
 from mercurial import ui, hg, hook, error, encoding, templater, util, repoview
 from mercurial.templatefilters import websub
 from mercurial.i18n import _
@@ -14,7 +14,7 @@
 from common import HTTP_OK, HTTP_NOT_MODIFIED, HTTP_BAD_REQUEST
 from common import HTTP_NOT_FOUND, HTTP_SERVER_ERROR
 from request import wsgirequest
-import webcommands, protocol, webutil, re
+import webcommands, protocol, webutil
 
 perms = {
     'changegroup': 'pull',
--- a/mercurial/hgweb/webcommands.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/hgweb/webcommands.py	Wed Jan 01 18:28:40 2014 -0500
@@ -537,18 +537,18 @@
     tips = []
     heads = web.repo.heads()
     parity = paritygen(web.stripecount)
-    sortkey = lambda ctx: (not ctx.closesbranch(), ctx.rev())
+    sortkey = lambda item: (not item[1], item[0].rev())
 
     def entries(limit, **map):
         count = 0
         if not tips:
-            for t, n in web.repo.branchtags().iteritems():
-                tips.append(web.repo[n])
-        for ctx in sorted(tips, key=sortkey, reverse=True):
+            for tag, hs, tip, closed in web.repo.branchmap().iterbranches():
+                tips.append((web.repo[tip], closed))
+        for ctx, closed in sorted(tips, key=sortkey, reverse=True):
             if limit > 0 and count >= limit:
                 return
             count += 1
-            if not web.repo.branchheads(ctx.branch()):
+            if closed:
                 status = 'closed'
             elif ctx.node() not in heads:
                 status = 'inactive'
@@ -596,8 +596,9 @@
     def branches(**map):
         parity = paritygen(web.stripecount)
 
-        b = web.repo.branchtags()
-        l = [(-web.repo.changelog.rev(n), n, t) for t, n in b.iteritems()]
+        b = web.repo.branchmap()
+        l = [(-web.repo.changelog.rev(tip), tip, tag)
+             for tag, heads, tip, closed in b.iterbranches()]
         for r, n, t in sorted(l):
             yield {'parity': parity.next(),
                    'branch': t,
@@ -845,15 +846,11 @@
     end = min(count, start + revcount) # last rev on this page
     parity = paritygen(web.stripecount, offset=start - end)
 
-    def entries(latestonly, **map):
+    def entries():
         l = []
 
         repo = web.repo
-        revs = repo.changelog.revs(start, end - 1)
-        if latestonly:
-            for r in revs:
-                pass
-            revs = (r,)
+        revs = fctx.filelog().revs(start, end - 1)
         for i in revs:
             iterfctx = fctx.filectx(i)
 
@@ -877,11 +874,14 @@
         for e in reversed(l):
             yield e
 
+    entries = list(entries())
+    latestentry = entries[:1]
+
     revnav = webutil.filerevnav(web.repo, fctx.path())
     nav = revnav.gen(end - 1, revcount, count)
     return tmpl("filelog", file=f, node=fctx.hex(), nav=nav,
-                entries=lambda **x: entries(latestonly=False, **x),
-                latestentry=lambda **x: entries(latestonly=True, **x),
+                entries=entries,
+                latestentry=latestentry,
                 revcount=revcount, morevars=morevars, lessvars=lessvars)
 
 def archive(web, req, tmpl):
--- a/mercurial/hgweb/webutil.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/hgweb/webutil.py	Wed Jan 01 18:28:40 2014 -0500
@@ -7,7 +7,7 @@
 # GNU General Public License version 2 or any later version.
 
 import os, copy
-from mercurial import match, patch, scmutil, error, ui, util
+from mercurial import match, patch, error, ui, util, pathutil
 from mercurial.i18n import _
 from mercurial.node import hex, nullid
 from common import ErrorResponse
@@ -196,7 +196,7 @@
 
 def cleanpath(repo, path):
     path = path.lstrip('/')
-    return scmutil.canonpath(repo.root, '', path)
+    return pathutil.canonpath(repo.root, '', path)
 
 def changeidctx (repo, changeid):
     try:
--- a/mercurial/localrepo.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/localrepo.py	Wed Jan 01 18:28:40 2014 -0500
@@ -8,14 +8,15 @@
 from i18n import _
 import peer, changegroup, subrepo, discovery, pushkey, obsolete, repoview
 import changelog, dirstate, filelog, manifest, context, bookmarks, phases
-import lock, transaction, store, encoding
+import lock as lockmod
+import transaction, store, encoding
 import scmutil, util, extensions, hook, error, revset
 import match as matchmod
 import merge as mergemod
 import tags as tagsmod
 from lock import release
 import weakref, errno, os, time, inspect
-import branchmap
+import branchmap, pathutil
 propertycache = util.propertycache
 filecache = scmutil.filecache
 
@@ -166,11 +167,12 @@
         self.root = self.wvfs.base
         self.path = self.wvfs.join(".hg")
         self.origroot = path
-        self.auditor = scmutil.pathauditor(self.root, self._checknested)
+        self.auditor = pathutil.pathauditor(self.root, self._checknested)
         self.vfs = scmutil.vfs(self.path)
         self.opener = self.vfs
         self.baseui = baseui
         self.ui = baseui.copy()
+        self.ui.copy = baseui.copy # prevent copying repo configuration
         # A list of callback to shape the phase if no data were found.
         # Callback are in the form: func(repo, roots) --> processed root.
         # This list it to be filled by extension during repo setup
@@ -279,6 +281,9 @@
         self.requirements = requirements
         self.sopener.options = dict((r, 1) for r in requirements
                                            if r in self.openerreqs)
+        chunkcachesize = self.ui.configint('format', 'chunkcachesize')
+        if chunkcachesize is not None:
+            self.sopener.options['chunkcachesize'] = chunkcachesize
 
     def _writerequirements(self):
         reqfile = self.opener("requires", "w")
@@ -654,29 +659,12 @@
         branchmap.updatecache(self)
         return self._branchcaches[self.filtername]
 
-
-    def _branchtip(self, heads):
-        '''return the tipmost branch head in heads'''
-        tip = heads[-1]
-        for h in reversed(heads):
-            if not self[h].closesbranch():
-                tip = h
-                break
-        return tip
-
     def branchtip(self, branch):
         '''return the tip node for a given branch'''
-        if branch not in self.branchmap():
+        try:
+            return self.branchmap().branchtip(branch)
+        except KeyError:
             raise error.RepoLookupError(_("unknown branch '%s'") % branch)
-        return self._branchtip(self.branchmap()[branch])
-
-    def branchtags(self):
-        '''return a dict where branch names map to the tipmost head of
-        the branch, open heads come before closed'''
-        bt = {}
-        for bn, heads in self.branchmap().iteritems():
-            bt[bn] = self._branchtip(heads)
-        return bt
 
     def lookup(self, key):
         return self[key].node()
@@ -832,7 +820,7 @@
         renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()]
         rp = report and report or self.ui.warn
         tr = transaction.transaction(rp, self.sopener,
-                                     self.sjoin("journal"),
+                                     "journal",
                                      aftertrans(renames),
                                      self.store.createmode)
         self._transref = weakref.ref(tr)
@@ -866,7 +854,7 @@
         try:
             if self.svfs.exists("journal"):
                 self.ui.status(_("rolling back interrupted transaction\n"))
-                transaction.rollback(self.sopener, self.sjoin("journal"),
+                transaction.rollback(self.sopener, "journal",
                                      self.ui.warn)
                 self.invalidate()
                 return True
@@ -922,7 +910,7 @@
 
         parents = self.dirstate.parents()
         self.destroying()
-        transaction.rollback(self.sopener, self.sjoin('undo'), ui.warn)
+        transaction.rollback(self.sopener, 'undo', ui.warn)
         if self.vfs.exists('undo.bookmarks'):
             self.vfs.rename('undo.bookmarks', 'bookmarks')
         if self.svfs.exists('undo.phaseroots'):
@@ -998,17 +986,18 @@
                 pass
         self.invalidatecaches()
 
-    def _lock(self, lockname, wait, releasefn, acquirefn, desc):
+    def _lock(self, vfs, lockname, wait, releasefn, acquirefn, desc):
         try:
-            l = lock.lock(lockname, 0, releasefn, desc=desc)
+            l = lockmod.lock(vfs, lockname, 0, releasefn, desc=desc)
         except error.LockHeld, inst:
             if not wait:
                 raise
             self.ui.warn(_("waiting for lock on %s held by %r\n") %
                          (desc, inst.locker))
             # default to 600 seconds timeout
-            l = lock.lock(lockname, int(self.ui.config("ui", "timeout", "600")),
-                          releasefn, desc=desc)
+            l = lockmod.lock(vfs, lockname,
+                             int(self.ui.config("ui", "timeout", "600")),
+                             releasefn, desc=desc)
         if acquirefn:
             acquirefn()
         return l
@@ -1041,7 +1030,7 @@
                     continue
                 ce.refresh()
 
-        l = self._lock(self.sjoin("lock"), wait, unlock,
+        l = self._lock(self.svfs, "lock", wait, unlock,
                        self.invalidate, _('repository %s') % self.origroot)
         self._lockref = weakref.ref(l)
         return l
@@ -1059,7 +1048,7 @@
             self.dirstate.write()
             self._filecache['dirstate'].refresh()
 
-        l = self._lock(self.join("wlock"), wait, unlock,
+        l = self._lock(self.vfs, "wlock", wait, unlock,
                        self.invalidatedirstate, _('working directory of %s') %
                        self.origroot)
         self._wlockref = weakref.ref(l)
@@ -1379,7 +1368,7 @@
                       parent2=xp2, pending=p)
             self.changelog.finalize(trp)
             # set the new commit is proper phase
-            targetphase = phases.newcommitphase(self.ui)
+            targetphase = subrepo.newcommitphase(self.ui, ctx)
             if targetphase:
                 # retract boundary do not alter parent changeset.
                 # if a parent have higher the resulting phase will
@@ -1621,13 +1610,11 @@
         if branch not in branches:
             return []
         # the cache returns heads ordered lowest to highest
-        bheads = list(reversed(branches[branch]))
+        bheads = list(reversed(branches.branchheads(branch, closed=closed)))
         if start is not None:
             # filter out the heads that cannot be reached from startrev
             fbheads = set(self.changelog.nodesbetween([start], bheads)[2])
             bheads = [h for h in bheads if h in fbheads]
-        if not closed:
-            bheads = [h for h in bheads if not self[h].closesbranch()]
         return bheads
 
     def branches(self, nodes):
@@ -1861,9 +1848,10 @@
                                     raise util.Abort(_(mst)
                                                      % (ctx.troubles()[0],
                                                         ctx))
+                        newbm = self.ui.configlist('bookmarks', 'pushing')
                         discovery.checkheads(unfi, remote, outgoing,
                                              remoteheads, newbranch,
-                                             bool(inc))
+                                             bool(inc), newbm)
 
                     # TODO: get bundlecaps from remote
                     bundlecaps = None
@@ -1976,27 +1964,7 @@
             if locallock is not None:
                 locallock.release()
 
-        self.ui.debug("checking for updated bookmarks\n")
-        rb = remote.listkeys('bookmarks')
-        revnums = map(unfi.changelog.rev, revs or [])
-        ancestors = [
-            a for a in unfi.changelog.ancestors(revnums, inclusive=True)]
-        for k in rb.keys():
-            if k in unfi._bookmarks:
-                nr, nl = rb[k], hex(self._bookmarks[k])
-                if nr in unfi:
-                    cr = unfi[nr]
-                    cl = unfi[nl]
-                    if bookmarks.validdest(unfi, cr, cl):
-                        if ancestors and cl.rev() not in ancestors:
-                            continue
-                        r = remote.pushkey('bookmarks', k, nr, nl)
-                        if r:
-                            self.ui.status(_("updating bookmark %s\n") % k)
-                        else:
-                            self.ui.warn(_('updating bookmark %s'
-                                           ' failed!\n') % k)
-
+        bookmarks.updateremote(self.ui, unfi, remote, revs)
         return ret
 
     def changegroupinfo(self, nodes, source):
--- a/mercurial/lock.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/lock.py	Wed Jan 01 18:28:40 2014 -0500
@@ -29,7 +29,8 @@
 
     _host = None
 
-    def __init__(self, file, timeout=-1, releasefn=None, desc=None):
+    def __init__(self, vfs, file, timeout=-1, releasefn=None, desc=None):
+        self.vfs = vfs
         self.f = file
         self.held = 0
         self.timeout = timeout
@@ -75,13 +76,14 @@
         lockname = '%s:%s' % (lock._host, self.pid)
         while not self.held:
             try:
-                util.makelock(lockname, self.f)
+                self.vfs.makelock(lockname, self.f)
                 self.held = 1
             except (OSError, IOError), why:
                 if why.errno == errno.EEXIST:
                     locker = self.testlock()
                     if locker is not None:
-                        raise error.LockHeld(errno.EAGAIN, self.f, self.desc,
+                        raise error.LockHeld(errno.EAGAIN,
+                                             self.vfs.join(self.f), self.desc,
                                              locker)
                 else:
                     raise error.LockUnavailable(why.errno, why.strerror,
@@ -99,7 +101,7 @@
 
         """
         try:
-            locker = util.readlock(self.f)
+            locker = self.vfs.readlock(self.f)
         except (OSError, IOError), why:
             if why.errno == errno.ENOENT:
                 return None
@@ -119,8 +121,8 @@
         # if locker dead, break lock.  must do this with another lock
         # held, or can race and break valid lock.
         try:
-            l = lock(self.f + '.break', timeout=0)
-            util.unlink(self.f)
+            l = lock(self.vfs, self.f + '.break', timeout=0)
+            self.vfs.unlink(self.f)
             l.release()
         except error.LockError:
             return locker
@@ -140,7 +142,7 @@
             if self.releasefn:
                 self.releasefn()
             try:
-                util.unlink(self.f)
+                self.vfs.unlink(self.f)
             except OSError:
                 pass
             for callback in self.postrelease:
--- a/mercurial/manifest.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/manifest.py	Wed Jan 01 18:28:40 2014 -0500
@@ -30,8 +30,9 @@
 
 class manifest(revlog.revlog):
     def __init__(self, opener):
-        # we expect to deal with not more than three revs at a time in merge
-        self._mancache = util.lrucachedict(3)
+        # we expect to deal with not more than four revs at a time,
+        # during a commit --amend
+        self._mancache = util.lrucachedict(4)
         revlog.revlog.__init__(self, opener, "00manifest.i")
 
     def parse(self, lines):
--- a/mercurial/match.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/match.py	Wed Jan 01 18:28:40 2014 -0500
@@ -6,7 +6,7 @@
 # GNU General Public License version 2 or any later version.
 
 import re
-import scmutil, util, fileset
+import util, fileset, pathutil
 from i18n import _
 
 def _rematcher(pat):
@@ -317,7 +317,7 @@
     pats = []
     for kind, name in [_patsplit(p, default) for p in names]:
         if kind in ('glob', 'relpath'):
-            name = scmutil.canonpath(root, cwd, name, auditor)
+            name = pathutil.canonpath(root, cwd, name, auditor)
         elif kind in ('relglob', 'path'):
             name = util.normpath(name)
         elif kind in ('listfile', 'listfile0'):
--- a/mercurial/mdiff.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/mdiff.py	Wed Jan 01 18:28:40 2014 -0500
@@ -6,8 +6,8 @@
 # GNU General Public License version 2 or any later version.
 
 from i18n import _
-import bdiff, mpatch, util
-import re, struct, base85, zlib
+import bdiff, mpatch, util, base85
+import re, struct, zlib
 
 def splitnewlines(text):
     '''like str.splitlines, but only split on newlines.'''
--- a/mercurial/obsolete.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/obsolete.py	Wed Jan 01 18:28:40 2014 -0500
@@ -84,6 +84,7 @@
 """
 import struct
 import util, base85, node
+import phases
 from i18n import _
 
 _pack = struct.pack
@@ -196,6 +197,14 @@
         self._data = data
         self._decodedmeta = None
 
+    def __hash__(self):
+        return hash(self._data)
+
+    def __eq__(self, other):
+        if type(other) != type(self):
+            return False
+        return self._data == other._data
+
     def precnode(self):
         """Precursor changeset node identifier"""
         return self._data[0]
@@ -268,7 +277,11 @@
         if not _enabled:
             raise util.Abort('obsolete feature is not enabled on this repo')
         known = set(self._all)
-        new = [m for m in markers if m not in known]
+        new = []
+        for m in markers:
+            if m not in known:
+                known.add(m)
+                new.append(m)
         if new:
             f = self.sopener('obsstore', 'ab')
             try:
@@ -428,14 +441,15 @@
 
     Some successors may be unknown locally.
 
-    This is a linear yield unsuited to detecting split changesets."""
+    This is a linear yield unsuited to detecting split changesets. It includes
+    initial nodes too."""
     remaining = set(nodes)
     seen = set(remaining)
     while remaining:
         current = remaining.pop()
         yield current
         for mark in obsstore.successors.get(current, ()):
-            # ignore marker flagged with with specified flag
+            # ignore marker flagged with specified flag
             if mark[2] & ignoreflags:
                 continue
             for suc in mark[1]:
@@ -443,6 +457,28 @@
                     seen.add(suc)
                     remaining.add(suc)
 
+def allprecursors(obsstore, nodes, ignoreflags=0):
+    """Yield node for every precursors of <nodes>.
+
+    Some precursors may be unknown locally.
+
+    This is a linear yield unsuited to detecting folded changesets. It includes
+    initial nodes too."""
+
+    remaining = set(nodes)
+    seen = set(remaining)
+    while remaining:
+        current = remaining.pop()
+        yield current
+        for mark in obsstore.precursors.get(current, ()):
+            # ignore marker flagged with specified flag
+            if mark[2] & ignoreflags:
+                continue
+            suc = mark[0]
+            if suc not in seen:
+                seen.add(suc)
+                remaining.add(suc)
+
 def foreground(repo, nodes):
     """return all nodes in the "foreground" of other node
 
@@ -751,14 +787,26 @@
 @cachefor('bumped')
 def _computebumpedset(repo):
     """the set of revs trying to obsolete public revisions"""
-    # get all possible bumped changesets
-    tonode = repo.changelog.node
-    publicnodes = (tonode(r) for r in repo.revs('public()'))
-    successors = allsuccessors(repo.obsstore, publicnodes,
-                               ignoreflags=bumpedfix)
-    # revision public or already obsolete don't count as bumped
-    query = '%ld - obsolete() - public()'
-    return set(repo.revs(query, _knownrevs(repo, successors)))
+    bumped = set()
+    # utils function (avoid attribut lookup in the loop)
+    phase = repo._phasecache.phase # would be faster to grab the full list
+    public = phases.public
+    cl = repo.changelog
+    torev = cl.nodemap.get
+    obs = getrevs(repo, 'obsolete')
+    for rev in repo:
+        # 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!
+    return bumped
 
 @cachefor('divergent')
 def _computedivergentset(repo):
--- a/mercurial/parsers.c	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/parsers.c	Wed Jan 01 18:28:40 2014 -0500
@@ -926,8 +926,13 @@
 static int nt_init(indexObject *self)
 {
 	if (self->nt == NULL) {
+		if (self->raw_length > INT_MAX) {
+			PyErr_SetString(PyExc_ValueError, "overflow in nt_init");
+			return -1;
+		}
 		self->ntcapacity = self->raw_length < 4
-			? 4 : self->raw_length / 2;
+			? 4 : (int)self->raw_length / 2;
+
 		self->nt = calloc(self->ntcapacity, sizeof(nodetree));
 		if (self->nt == NULL) {
 			PyErr_NoMemory();
--- a/mercurial/patch.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/patch.py	Wed Jan 01 18:28:40 2014 -0500
@@ -16,7 +16,6 @@
 from i18n import _
 from node import hex, short
 import base85, mdiff, scmutil, util, diffhelpers, copies, encoding, error
-import context
 
 gitre = re.compile('diff --git a/(.*) b/(.*)')
 
@@ -722,8 +721,9 @@
             if self.remove:
                 self.backend.unlink(self.fname)
             else:
-                self.lines[:] = h.new()
-                self.offset += len(h.new())
+                l = h.new(self.lines)
+                self.lines[:] = l
+                self.offset += len(l)
                 self.dirty = True
             return 0
 
@@ -1017,9 +1017,10 @@
         return old, oldstart, new, newstart
 
 class binhunk(object):
-    'A binary patch file. Only understands literals so far.'
+    'A binary patch file.'
     def __init__(self, lr, fname):
         self.text = None
+        self.delta = False
         self.hunk = ['GIT binary patch\n']
         self._fname = fname
         self._read(lr)
@@ -1027,7 +1028,9 @@
     def complete(self):
         return self.text is not None
 
-    def new(self):
+    def new(self, lines):
+        if self.delta:
+            return [applybindelta(self.text, ''.join(lines))]
         return [self.text]
 
     def _read(self, lr):
@@ -1036,14 +1039,19 @@
             hunk.append(l)
             return l.rstrip('\r\n')
 
+        size = 0
         while True:
             line = getline(lr, self.hunk)
             if not line:
                 raise PatchError(_('could not extract "%s" binary data')
                                  % self._fname)
             if line.startswith('literal '):
+                size = int(line[8:].rstrip())
                 break
-        size = int(line[8:].rstrip())
+            if line.startswith('delta '):
+                size = int(line[6:].rstrip())
+                self.delta = True
+                break
         dec = []
         line = getline(lr, self.hunk)
         while len(line) > 1:
@@ -1266,6 +1274,62 @@
         gp = gitpatches.pop()
         yield 'file', ('a/' + gp.path, 'b/' + gp.path, None, gp.copy())
 
+def applybindelta(binchunk, data):
+    """Apply a binary delta hunk
+    The algorithm used is the algorithm from git's patch-delta.c
+    """
+    def deltahead(binchunk):
+        i = 0
+        for c in binchunk:
+            i += 1
+            if not (ord(c) & 0x80):
+                return i
+        return i
+    out = ""
+    s = deltahead(binchunk)
+    binchunk = binchunk[s:]
+    s = deltahead(binchunk)
+    binchunk = binchunk[s:]
+    i = 0
+    while i < len(binchunk):
+        cmd = ord(binchunk[i])
+        i += 1
+        if (cmd & 0x80):
+            offset = 0
+            size = 0
+            if (cmd & 0x01):
+                offset = ord(binchunk[i])
+                i += 1
+            if (cmd & 0x02):
+                offset |= ord(binchunk[i]) << 8
+                i += 1
+            if (cmd & 0x04):
+                offset |= ord(binchunk[i]) << 16
+                i += 1
+            if (cmd & 0x08):
+                offset |= ord(binchunk[i]) << 24
+                i += 1
+            if (cmd & 0x10):
+                size = ord(binchunk[i])
+                i += 1
+            if (cmd & 0x20):
+                size |= ord(binchunk[i]) << 8
+                i += 1
+            if (cmd & 0x40):
+                size |= ord(binchunk[i]) << 16
+                i += 1
+            if size == 0:
+                size = 0x10000
+            offset_end = offset + size
+            out += data[offset:offset_end]
+        elif cmd != 0:
+            offset_end = i + cmd
+            out += binchunk[i:offset_end]
+            i += cmd
+        else:
+            raise PatchError(_('unexpected delta opcode 0'))
+    return out
+
 def applydiff(ui, fp, backend, store, strip=1, eolmode='strict'):
     """Reads a patch from fp and tries to apply it.
 
@@ -1441,21 +1505,6 @@
     backend = repobackend(ui, repo, ctx, store)
     return patchbackend(ui, backend, patchobj, strip, files, eolmode)
 
-def makememctx(repo, parents, text, user, date, branch, files, store,
-               editor=None):
-    def getfilectx(repo, memctx, path):
-        data, (islink, isexec), copied = store.getfile(path)
-        return context.memfilectx(path, data, islink=islink, isexec=isexec,
-                                  copied=copied)
-    extra = {}
-    if branch:
-        extra['branch'] = encoding.fromlocal(branch)
-    ctx =  context.memctx(repo, parents, text, files, getfilectx, user,
-                          date, extra)
-    if editor:
-        ctx._text = editor(repo, ctx, [])
-    return ctx
-
 def patch(ui, repo, patchname, strip=1, files=None, eolmode='strict',
           similarity=0):
     """Apply <patchname> to the working directory.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/pathutil.py	Wed Jan 01 18:28:40 2014 -0500
@@ -0,0 +1,144 @@
+import os, errno, stat
+
+import util
+from i18n import _
+
+class pathauditor(object):
+    '''ensure that a filesystem path contains no banned components.
+    the following properties of a path are checked:
+
+    - ends with a directory separator
+    - under top-level .hg
+    - starts at the root of a windows drive
+    - contains ".."
+    - traverses a symlink (e.g. a/symlink_here/b)
+    - inside a nested repository (a callback can be used to approve
+      some nested repositories, e.g., subrepositories)
+    '''
+
+    def __init__(self, root, callback=None):
+        self.audited = set()
+        self.auditeddir = set()
+        self.root = root
+        self.callback = callback
+        if os.path.lexists(root) and not util.checkcase(root):
+            self.normcase = util.normcase
+        else:
+            self.normcase = lambda x: x
+
+    def __call__(self, path):
+        '''Check the relative path.
+        path may contain a pattern (e.g. foodir/**.txt)'''
+
+        path = util.localpath(path)
+        normpath = self.normcase(path)
+        if normpath in self.audited:
+            return
+        # AIX ignores "/" at end of path, others raise EISDIR.
+        if util.endswithsep(path):
+            raise util.Abort(_("path ends in directory separator: %s") % path)
+        parts = util.splitpath(path)
+        if (os.path.splitdrive(path)[0]
+            or parts[0].lower() in ('.hg', '.hg.', '')
+            or os.pardir in parts):
+            raise util.Abort(_("path contains illegal component: %s") % path)
+        if '.hg' in path.lower():
+            lparts = [p.lower() for p in parts]
+            for p in '.hg', '.hg.':
+                if p in lparts[1:]:
+                    pos = lparts.index(p)
+                    base = os.path.join(*parts[:pos])
+                    raise util.Abort(_("path '%s' is inside nested repo %r")
+                                     % (path, base))
+
+        normparts = util.splitpath(normpath)
+        assert len(parts) == len(normparts)
+
+        parts.pop()
+        normparts.pop()
+        prefixes = []
+        while parts:
+            prefix = os.sep.join(parts)
+            normprefix = os.sep.join(normparts)
+            if normprefix in self.auditeddir:
+                break
+            curpath = os.path.join(self.root, prefix)
+            try:
+                st = os.lstat(curpath)
+            except OSError, err:
+                # EINVAL can be raised as invalid path syntax under win32.
+                # They must be ignored for patterns can be checked too.
+                if err.errno not in (errno.ENOENT, errno.ENOTDIR, errno.EINVAL):
+                    raise
+            else:
+                if stat.S_ISLNK(st.st_mode):
+                    raise util.Abort(
+                        _('path %r traverses symbolic link %r')
+                        % (path, prefix))
+                elif (stat.S_ISDIR(st.st_mode) and
+                      os.path.isdir(os.path.join(curpath, '.hg'))):
+                    if not self.callback or not self.callback(curpath):
+                        raise util.Abort(_("path '%s' is inside nested "
+                                           "repo %r")
+                                         % (path, prefix))
+            prefixes.append(normprefix)
+            parts.pop()
+            normparts.pop()
+
+        self.audited.add(normpath)
+        # only add prefixes to the cache after checking everything: we don't
+        # want to add "foo/bar/baz" before checking if there's a "foo/.hg"
+        self.auditeddir.update(prefixes)
+
+    def check(self, path):
+        try:
+            self(path)
+            return True
+        except (OSError, util.Abort):
+            return False
+
+def canonpath(root, cwd, myname, auditor=None):
+    '''return the canonical path of myname, given cwd and root'''
+    if util.endswithsep(root):
+        rootsep = root
+    else:
+        rootsep = root + os.sep
+    name = myname
+    if not os.path.isabs(name):
+        name = os.path.join(root, cwd, name)
+    name = os.path.normpath(name)
+    if auditor is None:
+        auditor = pathauditor(root)
+    if name != rootsep and name.startswith(rootsep):
+        name = name[len(rootsep):]
+        auditor(name)
+        return util.pconvert(name)
+    elif name == root:
+        return ''
+    else:
+        # Determine whether `name' is in the hierarchy at or beneath `root',
+        # by iterating name=dirname(name) until that causes no change (can't
+        # check name == '/', because that doesn't work on windows). The list
+        # `rel' holds the reversed list of components making up the relative
+        # file name we want.
+        rel = []
+        while True:
+            try:
+                s = util.samefile(name, root)
+            except OSError:
+                s = False
+            if s:
+                if not rel:
+                    # name was actually the same as root (maybe a symlink)
+                    return ''
+                rel.reverse()
+                name = os.path.join(*rel)
+                auditor(name)
+                return util.pconvert(name)
+            dirname, basename = util.split(name)
+            rel.append(basename)
+            if dirname == name:
+                break
+            name = dirname
+
+        raise util.Abort(_("%s not under root '%s'") % (myname, root))
--- a/mercurial/posix.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/posix.py	Wed Jan 01 18:28:40 2014 -0500
@@ -197,7 +197,6 @@
     return path.lower()
 
 if sys.platform == 'darwin':
-    import fcntl # only needed on darwin, missing on jython
 
     def normcase(path):
         '''
@@ -265,51 +264,6 @@
         # Decompose then lowercase (HFS+ technote specifies lower)
         return unicodedata.normalize('NFD', u).lower().encode('utf-8')
 
-    def realpath(path):
-        '''
-        Returns the true, canonical file system path equivalent to the given
-        path.
-
-        Equivalent means, in this case, resulting in the same, unique
-        file system link to the path. Every file system entry, whether a file,
-        directory, hard link or symbolic link or special, will have a single
-        path preferred by the system, but may allow multiple, differing path
-        lookups to point to it.
-
-        Most regular UNIX file systems only allow a file system entry to be
-        looked up by its distinct path. Obviously, this does not apply to case
-        insensitive file systems, whether case preserving or not. The most
-        complex issue to deal with is file systems transparently reencoding the
-        path, such as the non-standard Unicode normalisation required for HFS+
-        and HFSX.
-        '''
-        # Constants copied from /usr/include/sys/fcntl.h
-        F_GETPATH = 50
-        O_SYMLINK = 0x200000
-
-        try:
-            fd = os.open(path, O_SYMLINK)
-        except OSError, err:
-            if err.errno == errno.ENOENT:
-                return path
-            raise
-
-        try:
-            return fcntl.fcntl(fd, F_GETPATH, '\0' * 1024).rstrip('\0')
-        finally:
-            os.close(fd)
-elif sys.version_info < (2, 4, 2, 'final'):
-    # Workaround for http://bugs.python.org/issue1213894 (os.path.realpath
-    # didn't resolve symlinks that were the first component of the path.)
-    def realpath(path):
-        if os.path.isabs(path):
-            return os.path.realpath(path)
-        else:
-            return os.path.realpath('./' + path)
-else:
-    # Fallback to the likely inadequate Python builtin function.
-    realpath = os.path.realpath
-
 if sys.platform == 'cygwin':
     # workaround for cygwin, in which mount point part of path is
     # treated as case sensitive, even though underlying NTFS is case
--- a/mercurial/repair.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/repair.py	Wed Jan 01 18:28:40 2014 -0500
@@ -38,16 +38,8 @@
     """return the changesets which will be broken by the truncation"""
     s = set()
     def collectone(revlog):
-        linkgen = (revlog.linkrev(i) for i in revlog)
-        # find the truncation point of the revlog
-        for lrev in linkgen:
-            if lrev >= striprev:
-                break
-        # see if any revision after this point has a linkrev
-        # less than striprev (those will be broken by strip)
-        for lrev in linkgen:
-            if lrev < striprev:
-                s.add(lrev)
+        _, brokenset = revlog.getstrippoint(striprev)
+        s.update([revlog.linkrev(r) for r in brokenset])
 
     collectone(repo.manifest)
     for fname in files:
--- a/mercurial/repoview.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/repoview.py	Wed Jan 01 18:28:40 2014 -0500
@@ -94,20 +94,15 @@
     return frozenset(xrange(firstmutable, len(cl)))
 
 # function to compute filtered set
+#
+# When addding a new filter you MUST update the table at:
+#     mercurial.branchmap.subsettable
+# Otherwise your filter will have to recompute all its branches cache
+# from scratch (very slow).
 filtertable = {'visible': computehidden,
                'served': computeunserved,
                'immutable':  computemutable,
                'base':  computeimpactable}
-### Nearest subset relation
-# Nearest subset of filter X is a filter Y so that:
-# * Y is included in X,
-# * X - Y is as small as possible.
-# This create and ordering used for branchmap purpose.
-# the ordering may be partial
-subsettable = {None: 'visible',
-               'visible': 'served',
-               'served': 'immutable',
-               'immutable': 'base'}
 
 def filterrevs(repo, filtername):
     """returns set of filtered revision for this filter name"""
@@ -215,4 +210,3 @@
     @property
     def requirements(self):
         return self._unfilteredrepo.requirements
-
--- a/mercurial/revlog.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/revlog.py	Wed Jan 01 18:28:40 2014 -0500
@@ -202,6 +202,7 @@
         self._cache = None
         self._basecache = None
         self._chunkcache = (0, '')
+        self._chunkcachesize = 65536
         self.index = []
         self._pcache = {}
         self._nodecache = {nullid: nullrev}
@@ -215,6 +216,15 @@
                     v |= REVLOGGENERALDELTA
             else:
                 v = 0
+            if 'chunkcachesize' in opts:
+                self._chunkcachesize = opts['chunkcachesize']
+
+        if self._chunkcachesize <= 0:
+            raise RevlogError(_('revlog chunk cache size %r is not greater '
+                                'than 0') % self._chunkcachesize)
+        elif self._chunkcachesize & (self._chunkcachesize - 1):
+            raise RevlogError(_('revlog chunk cache size %r is not a power '
+                                'of 2') % self._chunkcachesize)
 
         i = ''
         self._initempty = True
@@ -401,7 +411,29 @@
         heads = [self.rev(n) for n in heads]
 
         # we want the ancestors, but inclusive
-        has = set(self.ancestors(common))
+        class lazyset(object):
+            def __init__(self, lazyvalues):
+                self.addedvalues = set()
+                self.lazyvalues = lazyvalues
+
+            def __contains__(self, value):
+                return value in self.addedvalues or value in self.lazyvalues
+
+            def __iter__(self):
+                added = self.addedvalues
+                for r in added:
+                    yield r
+                for r in self.lazyvalues:
+                    if not r in added:
+                        yield r
+
+            def add(self, value):
+                self.addedvalues.add(value)
+
+            def update(self, values):
+                self.addedvalues.update(values)
+
+        has = lazyset(self.ancestors(common))
         has.add(nullrev)
         has.update(common)
 
@@ -820,13 +852,19 @@
         else:
             df = self.opener(self.datafile)
 
-        readahead = max(65536, length)
-        df.seek(offset)
-        d = df.read(readahead)
+        # Cache data both forward and backward around the requested
+        # data, in a fixed size window. This helps speed up operations
+        # involving reading the revlog backwards.
+        cachesize = self._chunkcachesize
+        realoffset = offset & ~(cachesize - 1)
+        reallength = (((offset + length + cachesize) & ~(cachesize - 1))
+                      - realoffset)
+        df.seek(realoffset)
+        d = df.read(reallength)
         df.close()
-        self._addchunk(offset, d)
-        if readahead > length:
-            return util.buffer(d, 0, length)
+        self._addchunk(realoffset, d)
+        if offset != realoffset or reallength != length:
+            return util.buffer(d, offset - realoffset, length)
         return d
 
     def _getchunk(self, offset, length):
@@ -1263,6 +1301,46 @@
 
         return content
 
+    def getstrippoint(self, minlink):
+        """find the minimum rev that must be stripped to strip the linkrev
+
+        Returns a tuple containing the minimum rev and a set of all revs that
+        have linkrevs that will be broken by this strip.
+        """
+        brokenrevs = set()
+        strippoint = len(self)
+
+        heads = {}
+        futurelargelinkrevs = set()
+        for head in self.headrevs():
+            headlinkrev = self.linkrev(head)
+            heads[head] = headlinkrev
+            if headlinkrev >= minlink:
+                futurelargelinkrevs.add(headlinkrev)
+
+        # This algorithm involves walking down the rev graph, starting at the
+        # heads. Since the revs are topologically sorted according to linkrev,
+        # once all head linkrevs are below the minlink, we know there are
+        # no more revs that could have a linkrev greater than minlink.
+        # So we can stop walking.
+        while futurelargelinkrevs:
+            strippoint -= 1
+            linkrev = heads.pop(strippoint)
+
+            if linkrev < minlink:
+                brokenrevs.add(strippoint)
+            else:
+                futurelargelinkrevs.remove(linkrev)
+
+            for p in self.parentrevs(strippoint):
+                if p != nullrev:
+                    plinkrev = self.linkrev(p)
+                    heads[p] = plinkrev
+                    if plinkrev >= minlink:
+                        futurelargelinkrevs.add(plinkrev)
+
+        return strippoint, brokenrevs
+
     def strip(self, minlink, transaction):
         """truncate the revlog on the first revision with a linkrev >= minlink
 
@@ -1280,10 +1358,8 @@
         if len(self) == 0:
             return
 
-        for rev in self:
-            if self.index[rev][4] >= minlink:
-                break
-        else:
+        rev, _ = self.getstrippoint(minlink)
+        if rev == len(self):
             return
 
         # first truncate the files on disk
--- a/mercurial/scmutil.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/scmutil.py	Wed Jan 01 18:28:40 2014 -0500
@@ -8,8 +8,9 @@
 from i18n import _
 from mercurial.node import nullrev
 import util, error, osutil, revset, similar, encoding, phases, parsers
+import pathutil
 import match as matchmod
-import os, errno, re, stat, glob
+import os, errno, re, glob
 
 if os.name == 'nt':
     import scmwindows as scmplatform
@@ -97,9 +98,10 @@
         self._newfiles = set()
 
     def __call__(self, f):
+        if f in self._newfiles:
+            return
         fl = encoding.lower(f)
-        if (fl in self._loweredfiles and f not in self._dirstate and
-            f not in self._newfiles):
+        if fl in self._loweredfiles and f not in self._dirstate:
             msg = _('possible case-folding collision for %s') % f
             if self._abort:
                 raise util.Abort(msg)
@@ -107,100 +109,6 @@
         self._loweredfiles.add(fl)
         self._newfiles.add(f)
 
-class pathauditor(object):
-    '''ensure that a filesystem path contains no banned components.
-    the following properties of a path are checked:
-
-    - ends with a directory separator
-    - under top-level .hg
-    - starts at the root of a windows drive
-    - contains ".."
-    - traverses a symlink (e.g. a/symlink_here/b)
-    - inside a nested repository (a callback can be used to approve
-      some nested repositories, e.g., subrepositories)
-    '''
-
-    def __init__(self, root, callback=None):
-        self.audited = set()
-        self.auditeddir = set()
-        self.root = root
-        self.callback = callback
-        if os.path.lexists(root) and not util.checkcase(root):
-            self.normcase = util.normcase
-        else:
-            self.normcase = lambda x: x
-
-    def __call__(self, path):
-        '''Check the relative path.
-        path may contain a pattern (e.g. foodir/**.txt)'''
-
-        path = util.localpath(path)
-        normpath = self.normcase(path)
-        if normpath in self.audited:
-            return
-        # AIX ignores "/" at end of path, others raise EISDIR.
-        if util.endswithsep(path):
-            raise util.Abort(_("path ends in directory separator: %s") % path)
-        parts = util.splitpath(path)
-        if (os.path.splitdrive(path)[0]
-            or parts[0].lower() in ('.hg', '.hg.', '')
-            or os.pardir in parts):
-            raise util.Abort(_("path contains illegal component: %s") % path)
-        if '.hg' in path.lower():
-            lparts = [p.lower() for p in parts]
-            for p in '.hg', '.hg.':
-                if p in lparts[1:]:
-                    pos = lparts.index(p)
-                    base = os.path.join(*parts[:pos])
-                    raise util.Abort(_("path '%s' is inside nested repo %r")
-                                     % (path, base))
-
-        normparts = util.splitpath(normpath)
-        assert len(parts) == len(normparts)
-
-        parts.pop()
-        normparts.pop()
-        prefixes = []
-        while parts:
-            prefix = os.sep.join(parts)
-            normprefix = os.sep.join(normparts)
-            if normprefix in self.auditeddir:
-                break
-            curpath = os.path.join(self.root, prefix)
-            try:
-                st = os.lstat(curpath)
-            except OSError, err:
-                # EINVAL can be raised as invalid path syntax under win32.
-                # They must be ignored for patterns can be checked too.
-                if err.errno not in (errno.ENOENT, errno.ENOTDIR, errno.EINVAL):
-                    raise
-            else:
-                if stat.S_ISLNK(st.st_mode):
-                    raise util.Abort(
-                        _('path %r traverses symbolic link %r')
-                        % (path, prefix))
-                elif (stat.S_ISDIR(st.st_mode) and
-                      os.path.isdir(os.path.join(curpath, '.hg'))):
-                    if not self.callback or not self.callback(curpath):
-                        raise util.Abort(_("path '%s' is inside nested "
-                                           "repo %r")
-                                         % (path, prefix))
-            prefixes.append(normprefix)
-            parts.pop()
-            normparts.pop()
-
-        self.audited.add(normpath)
-        # only add prefixes to the cache after checking everything: we don't
-        # want to add "foo/bar/baz" before checking if there's a "foo/.hg"
-        self.auditeddir.update(prefixes)
-
-    def check(self, path):
-        try:
-            self(path)
-            return True
-        except (OSError, util.Abort):
-            return False
-
 class abstractvfs(object):
     """Abstract base class; cannot be instantiated"""
 
@@ -242,6 +150,9 @@
         finally:
             fp.close()
 
+    def chmod(self, path, mode):
+        return os.chmod(self.join(path), mode)
+
     def exists(self, path=None):
         return os.path.exists(self.join(path))
 
@@ -251,6 +162,9 @@
     def isdir(self, path=None):
         return os.path.isdir(self.join(path))
 
+    def isfile(self, path=None):
+        return os.path.isfile(self.join(path))
+
     def islink(self, path=None):
         return os.path.islink(self.join(path))
 
@@ -263,12 +177,18 @@
     def makedirs(self, path=None, mode=None):
         return util.makedirs(self.join(path), mode)
 
+    def makelock(self, info, path):
+        return util.makelock(info, self.join(path))
+
     def mkdir(self, path=None):
         return os.mkdir(self.join(path))
 
     def readdir(self, path=None, stat=None, skip=None):
         return osutil.listdir(self.join(path), stat, skip)
 
+    def readlock(self, path):
+        return util.readlock(self.join(path))
+
     def rename(self, src, dst):
         return util.rename(self.join(src), self.join(dst))
 
@@ -309,7 +229,7 @@
     def _setmustaudit(self, onoff):
         self._audit = onoff
         if onoff:
-            self.audit = pathauditor(self.base)
+            self.audit = pathutil.pathauditor(self.base)
         else:
             self.audit = util.always
 
@@ -444,52 +364,6 @@
         return self.vfs(path, mode, *args, **kw)
 
 
-def canonpath(root, cwd, myname, auditor=None):
-    '''return the canonical path of myname, given cwd and root'''
-    if util.endswithsep(root):
-        rootsep = root
-    else:
-        rootsep = root + os.sep
-    name = myname
-    if not os.path.isabs(name):
-        name = os.path.join(root, cwd, name)
-    name = os.path.normpath(name)
-    if auditor is None:
-        auditor = pathauditor(root)
-    if name != rootsep and name.startswith(rootsep):
-        name = name[len(rootsep):]
-        auditor(name)
-        return util.pconvert(name)
-    elif name == root:
-        return ''
-    else:
-        # Determine whether `name' is in the hierarchy at or beneath `root',
-        # by iterating name=dirname(name) until that causes no change (can't
-        # check name == '/', because that doesn't work on windows). The list
-        # `rel' holds the reversed list of components making up the relative
-        # file name we want.
-        rel = []
-        while True:
-            try:
-                s = util.samefile(name, root)
-            except OSError:
-                s = False
-            if s:
-                if not rel:
-                    # name was actually the same as root (maybe a symlink)
-                    return ''
-                rel.reverse()
-                name = os.path.join(*rel)
-                auditor(name)
-                return util.pconvert(name)
-            dirname, basename = util.split(name)
-            rel.append(basename)
-            if dirname == name:
-                break
-            name = dirname
-
-        raise util.Abort(_("%s not under root '%s'") % (myname, root))
-
 def walkrepos(path, followsym=False, seen_dirs=None, recurse=False):
     '''yield every hg repository under path, always recursively.
     The recurse flag will only control recursion into repo working dirs'''
@@ -767,7 +641,7 @@
     This is different from dirstate.status because it doesn't care about
     whether files are modified or clean.'''
     added, unknown, deleted, removed = [], [], [], []
-    audit_path = pathauditor(repo.root)
+    audit_path = pathutil.pathauditor(repo.root)
 
     ctx = repo[None]
     dirstate = repo.dirstate
@@ -851,14 +725,14 @@
               "Mercurial)") % "', '".join(missings))
     return requirements
 
-class filecacheentry(object):
-    def __init__(self, path, stat=True):
+class filecachesubentry(object):
+    def __init__(self, path, stat):
         self.path = path
         self.cachestat = None
         self._cacheable = None
 
         if stat:
-            self.cachestat = filecacheentry.stat(self.path)
+            self.cachestat = filecachesubentry.stat(self.path)
 
             if self.cachestat:
                 self._cacheable = self.cachestat.cacheable()
@@ -868,7 +742,7 @@
 
     def refresh(self):
         if self.cacheable():
-            self.cachestat = filecacheentry.stat(self.path)
+            self.cachestat = filecachesubentry.stat(self.path)
 
     def cacheable(self):
         if self._cacheable is not None:
@@ -882,7 +756,7 @@
         if not self.cacheable():
             return True
 
-        newstat = filecacheentry.stat(self.path)
+        newstat = filecachesubentry.stat(self.path)
 
         # we may not know if it's cacheable yet, check again now
         if newstat and self._cacheable is None:
@@ -906,24 +780,44 @@
             if e.errno != errno.ENOENT:
                 raise
 
+class filecacheentry(object):
+    def __init__(self, paths, stat=True):
+        self._entries = []
+        for path in paths:
+            self._entries.append(filecachesubentry(path, stat))
+
+    def changed(self):
+        '''true if any entry has changed'''
+        for entry in self._entries:
+            if entry.changed():
+                return True
+        return False
+
+    def refresh(self):
+        for entry in self._entries:
+            entry.refresh()
+
 class filecache(object):
-    '''A property like decorator that tracks a file under .hg/ for updates.
+    '''A property like decorator that tracks files under .hg/ for updates.
 
     Records stat info when called in _filecache.
 
-    On subsequent calls, compares old stat info with new info, and recreates
-    the object when needed, updating the new stat info in _filecache.
+    On subsequent calls, compares old stat info with new info, and recreates the
+    object when any of the files changes, updating the new stat info in
+    _filecache.
 
     Mercurial either atomic renames or appends for files under .hg,
     so to ensure the cache is reliable we need the filesystem to be able
     to tell us if a file has been replaced. If it can't, we fallback to
     recreating the object on every call (essentially the same behaviour as
-    propertycache).'''
-    def __init__(self, path):
-        self.path = path
+    propertycache).
+
+    '''
+    def __init__(self, *paths):
+        self.paths = paths
 
     def join(self, obj, fname):
-        """Used to compute the runtime path of the cached file.
+        """Used to compute the runtime path of a cached file.
 
         Users should subclass filecache and provide their own version of this
         function to call the appropriate join function on 'obj' (an instance
@@ -948,11 +842,11 @@
             if entry.changed():
                 entry.obj = self.func(obj)
         else:
-            path = self.join(obj, self.path)
+            paths = [self.join(obj, path) for path in self.paths]
 
             # We stat -before- creating the object so our cache doesn't lie if
             # a writer modified between the time we read and stat
-            entry = filecacheentry(path)
+            entry = filecacheentry(paths, True)
             entry.obj = self.func(obj)
 
             obj._filecache[self.name] = entry
@@ -964,7 +858,8 @@
         if self.name not in obj._filecache:
             # we add an entry for the missing value because X in __dict__
             # implies X in _filecache
-            ce = filecacheentry(self.join(obj, self.path), False)
+            paths = [self.join(obj, path) for path in self.paths]
+            ce = filecacheentry(paths, False)
             obj._filecache[self.name] = ce
         else:
             ce = obj._filecache[self.name]
--- a/mercurial/setdiscovery.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/setdiscovery.py	Wed Jan 01 18:28:40 2014 -0500
@@ -8,7 +8,8 @@
 
 from node import nullid
 from i18n import _
-import random, util, dagutil
+import random
+import util, dagutil
 
 def _updatesample(dag, nodes, sample, always, quicksamplesize=0):
     # if nodes is empty we scan the entire graph
--- a/mercurial/statichttprepo.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/statichttprepo.py	Wed Jan 01 18:28:40 2014 -0500
@@ -54,8 +54,10 @@
             data = data[:bytes]
         self.pos += len(data)
         return data
+    def readlines(self):
+        return self.read().splitlines(True)
     def __iter__(self):
-        return iter(self.read().splitlines(1))
+        return iter(self.readlines())
     def close(self):
         pass
 
--- a/mercurial/subrepo.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/subrepo.py	Wed Jan 01 18:28:40 2014 -0500
@@ -9,7 +9,9 @@
 import xml.dom.minidom
 import stat, subprocess, tarfile
 from i18n import _
-import config, scmutil, util, node, error, cmdutil, bookmarks, match as matchmod
+import config, util, node, error, cmdutil, bookmarks, match as matchmod
+import phases
+import pathutil
 hg = None
 propertycache = util.propertycache
 
@@ -344,12 +346,43 @@
     import hg as h
     hg = h
 
-    scmutil.pathauditor(ctx._repo.root)(path)
+    pathutil.pathauditor(ctx._repo.root)(path)
     state = ctx.substate[path]
     if state[2] not in types:
         raise util.Abort(_('unknown subrepo type %s') % state[2])
     return types[state[2]](ctx, path, state[:2])
 
+def newcommitphase(ui, ctx):
+    commitphase = phases.newcommitphase(ui)
+    substate = getattr(ctx, "substate", None)
+    if not substate:
+        return commitphase
+    check = ui.config('phases', 'checksubrepos', 'follow')
+    if check not in ('ignore', 'follow', 'abort'):
+        raise util.Abort(_('invalid phases.checksubrepos configuration: %s')
+                         % (check))
+    if check == 'ignore':
+        return commitphase
+    maxphase = phases.public
+    maxsub = None
+    for s in sorted(substate):
+        sub = ctx.sub(s)
+        subphase = sub.phase(substate[s][1])
+        if maxphase < subphase:
+            maxphase = subphase
+            maxsub = s
+    if commitphase < maxphase:
+        if check == 'abort':
+            raise util.Abort(_("can't commit in %s phase"
+                               " conflicting %s from subrepository %s") %
+                             (phases.phasenames[commitphase],
+                              phases.phasenames[maxphase], maxsub))
+        ui.warn(_("warning: changes are committed in"
+                  " %s phase from subrepository %s\n") %
+                (phases.phasenames[maxphase], maxsub))
+        return maxphase
+    return commitphase
+
 # subrepo classes need to implement the following abstract class:
 
 class abstractsubrepo(object):
@@ -384,6 +417,11 @@
         """
         raise NotImplementedError
 
+    def phase(self, state):
+        """returns phase of specified state in the subrepository.
+        """
+        return phases.public
+
     def remove(self):
         """remove the subrepo
 
@@ -651,6 +689,10 @@
         return node.hex(n)
 
     @annotatesubrepoerror
+    def phase(self, state):
+        return self._repo[state].phase()
+
+    @annotatesubrepoerror
     def remove(self):
         # we can't fully delete the repository as it may contain
         # local-only history
--- a/mercurial/templatekw.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/templatekw.py	Wed Jan 01 18:28:40 2014 -0500
@@ -220,11 +220,12 @@
     return '%s: +%s/-%s' % (len(stats), adds, removes)
 
 def showextras(**args):
-    templ = args['templ']
-    for key, value in sorted(args['ctx'].extra().items()):
-        args = args.copy()
-        args.update(dict(key=key, value=value))
-        yield templ('extra', **args)
+    """:extras: List of dicts with key, value entries of the 'extras'
+    field of this changeset."""
+    extras = args['ctx'].extra()
+    c = [{'key': x[0], 'value': x[1]} for x in sorted(extras.items())]
+    f = _showlist('extra', c, plural='extras', **args)
+    return _hybrid(f, c, lambda x: '%s=%s' % (x['key'], x['value']))
 
 def showfileadds(**args):
     """:file_adds: List of strings. Files added by this changeset."""
@@ -392,6 +393,7 @@
     'parents': _showparents,
 }
 dockeywords.update(keywords)
+del dockeywords['branches']
 
 # tell hggettext to extract docstrings from these functions:
 i18nfunctions = dockeywords.values()
--- a/mercurial/transaction.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/transaction.py	Wed Jan 01 18:28:40 2014 -0500
@@ -12,8 +12,8 @@
 # GNU General Public License version 2 or any later version.
 
 from i18n import _
-import os, errno
-import error, util
+import errno
+import error
 
 def active(func):
     def _active(self, *args, **kwds):
@@ -35,14 +35,11 @@
                 raise
         else:
             try:
-                fp = opener(f)
-                fn = fp.name
-                fp.close()
-                util.unlink(fn)
+                opener.unlink(f)
             except (IOError, OSError), inst:
                 if inst.errno != errno.ENOENT:
                     raise
-    util.unlink(journal)
+    opener.unlink(journal)
 
 class transaction(object):
     def __init__(self, report, opener, journal, after=None, createmode=None):
@@ -56,9 +53,9 @@
         self.journal = journal
         self._queue = []
 
-        self.file = util.posixfile(self.journal, "w")
+        self.file = opener.open(self.journal, "w")
         if createmode is not None:
-            os.chmod(self.journal, createmode & 0666)
+            opener.chmod(self.journal, createmode & 0666)
 
     def __del__(self):
         if self.journal:
@@ -136,8 +133,8 @@
         self.entries = []
         if self.after:
             self.after()
-        if os.path.isfile(self.journal):
-            util.unlink(self.journal)
+        if self.opener.isfile(self.journal):
+            self.opener.unlink(self.journal)
         self.journal = None
 
     @active
@@ -155,7 +152,7 @@
         try:
             if not self.entries:
                 if self.journal:
-                    util.unlink(self.journal)
+                    self.opener.unlink(self.journal)
                 return
 
             self.report(_("transaction abort!\n"))
@@ -173,7 +170,7 @@
 def rollback(opener, file, report):
     entries = []
 
-    fp = util.posixfile(file)
+    fp = opener.open(file)
     lines = fp.readlines()
     fp.close()
     for l in lines:
--- a/mercurial/util.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/util.py	Wed Jan 01 18:28:40 2014 -0500
@@ -14,9 +14,9 @@
 """
 
 from i18n import _
-import error, osutil, encoding, collections
+import error, osutil, encoding
 import errno, re, shutil, sys, tempfile, traceback
-import os, time, datetime, calendar, textwrap, signal
+import os, time, datetime, calendar, textwrap, signal, collections
 import imp, socket, urllib
 
 if os.name == 'nt':
@@ -52,7 +52,6 @@
 popen = platform.popen
 posixfile = platform.posixfile
 quotecommand = platform.quotecommand
-realpath = platform.realpath
 rename = platform.rename
 samedevice = platform.samedevice
 samefile = platform.samefile
@@ -1033,9 +1032,10 @@
     if t < 0:
         t = 0   # time.gmtime(lt) fails on Windows for lt < -43200
         tz = 0
-    if "%1" in format or "%2" in format:
+    if "%1" in format or "%2" in format or "%z" in format:
         sign = (tz > 0) and "-" or "+"
         minutes = abs(tz) // 60
+        format = format.replace("%z", "%1%2")
         format = format.replace("%1", "%c%02d" % (sign, minutes // 60))
         format = format.replace("%2", "%02d" % (minutes % 60))
     try:
--- a/mercurial/windows.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/windows.py	Wed Jan 01 18:28:40 2014 -0500
@@ -133,15 +133,6 @@
 def normcase(path):
     return encoding.upper(path)
 
-def realpath(path):
-    '''
-    Returns the true, canonical file system path equivalent to the given
-    path.
-    '''
-    # TODO: There may be a more clever way to do this that also handles other,
-    # less common file systems.
-    return os.path.normpath(normcase(os.path.realpath(path)))
-
 def samestat(s1, s2):
     return False
 
--- a/mercurial/worker.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/mercurial/worker.py	Wed Jan 01 18:28:40 2014 -0500
@@ -6,7 +6,8 @@
 # GNU General Public License version 2 or any later version.
 
 from i18n import _
-import errno, os, signal, sys, threading, util
+import errno, os, signal, sys, threading
+import util
 
 def countcpus():
     '''try to count the number of CPUs on the system'''
--- a/tests/bzr-definitions	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/bzr-definitions	Wed Jan 01 18:28:40 2014 -0500
@@ -5,11 +5,10 @@
 TERM=dumb; export TERM
 echo '[extensions]' >> $HGRCPATH
 echo 'convert = ' >> $HGRCPATH
-echo 'hgext.graphlog = ' >> $HGRCPATH
 
 glog()
 {
-    hg glog --template '{rev}@{branch} "{desc|firstline}" files: {files}\n' "$@"
+    hg log -G --template '{rev}@{branch} "{desc|firstline}" files: {files}\n' "$@"
 }
 
 manifest()
--- a/tests/hghave.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/hghave.py	Wed Jan 01 18:28:40 2014 -0500
@@ -233,6 +233,9 @@
     finally:
         os.rmdir(d)
 
+def has_root():
+    return getattr(os, 'geteuid', None) and os.geteuid() == 0
+
 def has_pyflakes():
     return matchoutput("sh -c \"echo 'import re' 2>&1 | pyflakes\"",
                        r"<stdin>:1: 're' imported but unused",
@@ -312,6 +315,7 @@
     "p4": (has_p4, "Perforce server and client"),
     "pyflakes": (has_pyflakes, "Pyflakes python linter"),
     "pygments": (has_pygments, "Pygments source highlighting library"),
+    "root": (has_root, "root permissions"),
     "serve": (has_serve, "platform and python can manage 'hg serve -d'"),
     "ssl": (has_ssl, "python >= 2.6 ssl module and python OpenSSL"),
     "svn": (has_svn, "subversion client and admin tools"),
--- a/tests/run-tests.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/run-tests.py	Wed Jan 01 18:28:40 2014 -0500
@@ -103,6 +103,7 @@
 
 requiredtools = [os.path.basename(sys.executable), "diff", "grep", "unzip",
                  "gunzip", "bunzip2", "sed"]
+createdfiles = []
 
 defaults = {
     'jobs': ('HGTEST_JOBS', 1),
@@ -420,6 +421,11 @@
     if not options.keep_tmpdir:
         vlog("# Cleaning up HGTMP", HGTMP)
         shutil.rmtree(HGTMP, True)
+        for f in createdfiles:
+            try:
+                os.remove(f)
+            except OSError:
+                pass
 
 def usecorrectpython():
     # some tests run python interpreter. they must use same
@@ -439,6 +445,7 @@
         if findprogram(pyexename) != sys.executable:
             try:
                 os.symlink(sys.executable, mypython)
+                createdfiles.append(mypython)
             except OSError, err:
                 # child processes may race, which is harmless
                 if err.errno != errno.EEXIST:
@@ -498,18 +505,6 @@
 
     usecorrectpython()
 
-    vlog("# Installing dummy diffstat")
-    f = open(os.path.join(BINDIR, 'diffstat'), 'w')
-    f.write('#!' + sys.executable + '\n'
-            'import sys\n'
-            'files = 0\n'
-            'for line in sys.stdin:\n'
-            '    if line.startswith("diff "):\n'
-            '        files += 1\n'
-            'sys.stdout.write("files patched: %d\\n" % files)\n')
-    f.close()
-    os.chmod(os.path.join(BINDIR, 'diffstat'), 0700)
-
     if options.py3k_warnings and not options.anycoverage:
         vlog("# Updating hg command to enable Py3k Warnings switch")
         f = open(os.path.join(BINDIR, 'hg'), 'r')
@@ -1139,6 +1134,8 @@
         _checkhglib("Tested")
         print "# Ran %d tests, %d skipped, %d failed." % (
             tested, skipped + ignored, failed)
+        if results['!']:
+            print 'python hash seed:', os.environ['PYTHONHASHSEED']
         if options.time:
             outputtimes(options)
 
@@ -1190,7 +1187,6 @@
         # use a random python hash seed all the time
         # we do the randomness ourself to know what seed is used
         os.environ['PYTHONHASHSEED'] = str(random.getrandbits(32))
-        print 'python hash seed:', os.environ['PYTHONHASHSEED']
 
     global TESTDIR, HGTMP, INST, BINDIR, PYTHONDIR, COVERAGE_FILE
     TESTDIR = os.environ["TESTDIR"] = os.getcwd()
--- a/tests/test-alias.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-alias.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,8 +1,5 @@
   $ HGFOO=BAR; export HGFOO
   $ cat >> $HGRCPATH <<EOF
-  > [extensions]
-  > graphlog=
-  > 
   > [alias]
   > # should clobber ci but not commit (issue2993)
   > ci = version
@@ -34,7 +31,7 @@
   > count = !hg log -r "\$@" --template=. | wc -c | sed -e 's/ //g'
   > mcount = !hg log \$@ --template=. | wc -c | sed -e 's/ //g'
   > rt = root
-  > tglog = glog --template "{rev}:{node|short}: '{desc}' {branches}\n"
+  > tglog = log -G --template "{rev}:{node|short}: '{desc}' {branches}\n"
   > idalias = id
   > idaliaslong = id
   > idaliasshell = !echo test
--- a/tests/test-blackbox.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-blackbox.t	Wed Jan 01 18:28:40 2014 -0500
@@ -65,7 +65,7 @@
   $ hg rollback
   repository tip rolled back to revision 1 (undo pull)
 
-#if unix-permissions
+#if unix-permissions no-root
   $ chmod 000 .hg/blackbox.log
   $ hg --debug incoming
   warning: cannot write to blackbox.log: Permission denied
@@ -98,7 +98,7 @@
   (run 'hg update' to get a working copy)
 
 a failure reading from the log is fine
-#if unix-permissions
+#if unix-permissions no-root
   $ hg blackbox -l 3
   abort: Permission denied: $TESTTMP/blackboxtest2/.hg/blackbox.log
   [255]
--- a/tests/test-bookmarks-pushpull.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-bookmarks-pushpull.t	Wed Jan 01 18:28:40 2014 -0500
@@ -424,4 +424,22 @@
   remote: added 1 changesets with 1 changes to 1 files
   exporting bookmark add-foo
 
+pushing a new bookmark on a new head does not require -f if -B is specified
+
+  $ hg up -q X
+  $ hg book W
+  $ echo c5 > f2
+  $ hg ci -Am5
+  created new head
+  $ hg push -B W
+  pushing to http://localhost:$HGPORT/
+  searching for changes
+  remote: adding changesets
+  remote: adding manifests
+  remote: adding file changes
+  remote: added 1 changesets with 1 changes to 1 files (+1 heads)
+  exporting bookmark W
+  $ hg -R ../b id -r W
+  cc978a373a53 tip W
+
   $ cd ..
--- a/tests/test-bookmarks.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-bookmarks.t	Wed Jan 01 18:28:40 2014 -0500
@@ -549,7 +549,7 @@
 
 test stripping a non-checked-out but bookmarked revision
 
-  $ hg --config extensions.graphlog= log --graph
+  $ hg log --graph
   o  changeset:   4:9ba5f110a0b3
   |  branch:      test
   |  tag:         tip
@@ -587,7 +587,7 @@
   saved backup bundle to * (glob)
 should-end-on-two should end up pointing to revision 2, as that's the
 tipmost surviving ancestor of the stripped revision.
-  $ hg --config extensions.graphlog= log --graph
+  $ hg log --graph
   @  changeset:   3:9ba5f110a0b3
   |  branch:      test
   |  bookmark:    four
--- a/tests/test-bundle-vs-outgoing.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-bundle-vs-outgoing.t	Wed Jan 01 18:28:40 2014 -0500
@@ -75,12 +75,9 @@
   $ mkrev 8
   rev 8
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "graphlog=" >> $HGRCPATH
-
 the story so far
 
-  $ hg glog --template "{rev}\n"
+  $ hg log -G --template "{rev}\n"
   @  8
   |
   | o  7
--- a/tests/test-clone.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-clone.t	Wed Jan 01 18:28:40 2014 -0500
@@ -543,7 +543,7 @@
   $ rm -rf b # work around bug with http clone
 
 
-#if unix-permissions
+#if unix-permissions no-root
 
 Inaccessible source
 
@@ -596,7 +596,7 @@
   [255]
 
 
-#if unix-permissions
+#if unix-permissions no-root
 
 leave existing directory in place after clone failure
 
--- a/tests/test-command-template.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-command-template.t	Wed Jan 01 18:28:40 2014 -0500
@@ -447,7 +447,7 @@
 
 Error if style not readable:
 
-#if unix-permissions
+#if unix-permissions no-root
   $ touch q
   $ chmod 0 q
   $ hg log --style ./q
@@ -479,7 +479,7 @@
 Error if include fails:
 
   $ echo 'changeset = q' >> t
-#if unix-permissions
+#if unix-permissions no-root
   $ hg log --style ./t
   abort: template file ./q: Permission denied
   [255]
@@ -1445,7 +1445,7 @@
   $ hg ci -m h2e -d '4 0'
 
   $ hg merge -q
-  $ hg ci -m merge -d '5 0'
+  $ hg ci -m merge -d '5 -3600'
 
 No tag set:
 
@@ -1533,7 +1533,7 @@
   > EOF
 
   $ hg -R latesttag tip
-  test 10:dee8f28249af
+  test 10:9b4a630e5f5f
 
 Test recursive showlist template (issue1989):
 
@@ -1587,6 +1587,21 @@
   b
   a
 
+Test date format:
+
+  $ hg log -R latesttag --template 'date: {date(date, "%y %m %d %S %z")}\n'
+  date: 70 01 01 10 +0000
+  date: 70 01 01 09 +0000
+  date: 70 01 01 08 +0000
+  date: 70 01 01 07 +0000
+  date: 70 01 01 06 +0000
+  date: 70 01 01 05 +0100
+  date: 70 01 01 04 +0000
+  date: 70 01 01 03 +0000
+  date: 70 01 01 02 +0000
+  date: 70 01 01 01 +0000
+  date: 70 01 01 00 +0000
+
 Test string escaping:
 
   $ hg log -R latesttag -r 0 --template '>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n'
--- a/tests/test-commit-multiple.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-commit-multiple.t	Wed Jan 01 18:28:40 2014 -0500
@@ -4,7 +4,6 @@
   $ cat <<EOF >> $HGRCPATH
   > [extensions]
   > transplant =
-  > graphlog =
   > EOF
   $ hg init repo
   $ cd repo
@@ -39,7 +38,7 @@
   $ echo fix2 > bugfix
   $ echo fix2 >> file1
   $ hg ci -Am"fix 2"
-  $ hg glog --template="$template"
+  $ hg log -G --template="$template"
   @  3  fix 2  [fixes]
   |
   o  2  fix 1  [fixes]
@@ -59,7 +58,7 @@
   [0-9a-f]{12} transplanted to [0-9a-f]{12} (re)
   applying [0-9a-f]{12} (re)
   [0-9a-f]{12} transplanted to [0-9a-f]{12} (re)
-  $ hg glog --template="$template"
+  $ hg log -G --template="$template"
   @  5  fix 2  [release]
   |
   o  4  fix 1  [release]
--- a/tests/test-commit-unresolved.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-commit-unresolved.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,6 +1,3 @@
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "graphlog=" >> $HGRCPATH
-
   $ addcommit () {
   >     echo $1 > $1
   >     hg add $1
--- a/tests/test-completion.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-completion.t	Wed Jan 01 18:28:40 2014 -0500
@@ -305,7 +305,7 @@
 
   $ hg debugpathcomplete f
   fee
-  fie/
+  fie
   fo
   $ hg debugpathcomplete -f f
   fee
@@ -317,12 +317,6 @@
   $ hg debugpathcomplete -r F
   Fum
 
-If one directory and no files match, give an ambiguous answer
-
-  $ hg debugpathcomplete fi
-  fie/
-  fie/.
-
 Test debuglabelcomplete
 
   $ hg debuglabelcomplete
--- a/tests/test-convert-baz.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-convert-baz.t	Wed Jan 01 18:28:40 2014 -0500
@@ -4,7 +4,6 @@
 
   $ echo "[extensions]" >> $HGRCPATH
   $ echo "convert=" >> $HGRCPATH
-  $ echo 'graphlog =' >> $HGRCPATH
 
 create baz archive
   $ baz make-archive baz@mercurial--convert hg-test-convert-baz
@@ -129,7 +128,7 @@
 
   $ glog()
   > {
-  >     hg glog --template '{rev} "{desc|firstline}" files: {files}\n' "$@"
+  >     hg log -G --template '{rev} "{desc|firstline}" files: {files}\n' "$@"
   > }
 
 show graph log
--- a/tests/test-convert-cvs-branch.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-convert-cvs-branch.t	Wed Jan 01 18:28:40 2014 -0500
@@ -8,7 +8,6 @@
   > }
   $ echo "[extensions]" >> $HGRCPATH
   $ echo "convert = " >> $HGRCPATH
-  $ echo "graphlog = " >> $HGRCPATH
   $ echo "[convert]" >> $HGRCPATH
   $ echo "cvsps.cache=0" >> $HGRCPATH
 
@@ -79,7 +78,7 @@
 
 Check the result
 
-  $ hg -R src-hg glog --template '{rev} ({branches}) {desc} files: {files}\n'
+  $ hg -R src-hg log -G --template '{rev} ({branches}) {desc} files: {files}\n'
   o  5 () update tags files: .hgtags
   |
   | o  4 (BRANCH) mod a again files: a
--- a/tests/test-convert-cvs-detectmerge.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-convert-cvs-detectmerge.t	Wed Jan 01 18:28:40 2014 -0500
@@ -24,7 +24,6 @@
 
   $ echo "[extensions]" >> $HGRCPATH
   $ echo "convert = " >> $HGRCPATH
-  $ echo "graphlog = " >> $HGRCPATH
   $ echo "[convert]" >> $HGRCPATH
   $ echo "cvsps.cache=0" >> $HGRCPATH
   $ echo "cvsps.mergefrom=\[MERGE from (\S+)\]" >> $HGRCPATH
@@ -210,7 +209,7 @@
 
 graphical log
 
-  $ hg -R proj.hg glog --template="$template"
+  $ hg -R proj.hg log -G --template="$template"
   o  9: '' fix file1 [MERGE from v1-1]
   |
   | o  8: 'v1_1' fix file1
--- a/tests/test-convert-cvs-synthetic.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-convert-cvs-synthetic.t	Wed Jan 01 18:28:40 2014 -0500
@@ -3,7 +3,6 @@
   $ "$TESTDIR/hghave" cvs || exit 80
   $ echo "[extensions]" >> $HGRCPATH
   $ echo "convert = " >> $HGRCPATH
-  $ echo "graphlog = " >> $HGRCPATH
 
 create cvs repository with one project
 
@@ -153,9 +152,9 @@
   1 MERGE from HEAD: add file6
   0 MERGE from v1_2: add file5
 
-hg glog output (#1)
+hg log -G output (#1)
 
-  $ hg -R proj.hg glog --template "{rev} {desc}\n"
+  $ hg -R proj.hg log -G --template "{rev} {desc}\n"
   o  8 MERGE from v1_2: add file5
   |
   | o  7 MERGE from HEAD: add file6
@@ -200,9 +199,9 @@
   1 MERGE from HEAD: add file6
   0 MERGE from v1_2: add file5
 
-hg glog output (#2)
+hg log -G output (#2)
 
-  $ hg -R proj.hg2 glog --template "{rev} {desc}\n"
+  $ hg -R proj.hg2 log -G --template "{rev} {desc}\n"
   o  8 MERGE from v1_2: add file5
   |
   | o  7 MERGE from HEAD: add file6
--- a/tests/test-convert-cvs.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-convert-cvs.t	Wed Jan 01 18:28:40 2014 -0500
@@ -10,7 +10,6 @@
   > }
   $ echo "[extensions]" >> $HGRCPATH
   $ echo "convert = " >> $HGRCPATH
-  $ echo "graphlog = " >> $HGRCPATH
   $ cat > cvshooks.py <<EOF
   > def cvslog(ui,repo,hooktype,log):
   >     print "%s hook: %d entries"%(hooktype,len(log))
@@ -307,7 +306,7 @@
   2 funny
   1 fuzzy
   0 fuzzy
-  $ hg -R src-hg glog --template '{rev} ({branches}) {desc} date: {date|date} files: {files}\n'
+  $ hg -R src-hg log -G --template '{rev} ({branches}) {desc} date: {date|date} files: {files}\n'
   o  8 (branch) fuzzy date: * -1000 files: b/c (glob)
   |
   o  7 (branch) fuzzy date: * -1000 files: a (glob)
--- a/tests/test-convert-cvsnt-mergepoints.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-convert-cvsnt-mergepoints.t	Wed Jan 01 18:28:40 2014 -0500
@@ -22,7 +22,6 @@
   > }
   $ echo "[extensions]" >> $HGRCPATH
   $ echo "convert = " >> $HGRCPATH
-  $ echo "graphlog = " >> $HGRCPATH
 
 create cvs repository
 
--- a/tests/test-convert-darcs.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-convert-darcs.t	Wed Jan 01 18:28:40 2014 -0500
@@ -2,7 +2,6 @@
   $ "$TESTDIR/hghave" darcs || exit 80
   $ echo "[extensions]" >> $HGRCPATH
   $ echo "convert=" >> $HGRCPATH
-  $ echo 'graphlog =' >> $HGRCPATH
   $ DARCS_EMAIL='test@example.org'; export DARCS_EMAIL
 
 initialize darcs repo
--- a/tests/test-convert-datesort.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-convert-datesort.t	Wed Jan 01 18:28:40 2014 -0500
@@ -2,7 +2,6 @@
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
   > convert=
-  > graphlog=
   > EOF
   $ hg init t
   $ cd t
@@ -83,7 +82,7 @@
 
 graph converted repo
 
-  $ hg -R t-datesort glog --template '{rev} "{desc}"\n'
+  $ hg -R t-datesort log -G --template '{rev} "{desc}"\n'
   o    12 "c1"
   |\
   | o  11 "b2x"
@@ -134,7 +133,7 @@
 
 graph converted repo
 
-  $ hg -R t-sourcesort glog --template '{rev} "{desc}"\n'
+  $ hg -R t-sourcesort log -G --template '{rev} "{desc}"\n'
   o    12 "c1"
   |\
   | o  11 "b2x"
@@ -185,7 +184,7 @@
 
 graph converted repo
 
-  $ hg -R t-closesort glog --template '{rev} "{desc}"\n'
+  $ hg -R t-closesort log -G --template '{rev} "{desc}"\n'
   o    12 "c1"
   |\
   | o  11 "c0"
--- a/tests/test-convert-filemap.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-convert-filemap.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,11 +1,10 @@
 
   $ HGMERGE=true; export HGMERGE
   $ echo '[extensions]' >> $HGRCPATH
-  $ echo 'graphlog =' >> $HGRCPATH
   $ echo 'convert =' >> $HGRCPATH
   $ glog()
   > {
-  >     hg glog --template '{rev} "{desc}" files: {files}\n' "$@"
+  >     hg log -G --template '{rev} "{desc}" files: {files}\n' "$@"
   > }
   $ hg init source
   $ cd source
@@ -473,7 +472,7 @@
 
   $ glog()
   > {
-  >     hg glog --template '{rev}:{node|short}@{branch} "{desc}" files: {files}\n' "$@"
+  >     hg log -G --template '{rev}:{node|short}@{branch} "{desc}" files: {files}\n' "$@"
   > }
 
 test anonymous branch pruning
--- a/tests/test-convert-git.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-convert-git.t	Wed Jan 01 18:28:40 2014 -0500
@@ -6,7 +6,6 @@
   $ echo "autocrlf = false" >> $HOME/.gitconfig
   $ echo "[extensions]" >> $HGRCPATH
   $ echo "convert=" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
@@ -114,7 +113,7 @@
   $ cd ..
   $ glog()
   > {
-  >     hg glog --template '{rev} "{desc|firstline}" files: {files}\n' "$@"
+  >     hg log -G --template '{rev} "{desc|firstline}" files: {files}\n' "$@"
   > }
   $ splitrepo()
   > {
--- a/tests/test-convert-hg-startrev.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-convert-hg-startrev.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,7 +1,6 @@
 
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
-  > graphlog =
   > convert =
   > [convert]
   > hg.saverev = yes
@@ -9,7 +8,7 @@
 
   $ glog()
   > {
-  >     hg -R "$1" glog --template '{rev} "{desc}" files: {files}\n'
+  >     hg -R "$1" log -G --template '{rev} "{desc}" files: {files}\n'
   > }
 
   $ hg init source
--- a/tests/test-convert-mtn.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-convert-mtn.t	Wed Jan 01 18:28:40 2014 -0500
@@ -16,7 +16,6 @@
 
   $ echo "[extensions]" >> $HGRCPATH
   $ echo "convert=" >> $HGRCPATH
-  $ echo 'graphlog =' >> $HGRCPATH
 
 Windows version of monotone home
 
@@ -257,7 +256,7 @@
   0 largefile
   $ glog()
   > {
-  >     hg glog --template '{rev} "{desc|firstline}" files: {files}\n' "$@"
+  >     hg log -G --template '{rev} "{desc|firstline}" files: {files}\n' "$@"
   > }
   $ cd repo.mtn-hg
   $ hg up -C
--- a/tests/test-convert-splicemap.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-convert-splicemap.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,10 +1,9 @@
 
   $ echo "[extensions]" >> $HGRCPATH
   $ echo "convert=" >> $HGRCPATH
-  $ echo 'graphlog =' >> $HGRCPATH
   $ glog()
   > {
-  >     hg glog --template '{rev}:{node|short} "{desc|firstline}"\
+  >     hg log -G --template '{rev}:{node|short} "{desc|firstline}"\
   >  files: {files}\n' "$@"
   > }
   $ hg init repo1
--- a/tests/test-convert-svn-branches.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-convert-svn-branches.t	Wed Jan 01 18:28:40 2014 -0500
@@ -4,7 +4,6 @@
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
   > convert =
-  > graphlog =
   > EOF
 
   $ svnadmin create svn-repo
@@ -58,7 +57,7 @@
   0 branch trunk@1 into old3
 
   $ cd A-hg
-  $ hg glog --template 'branch={branches} {rev} {desc|firstline} files: {files}\n'
+  $ hg log -G --template 'branch={branches} {rev} {desc|firstline} files: {files}\n'
   o  branch=newbranch 11 branch trunk@1 into old3 files:
   |
   | o  branch= 10 last change to a files: a
--- a/tests/test-convert-svn-encoding.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-convert-svn-encoding.t	Wed Jan 01 18:28:40 2014 -0500
@@ -4,7 +4,6 @@
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
   > convert =
-  > graphlog =
   > EOF
 
   $ svnadmin create svn-repo
--- a/tests/test-convert-svn-move.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-convert-svn-move.t	Wed Jan 01 18:28:40 2014 -0500
@@ -4,7 +4,6 @@
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
   > convert =
-  > graphlog =
   > EOF
 
   $ svnadmin create svn-repo
@@ -39,7 +38,7 @@
   0 rename d4old into d4new
 
   $ cd A-hg
-  $ hg glog --template '{rev} {desc|firstline} files: {files}\n'
+  $ hg log -G --template '{rev} {desc|firstline} files: {files}\n'
   o  13 rename d4old into d4new files: d4new/g d4old/g
   |
   o  12 add d4old files: d4old/g
--- a/tests/test-convert-svn-sink.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-convert-svn-sink.t	Wed Jan 01 18:28:40 2014 -0500
@@ -17,7 +17,6 @@
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
   > convert =
-  > graphlog =
   > EOF
 
   $ hg init a
--- a/tests/test-convert-svn-source.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-convert-svn-source.t	Wed Jan 01 18:28:40 2014 -0500
@@ -4,7 +4,6 @@
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
   > convert =
-  > graphlog =
   > [convert]
   > svn.trunk = mytrunk
   > EOF
@@ -127,7 +126,7 @@
   updating tags
 
   $ cd B-hg
-  $ hg glog --template '{rev} {desc|firstline} date: {date|date} files: {files}\n'
+  $ hg log -G --template '{rev} {desc|firstline} date: {date|date} files: {files}\n'
   o  7 update tags date: * +0000 files: .hgtags (glob)
   |
   o  6 work in progress date: * -1000 files: letter2.txt (glob)
@@ -165,7 +164,7 @@
   0 work in progress
   $ hg -R fmap branch -q
   default
-  $ hg glog -R fmap --template '{rev} {desc|firstline} files: {files}\n'
+  $ hg log -G -R fmap --template '{rev} {desc|firstline} files: {files}\n'
   o  1 work in progress files: letter2.txt
   |
   o  0 second letter files: letter2.txt
--- a/tests/test-convert-svn-startrev.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-convert-svn-startrev.t	Wed Jan 01 18:28:40 2014 -0500
@@ -4,7 +4,6 @@
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
   > convert =
-  > graphlog =
   > EOF
   $ convert()
   > {
@@ -15,7 +14,7 @@
   >         --config convert.svn.branches="  " \
   >         --config convert.svn.tags= \
   >         --datesort svn-repo $repopath
-  >     hg -R $repopath glog \
+  >     hg -R $repopath log -G \
   >         --template '{rev} {desc|firstline} files: {files}\n'
   >     echo
   > }
--- a/tests/test-convert-svn-tags.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-convert-svn-tags.t	Wed Jan 01 18:28:40 2014 -0500
@@ -4,7 +4,6 @@
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
   > convert =
-  > graphlog =
   > EOF
 
   $ svnadmin create svn-repo
@@ -25,7 +24,7 @@
   updating tags
 
   $ cd A-hg
-  $ hg glog --template '{rev} {desc|firstline} tags: {tags}\n'
+  $ hg log -G --template '{rev} {desc|firstline} tags: {tags}\n'
   o  6 update tags tags: tip
   |
   o  5 changea tags: trunk.goodtag
--- a/tests/test-convert-tagsbranch-topology.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-convert-tagsbranch-topology.t	Wed Jan 01 18:28:40 2014 -0500
@@ -6,7 +6,6 @@
   $ echo "autocrlf = false" >> $HOME/.gitconfig
   $ echo "[extensions]" >> $HGRCPATH
   $ echo "convert=" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
   $ echo '[convert]' >> $HGRCPATH
   $ echo 'hg.usebranchnames = True' >> $HGRCPATH
   $ echo 'hg.tagsbranch = tags-update' >> $HGRCPATH
@@ -26,7 +25,7 @@
   > }
   $ glog()
   > {
-  >     hg glog --template '{rev} "{desc|firstline}" files: {files}\n' "$@"
+  >     hg log -G --template '{rev} "{desc|firstline}" files: {files}\n' "$@"
   > }
   $ convertrepo()
   > {
--- a/tests/test-convert-tla.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-convert-tla.t	Wed Jan 01 18:28:40 2014 -0500
@@ -3,7 +3,6 @@
   $ tla my-id "mercurial <mercurial@selenic.com>"
   $ echo "[extensions]" >> $HGRCPATH
   $ echo "convert=" >> $HGRCPATH
-  $ echo 'graphlog =' >> $HGRCPATH
 
 create tla archive
 
@@ -109,7 +108,7 @@
   $ tla register-archive -d tla@mercurial--convert
   $ glog()
   > {
-  >     hg glog --template '{rev} "{desc|firstline}" files: {files}\n' "$@"
+  >     hg log -G --template '{rev} "{desc|firstline}" files: {files}\n' "$@"
   > }
 
 show graph log
--- a/tests/test-convert.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-convert.t	Wed Jan 01 18:28:40 2014 -0500
@@ -310,7 +310,7 @@
   abort: cannot create new bundle repository
   [255]
 
-#if unix-permissions
+#if unix-permissions no-root
 
 conversion to dir without permissions should fail
 
--- a/tests/test-debugbuilddag.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-debugbuilddag.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,5 +1,3 @@
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "graphlog=" >> $HGRCPATH
 
 plain
 
@@ -60,7 +58,7 @@
   $ hg id
   000000000000
 glog
-  $ hg glog --template '{rev}: {desc} [{branches}] @ {date}\n'
+  $ hg log -G --template '{rev}: {desc} [{branches}] @ {date}\n'
   o  11: r11 [] @ 11.00
   |
   o  10: r10 [] @ 10.00
@@ -106,7 +104,7 @@
   $ hg id
   000000000000
 glog
-  $ hg glog --template '{rev}: {desc} [{branches}] @ {date}\n'
+  $ hg log -G --template '{rev}: {desc} [{branches}] @ {date}\n'
   o  11: r11 [] @ 11.00
   |
   o  10: r10 [] @ 10.00
@@ -132,7 +130,7 @@
   o  0: r0 [start] @ 0.00
   
 glog of
-  $ hg glog --template '{rev}: {desc} [{branches}]\n' of
+  $ hg log -G --template '{rev}: {desc} [{branches}]\n' of
   o  11: r11 []
   |
   o  10: r10 []
@@ -182,7 +180,7 @@
   $ hg id
   000000000000
 glog
-  $ hg glog --template '{rev}: {desc} [{branches}] @ {date}\n'
+  $ hg log -G --template '{rev}: {desc} [{branches}] @ {date}\n'
   o  11: r11 [] @ 11.00
   |
   o  10: r10 [] @ 10.00
@@ -208,7 +206,7 @@
   o  0: r0 [] @ 0.00
   
 glog mf
-  $ hg glog --template '{rev}: {desc} [{branches}]\n' mf
+  $ hg log -G --template '{rev}: {desc} [{branches}]\n' mf
   o  11: r11 []
   |
   o  10: r10 []
--- a/tests/test-doctest.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-doctest.py	Wed Jan 01 18:28:40 2014 -0500
@@ -1,49 +1,29 @@
 # this is hack to make sure no escape characters are inserted into the output
-import os
+import os, sys
 if 'TERM' in os.environ:
     del os.environ['TERM']
 import doctest
 
-import mercurial.util
-doctest.testmod(mercurial.util)
-# Only run doctests for the current platform
-doctest.testmod(mercurial.util.platform)
-
-import mercurial.changelog
-doctest.testmod(mercurial.changelog)
-
-import mercurial.dagparser
-doctest.testmod(mercurial.dagparser, optionflags=doctest.NORMALIZE_WHITESPACE)
-
-import mercurial.match
-doctest.testmod(mercurial.match)
-
-import mercurial.store
-doctest.testmod(mercurial.store)
-
-import mercurial.ui
-doctest.testmod(mercurial.ui)
+def testmod(name, optionflags=0, testtarget=None):
+    __import__(name)
+    mod = sys.modules[name]
+    if testtarget is not None:
+        mod = getattr(mod, testtarget)
+    doctest.testmod(mod, optionflags=optionflags)
 
-import mercurial.url
-doctest.testmod(mercurial.url)
-
-import mercurial.dispatch
-doctest.testmod(mercurial.dispatch)
-
-import mercurial.encoding
-doctest.testmod(mercurial.encoding)
-
-import mercurial.hgweb.hgwebdir_mod
-doctest.testmod(mercurial.hgweb.hgwebdir_mod)
-
-import hgext.convert.cvsps
-doctest.testmod(hgext.convert.cvsps)
-
-import mercurial.revset
-doctest.testmod(mercurial.revset)
-
-import mercurial.minirst
-doctest.testmod(mercurial.minirst)
-
-import mercurial.templatefilters
-doctest.testmod(mercurial.templatefilters)
+testmod('mercurial.changelog')
+testmod('mercurial.dagparser', optionflags=doctest.NORMALIZE_WHITESPACE)
+testmod('mercurial.dispatch')
+testmod('mercurial.encoding')
+testmod('mercurial.hgweb.hgwebdir_mod')
+testmod('mercurial.match')
+testmod('mercurial.minirst')
+testmod('mercurial.revset')
+testmod('mercurial.store')
+testmod('mercurial.templatefilters')
+testmod('mercurial.ui')
+testmod('mercurial.url')
+testmod('mercurial.util')
+testmod('mercurial.util', testtarget='platform')
+testmod('hgext.convert.cvsps')
+testmod('hgext.convert.filemap')
--- a/tests/test-filecache.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-filecache.py	Wed Jan 01 18:28:40 2014 -0500
@@ -18,9 +18,10 @@
     def sjoin(self, p):
         return p
 
-    @filecache('x')
+    @filecache('x', 'y')
     def cached(self):
         print 'creating'
+        return 'string from function'
 
     def invalidate(self):
         for k in self._filecache:
@@ -30,17 +31,20 @@
                 pass
 
 def basic(repo):
-    # file doesn't exist, calls function
+    print "* neither file exists"
+    # calls function
     repo.cached
 
     repo.invalidate()
-    # file still doesn't exist, uses cache
+    print "* neither file still exists"
+    # uses cache
     repo.cached
 
     # create empty file
     f = open('x', 'w')
     f.close()
     repo.invalidate()
+    print "* empty file x created"
     # should recreate the object
     repo.cached
 
@@ -48,11 +52,13 @@
     f.write('a')
     f.close()
     repo.invalidate()
+    print "* file x changed size"
     # should recreate the object
     repo.cached
 
     repo.invalidate()
-    # stats file again, nothing changed, reuses object
+    print "* nothing changed with either file"
+    # stats file again, reuses object
     repo.cached
 
     # atomic replace file, size doesn't change
@@ -63,6 +69,42 @@
     f.close()
 
     repo.invalidate()
+    print "* file x changed inode"
+    repo.cached
+
+    # create empty file y
+    f = open('y', 'w')
+    f.close()
+    repo.invalidate()
+    print "* empty file y created"
+    # should recreate the object
+    repo.cached
+
+    f = open('y', 'w')
+    f.write('A')
+    f.close()
+    repo.invalidate()
+    print "* file y changed size"
+    # should recreate the object
+    repo.cached
+
+    f = scmutil.opener('.')('y', 'w', atomictemp=True)
+    f.write('B')
+    f.close()
+
+    repo.invalidate()
+    print "* file y changed inode"
+    repo.cached
+
+    f = scmutil.opener('.')('x', 'w', atomictemp=True)
+    f.write('c')
+    f.close()
+    f = scmutil.opener('.')('y', 'w', atomictemp=True)
+    f.write('C')
+    f.close()
+
+    repo.invalidate()
+    print "* both files changed inode"
     repo.cached
 
 def fakeuncacheable():
@@ -76,10 +118,11 @@
     origcacheable = extensions.wrapfunction(util.cachestat, 'cacheable',
                                             wrapcacheable)
 
-    try:
-        os.remove('x')
-    except OSError:
-        pass
+    for fn in ['x', 'y']:
+        try:
+            os.remove(fn)
+        except OSError:
+            pass
 
     basic(fakerepo())
 
@@ -103,13 +146,28 @@
 
 def setbeforeget(repo):
     os.remove('x')
-    repo.cached = 0
+    os.remove('y')
+    repo.cached = 'string set externally'
     repo.invalidate()
+    print "* neither file exists"
     print repo.cached
     repo.invalidate()
     f = open('x', 'w')
     f.write('a')
     f.close()
+    print "* file x created"
+    print repo.cached
+
+    repo.cached = 'string 2 set externally'
+    repo.invalidate()
+    print "* string set externally again"
+    print repo.cached
+
+    repo.invalidate()
+    f = open('y', 'w')
+    f.write('b')
+    f.close()
+    print "* file y created"
     print repo.cached
 
 print 'basic:'
--- a/tests/test-filecache.py.out	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-filecache.py.out	Wed Jan 01 18:28:40 2014 -0500
@@ -1,17 +1,45 @@
 basic:
 
+* neither file exists
 creating
+* neither file still exists
+* empty file x created
+creating
+* file x changed size
 creating
+* nothing changed with either file
+* file x changed inode
 creating
+* empty file y created
+creating
+* file y changed size
+creating
+* file y changed inode
+creating
+* both files changed inode
 creating
 
 fakeuncacheable:
 
+* neither file exists
 creating
+* neither file still exists
 creating
+* empty file x created
+creating
+* file x changed size
+creating
+* nothing changed with either file
 creating
+* file x changed inode
 creating
+* empty file y created
 creating
+* file y changed size
+creating
+* file y changed inode
+creating
+* both files changed inode
 creating
 repository tip rolled back to revision -1 (undo commit)
 working directory now based on revision -1
@@ -20,6 +48,13 @@
 
 setbeforeget:
 
-0
+* neither file exists
+string set externally
+* file x created
 creating
-None
+string from function
+* string set externally again
+string 2 set externally
+* file y created
+creating
+string from function
--- a/tests/test-fncache.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-fncache.t	Wed Jan 01 18:28:40 2014 -0500
@@ -70,7 +70,7 @@
   .hg/00changelog.i
   .hg/00manifest.i
   .hg/cache
-  .hg/cache/branchheads-served
+  .hg/cache/branch2-served
   .hg/data
   .hg/data/tst.d.hg
   .hg/data/tst.d.hg/foo.i
@@ -98,7 +98,7 @@
   .hg
   .hg/00changelog.i
   .hg/cache
-  .hg/cache/branchheads-served
+  .hg/cache/branch2-served
   .hg/dirstate
   .hg/last-message.txt
   .hg/requires
--- a/tests/test-getbundle.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-getbundle.t	Wed Jan 01 18:28:40 2014 -0500
@@ -2,17 +2,12 @@
 
 = Test the getbundle() protocol function =
 
-Enable graphlog extension:
-
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "graphlog=" >> $HGRCPATH
-
 Create a test repository:
 
   $ hg init repo
   $ cd repo
   $ hg debugbuilddag -n -m '+2 :fork +5 :p1 *fork +6 :p2 /p1 :m1 +3' > /dev/null
-  $ hg glog --template '{node}\n'
+  $ hg log -G --template '{node}\n'
   o  10c14a2cc935e1d8c31f9e98587dcf27fb08a6da
   |
   o  4801a72e5d88cb515b0c7e40fae34180f3f837f2
--- a/tests/test-glog.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-glog.t	Wed Jan 01 18:28:40 2014 -0500
@@ -102,7 +102,6 @@
   > EOF
 
   $ echo "[extensions]" >> $HGRCPATH
-  $ echo "graphlog=" >> $HGRCPATH
   $ echo "printrevset=`pwd`/printrevset.py" >> $HGRCPATH
 
   $ hg init repo
@@ -110,7 +109,7 @@
 
 Empty repo:
 
-  $ hg glog
+  $ hg log -G
 
 
 Building DAG:
@@ -152,7 +151,7 @@
   $ commit 34 "head" 32
 
 
-  $ hg glog -q
+  $ hg log -G -q
   @  34:fea3ac5810e0
   |
   | o  33:68608f5145f9
@@ -224,7 +223,7 @@
   o  0:e6eb3150255d
   
 
-  $ hg glog
+  $ hg log -G
   @  changeset:   34:fea3ac5810e0
   |  tag:         tip
   |  parent:      32:d06dffa21a31
@@ -461,7 +460,7 @@
   
 
 File glog:
-  $ hg glog a
+  $ hg log -G a
   @  changeset:   34:fea3ac5810e0
   |  tag:         tip
   |  parent:      32:d06dffa21a31
@@ -699,7 +698,7 @@
 
 File glog per revset:
 
-  $ hg glog -r 'file("a")'
+  $ hg log -G -r 'file("a")'
   @  changeset:   34:fea3ac5810e0
   |  tag:         tip
   |  parent:      32:d06dffa21a31
@@ -1131,14 +1130,14 @@
 
 
 Empty revision range - display nothing:
-  $ hg glog -r 1..0
+  $ hg log -G -r 1..0
 
   $ cd ..
 
 #if no-outer-repo
 
 From outer space:
-  $ hg glog -l1 repo
+  $ hg log -G -l1 repo
   @  changeset:   34:fea3ac5810e0
   |  tag:         tip
   |  parent:      32:d06dffa21a31
@@ -1146,7 +1145,7 @@
   |  date:        Thu Jan 01 00:00:34 1970 +0000
   |  summary:     (34) head
   |
-  $ hg glog -l1 repo/a
+  $ hg log -G -l1 repo/a
   @  changeset:   34:fea3ac5810e0
   |  tag:         tip
   |  parent:      32:d06dffa21a31
@@ -1154,7 +1153,7 @@
   |  date:        Thu Jan 01 00:00:34 1970 +0000
   |  summary:     (34) head
   |
-  $ hg glog -l1 repo/missing
+  $ hg log -G -l1 repo/missing
 
 #endif
 
@@ -1169,7 +1168,7 @@
   $ hg commit -mtwo
   $ echo more >two
   $ hg commit -mmore
-  $ hg glog two
+  $ hg log -G two
   @  changeset:   2:12c28321755b
   |  tag:         tip
   |  user:        test
@@ -1183,14 +1182,14 @@
   |
 
 Issue1896: File log with explicit style
-  $ hg glog --style=default one
+  $ hg log -G --style=default one
   o  changeset:   0:3d578b4a1f53
      user:        test
      date:        Thu Jan 01 00:00:00 1970 +0000
      summary:     one
   
 Issue2395: glog --style header and footer
-  $ hg glog --style=xml one
+  $ hg log -G --style=xml one
   <?xml version="1.0"?>
   <log>
   o  <logentry revision="0" node="3d578b4a1f537d5fcf7301bfa9c0b97adfaa6fb1">
@@ -1276,7 +1275,7 @@
   $ cd repo
   $ touch b
   $ hg ci -Aqm0
-  $ hg glog -l2 a
+  $ hg log -G -l2 a
   o  changeset:   34:fea3ac5810e0
   |  parent:      32:d06dffa21a31
   |  user:        test
@@ -1291,7 +1290,7 @@
   | |
 
 File + limit + -ra:b, (b - a) < limit:
-  $ hg glog -l3000 -r32:tip a
+  $ hg log -G -l3000 -r32:tip a
   o  changeset:   34:fea3ac5810e0
   |  parent:      32:d06dffa21a31
   |  user:        test
@@ -1314,7 +1313,7 @@
 
 Point out a common and an uncommon unshown parent
 
-  $ hg glog -r 'rev(8) or rev(9)'
+  $ hg log -G -r 'rev(8) or rev(9)'
   o    changeset:   9:7010c0af0a35
   |\   parent:      7:b632bb1b1224
   | |  parent:      8:7a0b11f71937
@@ -1332,7 +1331,7 @@
 
 File + limit + -ra:b, b < tip:
 
-  $ hg glog -l1 -r32:34 a
+  $ hg log -G -l1 -r32:34 a
   o  changeset:   34:fea3ac5810e0
   |  parent:      32:d06dffa21a31
   |  user:        test
@@ -1342,7 +1341,7 @@
 
 file(File) + limit + -ra:b, b < tip:
 
-  $ hg glog -l1 -r32:34 -r 'file("a")'
+  $ hg log -G -l1 -r32:34 -r 'file("a")'
   o  changeset:   34:fea3ac5810e0
   |  parent:      32:d06dffa21a31
   |  user:        test
@@ -1352,7 +1351,7 @@
 
 limit(file(File) and a::b), b < tip:
 
-  $ hg glog -r 'limit(file("a") and 32::34, 1)'
+  $ hg log -G -r 'limit(file("a") and 32::34, 1)'
   o    changeset:   32:d06dffa21a31
   |\   parent:      27:886ed638191b
   | |  parent:      31:621d83e11f67
@@ -1363,11 +1362,11 @@
 
 File + limit + -ra:b, b < tip:
 
-  $ hg glog -r 'limit(file("a") and 34::32, 1)'
+  $ hg log -G -r 'limit(file("a") and 34::32, 1)'
 
 File + limit + -ra:b, b < tip, (b - a) < limit:
 
-  $ hg glog -l10 -r33:34 a
+  $ hg log -G -l10 -r33:34 a
   o  changeset:   34:fea3ac5810e0
   |  parent:      32:d06dffa21a31
   |  user:        test
@@ -1387,7 +1386,7 @@
   marked working directory as branch branch
   (branches are permanent and global, did you want a bookmark?)
   $ commit 36 "buggy merge: identical parents" 35 35
-  $ hg glog -l5
+  $ hg log -G -l5
   @  changeset:   36:08a19a744424
   |  branch:      branch
   |  tag:         tip
@@ -1561,7 +1560,7 @@
   $ hg ci -m "mv a b; add d"
   $ hg mv dir/b e
   $ hg ci -m "mv dir/b e"
-  $ hg glog --template '({rev}) {desc|firstline}\n'
+  $ hg log -G --template '({rev}) {desc|firstline}\n'
   @  (4) mv dir/b e
   |
   o  (3) mv a b; add d
@@ -2058,7 +2057,7 @@
   $ testlog --hidden
   []
   []
-  $ hg glog --template '{rev} {desc}\n'
+  $ hg log -G --template '{rev} {desc}\n'
   o  7 Added tag foo-bar for changeset fc281d8ff18d
   |
   o    6 merge 5 and 4
@@ -2078,7 +2077,7 @@
 
 A template without trailing newline should do something sane
 
-  $ hg glog -r ::2 --template '{rev} {desc}'
+  $ hg log -G -r ::2 --template '{rev} {desc}'
   o  2 mv b dir/b
   |
   o  1 copy a b
@@ -2088,7 +2087,7 @@
 
 Extra newlines must be preserved
 
-  $ hg glog -r ::2 --template '\n{rev} {desc}\n\n'
+  $ hg log -G -r ::2 --template '\n{rev} {desc}\n\n'
   o
   |  2 mv b dir/b
   |
@@ -2101,7 +2100,7 @@
 
 The almost-empty template should do something sane too ...
 
-  $ hg glog -r ::2 --template '\n'
+  $ hg log -G -r ::2 --template '\n'
   o
   |
   o
@@ -2111,12 +2110,12 @@
 
 issue3772
 
-  $ hg glog -r :null
+  $ hg log -G -r :null
   o  changeset:   -1:000000000000
      user:
      date:        Thu Jan 01 00:00:00 1970 +0000
   
-  $ hg glog -r null:null
+  $ hg log -G -r null:null
   o  changeset:   -1:000000000000
      user:
      date:        Thu Jan 01 00:00:00 1970 +0000
--- a/tests/test-graft.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-graft.t	Wed Jan 01 18:28:40 2014 -0500
@@ -25,7 +25,7 @@
   $ hg phase --public 3
   $ hg phase --force --secret 6
 
-  $ hg --config extensions.graphlog= log -G --template '{author}@{rev}.{phase}: {desc}\n'
+  $ hg log -G --template '{author}@{rev}.{phase}: {desc}\n'
   @    test@6.secret: 6
   |\
   | o  test@5.draft: 5
@@ -249,7 +249,7 @@
 
 View graph:
 
-  $ hg --config extensions.graphlog= log -G --template '{author}@{rev}.{phase}: {desc}\n'
+  $ hg log -G --template '{author}@{rev}.{phase}: {desc}\n'
   @  test@11.draft: 3
   |
   o  test@10.draft: 4
--- a/tests/test-hardlinks.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-hardlinks.t	Wed Jan 01 18:28:40 2014 -0500
@@ -196,7 +196,7 @@
   $ nlinksdir r4
   2 r4/.hg/00changelog.i
   2 r4/.hg/branch
-  2 r4/.hg/cache/branchheads-served
+  2 r4/.hg/cache/branch2-served
   2 r4/.hg/dirstate
   2 r4/.hg/hgrc
   2 r4/.hg/last-message.txt
@@ -226,7 +226,7 @@
   $ nlinksdir r4
   2 r4/.hg/00changelog.i
   1 r4/.hg/branch
-  2 r4/.hg/cache/branchheads-served
+  2 r4/.hg/cache/branch2-served
   1 r4/.hg/dirstate
   2 r4/.hg/hgrc
   2 r4/.hg/last-message.txt
--- a/tests/test-histedit-bookmark-motion.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-histedit-bookmark-motion.t	Wed Jan 01 18:28:40 2014 -0500
@@ -2,7 +2,6 @@
 
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
-  > graphlog=
   > histedit=
   > EOF
 
--- a/tests/test-histedit-commute.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-histedit-commute.t	Wed Jan 01 18:28:40 2014 -0500
@@ -2,7 +2,6 @@
 
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
-  > graphlog=
   > histedit=
   > EOF
 
--- a/tests/test-histedit-drop.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-histedit-drop.t	Wed Jan 01 18:28:40 2014 -0500
@@ -2,7 +2,6 @@
 
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
-  > graphlog=
   > histedit=
   > EOF
 
--- a/tests/test-histedit-edit.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-histedit-edit.t	Wed Jan 01 18:28:40 2014 -0500
@@ -2,7 +2,6 @@
 
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
-  > graphlog=
   > histedit=
   > EOF
 
--- a/tests/test-histedit-fold-non-commute.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-histedit-fold-non-commute.t	Wed Jan 01 18:28:40 2014 -0500
@@ -2,7 +2,6 @@
 
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
-  > graphlog=
   > histedit=
   > EOF
 
--- a/tests/test-histedit-fold.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-histedit-fold.t	Wed Jan 01 18:28:40 2014 -0500
@@ -14,7 +14,6 @@
   > [alias]
   > logt = log --template '{rev}:{node|short} {desc|firstline}\n'
   > [extensions]
-  > graphlog=
   > histedit=
   > EOF
 
--- a/tests/test-histedit-no-change.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-histedit-no-change.t	Wed Jan 01 18:28:40 2014 -0500
@@ -5,7 +5,6 @@
 
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
-  > graphlog=
   > histedit=
   > EOF
 
@@ -64,7 +63,7 @@
   > {
   >     comment="${1:-log}"
   >     echo % "${comment}"
-  >     hg glog --template '{rev} {node} \"{desc|firstline}\"\n'
+  >     hg log -G --template '{rev} {node} \"{desc|firstline}\"\n'
   > }
 
 
--- a/tests/test-histedit-non-commute-abort.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-histedit-non-commute-abort.t	Wed Jan 01 18:28:40 2014 -0500
@@ -2,7 +2,6 @@
 
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
-  > graphlog=
   > histedit=
   > EOF
 
--- a/tests/test-histedit-non-commute.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-histedit-non-commute.t	Wed Jan 01 18:28:40 2014 -0500
@@ -2,7 +2,6 @@
 
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
-  > graphlog=
   > histedit=
   > EOF
 
--- a/tests/test-histedit-outgoing.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-histedit-outgoing.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,6 +1,5 @@
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
-  > graphlog=
   > histedit=
   > EOF
 
--- a/tests/test-impexp-branch.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-impexp-branch.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,5 +1,5 @@
   $ echo '[extensions]' >> $HGRCPATH
-  $ echo 'mq =' >> $HGRCPATH
+  $ echo 'strip =' >> $HGRCPATH
 
   $ cat >findbranch.py <<EOF
   > import re, sys
--- a/tests/test-import-bypass.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-import-bypass.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,9 +1,8 @@
   $ echo "[extensions]" >> $HGRCPATH
   $ echo "purge=" >> $HGRCPATH
-  $ echo "graphlog=" >> $HGRCPATH
 
   $ shortlog() {
-  >     hg glog --template '{rev}:{node|short} {author} {date|hgdate} - {branch} - {desc|firstline}\n'
+  >     hg log -G --template '{rev}:{node|short} {author} {date|hgdate} - {branch} - {desc|firstline}\n'
   > }
 
 Test --bypass with other options
--- a/tests/test-import-git.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-import-git.t	Wed Jan 01 18:28:40 2014 -0500
@@ -320,6 +320,118 @@
   045c85ba38952325e126c70962cc0f9d9077bc67 644   mbinary1
   a874b471193996e7cb034bb301cac7bdaf3e3f46 644   mbinary2
 
+Binary file and delta hunk (we build the patch using this sed hack to
+avoid an unquoted ^, which check-code says breaks sh on solaris):
+
+  $ sed 's/ caret /^/g;s/ dollarparen /$(/g' > quote-hack.patch <<'EOF'
+  > diff --git a/delta b/delta
+  > new file mode 100644
+  > index 0000000000000000000000000000000000000000..8c9b7831b231c2600843e303e66b521353a200b3
+  > GIT binary patch
+  > literal 3749
+  > zcmV;W4qEYvP)<h;3K|Lk000e1NJLTq006iE002D*0ssI2kt{U(0000PbVXQnQ*UN;
+  > zcVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBU=M@d9MRCwC#oC!>o#}>x{(W-y~UN*tK
+  > z%A%sxiUy2Ys)0Vm#ueArYKoYqX;GuiqZpgirM6nCVoYk?YNAz3G~z;BZ~@~&OQEe4
+  > zmGvS5isFJI;Pd_7J+EKxyHZeu` caret t4r2>F;h-+VK3{_{WoGv8dSpFDYDrA%3UX03pt
+  > zOaVoi0*W#P6lDr1$`nwPDWE7*rhuYM0Y#YtiZTThWeO<D6i}2YpqR<%$s>bRRaI42
+  > zS3iFIxJ8Q=EnBv1Z7?pBw_bLjJb3V+tgP(Tty_2R-mR#p04x78n2n7MSOFyt4i1iv
+  > zjxH`PPEJmgD7U?IK&h;(EGQ@_DJc<@01=4fiNXHcKZ8LhZQ8T}E3U4tUS3}OrcgQW
+  > zWdX{K8#l7Ev&#$ysR)G#0*rC+<WGZ3?CtG4bm-ve>Dj$|_qJ`@D*stNP_AFUe&x!Q
+  > zJ9q9B7Z=ym)MyZ?Tg1ROunUYr81nV?B@!tYS~5_|%gfW#(_s<4UN1!Q?Dv8d>g#m6
+  > z%*@R2@bI2JdnzxQ!EDU`$eQY!tgI~Zn$prz;gaXNod5*5p(1Bz=P$qfvZ$y?dC@X~
+  > zlAD+NAKhB{=;6bMwzjqn>9mavvKOGd`s%A+fBiL>Q;xJWpa72C+}u{JTHUX>{~}Qj
+  > zUb%hyHgN~c?cBLjInvUALMD9g-aXt54ZL8AOCvXL-V6!~ijR*kEG$&Mv?!pE61OlI
+  > z8nzMSPE8F7bH|Py*RNl1VUCggq<V)>@_6gkEeiz7{rmTeuNTW6+KVS#0FG%IHf-3L
+  > zGiS21vn>WCCr+GLx caret !uNetzB6u3o(w6&1C2?_LW8ij$+$sZ*zZ`|US3H@8N~%&V%Z
+  > zAeA0HdhFS=$6|nzn3%YH`SN<>DQRO;Qc caret )dfdvA caret 5u`Xf;Zzu<ZQHgG?28V-#s<;T
+  > zzkh#LA)v7gpoE5ou3o*GoUUF%b#iht&kl9d0)><$FE1}ACr68;uCA`6DrGmz_U+rp
+  > zL>Rx;X_yhk$fP_yJrTCQ|NgsW0A<985g&c@k-NKly<>mgU8n||ZPPV<`SN8#%$+-T
+  > zfP$T!ou8jypFVwnzqhxyUvIxXd-wF~*U!ht=hCH1wzjqn9x#)IrhDa;S0JbK caret z_$W
+  > zd(8rX@;7|t*;GJ5h$SZ{v(}+UBEs$4w~?{@9%`_Z<P<kox5bMWuUWH(sF9hONgd$Q
+  > zunCgwT@1|CU9+;X caret 4z&|M~@yw23Ay50NFWn=FqF%yLZEUty;AT2??1oV@B)Nt))J7
+  > zh>{5j2@f7T=-an%L_`E)h;mZ4D_5>?7tjQtVPRo2XU-&;mX(!l-MSTJP4XWY82JAC
+  > z@57+y&!1=P{Mn{W8)-HzEsgAtd63}Cazc>O6vGb>51%@9DzbyI3?4j~$ijmT95_IS
+  > zS#r!LCDW%*4-O7CGnkr$xXR1RQ&UrA<CQt} caret 73NL%zk`)Jk!yxUAt-1r}ggLn-Zq}
+  > z*s){8pw68;i+kiG%CpBKYSJLLFyq&*U8}qDp+kpe&6<Vp(Z58%l#~>ZK?&s7y?b}i
+  > zuwcOgO%x-27A;y785zknl_{sU;E6v$8{pWmVS{KaJPpu`i;HP$#flY@u~Ua~K3%tN
+  > z-LhrNh{9SoHgDd%WXTc$$~Dq{?AWou3!H&?V8K{ caret {P9Ot5vecD?%1&-E-ntBFj87(
+  > zy5`QE%QRX7qcHC%1{Ua}M~}L6=`wQUNEQ=I;qc+ZMMXtK2T+0os;jEco;}OV9z1w3
+  > zARqv caret bm-85xnRCng3OT|MyVSmR3ND7 caret ?KaQGG! caret (aTbo1N;Nz;X3Q9FJbwK6`0?Yp
+  > zj*X2ac;Pw3!I2|JShDaF>-gJmzm1NLj){rk&o|$E caret WAsfrK=x&@B!`w7Hik81sPz4
+  > zuJTaiCppM>-+c!wPzcUw)5@?J4U-u|pJ~xbWUe-C+60k caret 7>9!)56DbjmA~`OJJ40v
+  > zu3hCA7eJXZWeN|1iJLu87$;+fS8+Kq6O`aT)*_x@sY#t7LxwoEcVw*)cWhhQW@l%!
+  > z{#Z=y+qcK@%z{p*D=8_Fcg278AnH3fI5;~yGu?9TscxXaaP*4$f<LIv! caret 5Lfr%vKg
+  > zpxmunH#%=+ICMvZA~wyNH%~eMl!-g caret R!cYJ#WmLq5N8viz#J%%LPtkO?V)tZ81cp>
+  > z{ALK?fNPePmd;289&M8Q3>YwgZX5GcGY&n>K1<x)!`;Qjg&}bb!Lrnl@xH#kS~VYE
+  > zpJmIJO`A3iy+Y3X`k>cY-@}Iw2Onq`=!ba3eATgs3yg3Wej=+P-Z8WF#w=RXvS@J3
+  > zEyhVTj-gO?kfDu1g9afo<RkPrYzG#_yF41IFxF%Ylg>9lx6<clPweR-b7Hn+r)e1l
+  > zO6c6FbNt@;;*w$z;N|H>h{czme)_4V6UC4hv**kX2@L caret Bgds dollarparen &P7M4dhfmWe)!=B
+  > zR3X=Y{P9N}p@-##@1ZNW1YbVaiP~D@8m&<dzEP&cO|87Ju#j*=;wH~Exr>i*Hpp&@
+  > z`9!Sj+O;byD~s8qZ>6QB8uv7Bpn&&?xe;;e<M4F8KEID&pT7QmqoSgq&06adp5T=U
+  > z6DH*4=AB7C1D9Amu?ia-wtxSAlmTEO96XHx)-+rKP;ip$pukuSJGW3P1aUmc2yo%)
+  > z&<t3F>d1X+1qzaag-%x+eKHx{?Afz3GBQSw9u0lw<mB+I#v11TKRpKWQS+lvVL7=u
+  > zHr6)1ynEF<i3kO6A8&ppPMo-F=PnWfXkSj@i*7J6C<F}wR?s(O0niC?t+6;+k}pPq
+  > zrok&TPU40rL0ZYDwenNrrmPZ`gjo@DEF`7 caret cKP||pUr;+r)hyn9O37=xA`3%Bj-ih
+  > z+1usk<%5G-y+R?tA`qY=)6&vNjL{P?QzHg%P%>`ZxP=QB%DHY6L26?36V_p caret {}n$q
+  > z3@9W=KmGI*Ng_Q#AzA%-z|Z caret |#oW(hkfgpuS$RKRhlrarX%efMMCs}GLChec5+y{6
+  > z1Qnxim_C-fmQuaAK_NUHUBV&;1c0V)wji<RcdZ*aAWTwyt>hVnlt caret asFCe0&a@tqp
+  > zEEy;$L}D$X6)wfQNl8gu6Z>oB3_RrP=gTyK2@@w#LbQfLNHj>Q&z(C5wUFhK+}0aV
+  > zSohlc=7K+spN<ctf}5KgKqNyJDNP9;LZd)nTE=9|6Xdr9%Hzk63-tL2c9FD*rsyYY
+  > z!}t+Yljq7-p$X;4_YL?6d;mdY3R##o1e%rlPxrsMh8|;sKTr~ caret QD#sw3&vS$FwlTk
+  > zp1#Gw!Qo-$LtvpXt#ApV0g) caret F=qFB`VB!W297x=$mr<$>rco3v$QKih_xN!k6;M=@
+  > zCr?gDNQj7tm@;JwD;Ty&NlBSCYZk(b3dZeN8D4h2{r20dSFc7;(>E&r`s=TVtzpB4
+  > zk+ caret N&zCAiRns(?p6iBlk9v&h{1ve(FNtc)td51M>)TkXhc6{>5C)`fS$&)A1*CP1%
+  > zld+peue4aYbg3C0!+4mu+}vE caret j_feX+ZijvffBI7Ofh#RZ*U3<3J5(+nfRCzexqQ5
+  > zgM&##Y4Dd{e%ZKjqrbm@|Ni}l4jo!AqtFynj3Xsd$o caret ?yV4$|UQ(j&UWCH>M=o_&N
+  > zmclXc3i|Q#<;#EoG>~V}4unTHbUK}u=y4;rA3S&vzC3 caret aJP!&D4RvvGfoyo(>C>la
+  > zijP<=v>X{3Ne&2BXo}DV8l0V-jdv`$am0ubG{Wuh%CTd|l9Q7m;G&|U@#Dvbhlj(d
+  > zg6W{3ATxYt#T?)3;SmIgOP4M|Dki~I_TX7SxP0x}wI~DQI7Lhm2BI7gph(aPIFAd;
+  > zQ&UsF`Q{rOz+z=87c5v%@5u~d6dWV5OlX`oH3cAH&UlvsZUEo(Q(P|lKs17rXvaiU
+  > zQcj}IEufi1+Bnh6&(EhF{7O3vLHp`jjlp0J<M1kh$+$2xGm~Zk7OY7(q=&Rdhq*RG
+  > zwrmcd5MnP}xByB_)P@{J>DR9x6;`cUwPM8z){yooNiXPOc9_{W-gtwxE5TUg0vJk6
+  > zO#JGruV&1cL6VGK2?+_YQr4`+EY8;Sm$9U$uuGRN=uj3k7?O9b+R~J7t_y*K64ZnI
+  > zM+{aE<b(v?vSmw;9zFP!aE266zHIhlmdI@ caret xa6o2jwdRk54a$>pcRbC29ZyG!Cfdp
+  > zutFf`Q`vljgo!(wHf=)F#m2_MIuj;L(2ja2YsQRX+rswV{d<H`Ar;(@%aNa9VPU8Z
+  > z;tq*`y}dm#NDJHKlV}uTIm!_vAq5E7!X-p{P=Z=Sh668>PuVS1*6e}OwOiMc;u3OQ
+  > z@Bs)w3=lzfKoufH$SFuPG@uZ4NOnM#+=8LnQ2Q4zUd+nM+OT26;lqbN{P07dhH{jH
+  > zManE8 caret dLms-Q2;1kB<*Q1a3f8kZr;xX=!Qro@`~@xN*Qj>gx;i;0Z24!~i2uLb`}v
+  > zA?R$|wvC+m caret Ups=*(4lDh*=UN8{5h(A?p#D caret 2N$8u4Z55!q?ZAh(iEEng9_Zi>IgO
+  > z#~**JC8hE4@n{hO&8btT5F*?nC_%LhA3i)PDhh-pB_&1wGrDIl caret *=8x3n&;akBf caret -
+  > zJd&86kq$%%907v caret tgWoQdwI`|oNK%VvU~S#C<o caret F?6c48?Cjj#-4P<>HFD%&|Ni~t
+  > zKJ(|#H`$<5W+6ZkBb213rXonKZLB+X> caret L}J@W6osP3piLD_5?R!`S}*{xLBzFiL4@
+  > zX+}l{`A%?f@T5tT%ztu60p;)be`fWC`tP@WpO=?cpf8Xuf1OSj6d3f@Ki(ovDYq%0
+  > z{4ZSe`kOay5@=lAT!}vFzxyemC{sXDrhuYM0Y#ZI1r%ipD9W11{w=@&xgJ}t2x;ep
+  > P00000NkvXXu0mjfZ5|Er
+  > 
+  > literal 0
+  > HcmV?d00001
+  > 
+  > EOF
+  $ hg import -d "1000000 0" -m delta quote-hack.patch
+  applying quote-hack.patch
+  $ rm quote-hack.patch
+
+  $ hg manifest --debug | grep delta
+  9600f98bb60ce732634d126aaa4ac1ec959c573e 644   delta
+
+  $ hg import -d "1000000 0" -m delta - <<'EOF'
+  > diff --git a/delta b/delta
+  > index 8c9b7831b231c2600843e303e66b521353a200b3..0021dd95bc0dba53c39ce81377126d43731d68df 100644
+  > GIT binary patch
+  > delta 49
+  > zcmZ1~yHs|=21Z8J$r~9bFdA-lVv=EEw4WT$qRf2QSa5SIOAHI6(&k4T8H|kLo4vWB
+  > FSO9ZT4bA`n
+  > 
+  > delta 49
+  > zcmV-10M7rV9i<(xumJ(}ld%Di0Xefm0vrMXpOaq%BLm9I%d>?9Tm%6Vv*HM70RcC&
+  > HOA1;9yU-AD
+  > 
+  > EOF
+  applying patch from stdin
+
+  $ hg manifest --debug | grep delta
+  56094bbea136dcf8dbd4088f6af469bde1a98b75 644   delta
+
 Filenames with spaces:
 
   $ sed 's,EOL$,,g' <<EOF | hg import -d "1000000 0" -m spaces -
@@ -334,7 +446,7 @@
   applying patch from stdin
 
   $ hg tip -q
-  12:47500ce1614e
+  14:4b79479c9a6d
 
   $ cat "foo bar"
   foo
@@ -357,7 +469,7 @@
   applying patch from stdin
 
   $ hg tip -q
-  13:6757efb07ea9
+  15:9cbe44af4ae9
 
   $ cat foo3
   foo
@@ -392,8 +504,8 @@
 Invalid base85 content
 
   $ hg rollback
-  repository tip rolled back to revision 14 (undo import)
-  working directory now based on revision 14
+  repository tip rolled back to revision 16 (undo import)
+  working directory now based on revision 16
   $ hg revert -aq
   $ hg import -d "1000000 0" -m invalid-binary - <<"EOF"
   > diff --git a/text2 b/binary2
--- a/tests/test-inherit-mode.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-inherit-mode.t	Wed Jan 01 18:28:40 2014 -0500
@@ -66,7 +66,7 @@
   00700 ./.hg/
   00600 ./.hg/00changelog.i
   00770 ./.hg/cache/
-  00660 ./.hg/cache/branchheads-served
+  00660 ./.hg/cache/branch2-served
   00660 ./.hg/dirstate
   00660 ./.hg/last-message.txt
   00600 ./.hg/requires
@@ -111,7 +111,7 @@
   00770 ../push/.hg/
   00660 ../push/.hg/00changelog.i
   00770 ../push/.hg/cache/
-  00660 ../push/.hg/cache/branchheads-base
+  00660 ../push/.hg/cache/branch2-base
   00660 ../push/.hg/requires
   00770 ../push/.hg/store/
   00660 ../push/.hg/store/00changelog.i
--- a/tests/test-init.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-init.t	Wed Jan 01 18:28:40 2014 -0500
@@ -26,6 +26,31 @@
   $ hg ci --cwd local -A -m "init"
   adding foo
 
+test custom revlog chunk cache sizes
+
+  $ hg --config format.chunkcachesize=0 log -R local -pv
+  abort: revlog chunk cache size 0 is not greater than 0!
+  [255]
+  $ hg --config format.chunkcachesize=1023 log -R local -pv
+  abort: revlog chunk cache size 1023 is not a power of 2!
+  [255]
+  $ hg --config format.chunkcachesize=1024 log -R local -pv
+  changeset:   0:08b9e9f63b32
+  tag:         tip
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  files:       foo
+  description:
+  init
+  
+  
+  diff -r 000000000000 -r 08b9e9f63b32 foo
+  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/foo	Thu Jan 01 00:00:00 1970 +0000
+  @@ -0,0 +1,1 @@
+  +this
+  
+
 creating repo with format.usestore=false
 
   $ hg --config format.usestore=false init old
--- a/tests/test-journal-exists.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-journal-exists.t	Wed Jan 01 18:28:40 2014 -0500
@@ -22,7 +22,7 @@
 
 Check that zero-size journals are correctly aborted:
 
-#if unix-permissions
+#if unix-permissions no-root
   $ hg bundle -qa repo.hg
   $ chmod -w foo/.hg/store/00changelog.i
 
--- a/tests/test-largefiles.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-largefiles.t	Wed Jan 01 18:28:40 2014 -0500
@@ -2256,7 +2256,7 @@
   > largefiles=
   > EOF
   $ hg -R enabledlocally root
-  $TESTTMP/individualenabling/enabledlocally
+  $TESTTMP/individualenabling/enabledlocally (glob)
   $ hg -R notenabledlocally root
   abort: unknown repository format: requires features 'largefiles' (upgrade Mercurial)!
   [255]
--- a/tests/test-lfconvert.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-lfconvert.t	Wed Jan 01 18:28:40 2014 -0500
@@ -4,8 +4,7 @@
   > [extensions]
   > largefiles =
   > share =
-  > graphlog =
-  > mq =
+  > strip =
   > convert =
   > [largefiles]
   > minsize = 0.5
@@ -134,7 +133,7 @@
   $ hg cat -r . sub/maybelarge.dat > stuff/maybelarge.dat
   $ hg resolve -m stuff/maybelarge.dat
   $ hg commit -m"merge"
-  $ hg glog --template "{rev}:{node|short}  {desc|firstline}\n"
+  $ hg log -G --template "{rev}:{node|short}  {desc|firstline}\n"
   @    5:4884f215abda  merge
   |\
   | o  4:7285f817b77e  remove large, normal3
@@ -154,7 +153,7 @@
   $ hg lfconvert --size 0.2 bigfile-repo largefiles-repo
   initializing destination largefiles-repo
   $ cd largefiles-repo
-  $ hg glog --template "{rev}:{node|short}  {desc|firstline}\n"
+  $ hg log -G --template "{rev}:{node|short}  {desc|firstline}\n"
   o    5:8e05f5f2b77e  merge
   |\
   | o  4:a5a02de7a8e4  remove large, normal3
@@ -248,7 +247,7 @@
 # "hg remove" + "hg merge" + "hg commit".
 #  $ hg -R ../bigfile-repo debugdata -c 5
 #  $ hg debugdata -c 5
-  $ hg glog --template "{rev}:{node|short}  {desc|firstline}\n"
+  $ hg log -G --template "{rev}:{node|short}  {desc|firstline}\n"
   o  6:1635824e6f59  add anotherlarge (should be a largefile)
   |
   o    5:7215f8deeaaf  merge
@@ -292,7 +291,7 @@
   1 merge
   0 add anotherlarge (should be a largefile)
 
-  $ hg -R largefiles-repo-hg glog --template "{rev}:{node|short}  {desc|firstline}\n"
+  $ hg -R largefiles-repo-hg log -G --template "{rev}:{node|short}  {desc|firstline}\n"
   o  6:17126745edfd  add anotherlarge (should be a largefile)
   |
   o    5:9cc5aa7204f0  merge
--- a/tests/test-lock-badness.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-lock-badness.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,5 +1,4 @@
-  $ "$TESTDIR/hghave" unix-permissions || exit 80
-
+#if unix-permissions no-root
   $ hg init a
   $ echo a > a/a
   $ hg -R a ci -A -m a
@@ -21,4 +20,4 @@
   [255]
 
   $ chmod 700 a/.hg/store
-
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-module-imports.t	Wed Jan 01 18:28:40 2014 -0500
@@ -0,0 +1,39 @@
+This code uses the ast module, which was new in 2.6, so we'll skip
+this test on anything earlier.
+  $ python -c 'import sys ; assert sys.version_info >= (2, 6)' || exit 80
+
+  $ import_checker="$TESTDIR"/../contrib/import-checker.py
+Run the doctests from the import checker, and make sure
+it's working correctly.
+  $ TERM=dumb
+  $ export TERM
+  $ python -m doctest $import_checker
+
+  $ cd "$TESTDIR"/..
+  $ if hg identify -q > /dev/null 2>&1; then :
+  > else
+  >     echo "skipped: not a Mercurial working dir" >&2
+  >     exit 80
+  > fi
+
+There are a handful of cases here that require renaming a module so it
+doesn't overlap with a stdlib module name. There are also some cycles
+here that we should still endeavor to fix, and some cycles will be
+hidden by deduplication algorithm in the cycle detector, so fixing
+these may expose other cycles.
+
+  $ hg locate 'mercurial/**.py' | xargs python "$import_checker"
+  mercurial/dispatch.py mixed stdlib and relative imports:
+     commands, error, extensions, fancyopts, hg, hook, util
+  mercurial/fileset.py mixed stdlib and relative imports:
+     error, merge, parser, util
+  mercurial/revset.py mixed stdlib and relative imports:
+     discovery, error, hbisect, parser, phases, util
+  mercurial/templater.py mixed stdlib and relative imports:
+     config, error, parser, templatefilters, util
+  mercurial/ui.py mixed stdlib and relative imports:
+     config, error, formatter, scmutil, util
+  Import cycle: mercurial.cmdutil -> mercurial.subrepo -> mercurial.cmdutil
+  Import cycle: mercurial.repoview -> mercurial.revset -> mercurial.repoview
+  Import cycle: mercurial.fileset -> mercurial.merge -> mercurial.subrepo -> mercurial.match -> mercurial.fileset
+  Import cycle: mercurial.filemerge -> mercurial.match -> mercurial.fileset -> mercurial.merge -> mercurial.filemerge
--- a/tests/test-mq-qpush-exact.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-mq-qpush-exact.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,6 +1,5 @@
   $ echo "[extensions]" >> $HGRCPATH
   $ echo "mq=" >> $HGRCPATH
-  $ echo "graphlog=" >> $HGRCPATH
 
 make a test repository that looks like this:
 
--- a/tests/test-mq-safety.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-mq-safety.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,6 +1,5 @@
   $ echo '[extensions]' >> $HGRCPATH
   $ echo 'hgext.mq =' >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
 
   $ hg init repo
   $ cd repo
--- a/tests/test-newbranch.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-newbranch.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,13 +1,13 @@
-  $ branchcache=.hg/cache/branchheads
+  $ branchcache=.hg/cache/branch2
 
   $ listbranchcaches() {
-  >    for f in .hg/cache/branchheads*;
+  >    for f in .hg/cache/branch2*;
   >       do echo === $f ===;
   >       cat $f;
   >     done;
   > }
   $ purgebranchcaches() {
-  >     rm .hg/cache/branchheads*
+  >     rm .hg/cache/branch2*
   > }
 
   $ hg init t
@@ -158,13 +158,13 @@
   4:adf1a74a7f7b
 
   $ listbranchcaches
-  === .hg/cache/branchheads ===
+  === .hg/cache/branch2 ===
   corrupted
-  === .hg/cache/branchheads-served ===
+  === .hg/cache/branch2-served ===
   adf1a74a7f7b4cd193d12992f5d0d6a004ed21d6 4
-  c21617b13b220988e7a2e26290fbe4325ffa7139 bar
-  1c28f494dae69a2f8fc815059d257eccf3fcfe75 default
-  adf1a74a7f7b4cd193d12992f5d0d6a004ed21d6 foo
+  c21617b13b220988e7a2e26290fbe4325ffa7139 o bar
+  1c28f494dae69a2f8fc815059d257eccf3fcfe75 o default
+  adf1a74a7f7b4cd193d12992f5d0d6a004ed21d6 o foo
 
 Push should update the branch cache:
 
@@ -175,20 +175,20 @@
   $ hg push -qr 0 ../target
 
   $ (cd ../target/; listbranchcaches)
-  === .hg/cache/branchheads-base ===
+  === .hg/cache/branch2-base ===
   db01e8ea3388fd3c7c94e1436ea2bd6a53d581c5 0
-  db01e8ea3388fd3c7c94e1436ea2bd6a53d581c5 default
+  db01e8ea3388fd3c7c94e1436ea2bd6a53d581c5 o default
 
 Pushing everything:
 
   $ hg push -qf ../target
 
   $ (cd ../target/; listbranchcaches)
-  === .hg/cache/branchheads-base ===
+  === .hg/cache/branch2-base ===
   adf1a74a7f7b4cd193d12992f5d0d6a004ed21d6 4
-  c21617b13b220988e7a2e26290fbe4325ffa7139 bar
-  1c28f494dae69a2f8fc815059d257eccf3fcfe75 default
-  adf1a74a7f7b4cd193d12992f5d0d6a004ed21d6 foo
+  c21617b13b220988e7a2e26290fbe4325ffa7139 o bar
+  1c28f494dae69a2f8fc815059d257eccf3fcfe75 o default
+  adf1a74a7f7b4cd193d12992f5d0d6a004ed21d6 o foo
 
 Update with no arguments: tipmost revision of the current branch:
 
--- a/tests/test-obsolete-checkheads.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-obsolete-checkheads.t	Wed Jan 01 18:28:40 2014 -0500
@@ -10,9 +10,8 @@
   > [ui]
   > logtemplate='{node|short} ({phase}) {desc|firstline}\n'
   > [extensions]
-  > graphlog=
+  > obs=${TESTTMP}/obs.py
   > EOF
-  $ echo "obs=${TESTTMP}/obs.py" >> $HGRCPATH
   $ mkcommit() {
   >    echo "$1" > "$1"
   >    hg add "$1"
@@ -52,7 +51,7 @@
   $ mkcommit new
   created new head
   $ hg debugobsolete --flags 1 `getid old` `getid new`
-  $ hg glog --hidden
+  $ hg log -G --hidden
   @  71e3228bffe1 (draft) add new
   |
   | x  c70b08862e08 (draft) add old
@@ -84,7 +83,7 @@
   pulling from $TESTTMP/remote (glob)
   searching for changes
   no changes found
-  $ hg glog --hidden
+  $ hg log -G --hidden
   @  71e3228bffe1 (draft) add new
   |
   | o  c70b08862e08 (public) add old
@@ -112,7 +111,7 @@
 #   $ cp -r ../backup1 ../remote
 #   $ hg -R ../remote phase --public c70b08862e08
 #   $ hg phase --draft --force c70b08862e08
-#   $ hg glog --hidden
+#   $ hg log -G --hidden
 #   @  71e3228bffe1 (draft) add new
 #   |
 #   | x  c70b08862e08 (draft) add old
@@ -141,7 +140,7 @@
   $ hg up -q '.^'
   $ mkcommit other
   created new head
-  $ hg glog --hidden
+  $ hg log -G --hidden
   @  d7d41ccbd4de (draft) add other
   |
   | o  71e3228bffe1 (draft) add new
@@ -193,7 +192,7 @@
   $ mkcommit desc2
   created new head
   $ hg debugobsolete `getid old` `getid new`
-  $ hg glog --hidden
+  $ hg log -G --hidden
   @  5fe37041cc2b (draft) add desc2
   |
   | o  a3ef1d111c5f (draft) add desc1
@@ -204,7 +203,7 @@
   |/
   o  b4952fcf48cf (public) add base
   
-  $ hg glog --hidden -R ../remote
+  $ hg log -G --hidden -R ../remote
   o  71e3228bffe1 (draft) add new
   |
   | o  c70b08862e08 (draft) add old
@@ -248,12 +247,12 @@
   $ hg  id --debug -r tip
   71e3228bffe1886550777233d6c97bb5a6b2a650 tip
   $ hg debugobsolete c70b08862e0838ea6d7c59c85da2f1ed6c8d67da 71e3228bffe1886550777233d6c97bb5a6b2a650
-  $ hg glog --hidden
+  $ hg log -G --hidden
   @  71e3228bffe1 (draft) add new
   |
   o  b4952fcf48cf (public) add base
   
-  $ hg glog --hidden -R ../remote
+  $ hg log -G --hidden -R ../remote
   o  c70b08862e08 (draft) add old
   |
   @  b4952fcf48cf (public) add base
@@ -261,9 +260,6 @@
 
 Push should not complain about new heads.
 
-It should not complain about "unsynced remote changes!" either but that's not
-handled yet.
-
   $ hg push --traceback
   pushing to $TESTTMP/remote (glob)
   searching for changes
--- a/tests/test-obsolete.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-obsolete.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,6 +1,4 @@
   $ cat >> $HGRCPATH << EOF
-  > [extensions]
-  > graphlog=
   > [phases]
   > # public changeset are not obsolete
   > publish=false
@@ -120,7 +118,7 @@
 
 Check that graphlog detect that a changeset is obsolete:
 
-  $ hg glog
+  $ hg log -G
   @  changeset:   5:5601fb93a350
   |  tag:         tip
   |  parent:      1:7c3bad9141dc
@@ -217,7 +215,7 @@
 Check that public changeset are not accounted as obsolete:
 
   $ hg --hidden phase --public 2
-  $ hg --config 'extensions.graphlog=' glog
+  $ hg log -G
   @  changeset:   5:5601fb93a350
   |  tag:         tip
   |  parent:      1:7c3bad9141dc
@@ -514,7 +512,7 @@
 ---------------------------------------
 
 
-  $ hg glog
+  $ hg log -G
   o  changeset:   3:6f9641995072
   |  tag:         tip
   |  parent:      1:7c3bad9141dc
@@ -548,7 +546,7 @@
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     add original_d
   
-  $ hg glog -r '::unstable()'
+  $ hg log -G -r '::unstable()'
   @  changeset:   5:cda648ca50f5
   |  tag:         tip
   |  user:        test
@@ -653,7 +651,7 @@
 
 Do not warn about new head when the new head is a successors of a remote one
 
-  $ hg glog
+  $ hg log -G
   @  changeset:   5:cda648ca50f5
   |  tag:         tip
   |  user:        test
--- a/tests/test-parseindex2.py	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-parseindex2.py	Wed Jan 01 18:28:40 2014 -0500
@@ -1,11 +1,9 @@
+"""This unit test tests parsers.parse_index2()."""
+
 from mercurial import parsers
 from mercurial.node import nullid, nullrev
 import struct
 
-# This unit test compares the return value of the original Python
-# implementation of parseindex and the new C implementation for
-# an index file with and without inlined data
-
 # original python implementation
 def gettype(q):
     return int(q & 0xFFFF)
@@ -106,6 +104,9 @@
     else:
         print "Expected to get TypeError."
 
+   # Check parsers.parse_index2() on an index file against the original
+   # Python implementation of parseindex, both with and without inlined data.
+
     py_res_1 = py_parseindex(data_inlined, True)
     c_res_1 = parse_index2(data_inlined, True)
 
--- a/tests/test-patchbomb.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-patchbomb.t	Wed Jan 01 18:28:40 2014 -0500
@@ -2127,7 +2127,7 @@
   $ hg ci -md -d '4 0'
   $ echo d >> d
   $ hg ci -mdd -d '5 0'
-  $ hg --config extensions.graphlog= glog --template "{rev}:{node|short} {desc|firstline}\n"
+  $ hg log -G --template "{rev}:{node|short} {desc|firstline}\n"
   @  10:3b6f1ec9dde9 dd
   |
   o  9:2f9fa9b998c5 d
--- a/tests/test-permissions.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-permissions.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,4 +1,4 @@
-  $ "$TESTDIR/hghave" unix-permissions || exit 80
+#ifdef unix-permissions no-root
 
   $ hg init t
   $ cd t
@@ -70,3 +70,5 @@
   $ chmod +rx dir
 
   $ cd ..
+
+#endif
--- a/tests/test-phases-exchange.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-phases-exchange.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,9 +1,5 @@
   $ "$TESTDIR/hghave" killdaemons || exit 80
 
-  $ cat >> $HGRCPATH <<EOF
-  > [extensions]
-  > graphlog=
-  > EOF
   $ hgph() { hg log -G --template "{rev} {phase} {desc} - {node|short}\n" $*; }
 
   $ mkcommit() {
@@ -399,7 +395,7 @@
 
 initial setup
 
-  $ hg glog # of alpha
+  $ hg log -G # of alpha
   o  changeset:   6:145e75495359
   |  tag:         tip
   |  user:        test
@@ -1062,7 +1058,7 @@
   |
   o  0 public a-A - 054250a37db4
   
-#if unix-permissions
+#if unix-permissions no-root
 
 Pushing From an unlockable repo
 --------------------------------
--- a/tests/test-phases.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-phases.t	Wed Jan 01 18:28:40 2014 -0500
@@ -175,28 +175,28 @@
 
 check that branch cache with "served" filter are properly computed and stored
 
-  $ ls ../push-dest/.hg/cache/branchheads*
-  ../push-dest/.hg/cache/branchheads-served
-  $ cat ../push-dest/.hg/cache/branchheads-served
+  $ ls ../push-dest/.hg/cache/branch2*
+  ../push-dest/.hg/cache/branch2-served
+  $ cat ../push-dest/.hg/cache/branch2-served
   6d6770faffce199f1fddd1cf87f6f026138cf061 6 465891ffab3c47a3c23792f7dc84156e19a90722
-  b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e default
-  6d6770faffce199f1fddd1cf87f6f026138cf061 default
+  b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e o default
+  6d6770faffce199f1fddd1cf87f6f026138cf061 o default
   $ hg heads -R ../push-dest --template '{rev}:{node} {phase}\n'  #update visible cache too
   6:6d6770faffce199f1fddd1cf87f6f026138cf061 draft
   5:2713879da13d6eea1ff22b442a5a87cb31a7ce6a secret
   3:b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e draft
-  $ ls ../push-dest/.hg/cache/branchheads*
-  ../push-dest/.hg/cache/branchheads-served
-  ../push-dest/.hg/cache/branchheads-visible
-  $ cat ../push-dest/.hg/cache/branchheads-served
+  $ ls ../push-dest/.hg/cache/branch2*
+  ../push-dest/.hg/cache/branch2-served
+  ../push-dest/.hg/cache/branch2-visible
+  $ cat ../push-dest/.hg/cache/branch2-served
   6d6770faffce199f1fddd1cf87f6f026138cf061 6 465891ffab3c47a3c23792f7dc84156e19a90722
-  b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e default
-  6d6770faffce199f1fddd1cf87f6f026138cf061 default
-  $ cat ../push-dest/.hg/cache/branchheads-visible
+  b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e o default
+  6d6770faffce199f1fddd1cf87f6f026138cf061 o default
+  $ cat ../push-dest/.hg/cache/branch2-visible
   6d6770faffce199f1fddd1cf87f6f026138cf061 6
-  b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e default
-  2713879da13d6eea1ff22b442a5a87cb31a7ce6a default
-  6d6770faffce199f1fddd1cf87f6f026138cf061 default
+  b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e o default
+  2713879da13d6eea1ff22b442a5a87cb31a7ce6a o default
+  6d6770faffce199f1fddd1cf87f6f026138cf061 o default
 
 
 Restore condition prior extra insertion.
@@ -378,10 +378,6 @@
 
 initial picture
 
-  $ cat >> $HGRCPATH << EOF
-  > [extensions]
-  > hgext.graphlog=
-  > EOF
   $ hg log -G --template "{rev} {phase} {desc}\n"
   @    7 secret merge B' and E
   |\
--- a/tests/test-pull-permission.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-pull-permission.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,4 +1,4 @@
-  $ "$TESTDIR/hghave" unix-permissions || exit 80
+#if unix-permissions no-root
 
   $ hg init a
   $ cd a
@@ -30,3 +30,5 @@
   1 files, 1 changesets, 1 total revisions
 
   $ cd ..
+
+#endif
--- a/tests/test-push-warn.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-push-warn.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,6 +1,3 @@
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "graphlog=" >> $HGRCPATH
-
   $ hg init a
   $ cd a
   $ echo foo > t1
@@ -38,8 +35,8 @@
   query 2; still undecided: 1, sample size is: 1
   2 total queries
   listing keys for "bookmarks"
-  new remote heads on branch 'default'
-  new remote head 1e108cc5548c
+  new remote heads on branch 'default':
+   1e108cc5548c
   abort: push creates new remote head 1e108cc5548c!
   (pull and merge or see "hg help push" for details about pushing new heads)
   [255]
@@ -129,9 +126,9 @@
   $ hg push -v -r 3 -r 4 ../c
   pushing to ../c
   searching for changes
-  new remote heads on branch 'default'
-  new remote head a5dda829a167
-  new remote head ee8fbc7a0295
+  new remote heads on branch 'default':
+   a5dda829a167
+   ee8fbc7a0295
   abort: push creates new remote head a5dda829a167!
   (merge or see "hg help push" for details about pushing new heads)
   [255]
@@ -367,7 +364,7 @@
   $ hg push --branch f --new-branch ../f
   pushing to ../f
   searching for changes
-  abort: push creates multiple headed new branch 'f'
+  abort: push creates new branch 'f' with multiple heads
   (merge or see "hg help push" for details about pushing new heads)
   [255]
   $ hg push --branch f --new-branch --force ../f
@@ -532,7 +529,7 @@
 
 glog of local:
 
-  $ hg glog --template "{rev}: {branches} {desc}\n"
+  $ hg log -G --template "{rev}: {branches} {desc}\n"
   @  2: A a2
   |
   | o  1: B b
@@ -541,7 +538,7 @@
   
 glog of remote:
 
-  $ hg glog -R inner --template "{rev}: {branches} {desc}\n"
+  $ hg log -G -R inner --template "{rev}: {branches} {desc}\n"
   @  2: B b1
   |
   o  1: B b
@@ -615,7 +612,7 @@
 
 glog of local:
 
-  $ hg glog --template "{rev}: {branches} {desc}\n"
+  $ hg log -G --template "{rev}: {branches} {desc}\n"
   @  3: A a2
   |
   o  2: A a1
@@ -626,7 +623,7 @@
   
 glog of remote:
 
-  $ hg glog -R inner --template "{rev}: {branches} {desc}\n"
+  $ hg log -G -R inner --template "{rev}: {branches} {desc}\n"
   @  3: B b1
   |
   | o  2: A a1
@@ -700,7 +697,7 @@
 
 glog of local:
 
-  $ hg glog --template "{rev}: {branches} {desc}\n"
+  $ hg log -G --template "{rev}: {branches} {desc}\n"
   @  5: A b3
   |
   | o  4: B a3
@@ -715,7 +712,7 @@
   
 glog of remote:
 
-  $ hg glog -R inner --template "{rev}: {branches} {desc}\n"
+  $ hg log -G -R inner --template "{rev}: {branches} {desc}\n"
   @  3: B b1
   |
   o  2: B b0
--- a/tests/test-rebase-abort.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-rebase-abort.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,6 +1,5 @@
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
-  > graphlog=
   > rebase=
   > 
   > [phases]
--- a/tests/test-rebase-bookmarks.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-rebase-bookmarks.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,6 +1,5 @@
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
-  > graphlog=
   > rebase=
   > 
   > [phases]
--- a/tests/test-rebase-cache.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-rebase-cache.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,6 +1,5 @@
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
-  > graphlog=
   > rebase=
   > mq=
   > 
--- a/tests/test-rebase-check-restore.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-rebase-check-restore.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,6 +1,5 @@
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
-  > graphlog=
   > rebase=
   > 
   > [phases]
--- a/tests/test-rebase-collapse.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-rebase-collapse.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,6 +1,5 @@
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
-  > graphlog=
   > rebase=
   > mq=
   > 
@@ -275,18 +274,18 @@
   7:c65502d4178782309ce0574c5ae6ee9485a9bafa default
   6:c772a8b2dc17629cec88a19d09c926c4814b12c7 default
 
-  $ cat $TESTTMP/b2/.hg/cache/branchheads-served
+  $ cat $TESTTMP/b2/.hg/cache/branch2-served
   c65502d4178782309ce0574c5ae6ee9485a9bafa 7
-  c772a8b2dc17629cec88a19d09c926c4814b12c7 default
-  c65502d4178782309ce0574c5ae6ee9485a9bafa default
+  c772a8b2dc17629cec88a19d09c926c4814b12c7 o default
+  c65502d4178782309ce0574c5ae6ee9485a9bafa o default
 
   $ hg strip 4
   saved backup bundle to $TESTTMP/b2/.hg/strip-backup/8a5212ebc852-backup.hg (glob)
 
-  $ cat $TESTTMP/b2/.hg/cache/branchheads-served
+  $ cat $TESTTMP/b2/.hg/cache/branch2-served
   c65502d4178782309ce0574c5ae6ee9485a9bafa 4
-  2870ad076e541e714f3c2bc32826b5c6a6e5b040 default
-  c65502d4178782309ce0574c5ae6ee9485a9bafa default
+  2870ad076e541e714f3c2bc32826b5c6a6e5b040 o default
+  c65502d4178782309ce0574c5ae6ee9485a9bafa o default
 
   $ hg heads --template="{rev}:{node} {branch}\n"
   4:c65502d4178782309ce0574c5ae6ee9485a9bafa default
--- a/tests/test-rebase-conflicts.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-rebase-conflicts.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,6 +1,5 @@
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
-  > graphlog=
   > rebase=
   > 
   > [phases]
--- a/tests/test-rebase-detach.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-rebase-detach.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,6 +1,5 @@
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
-  > graphlog=
   > rebase=
   > 
   > [phases]
--- a/tests/test-rebase-interruptions.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-rebase-interruptions.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,6 +1,5 @@
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
-  > graphlog=
   > rebase=
   > 
   > [phases]
--- a/tests/test-rebase-issue-noparam-single-rev.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-rebase-issue-noparam-single-rev.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,6 +1,5 @@
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
-  > graphlog=
   > rebase=
   > 
   > [phases]
--- a/tests/test-rebase-mq-skip.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-rebase-mq-skip.t	Wed Jan 01 18:28:40 2014 -0500
@@ -3,7 +3,6 @@
 
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
-  > graphlog=
   > rebase=
   > mq=
   > 
--- a/tests/test-rebase-mq.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-rebase-mq.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,6 +1,5 @@
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
-  > graphlog=
   > rebase=
   > mq=
   > 
--- a/tests/test-rebase-named-branches.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-rebase-named-branches.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,6 +1,5 @@
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
-  > graphlog=
   > rebase=
   > 
   > [phases]
--- a/tests/test-rebase-newancestor.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-rebase-newancestor.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,6 +1,5 @@
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
-  > graphlog=
   > rebase=
   > 
   > [alias]
--- a/tests/test-rebase-parameters.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-rebase-parameters.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,6 +1,5 @@
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
-  > graphlog=
   > rebase=
   > 
   > [phases]
--- a/tests/test-rebase-pull.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-rebase-pull.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,6 +1,5 @@
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
-  > graphlog=
   > rebase=
   > 
   > [alias]
--- a/tests/test-rebase-rename.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-rebase-rename.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,6 +1,5 @@
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
-  > graphlog=
   > rebase=
   > 
   > [alias]
--- a/tests/test-rebase-scenario-global.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-rebase-scenario-global.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,6 +1,5 @@
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
-  > graphlog=
   > rebase=
   > 
   > [phases]
--- a/tests/test-record.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-record.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1277,5 +1277,25 @@
    c
   +d
   
+Test --user when ui.username not set
+  $ unset HGUSER
+  $ echo e >> subdir/f1
+  $ hg record  --config ui.username= -d '8 0' --user xyz -m "user flag" <<EOF
+  > y
+  > y
+  > EOF
+  diff --git a/subdir/f1 b/subdir/f1
+  1 hunks, 1 lines changed
+  examine changes to 'subdir/f1'? [Ynesfdaq?] 
+  @@ -4,3 +4,4 @@
+   b
+   c
+   d
+  +e
+  record this change to 'subdir/f1'? [Ynesfdaq?] 
+  $ hg log --template '{author}\n' -l 1
+  xyz
+  $ HGUSER="test"
+  $ export HGUSER
 
   $ cd ..
--- a/tests/test-repair-strip.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-repair-strip.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,4 +1,4 @@
-  $ "$TESTDIR/hghave" unix-permissions || exit 80
+#if unix-permissions no-root
 
   $ echo "[extensions]" >> $HGRCPATH
   $ echo "mq=">> $HGRCPATH
@@ -130,3 +130,5 @@
   2 files, 2 changesets, 2 total revisions
 
   $ cd ..
+
+#endif
--- a/tests/test-revset-outgoing.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-revset-outgoing.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,7 +1,4 @@
   $ cat >> $HGRCPATH <<EOF
-  > [extensions]
-  > graphlog=
-  > 
   > [alias]
   > tlog = log --template "{rev}:{node|short}: '{desc}' {branches}\n"
   > tglog = tlog -G
--- a/tests/test-serve.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-serve.t	Wed Jan 01 18:28:40 2014 -0500
@@ -45,12 +45,14 @@
 
 With -v and -p daytime (should fail because low port)
 
+#if no-root
   $ KILLQUIETLY=Y
   $ hgserve -p daytime
   abort: cannot start server at 'localhost:13': Permission denied
   abort: child process failed to start
   % errors
   $ KILLQUIETLY=N
+#endif
 
 With --prefix foo
 
--- a/tests/test-strip-cross.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-strip-cross.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,7 +1,7 @@
 test stripping of filelogs where the linkrev doesn't always increase
 
   $ echo '[extensions]' >> $HGRCPATH
-  $ echo 'hgext.mq =' >> $HGRCPATH
+  $ echo 'strip =' >> $HGRCPATH
   $ hg init orig
   $ cd orig
   $ commit()
--- a/tests/test-strip.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-strip.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1,6 +1,5 @@
   $ echo "[extensions]" >> $HGRCPATH
   $ echo "strip=" >> $HGRCPATH
-  $ echo "graphlog=" >> $HGRCPATH
 
   $ restore() {
   >     hg unbundle -q .hg/strip-backup/*
@@ -226,7 +225,7 @@
 
   $ hg up
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hg glog
+  $ hg log -G
   @  changeset:   4:264128213d29
   |  tag:         tip
   |  parent:      1:ef3a871183d7
@@ -259,7 +258,7 @@
 
   $ hg strip "roots(2)" 3
   saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
-  $ hg glog
+  $ hg log -G
   @  changeset:   2:264128213d29
   |  tag:         tip
   |  user:        test
@@ -277,7 +276,7 @@
      summary:     a
   
   $ restore
-  $ hg glog
+  $ hg log -G
   o  changeset:   4:443431ffac4f
   |  tag:         tip
   |  user:        test
@@ -311,7 +310,7 @@
   $ hg strip 2 4
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
-  $ hg glog
+  $ hg log -G
   o  changeset:   2:65bd5f99a4a3
   |  tag:         tip
   |  user:        test
--- a/tests/test-subrepo.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-subrepo.t	Wed Jan 01 18:28:40 2014 -0500
@@ -1232,4 +1232,69 @@
   searching for changes
   no changes found
   [1]
+  $ cd ..
 
+Test phase choice for newly created commit with "phases.subrepochecks"
+configuration
+
+  $ cd t
+  $ hg update -q -r 12
+
+  $ cat >> s/ss/.hg/hgrc <<EOF
+  > [phases]
+  > new-commit = secret
+  > EOF
+  $ cat >> s/.hg/hgrc <<EOF
+  > [phases]
+  > new-commit = draft
+  > EOF
+  $ echo phasecheck1 >> s/ss/a
+  $ hg -R s commit -S --config phases.checksubrepos=abort -m phasecheck1
+  committing subrepository ss
+  transaction abort!
+  rollback completed
+  abort: can't commit in draft phase conflicting secret from subrepository ss
+  [255]
+  $ echo phasecheck2 >> s/ss/a
+  $ hg -R s commit -S --config phases.checksubrepos=ignore -m phasecheck2
+  committing subrepository ss
+  $ hg -R s/ss phase tip
+  3: secret
+  $ hg -R s phase tip
+  6: draft
+  $ echo phasecheck3 >> s/ss/a
+  $ hg -R s commit -S -m phasecheck3
+  committing subrepository ss
+  warning: changes are committed in secret phase from subrepository ss
+  $ hg -R s/ss phase tip
+  4: secret
+  $ hg -R s phase tip
+  7: secret
+
+  $ cat >> t/.hg/hgrc <<EOF
+  > [phases]
+  > new-commit = draft
+  > EOF
+  $ cat >> .hg/hgrc <<EOF
+  > [phases]
+  > new-commit = public
+  > EOF
+  $ echo phasecheck4 >>   s/ss/a
+  $ echo phasecheck4 >>   t/t
+  $ hg commit -S -m phasecheck4
+  committing subrepository s
+  committing subrepository s/ss
+  warning: changes are committed in secret phase from subrepository ss
+  committing subrepository t
+  warning: changes are committed in secret phase from subrepository s
+  created new head
+  $ hg -R s/ss phase tip
+  5: secret
+  $ hg -R s phase tip
+  8: secret
+  $ hg -R t phase tip
+  6: draft
+  $ hg phase tip
+  15: secret
+
+  $ cd ..
--- a/tests/test-transplant.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-transplant.t	Wed Jan 01 18:28:40 2014 -0500
@@ -430,6 +430,20 @@
   adding manifests
   adding file changes
   added 4 changesets with 4 changes to 4 files
+
+test "--merge" causing pull from source repository on local host
+
+  $ hg --config extensions.mq= -q strip 2
+  $ hg transplant -s ../t --merge tip
+  searching for changes
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 2 changes to 2 files
+  applying a53251cdf717
+  4:a53251cdf717 merged at 4831f4dc831a
+
   $ cd ..
 
 
--- a/tests/test-treediscovery-legacy.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-treediscovery-legacy.t	Wed Jan 01 18:28:40 2014 -0500
@@ -5,8 +5,6 @@
   $ cat >> $HGRCPATH <<EOF
   > [ui]
   > logtemplate="{rev} {node|short}: {desc} {branches}\n"
-  > [extensions]
-  > graphlog=
   > EOF
   $ cp $HGRCPATH $HGRCPATH-withcap
 
@@ -66,7 +64,7 @@
   $ hg init main
   $ cd main
   $ hg debugbuilddag -mo '+2:tbase @name1 +3:thead1 <tbase @name2 +4:thead2 @both /thead1 +2:tmaintip'
-  $ hg glog
+  $ hg log -G
   o  11 a19bfa7e7328: r11 both
   |
   o  10 8b6bad1512e1: r10 both
--- a/tests/test-treediscovery.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-treediscovery.t	Wed Jan 01 18:28:40 2014 -0500
@@ -7,8 +7,6 @@
   $ cat >> $HGRCPATH <<EOF
   > [ui]
   > logtemplate="{rev} {node|short}: {desc} {branches}\n"
-  > [extensions]
-  > graphlog=
   > EOF
 
 Setup HTTP server control:
@@ -53,7 +51,7 @@
   $ hg init main
   $ cd main
   $ hg debugbuilddag -mo '+2:tbase @name1 +3:thead1 <tbase @name2 +4:thead2 @both /thead1 +2:tmaintip'
-  $ hg glog
+  $ hg log -G
   o  11 a19bfa7e7328: r11 both
   |
   o  10 8b6bad1512e1: r10 both
--- a/tests/test-update-branches.t	Sat Dec 21 12:44:19 2013 +0900
+++ b/tests/test-update-branches.t	Wed Jan 01 18:28:40 2014 -0500
@@ -34,8 +34,7 @@
 
 Initial repo state:
 
-  $ hg --config 'extensions.graphlog=' \
-  >    glog --template '{rev}:{node|short} {parents} {branches}\n'
+  $ hg log -G --template '{rev}:{node|short} {parents} {branches}\n'
   @  5:ff252e8273df  b1
   |
   o  4:d047485b3896 0:60829823a42a  b1