summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rw-r--r--contrib/ciabot/INSTALL54
-rw-r--r--contrib/ciabot/README11
-rwxr-xr-xcontrib/ciabot/ciabot.py255
-rwxr-xr-xcontrib/ciabot/ciabot.sh233
-rw-r--r--contrib/completion/git-completion.bash8
-rw-r--r--contrib/completion/git-prompt.sh6
-rwxr-xr-xcontrib/contacts/git-contacts35
-rwxr-xr-xcontrib/credential/netrc/git-credential-netrc4
-rwxr-xr-xcontrib/examples/git-log.sh15
-rwxr-xr-xcontrib/examples/git-merge.sh2
-rwxr-xr-xcontrib/examples/git-whatchanged.sh28
-rwxr-xr-xcontrib/hooks/post-receive-email15
-rw-r--r--contrib/mw-to-git/Makefile10
-rwxr-xr-xcontrib/mw-to-git/git-remote-mediawiki.perl18
-rwxr-xr-xcontrib/mw-to-git/t/t9365-continuing-queries.sh23
-rwxr-xr-xcontrib/remote-helpers/git-remote-bzr73
-rwxr-xr-xcontrib/remote-helpers/git-remote-hg92
-rwxr-xr-xcontrib/remote-helpers/test-bzr.sh136
-rwxr-xr-xcontrib/remote-helpers/test-hg-bidi.sh52
-rwxr-xr-xcontrib/remote-helpers/test-hg-hg-git.sh156
-rwxr-xr-xcontrib/remote-helpers/test-hg.sh160
21 files changed, 501 insertions, 885 deletions
diff --git a/contrib/ciabot/INSTALL b/contrib/ciabot/INSTALL
deleted file mode 100644
index 7222961d35..0000000000
--- a/contrib/ciabot/INSTALL
+++ /dev/null
@@ -1,54 +0,0 @@
-= Installation instructions =
-
-Two scripts are included. The Python one (ciabot.py) is faster and
-more capable; the shell one (ciabot.sh) is a fallback in case Python
-gives your git hosting site indigestion. (I know of no such sites.)
-
-It is no longer necessary to modify the script in order to put it
-in place; in fact, this is now discouraged. It is entirely
-configurable with the following git config variables:
-
-ciabot.project = name of the project
-ciabot.repo = name of the project repo for gitweb/cgit purposes
-ciabot.xmlrpc = if true, ship notifications via XML-RPC
-ciabot.revformat = format in which the revision is shown
-
-The revformat variable may have the following values
-raw -> full hex ID of commit
-short -> first 12 chars of hex ID
-describe -> describe relative to last tag, falling back to short
-
-ciabot.project defaults to the directory name of the repository toplevel.
-ciabot.repo defaults to ciabot.project lowercased.
-ciabot.xmlrpc defaults to True
-ciabot.revformat defaults to 'describe'.
-
-This means that in the normal case you need not do any configuration at all,
-however setting ciabot.project will allow the hook to run slightly faster.
-
-Once you've set these variables, try your script with -n to see the
-notification message dumped to stdout and verify that it looks sane.
-
-To live-test these scripts, your project needs to have been registered with
-the CIA site. Here are the steps:
-
-1. Open an IRC window on irc://freenode/commits or your registered
- project IRC channel.
-
-2. Run ciabot.py and/or ciabot.sh from any directory under git
- control.
-
-You should see a notification on the channel for your most recent commit.
-
-After verifying correct function, install one of these scripts either
-in a post-commit hook or in an update hook.
-
-In post-commit, run it without arguments. It will query for
-current HEAD and the latest commit ID to get the information it
-needs.
-
-In update, call it with a refname followed by a list of commits:
-You want to reverse the order git rev-list emits because it lists
-from most recent to oldest.
-
-/path/to/ciabot.py ${refname} $(git rev-list ${oldhead}..${newhead} | tac)
diff --git a/contrib/ciabot/README b/contrib/ciabot/README
deleted file mode 100644
index 2dfe1f91f5..0000000000
--- a/contrib/ciabot/README
+++ /dev/null
@@ -1,11 +0,0 @@
-These are hook scripts for the CIA notification service at <http://cia.vc/>
-
-They are maintained by Eric S. Raymond <esr@thyrsus.com>. There is an
-upstream resource page for them at <http://www.catb.org/esr/ciabot/>,
-but they are unlikely to change rapidly.
-
-You probably want the Python version; it's faster, more capable, and
-better documented. The shell version is maintained only as a fallback
-for use on hosting sites that don't permit Python hook scripts.
-
-See the file INSTALL for installation instructions.
diff --git a/contrib/ciabot/ciabot.py b/contrib/ciabot/ciabot.py
deleted file mode 100755
index befa0c3967..0000000000
--- a/contrib/ciabot/ciabot.py
+++ /dev/null
@@ -1,255 +0,0 @@
-#!/usr/bin/env python
-# Copyright (c) 2010 Eric S. Raymond <esr@thyrsus.com>
-# Distributed under BSD terms.
-#
-# This script contains porcelain and porcelain byproducts.
-# It's Python because the Python standard libraries avoid portability/security
-# issues raised by callouts in the ancestral Perl and sh scripts. It should
-# be compatible back to Python 2.1.5
-#
-# usage: ciabot.py [-V] [-n] [-p projectname] [refname [commits...]]
-#
-# This script is meant to be run either in a post-commit hook or in an
-# update hook. Try it with -n to see the notification mail dumped to
-# stdout and verify that it looks sane. With -V it dumps its version
-# and exits.
-#
-# In post-commit, run it without arguments. It will query for
-# current HEAD and the latest commit ID to get the information it
-# needs.
-#
-# In update, call it with a refname followed by a list of commits:
-# You want to reverse the order git rev-list emits because it lists
-# from most recent to oldest.
-#
-# /path/to/ciabot.py ${refname} $(git rev-list ${oldhead}..${newhead} | tac)
-#
-# Configuration variables affecting this script:
-#
-# ciabot.project = name of the project
-# ciabot.repo = name of the project repo for gitweb/cgit purposes
-# ciabot.xmlrpc = if true (default), ship notifications via XML-RPC
-# ciabot.revformat = format in which the revision is shown
-#
-# ciabot.project defaults to the directory name of the repository toplevel.
-# ciabot.repo defaults to ciabot.project lowercased.
-#
-# This means that in the normal case you need not do any configuration at all,
-# but setting the project name will speed it up slightly.
-#
-# The revformat variable may have the following values
-# raw -> full hex ID of commit
-# short -> first 12 chars of hex ID
-# describe = -> describe relative to last tag, falling back to short
-# The default is 'describe'.
-#
-# Note: the CIA project now says only XML-RPC is reliable, so
-# we default to that.
-#
-
-import sys
-if sys.hexversion < 0x02000000:
- # The limiter is the xml.sax module
- sys.stderr.write("ciabot.py: requires Python 2.0.0 or later.\n")
- sys.exit(1)
-
-import os, commands, socket, urllib
-from xml.sax.saxutils import escape
-
-# Changeset URL prefix for your repo: when the commit ID is appended
-# to this, it should point at a CGI that will display the commit
-# through gitweb or something similar. The defaults will probably
-# work if you have a typical gitweb/cgit setup.
-#
-#urlprefix="http://%(host)s/cgi-bin/gitweb.cgi?p=%(repo)s;a=commit;h="
-urlprefix="http://%(host)s/cgi-bin/cgit.cgi/%(repo)s/commit/?id="
-
-# The service used to turn your gitwebbish URL into a tinyurl so it
-# will take up less space on the IRC notification line.
-tinyifier = "http://tinyurl.com/api-create.php?url="
-
-# The template used to generate the XML messages to CIA. You can make
-# visible changes to the IRC-bot notification lines by hacking this.
-# The default will produce a notification line that looks like this:
-#
-# ${project}: ${author} ${repo}:${branch} * ${rev} ${files}: ${logmsg} ${url}
-#
-# By omitting $files you can collapse the files part to a single slash.
-xml = '''\
-<message>
- <generator>
- <name>CIA Python client for Git</name>
- <version>%(version)s</version>
- <url>%(generator)s</url>
- </generator>
- <source>
- <project>%(project)s</project>
- <branch>%(repo)s:%(branch)s</branch>
- </source>
- <timestamp>%(ts)s</timestamp>
- <body>
- <commit>
- <author>%(author)s</author>
- <revision>%(rev)s</revision>
- <files>
- %(files)s
- </files>
- <log>%(logmsg)s %(url)s</log>
- <url>%(url)s</url>
- </commit>
- </body>
-</message>
-'''
-
-#
-# No user-serviceable parts below this line:
-#
-
-# Where to ship e-mail notifications.
-toaddr = "cia@cia.vc"
-
-# Identify the generator script.
-# Should only change when the script itself gets a new home and maintainer.
-generator = "http://www.catb.org/~esr/ciabot.py"
-version = "3.6"
-
-def do(command):
- return commands.getstatusoutput(command)[1]
-
-def report(refname, merged, xmlrpc=True):
- "Generate a commit notification to be reported to CIA"
-
- # Try to tinyfy a reference to a web view for this commit.
- try:
- url = open(urllib.urlretrieve(tinyifier + urlprefix + merged)[0]).read()
- except:
- url = urlprefix + merged
-
- branch = os.path.basename(refname)
-
- # Compute a description for the revision
- if revformat == 'raw':
- rev = merged
- elif revformat == 'short':
- rev = ''
- else: # revformat == 'describe'
- rev = do("git describe %s 2>/dev/null" % merged)
- if not rev:
- rev = merged[:12]
-
- # Extract the meta-information for the commit
- files=do("git diff-tree -r --name-only '"+ merged +"' | sed -e '1d' -e 's-.*-<file>&</file>-'")
- metainfo = do("git log -1 '--pretty=format:%an <%ae>%n%at%n%s' " + merged)
- (author, ts, logmsg) = metainfo.split("\n")
- logmsg = escape(logmsg)
-
- # This discards the part of the author's address after @.
- # Might be be nice to ship the full email address, if not
- # for spammers' address harvesters - getting this wrong
- # would make the freenode #commits channel into harvester heaven.
- author = escape(author.replace("<", "").split("@")[0].split()[-1])
-
- # This ignores the timezone. Not clear what to do with it...
- ts = ts.strip().split()[0]
-
- context = locals()
- context.update(globals())
-
- out = xml % context
- mail = '''\
-Message-ID: <%(merged)s.%(author)s@%(project)s>
-From: %(fromaddr)s
-To: %(toaddr)s
-Content-type: text/xml
-Subject: DeliverXML
-
-%(out)s''' % locals()
-
- if xmlrpc:
- return out
- else:
- return mail
-
-if __name__ == "__main__":
- import getopt
-
- # Get all config variables
- revformat = do("git config --get ciabot.revformat")
- project = do("git config --get ciabot.project")
- repo = do("git config --get ciabot.repo")
- xmlrpc = do("git config --get ciabot.xmlrpc")
- xmlrpc = not (xmlrpc and xmlrpc == "false")
-
- host = socket.getfqdn()
- fromaddr = "CIABOT-NOREPLY@" + host
-
- try:
- (options, arguments) = getopt.getopt(sys.argv[1:], "np:xV")
- except getopt.GetoptError, msg:
- print "ciabot.py: " + str(msg)
- raise SystemExit, 1
-
- notify = True
- for (switch, val) in options:
- if switch == '-p':
- project = val
- elif switch == '-n':
- notify = False
- elif switch == '-x':
- xmlrpc = True
- elif switch == '-V':
- print "ciabot.py: version", version
- sys.exit(0)
-
- # The project variable defaults to the name of the repository toplevel.
- if not project:
- here = os.getcwd()
- while True:
- if os.path.exists(os.path.join(here, ".git")):
- project = os.path.basename(here)
- break
- elif here == '/':
- sys.stderr.write("ciabot.py: no .git below root!\n")
- sys.exit(1)
- here = os.path.dirname(here)
-
- if not repo:
- repo = project.lower()
-
- urlprefix = urlprefix % globals()
-
- # The script wants a reference to head followed by the list of
- # commit ID to report about.
- if len(arguments) == 0:
- refname = do("git symbolic-ref HEAD 2>/dev/null")
- merges = [do("git rev-parse HEAD")]
- else:
- refname = arguments[0]
- merges = arguments[1:]
-
- if notify:
- if xmlrpc:
- import xmlrpclib
- server = xmlrpclib.Server('http://cia.vc/RPC2');
- else:
- import smtplib
- server = smtplib.SMTP('localhost')
-
- for merged in merges:
- message = report(refname, merged, xmlrpc)
- if not notify:
- print message
- elif xmlrpc:
- try:
- # RPC server is flaky, this can fail due to timeout.
- server.hub.deliver(message)
- except socket.error, e:
- sys.stderr.write("%s\n" % e)
- else:
- server.sendmail(fromaddr, [toaddr], message)
-
- if notify:
- if not xmlrpc:
- server.quit()
-
-#End
diff --git a/contrib/ciabot/ciabot.sh b/contrib/ciabot/ciabot.sh
deleted file mode 100755
index dfb71a1a15..0000000000
--- a/contrib/ciabot/ciabot.sh
+++ /dev/null
@@ -1,233 +0,0 @@
-#!/bin/sh
-# Distributed under the terms of the GNU General Public License v2
-# Copyright (c) 2006 Fernando J. Pereda <ferdy@gentoo.org>
-# Copyright (c) 2008 Natanael Copa <natanael.copa@gmail.com>
-# Copyright (c) 2010 Eric S. Raymond <esr@thyrsus.com>
-# Assistance and review by Petr Baudis, author of ciabot.pl,
-# is gratefully acknowledged.
-#
-# This is a version 3.x of ciabot.sh; use -V to find the exact
-# version. Versions 1 and 2 were shipped in 2006 and 2008 and are not
-# version-stamped. The version 2 maintainer has passed the baton.
-#
-# Note: This script should be considered obsolete.
-# There is a faster, better-documented rewrite in Python: find it as ciabot.py
-# Use this only if your hosting site forbids Python hooks.
-# It requires: git(1), hostname(1), cut(1), sendmail(1), and wget(1).
-#
-# Originally based on Git ciabot.pl by Petr Baudis.
-# This script contains porcelain and porcelain byproducts.
-#
-# usage: ciabot.sh [-V] [-n] [-p projectname] [refname commit]
-#
-# This script is meant to be run either in a post-commit hook or in an
-# update hook. Try it with -n to see the notification mail dumped to
-# stdout and verify that it looks sane. With -V it dumps its version
-# and exits.
-#
-# In post-commit, run it without arguments. It will query for
-# current HEAD and the latest commit ID to get the information it
-# needs.
-#
-# In update, you have to call it once per merged commit:
-#
-# refname=$1
-# oldhead=$2
-# newhead=$3
-# for merged in $(git rev-list ${oldhead}..${newhead} | tac) ; do
-# /path/to/ciabot.sh ${refname} ${merged}
-# done
-#
-# The reason for the tac call is that git rev-list emits commits from
-# most recent to least - better to ship notifications from oldest to newest.
-#
-# Configuration variables affecting this script:
-#
-# ciabot.project = name of the project
-# ciabot.repo = name of the project repo for gitweb/cgit purposes
-# ciabot.revformat = format in which the revision is shown
-#
-# ciabot.project defaults to the directory name of the repository toplevel.
-# ciabot.repo defaults to ciabot.project lowercased.
-#
-# This means that in the normal case you need not do any configuration at all,
-# but setting the project name will speed it up slightly.
-#
-# The revformat variable may have the following values
-# raw -> full hex ID of commit
-# short -> first 12 chars of hex ID
-# describe = -> describe relative to last tag, falling back to short
-# The default is 'describe'.
-#
-# Note: the shell ancestors of this script used mail, not XML-RPC, in
-# order to avoid stalling until timeout when the CIA XML-RPC server is
-# down. It is unknown whether this is still an issue in 2010, but
-# XML-RPC would be annoying to do from sh in any case. (XML-RPC does
-# have the advantage that it guarantees notification of multiple commits
-# shipped from an update in their actual order.)
-#
-
-# The project as known to CIA. You can set this with a -p option,
-# or let it default to the directory name of the repo toplevel.
-project=$(git config --get ciabot.project)
-
-if [ -z $project ]
-then
- here=`pwd`;
- while :; do
- if [ -d $here/.git ]
- then
- project=`basename $here`
- break
- elif [ $here = '/' ]
- then
- echo "ciabot.sh: no .git below root!"
- exit 1
- fi
- here=`dirname $here`
- done
-fi
-
-# Name of the repo for gitweb/cgit purposes
-repo=$(git config --get ciabot.repo)
-[ -z $repo] && repo=$(echo "${project}" | tr '[A-Z]' '[a-z]')
-
-# What revision format do we want in the summary?
-revformat=$(git config --get ciabot.revformat)
-
-# Fully qualified domain name of the repo host. You can hardwire this
-# to make the script faster. The -f option works under Linux and FreeBSD,
-# but not OpenBSD and NetBSD. But under OpenBSD and NetBSD,
-# hostname without options gives the FQDN.
-if hostname -f >/dev/null 2>&1
-then
- hostname=`hostname -f`
-else
- hostname=`hostname`
-fi
-
-# Changeset URL prefix for your repo: when the commit ID is appended
-# to this, it should point at a CGI that will display the commit
-# through gitweb or something similar. The defaults will probably
-# work if you have a typical gitweb/cgit setup.
-#urlprefix="http://${host}/cgi-bin/gitweb.cgi?p=${repo};a=commit;h="
-urlprefix="http://${host}/cgi-bin/cgit.cgi/${repo}/commit/?id="
-
-#
-# You probably will not need to change the following:
-#
-
-# Identify the script. The 'generator' variable should change only
-# when the script itself gets a new home and maintainer.
-generator="http://www.catb.org/~esr/ciabot/ciabot.sh"
-version=3.5
-
-# Addresses for the e-mail
-from="CIABOT-NOREPLY@${hostname}"
-to="cia@cia.vc"
-
-# SMTP client to use - may need to edit the absolute pathname for your system
-sendmail="sendmail -t -f ${from}"
-
-#
-# No user-serviceable parts below this line:
-#
-
-# Should include all places sendmail is likely to lurk.
-PATH="$PATH:/usr/sbin/"
-
-mode=mailit
-while getopts pnV opt
-do
- case $opt in
- p) project=$2; shift ; shift ;;
- n) mode=dumpit; shift ;;
- V) echo "ciabot.sh: version $version"; exit 0; shift ;;
- esac
-done
-
-# Cough and die if user has not specified a project
-if [ -z "$project" ]
-then
- echo "ciabot.sh: no project specified, bailing out." >&2
- exit 1
-fi
-
-if [ $# -eq 0 ] ; then
- refname=$(git symbolic-ref HEAD 2>/dev/null)
- merged=$(git rev-parse HEAD)
-else
- refname=$1
- merged=$2
-fi
-
-# This tries to turn your gitwebbish URL into a tinyurl so it will take up
-# less space on the IRC notification line. Some repo sites (I'm looking at
-# you, berlios.de!) forbid wget calls for security reasons. On these,
-# the code will fall back to the full un-tinyfied URL.
-longurl=${urlprefix}${merged}
-url=$(wget -O - -q http://tinyurl.com/api-create.php?url=${longurl} 2>/dev/null)
-if [ -z "$url" ]; then
- url="${longurl}"
-fi
-
-refname=${refname##refs/heads/}
-
-case $revformat in
-raw) rev=$merged ;;
-short) rev='' ;;
-*) rev=$(git describe ${merged} 2>/dev/null) ;;
-esac
-[ -z ${rev} ] && rev=$(echo "$merged" | cut -c 1-12)
-
-# We discard the part of the author's address after @.
-# Might be nice to ship the full email address, if not
-# for spammers' address harvesters - getting this wrong
-# would make the freenode #commits channel into harvester heaven.
-author=$(git log -1 '--pretty=format:%an <%ae>' $merged)
-author=$(echo "$author" | sed -n -e '/^.*<\([^@]*\).*$/s--\1-p')
-
-logmessage=$(git log -1 '--pretty=format:%s' $merged)
-ts=$(git log -1 '--pretty=format:%at' $merged)
-files=$(git diff-tree -r --name-only ${merged} | sed -e '1d' -e 's-.*-<file>&</file>-')
-
-out="
-<message>
- <generator>
- <name>CIA Shell client for Git</name>
- <version>${version}</version>
- <url>${generator}</url>
- </generator>
- <source>
- <project>${project}</project>
- <branch>$repo:${refname}</branch>
- </source>
- <timestamp>${ts}</timestamp>
- <body>
- <commit>
- <author>${author}</author>
- <revision>${rev}</revision>
- <files>
- ${files}
- </files>
- <log>${logmessage} ${url}</log>
- <url>${url}</url>
- </commit>
- </body>
-</message>"
-
-if [ "$mode" = "dumpit" ]
-then
- sendmail=cat
-fi
-
-${sendmail} << EOM
-Message-ID: <${merged}.${author}@${project}>
-From: ${from}
-To: ${to}
-Content-type: text/xml
-Subject: DeliverXML
-${out}
-EOM
-
-# vim: set tw=70 :
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 5da920ecd9..dba3c15700 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -901,7 +901,7 @@ _git_add ()
esac
# XXX should we check for --update and --all options ?
- __git_complete_index_file "--others --modified"
+ __git_complete_index_file "--others --modified --directory --no-empty-directory"
}
_git_archive ()
@@ -1063,7 +1063,7 @@ _git_clean ()
esac
# XXX should we check for -x option ?
- __git_complete_index_file "--others"
+ __git_complete_index_file "--others --directory"
}
_git_clone ()
@@ -1188,7 +1188,7 @@ _git_diff ()
__git_complete_revlist_file
}
-__git_mergetools_common="diffuse ecmerge emerge kdiff3 meld opendiff
+__git_mergetools_common="diffuse diffmerge ecmerge emerge kdiff3 meld opendiff
tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc3 codecompare
"
@@ -2580,7 +2580,7 @@ if [[ -n ${ZSH_VERSION-} ]]; then
--*=*|*.) ;;
*) c="$c " ;;
esac
- array[$#array+1]="$c"
+ array[${#array[@]}+1]="$c"
done
compset -P '*[=:]'
compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
index a81ef5a482..d6c61b2bde 100644
--- a/contrib/completion/git-prompt.sh
+++ b/contrib/completion/git-prompt.sh
@@ -84,6 +84,10 @@
# the colored output of "git status -sb" and are available only when
# using __git_ps1 for PROMPT_COMMAND or precmd.
+# check whether printf supports -v
+__git_printf_supports_v=
+printf -v __git_printf_supports_v -- '%s' yes >/dev/null 2>&1
+
# stores the divergence from upstream in $p
# used by GIT_PS1_SHOWUPSTREAM
__git_ps1_show_upstream ()
@@ -433,7 +437,7 @@ __git_ps1 ()
local gitstring="$c${b##refs/heads/}${f:+$z$f}$r$p"
if [ $pcmode = yes ]; then
- if [[ -n ${ZSH_VERSION-} ]]; then
+ if [ "${__git_printf_supports_v-}" != yes ]; then
gitstring=$(printf -- "$printf_format" "$gitstring")
else
printf -v gitstring -- "$printf_format" "$gitstring"
diff --git a/contrib/contacts/git-contacts b/contrib/contacts/git-contacts
index d80f7d1b6e..428cc1a9a1 100755
--- a/contrib/contacts/git-contacts
+++ b/contrib/contacts/git-contacts
@@ -59,11 +59,11 @@ sub import_commits {
}
sub get_blame {
- my ($commits, $source, $start, $len, $from) = @_;
- $len = 1 unless defined($len);
- return if $len == 0;
+ my ($commits, $source, $from, $ranges) = @_;
+ return unless @$ranges;
open my $f, '-|',
- qw(git blame --porcelain -C), '-L', "$start,+$len",
+ qw(git blame --porcelain -C),
+ map({"-L$_->[0],+$_->[1]"} @$ranges),
'--since', $since, "$from^", '--', $source or die;
while (<$f>) {
if (/^([0-9a-f]{40}) \d+ \d+ \d+$/) {
@@ -76,8 +76,17 @@ sub get_blame {
close $f;
}
+sub blame_sources {
+ my ($sources, $commits) = @_;
+ for my $s (keys %$sources) {
+ for my $id (keys %{$sources->{$s}}) {
+ get_blame($commits, $s, $id, $sources->{$s}{$id});
+ }
+ }
+}
+
sub scan_patches {
- my ($commits, $id, $f) = @_;
+ my ($sources, $id, $f) = @_;
my $source;
while (<$f>) {
if (/^From ([0-9a-f]{40}) Mon Sep 17 00:00:00 2001$/) {
@@ -90,7 +99,8 @@ sub scan_patches {
} elsif (/^--- /) {
die "Cannot parse hunk source: $_\n";
} elsif (/^@@ -(\d+)(?:,(\d+))?/ && $source) {
- get_blame($commits, $source, $1, $2, $id);
+ my $len = defined($2) ? $2 : 1;
+ push @{$sources->{$source}{$id}}, [$1, $len] if $len;
}
}
}
@@ -163,13 +173,20 @@ for (@ARGV) {
}
}
-my %commits;
+my %sources;
for (@files) {
- scan_patch_file(\%commits, $_);
+ scan_patch_file(\%sources, $_);
}
if (@rev_args) {
- scan_rev_args(\%commits, \@rev_args)
+ scan_rev_args(\%sources, \@rev_args)
}
+
+my $toplevel = `git rev-parse --show-toplevel`;
+chomp $toplevel;
+chdir($toplevel) or die "chdir failure: $toplevel: $!\n";
+
+my %commits;
+blame_sources(\%sources, \%commits);
import_commits(\%commits);
my $contacts = {};
diff --git a/contrib/credential/netrc/git-credential-netrc b/contrib/credential/netrc/git-credential-netrc
index 6c51c43885..1571a7b269 100755
--- a/contrib/credential/netrc/git-credential-netrc
+++ b/contrib/credential/netrc/git-credential-netrc
@@ -369,7 +369,9 @@ sub find_netrc_entry {
{
my $entry_text = join ', ', map { "$_=$entry->{$_}" } keys %$entry;
foreach my $check (sort keys %$query) {
- if (defined $query->{$check}) {
+ if (!defined $entry->{$check}) {
+ log_debug("OK: entry has no $check token, so any value satisfies check $check");
+ } elsif (defined $query->{$check}) {
log_debug("compare %s [%s] to [%s] (entry: %s)",
$check,
$entry->{$check},
diff --git a/contrib/examples/git-log.sh b/contrib/examples/git-log.sh
new file mode 100755
index 0000000000..c2ea71cf14
--- /dev/null
+++ b/contrib/examples/git-log.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Linus Torvalds
+#
+
+USAGE='[--max-count=<n>] [<since>..<limit>] [--pretty=<format>] [git-rev-list options]'
+SUBDIRECTORY_OK='Yes'
+. git-sh-setup
+
+revs=$(git-rev-parse --revs-only --no-flags --default HEAD "$@") || exit
+[ "$revs" ] || {
+ die "No HEAD ref"
+}
+git-rev-list --pretty $(git-rev-parse --default HEAD "$@") |
+LESS=-S ${PAGER:-less}
diff --git a/contrib/examples/git-merge.sh b/contrib/examples/git-merge.sh
index 7b922c3948..a5e42a9f01 100755
--- a/contrib/examples/git-merge.sh
+++ b/contrib/examples/git-merge.sh
@@ -263,7 +263,7 @@ fi
# This could be traditional "merge <msg> HEAD <commit>..." and the
# way we can tell it is to see if the second token is HEAD, but some
-# people might have misused the interface and used a committish that
+# people might have misused the interface and used a commit-ish that
# is the same as HEAD there instead. Traditional format never would
# have "-m" so it is an additional safety measure to check for it.
diff --git a/contrib/examples/git-whatchanged.sh b/contrib/examples/git-whatchanged.sh
new file mode 100755
index 0000000000..1fb9feb348
--- /dev/null
+++ b/contrib/examples/git-whatchanged.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+USAGE='[-p] [--max-count=<n>] [<since>..<limit>] [--pretty=<format>] [-m] [git-diff-tree options] [git-rev-list options]'
+SUBDIRECTORY_OK='Yes'
+. git-sh-setup
+
+diff_tree_flags=$(git-rev-parse --sq --no-revs --flags "$@") || exit
+case "$0" in
+*whatchanged)
+ count=
+ test -z "$diff_tree_flags" &&
+ diff_tree_flags=$(git-repo-config --get whatchanged.difftree)
+ diff_tree_default_flags='-c -M --abbrev' ;;
+*show)
+ count=-n1
+ test -z "$diff_tree_flags" &&
+ diff_tree_flags=$(git-repo-config --get show.difftree)
+ diff_tree_default_flags='--cc --always' ;;
+esac
+test -z "$diff_tree_flags" &&
+ diff_tree_flags="$diff_tree_default_flags"
+
+rev_list_args=$(git-rev-parse --sq --default HEAD --revs-only "$@") &&
+diff_tree_args=$(git-rev-parse --sq --no-revs --no-flags "$@") &&
+
+eval "git-rev-list $count $rev_list_args" |
+eval "git-diff-tree --stdin --pretty -r $diff_tree_flags $diff_tree_args" |
+LESS="$LESS -S" ${PAGER:-less}
diff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email
index 153115029d..8ee410f843 100755
--- a/contrib/hooks/post-receive-email
+++ b/contrib/hooks/post-receive-email
@@ -242,6 +242,9 @@ generate_email_header()
cat <<-EOF
To: $recipients
Subject: ${emailprefix}$projectdesc $refname_type $short_refname ${change_type}d. $describe
+ MIME-Version: 1.0
+ Content-Type: text/plain; charset=utf-8
+ Content-Transfer-Encoding: 8bit
X-Git-Refname: $refname
X-Git-Reftype: $refname_type
X-Git-Oldrev: $oldrev
@@ -471,7 +474,7 @@ generate_delete_branch_email()
echo " was $oldrev"
echo ""
echo $LOGBEGIN
- git show -s --pretty=oneline $oldrev
+ git diff-tree -s --always --encoding=UTF-8 --pretty=oneline $oldrev
echo $LOGEND
}
@@ -547,11 +550,11 @@ generate_atag_email()
# performed on them
if [ -n "$prevtag" ]; then
# Show changes since the previous release
- git rev-list --pretty=short "$prevtag..$newrev" | git shortlog
+ git shortlog "$prevtag..$newrev"
else
# No previous tag, show all the changes since time
# began
- git rev-list --pretty=short $newrev | git shortlog
+ git shortlog $newrev
fi
;;
*)
@@ -571,7 +574,7 @@ generate_delete_atag_email()
echo " was $oldrev"
echo ""
echo $LOGBEGIN
- git show -s --pretty=oneline $oldrev
+ git diff-tree -s --always --encoding=UTF-8 --pretty=oneline $oldrev
echo $LOGEND
}
@@ -617,7 +620,7 @@ generate_general_email()
echo ""
if [ "$newrev_type" = "commit" ]; then
echo $LOGBEGIN
- git show --no-color --root -s --pretty=medium $newrev
+ git diff-tree -s --always --encoding=UTF-8 --pretty=medium $newrev
echo $LOGEND
else
# What can we do here? The tag marks an object that is not
@@ -636,7 +639,7 @@ generate_delete_general_email()
echo " was $oldrev"
echo ""
echo $LOGBEGIN
- git show -s --pretty=oneline $oldrev
+ git diff-tree -s --always --encoding=UTF-8 --pretty=oneline $oldrev
echo $LOGEND
}
diff --git a/contrib/mw-to-git/Makefile b/contrib/mw-to-git/Makefile
index 76fcd4defc..f206f9655b 100644
--- a/contrib/mw-to-git/Makefile
+++ b/contrib/mw-to-git/Makefile
@@ -24,6 +24,11 @@ INSTLIBDIR=$(shell $(MAKE) -C $(GIT_ROOT_DIR)/perl \
all: build
+test: all
+ $(MAKE) -C t
+
+check: perlcritic test
+
install_pm:
install $(GIT_MEDIAWIKI_PM) $(INSTLIBDIR)/$(GIT_MEDIAWIKI_PM)
@@ -41,4 +46,7 @@ clean:
rm $(INSTLIBDIR)/$(GIT_MEDIAWIKI_PM)
perlcritic:
- perlcritic -2 *.perl
+ perlcritic -5 $(SCRIPT_PERL)
+ -perlcritic -2 $(SCRIPT_PERL)
+
+.PHONY: all test check install_pm install clean perlcritic
diff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl
index f8d7d2ca6c..476e0a2bc0 100755
--- a/contrib/mw-to-git/git-remote-mediawiki.perl
+++ b/contrib/mw-to-git/git-remote-mediawiki.perl
@@ -590,6 +590,9 @@ sub mw_capabilities {
print {*STDOUT} "import\n";
print {*STDOUT} "list\n";
print {*STDOUT} "push\n";
+ if ($dumb_push) {
+ print {*STDOUT} "no-private-update\n";
+ }
print {*STDOUT} "\n";
return;
}
@@ -622,6 +625,9 @@ sub fetch_mw_revisions_for_page {
rvstartid => $fetch_from,
rvlimit => 500,
pageids => $id,
+
+ # Let MediaWiki know that we support the latest API.
+ continue => '',
};
my $revnum = 0;
@@ -637,8 +643,15 @@ sub fetch_mw_revisions_for_page {
push(@page_revs, $page_rev_ids);
$revnum++;
}
- last if (!$result->{'query-continue'});
- $query->{rvstartid} = $result->{'query-continue'}->{revisions}->{rvstartid};
+
+ if ($result->{'query-continue'}) { # For legacy APIs
+ $query->{rvstartid} = $result->{'query-continue'}->{revisions}->{rvstartid};
+ } elsif ($result->{continue}) { # For newer APIs
+ $query->{rvstartid} = $result->{continue}->{rvcontinue};
+ $query->{continue} = $result->{continue}->{continue};
+ } else {
+ last;
+ }
}
if ($shallow_import && @page_revs) {
print {*STDERR} " Found 1 revision (shallow import).\n";
@@ -1211,7 +1224,6 @@ sub mw_push_revision {
}
if (!$dumb_push) {
run_git(qq(notes --ref=${remotename}/mediawiki add -f -m "mediawiki_revision: ${mw_revision}" ${sha1_commit}));
- run_git(qq(update-ref -m "Git-MediaWiki push" refs/mediawiki/${remotename}/master ${sha1_commit} ${sha1_child}));
}
}
diff --git a/contrib/mw-to-git/t/t9365-continuing-queries.sh b/contrib/mw-to-git/t/t9365-continuing-queries.sh
new file mode 100755
index 0000000000..27e267f532
--- /dev/null
+++ b/contrib/mw-to-git/t/t9365-continuing-queries.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+test_description='Test the Git Mediawiki remote helper: queries w/ more than 500 results'
+
+. ./test-gitmw-lib.sh
+. $TEST_DIRECTORY/test-lib.sh
+
+test_check_precond
+
+test_expect_success 'creating page w/ >500 revisions' '
+ wiki_reset &&
+ for i in `test_seq 501`
+ do
+ echo "creating revision $i" &&
+ wiki_editpage foo "revision $i<br/>" true
+ done
+'
+
+test_expect_success 'cloning page w/ >500 revisions' '
+ git clone mediawiki::'"$WIKI_URL"' mw_dir
+'
+
+test_done
diff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr
index c3a3cac77b..054161ae21 100755
--- a/contrib/remote-helpers/git-remote-bzr
+++ b/contrib/remote-helpers/git-remote-bzr
@@ -13,8 +13,11 @@
# or
# % git clone bzr::lp:myrepo
#
-# If you want to specify which branches you want track (per repo):
-# git config remote-bzr.branches 'trunk, devel, test'
+# If you want to specify which branches you want to track (per repo):
+# % git config remote.origin.bzr-branches 'trunk, devel, test'
+#
+# Where 'origin' is the name of the repository you want to specify the
+# branches.
#
import sys
@@ -168,17 +171,16 @@ class Parser:
if not m:
return None
_, name, email, date, tz = m.groups()
+ name = name.decode('utf-8')
committer = '%s <%s>' % (name, email)
tz = int(tz)
tz = ((tz / 100) * 3600) + ((tz % 100) * 60)
return (committer, int(date), tz)
def rev_to_mark(rev):
- global marks
return marks.from_rev(rev)
def mark_to_rev(mark):
- global marks
return marks.to_rev(mark)
def fixup_user(user):
@@ -233,8 +235,6 @@ def get_filechanges(cur, prev):
return modified, removed
def export_files(tree, files):
- global marks, filenodes
-
final = []
for path, fid in files.iteritems():
kind = tree.kind(fid)
@@ -276,8 +276,6 @@ def export_files(tree, files):
return final
def export_branch(repo, name):
- global prefix
-
ref = '%s/heads/%s' % (prefix, name)
tip = marks.get_tip(name)
@@ -378,16 +376,12 @@ def export_branch(repo, name):
marks.set_tip(name, revid)
def export_tag(repo, name):
- global tags, prefix
-
ref = '%s/tags/%s' % (prefix, name)
print "reset %s" % ref
print "from :%u" % rev_to_mark(tags[name])
print
def do_import(parser):
- global dirname
-
repo = parser.repo
path = os.path.join(dirname, 'marks-git')
@@ -413,8 +407,6 @@ def do_import(parser):
sys.stdout.flush()
def parse_blob(parser):
- global blob_marks
-
parser.next()
mark = parser.get_mark()
parser.next()
@@ -425,8 +417,6 @@ def parse_blob(parser):
class CustomTree():
def __init__(self, branch, revid, parents, files):
- global files_cache
-
self.updates = {}
self.branch = branch
@@ -484,7 +474,7 @@ class CustomTree():
add_entry(fid, dirname, 'directory')
return fid
- def add_entry(fid, path, kind, mode = None):
+ def add_entry(fid, path, kind, mode=None):
dirname, basename = os.path.split(path)
parent_fid = get_parent(dirname, basename)
@@ -505,7 +495,7 @@ class CustomTree():
self.files[path] = [change[0], None]
changes.append(change)
- def update_entry(fid, path, kind, mode = None):
+ def update_entry(fid, path, kind, mode=None):
dirname, basename = os.path.split(path)
parent_fid = get_parent(dirname, basename)
@@ -583,9 +573,6 @@ def c_style_unescape(string):
return string
def parse_commit(parser):
- global marks, blob_marks, parsed_refs
- global mode
-
parents = []
ref = parser[1]
@@ -657,8 +644,6 @@ def parse_commit(parser):
marks.new_mark(revid, commit_mark)
def parse_reset(parser):
- global parsed_refs
-
ref = parser[1]
parser.next()
@@ -674,8 +659,6 @@ def parse_reset(parser):
parsed_refs[ref] = mark_to_rev(from_mark)
def do_export(parser):
- global parsed_refs, dirname
-
parser.next()
for line in parser.each_block('done'):
@@ -699,7 +682,8 @@ def do_export(parser):
branch.generate_revision_history(revid, marks.get_tip(name))
if name in peers:
- peer = bzrlib.branch.Branch.open(peers[name])
+ peer = bzrlib.branch.Branch.open(peers[name],
+ possible_transports=transports)
try:
peer.bzrdir.push_branch(branch, revision_id=revid)
except bzrlib.errors.DivergedBranches:
@@ -724,8 +708,6 @@ def do_export(parser):
print
def do_capabilities(parser):
- global dirname
-
print "import"
print "export"
print "refspec refs/heads/*:%s/heads/*" % prefix
@@ -743,8 +725,6 @@ def ref_is_valid(name):
return not True in [c in name for c in '~^: \\']
def do_list(parser):
- global tags
-
master_branch = None
for name in branches:
@@ -770,24 +750,24 @@ def do_list(parser):
def clone(path, remote_branch):
try:
- bdir = bzrlib.bzrdir.BzrDir.create(path)
+ bdir = bzrlib.bzrdir.BzrDir.create(path, possible_transports=transports)
except bzrlib.errors.AlreadyControlDirError:
- bdir = bzrlib.bzrdir.BzrDir.open(path)
+ bdir = bzrlib.bzrdir.BzrDir.open(path, possible_transports=transports)
repo = bdir.find_repository()
repo.fetch(remote_branch.repository)
return remote_branch.sprout(bdir, repository=repo)
def get_remote_branch(name):
- global dirname, branches
-
- remote_branch = bzrlib.branch.Branch.open(branches[name])
+ remote_branch = bzrlib.branch.Branch.open(branches[name],
+ possible_transports=transports)
if isinstance(remote_branch.user_transport, bzrlib.transport.local.LocalTransport):
return remote_branch
branch_path = os.path.join(dirname, 'clone', name)
try:
- branch = bzrlib.branch.Branch.open(branch_path)
+ branch = bzrlib.branch.Branch.open(branch_path,
+ possible_transports=transports)
except bzrlib.errors.NotBranchError:
# clone
branch = clone(branch_path, remote_branch)
@@ -821,17 +801,17 @@ def find_branches(repo):
yield name, branch.base
def get_repo(url, alias):
- global dirname, peer, branches
-
normal_url = bzrlib.urlutils.normalize_url(url)
- origin = bzrlib.bzrdir.BzrDir.open(url)
+ origin = bzrlib.bzrdir.BzrDir.open(url, possible_transports=transports)
is_local = isinstance(origin.transport, bzrlib.transport.local.LocalTransport)
shared_path = os.path.join(gitdir, 'bzr')
try:
- shared_dir = bzrlib.bzrdir.BzrDir.open(shared_path)
+ shared_dir = bzrlib.bzrdir.BzrDir.open(shared_path,
+ possible_transports=transports)
except bzrlib.errors.NotBranchError:
- shared_dir = bzrlib.bzrdir.BzrDir.create(shared_path)
+ shared_dir = bzrlib.bzrdir.BzrDir.create(shared_path,
+ possible_transports=transports)
try:
shared_repo = shared_dir.open_repository()
except bzrlib.errors.NoRepositoryPresent:
@@ -844,16 +824,21 @@ def get_repo(url, alias):
else:
# check and remove old organization
try:
- bdir = bzrlib.bzrdir.BzrDir.open(clone_path)
+ bdir = bzrlib.bzrdir.BzrDir.open(clone_path,
+ possible_transports=transports)
bdir.destroy_repository()
except bzrlib.errors.NotBranchError:
pass
except bzrlib.errors.NoRepositoryPresent:
pass
- wanted = get_config('remote-bzr.branches').rstrip().split(', ')
+ wanted = get_config('remote.%s.bzr-branches' % alias).rstrip().split(', ')
# stupid python
wanted = [e for e in wanted if e]
+ if not wanted:
+ wanted = get_config('remote-bzr.branches').rstrip().split(', ')
+ # stupid python
+ wanted = [e for e in wanted if e]
if not wanted:
try:
@@ -897,6 +882,7 @@ def main(args):
global files_cache
global is_tmp
global branches, peers
+ global transports
alias = args[1]
url = args[2]
@@ -909,6 +895,7 @@ def main(args):
marks = None
branches = {}
peers = {}
+ transports = []
if alias[5:] == url:
is_tmp = True
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index 0194c67fb1..92d994e470 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -23,8 +23,12 @@ import subprocess
import urllib
import atexit
import urlparse, hashlib
+import time as ptime
#
+# If you want to see Mercurial revisions as Git commit notes:
+# git config core.notesRef refs/notes/hg
+#
# If you are not in hg-git-compat mode and want to disable the tracking of
# named branches:
# git config --global remote-hg.track-branches false
@@ -126,6 +130,7 @@ class Marks:
self.rev_marks = {}
self.last_mark = 0
self.version = 0
+ self.last_note = 0
def load(self):
if not os.path.exists(self.path):
@@ -137,6 +142,7 @@ class Marks:
self.marks = tmp['marks']
self.last_mark = tmp['last-mark']
self.version = tmp.get('version', 1)
+ self.last_note = tmp.get('last-note', 0)
for rev, mark in self.marks.iteritems():
self.rev_marks[mark] = rev
@@ -150,7 +156,7 @@ class Marks:
self.version = 2
def dict(self):
- return { 'tips': self.tips, 'marks': self.marks, 'last-mark' : self.last_mark, 'version' : self.version }
+ return { 'tips': self.tips, 'marks': self.marks, 'last-mark' : self.last_mark, 'version' : self.version, 'last-note' : self.last_note }
def store(self):
json.dump(self.dict(), open(self.path, 'w'))
@@ -227,8 +233,6 @@ class Parser:
return sys.stdin.read(size)
def get_author(self):
- global bad_mail
-
ex = None
m = RAW_AUTHOR_RE.match(self.line)
if not m:
@@ -261,8 +265,6 @@ def fix_file_path(path):
return os.path.relpath(path, '/')
def export_files(files):
- global marks, filenodes
-
final = []
for f in files:
fid = node.hex(f.filenode())
@@ -344,8 +346,6 @@ def fixup_user_hg(user):
return (name, mail)
def fixup_user(user):
- global mode, bad_mail
-
if mode == 'git':
name, mail = fixup_user_git(user)
else:
@@ -374,7 +374,7 @@ def updatebookmarks(repo, peer):
bookmarks.write(repo)
def get_repo(url, alias):
- global dirname, peer
+ global peer
myui = ui.ui()
myui.setconfig('ui', 'interactive', 'off')
@@ -391,11 +391,24 @@ def get_repo(url, alias):
os.makedirs(dirname)
else:
shared_path = os.path.join(gitdir, 'hg')
- if not os.path.exists(shared_path):
- try:
- hg.clone(myui, {}, url, shared_path, update=False, pull=True)
- except:
- die('Repository error')
+
+ # check and upgrade old organization
+ hg_path = os.path.join(shared_path, '.hg')
+ if os.path.exists(shared_path) and not os.path.exists(hg_path):
+ repos = os.listdir(shared_path)
+ for x in repos:
+ local_hg = os.path.join(shared_path, x, 'clone', '.hg')
+ if not os.path.exists(local_hg):
+ continue
+ if not os.path.exists(hg_path):
+ shutil.move(local_hg, hg_path)
+ shutil.rmtree(os.path.join(shared_path, x, 'clone'))
+
+ # setup shared repo (if not there)
+ try:
+ hg.peer(myui, {}, shared_path, create=True)
+ except error.RepoError:
+ pass
if not os.path.exists(dirname):
os.makedirs(dirname)
@@ -416,16 +429,12 @@ def get_repo(url, alias):
return repo
def rev_to_mark(rev):
- global marks
return marks.from_rev(rev.hex())
def mark_to_rev(mark):
- global marks
return marks.to_rev(mark)
def export_ref(repo, name, kind, head):
- global prefix, marks, mode
-
ename = '%s/%s' % (kind, name)
try:
tip = marks.get_tip(ename)
@@ -522,6 +531,31 @@ def export_ref(repo, name, kind, head):
print "from :%u" % rev_to_mark(head)
print
+ pending_revs = set(revs) - notes
+ if pending_revs:
+ note_mark = marks.next_mark()
+ ref = "refs/notes/hg"
+
+ print "commit %s" % ref
+ print "mark :%d" % (note_mark)
+ print "committer remote-hg <> %s" % (ptime.strftime('%s %z'))
+ desc = "Notes for %s\n" % (name)
+ print "data %d" % (len(desc))
+ print desc
+ if marks.last_note:
+ print "from :%u" % marks.last_note
+
+ for rev in pending_revs:
+ notes.add(rev)
+ c = repo[rev]
+ print "N inline :%u" % rev_to_mark(c)
+ msg = c.hex()
+ print "data %d" % (len(msg))
+ print msg
+ print
+
+ marks.last_note = note_mark
+
marks.set_tip(ename, head.hex())
def export_tag(repo, tag):
@@ -537,12 +571,9 @@ def export_branch(repo, branch):
export_ref(repo, branch, 'branches', head)
def export_head(repo):
- global g_head
export_ref(repo, g_head[0], 'bookmarks', g_head[1])
def do_capabilities(parser):
- global prefix, dirname
-
print "import"
print "export"
print "refspec refs/heads/branches/*:%s/branches/*" % prefix
@@ -562,8 +593,6 @@ def branch_tip(branch):
return branches[branch][-1]
def get_branch_tip(repo, branch):
- global branches
-
heads = branches.get(hgref(branch), None)
if not heads:
return None
@@ -576,7 +605,7 @@ def get_branch_tip(repo, branch):
return heads[0]
def list_head(repo, cur):
- global g_head, bmarks, fake_bmark
+ global g_head, fake_bmark
if 'default' not in branches:
# empty repo
@@ -592,8 +621,6 @@ def list_head(repo, cur):
g_head = (head, node)
def do_list(parser):
- global branches, bmarks, track_branches
-
repo = parser.repo
for bmark, node in bookmarks.listbookmarks(repo).iteritems():
bmarks[bmark] = repo[node]
@@ -661,8 +688,6 @@ def do_import(parser):
print 'done'
def parse_blob(parser):
- global blob_marks
-
parser.next()
mark = parser.get_mark()
parser.next()
@@ -679,9 +704,6 @@ def get_merge_files(repo, p1, p2, files):
files[e] = f
def parse_commit(parser):
- global marks, blob_marks, parsed_refs
- global mode
-
from_mark = merge_mark = None
ref = parser[1]
@@ -799,8 +821,6 @@ def parse_commit(parser):
marks.new_mark(node, commit_mark)
def parse_reset(parser):
- global parsed_refs
-
ref = parser[1]
parser.next()
# ugh
@@ -993,8 +1013,6 @@ def check_tip(ref, kind, name, heads):
return tip in heads
def do_export(parser):
- global parsed_refs, bmarks, peer
-
p_bmarks = []
p_revs = {}
@@ -1066,7 +1084,7 @@ def do_export(parser):
author, msg = parsed_tags.get(tag, (None, None))
if mode == 'git':
if not msg:
- msg = 'Added tag %s for changeset %s' % (tag, node[:12]);
+ msg = 'Added tag %s for changeset %s' % (tag, node[:12])
tagnode, branch = write_tag(parser.repo, tag, node, msg, author)
p_revs[tagnode] = 'refs/heads/branches/' + gitref(branch)
else:
@@ -1124,7 +1142,7 @@ def do_option(parser):
def fix_path(alias, repo, orig_url):
url = urlparse.urlparse(orig_url, 'file')
- if url.scheme != 'file' or os.path.isabs(url.path):
+ if url.scheme != 'file' or os.path.isabs(os.path.expanduser(url.path)):
return
abs_url = urlparse.urljoin("%s/" % os.getcwd(), orig_url)
cmd = ['git', 'config', 'remote.%s.url' % alias, "hg::%s" % abs_url]
@@ -1139,6 +1157,7 @@ def main(args):
global filenodes
global fake_bmark, hg_version
global dry_run
+ global notes, alias
alias = args[1]
url = args[2]
@@ -1178,6 +1197,7 @@ def main(args):
except:
hg_version = None
dry_run = False
+ notes = set()
repo = get_repo(url, alias)
prefix = 'refs/hg/%s' % alias
diff --git a/contrib/remote-helpers/test-bzr.sh b/contrib/remote-helpers/test-bzr.sh
index dce281f911..5c50251783 100755
--- a/contrib/remote-helpers/test-bzr.sh
+++ b/contrib/remote-helpers/test-bzr.sh
@@ -7,19 +7,21 @@ test_description='Test remote-bzr'
. ./test-lib.sh
-if ! test_have_prereq PYTHON; then
+if ! test_have_prereq PYTHON
+then
skip_all='skipping remote-bzr tests; python not available'
test_done
fi
-if ! python -c 'import bzrlib'; then
+if ! python -c 'import bzrlib'
+then
skip_all='skipping remote-bzr tests; bzr not available'
test_done
fi
check () {
- echo $3 > expected &&
- git --git-dir=$1/.git log --format='%s' -1 $2 > actual
+ echo $3 >expected &&
+ git --git-dir=$1/.git log --format='%s' -1 $2 >actual
test_cmp expected actual
}
@@ -29,7 +31,7 @@ test_expect_success 'cloning' '
(
bzr init bzrrepo &&
cd bzrrepo &&
- echo one > content &&
+ echo one >content &&
bzr add content &&
bzr commit -m one
) &&
@@ -41,7 +43,7 @@ test_expect_success 'cloning' '
test_expect_success 'pulling' '
(
cd bzrrepo &&
- echo two > content &&
+ echo two >content &&
bzr commit -m two
) &&
@@ -53,13 +55,13 @@ test_expect_success 'pulling' '
test_expect_success 'pushing' '
(
cd gitrepo &&
- echo three > content &&
+ echo three >content &&
git commit -a -m three &&
git push
) &&
- echo three > expected &&
- cat bzrrepo/content > actual &&
+ echo three >expected &&
+ cat bzrrepo/content >actual &&
test_cmp expected actual
'
@@ -67,16 +69,16 @@ test_expect_success 'roundtrip' '
(
cd gitrepo &&
git pull &&
- git log --format="%s" -1 origin/master > actual
+ git log --format="%s" -1 origin/master >actual
) &&
- echo three > expected &&
+ echo three >expected &&
test_cmp expected actual &&
(cd gitrepo && git push && git pull) &&
(
cd bzrrepo &&
- echo four > content &&
+ echo four >content &&
bzr commit -m four
) &&
@@ -86,19 +88,19 @@ test_expect_success 'roundtrip' '
(
cd gitrepo &&
- echo five > content &&
+ echo five >content &&
git commit -a -m five &&
git push && git pull
) &&
(cd bzrrepo && bzr revert) &&
- echo five > expected &&
- cat bzrrepo/content > actual &&
+ echo five >expected &&
+ cat bzrrepo/content >actual &&
test_cmp expected actual
'
-cat > expected <<EOF
+cat >expected <<\EOF
100644 blob 54f9d6da5c91d556e6b54340b1327573073030af content
100755 blob 68769579c3eaadbe555379b9c3538e6628bae1eb executable
120000 blob 6b584e8ece562ebffc15d38808cd6b98fc3d97ea link
@@ -107,7 +109,7 @@ EOF
test_expect_success 'special modes' '
(
cd bzrrepo &&
- echo exec > executable
+ echo exec >executable
chmod +x executable &&
bzr add executable
bzr commit -m exec &&
@@ -122,21 +124,21 @@ test_expect_success 'special modes' '
(
cd gitrepo &&
git pull
- git ls-tree HEAD > ../actual
+ git ls-tree HEAD >../actual
) &&
test_cmp expected actual &&
(
cd gitrepo &&
- git cat-file -p HEAD:link > ../actual
+ git cat-file -p HEAD:link >../actual
) &&
- printf content > expected &&
+ printf content >expected &&
test_cmp expected actual
'
-cat > expected <<EOF
+cat >expected <<\EOF
100644 blob 54f9d6da5c91d556e6b54340b1327573073030af content
100755 blob 68769579c3eaadbe555379b9c3538e6628bae1eb executable
120000 blob 6b584e8ece562ebffc15d38808cd6b98fc3d97ea link
@@ -147,8 +149,8 @@ test_expect_success 'moving directory' '
(
cd bzrrepo &&
mkdir movedir &&
- echo one > movedir/one &&
- echo two > movedir/two &&
+ echo one >movedir/one &&
+ echo two >movedir/two &&
bzr add movedir &&
bzr commit -m movedir &&
bzr mv movedir movedir-new &&
@@ -158,7 +160,7 @@ test_expect_success 'moving directory' '
(
cd gitrepo &&
git pull &&
- git ls-tree HEAD > ../actual
+ git ls-tree HEAD >../actual
) &&
test_cmp expected actual
@@ -167,7 +169,7 @@ test_expect_success 'moving directory' '
test_expect_success 'different authors' '
(
cd bzrrepo &&
- echo john >> content &&
+ echo john >>content &&
bzr commit -m john \
--author "Jane Rey <jrey@example.com>" \
--author "John Doe <jdoe@example.com>"
@@ -176,10 +178,10 @@ test_expect_success 'different authors' '
(
cd gitrepo &&
git pull &&
- git show --format="%an <%ae>, %cn <%ce>" --quiet > ../actual
+ git show --format="%an <%ae>, %cn <%ce>" --quiet >../actual
) &&
- echo "Jane Rey <jrey@example.com>, A U Thor <author@example.com>" > expected &&
+ echo "Jane Rey <jrey@example.com>, A U Thor <author@example.com>" >expected &&
test_cmp expected actual
'
@@ -196,12 +198,12 @@ test_expect_success 'fetch utf-8 filenames' '
bzr init bzrrepo &&
cd bzrrepo &&
- echo test >> "ærø" &&
+ echo test >>"ærø" &&
bzr add "ærø" &&
- echo test >> "ø~?" &&
+ echo test >>"ø~?" &&
bzr add "ø~?" &&
bzr commit -m add-utf-8 &&
- echo test >> "ærø" &&
+ echo test >>"ærø" &&
bzr commit -m test-utf-8 &&
bzr rm "ø~?" &&
bzr mv "ærø" "ø~?" &&
@@ -211,9 +213,9 @@ test_expect_success 'fetch utf-8 filenames' '
(
git clone "bzr::bzrrepo" gitrepo &&
cd gitrepo &&
- git -c core.quotepath=false ls-files > ../actual
+ git -c core.quotepath=false ls-files >../actual
) &&
- echo "ø~?" > expected &&
+ echo "ø~?" >expected &&
test_cmp expected actual
'
@@ -229,7 +231,7 @@ test_expect_success 'push utf-8 filenames' '
bzr init bzrrepo &&
cd bzrrepo &&
- echo one >> content &&
+ echo one >>content &&
bzr add content &&
bzr commit -m one
) &&
@@ -238,15 +240,15 @@ test_expect_success 'push utf-8 filenames' '
git clone "bzr::bzrrepo" gitrepo &&
cd gitrepo &&
- echo test >> "ærø" &&
+ echo test >>"ærø" &&
git add "ærø" &&
git commit -m utf-8 &&
git push
) &&
- (cd bzrrepo && bzr ls > ../actual) &&
- printf "content\nærø\n" > expected &&
+ (cd bzrrepo && bzr ls >../actual) &&
+ printf "content\nærø\n" >expected &&
test_cmp expected actual
'
@@ -256,7 +258,7 @@ test_expect_success 'pushing a merge' '
(
bzr init bzrrepo &&
cd bzrrepo &&
- echo one > content &&
+ echo one >content &&
bzr add content &&
bzr commit -m one
) &&
@@ -265,27 +267,27 @@ test_expect_success 'pushing a merge' '
(
cd bzrrepo &&
- echo two > content &&
+ echo two >content &&
bzr commit -m two
) &&
(
cd gitrepo &&
- echo three > content &&
+ echo three >content &&
git commit -a -m three &&
git fetch &&
git merge origin/master || true &&
- echo three > content &&
+ echo three >content &&
git commit -a --no-edit &&
git push
) &&
- echo three > expected &&
- cat bzrrepo/content > actual &&
+ echo three >expected &&
+ cat bzrrepo/content >actual &&
test_cmp expected actual
'
-cat > expected <<EOF
+cat >expected <<\EOF
origin/HEAD
origin/branch
origin/trunk
@@ -299,7 +301,7 @@ test_expect_success 'proper bzr repo' '
(
bzr init bzrrepo/trunk &&
cd bzrrepo/trunk &&
- echo one >> content &&
+ echo one >>content &&
bzr add content &&
bzr commit -m one
) &&
@@ -307,14 +309,14 @@ test_expect_success 'proper bzr repo' '
(
bzr branch bzrrepo/trunk bzrrepo/branch &&
cd bzrrepo/branch &&
- echo two >> content &&
+ echo two >>content &&
bzr commit -m one
) &&
(
git clone "bzr::bzrrepo" gitrepo &&
cd gitrepo &&
- git for-each-ref --format "%(refname:short)" refs/remotes/origin > ../actual
+ git for-each-ref --format "%(refname:short)" refs/remotes/origin >../actual
) &&
test_cmp expected actual
@@ -327,11 +329,11 @@ test_expect_success 'strip' '
bzr init bzrrepo &&
cd bzrrepo &&
- echo one >> content &&
+ echo one >>content &&
bzr add content &&
bzr commit -m one &&
- echo two >> content &&
+ echo two >>content &&
bzr commit -m two
) &&
@@ -341,21 +343,51 @@ test_expect_success 'strip' '
cd bzrrepo &&
bzr uncommit --force &&
- echo three >> content &&
+ echo three >>content &&
bzr commit -m three &&
- echo four >> content &&
+ echo four >>content &&
bzr commit -m four &&
- bzr log --line | sed -e "s/^[0-9][0-9]*: //" > ../expected
+ bzr log --line | sed -e "s/^[0-9][0-9]*: //" >../expected
) &&
(
cd gitrepo &&
git fetch &&
- git log --format="%an %ad %s" --date=short origin/master > ../actual
+ git log --format="%an %ad %s" --date=short origin/master >../actual
) &&
test_cmp expected actual
'
+test_expect_success 'export utf-8 authors' '
+ test_when_finished "rm -rf bzrrepo gitrepo && LC_ALL=C && unset GIT_COMMITTER_NAME" &&
+
+ LC_ALL=en_US.UTF-8
+ export LC_ALL
+
+ GIT_COMMITTER_NAME="Grégoire"
+ export GIT_COMMITTER_NAME
+
+ bzr init bzrrepo &&
+
+ (
+ git init gitrepo &&
+ cd gitrepo &&
+ echo greg >>content &&
+ git add content &&
+ git commit -m one &&
+ git remote add bzr "bzr::../bzrrepo" &&
+ git push bzr
+ ) &&
+
+ (
+ cd bzrrepo &&
+ bzr log | grep "^committer: " >../actual
+ ) &&
+
+ echo "committer: Grégoire <committer@example.com>" >expected &&
+ test_cmp expected actual
+'
+
test_done
diff --git a/contrib/remote-helpers/test-hg-bidi.sh b/contrib/remote-helpers/test-hg-bidi.sh
index f83d67d74f..e24c51daad 100755
--- a/contrib/remote-helpers/test-hg-bidi.sh
+++ b/contrib/remote-helpers/test-hg-bidi.sh
@@ -10,12 +10,14 @@ test_description='Test bidirectionality of remote-hg'
. ./test-lib.sh
-if ! test_have_prereq PYTHON; then
+if ! test_have_prereq PYTHON
+then
skip_all='skipping remote-hg tests; python not available'
test_done
fi
-if ! python -c 'import mercurial'; then
+if ! python -c 'import mercurial'
+then
skip_all='skipping remote-hg tests; mercurial not available'
test_done
fi
@@ -43,7 +45,7 @@ hg_push () {
git checkout -q -b tmp &&
git fetch -q "hg::../$1" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*' &&
git checkout -q @{-1} &&
- git branch -q -D tmp 2> /dev/null || true
+ git branch -q -D tmp 2>/dev/null || true
)
}
@@ -62,7 +64,7 @@ setup () {
echo "tag = -d \"0 0\""
echo "[extensions]"
echo "graphlog ="
- ) >> "$HOME"/.hgrc &&
+ ) >>"$HOME"/.hgrc &&
git config --global remote-hg.hg-git-compat true
git config --global remote-hg.track-branches true
@@ -81,22 +83,22 @@ test_expect_success 'encoding' '
git init -q gitrepo &&
cd gitrepo &&
- echo alpha > alpha &&
+ echo alpha >alpha &&
git add alpha &&
git commit -m "add älphà" &&
GIT_AUTHOR_NAME="tést èncödîng" &&
export GIT_AUTHOR_NAME &&
- echo beta > beta &&
+ echo beta >beta &&
git add beta &&
git commit -m "add beta" &&
- echo gamma > gamma &&
+ echo gamma >gamma &&
git add gamma &&
git commit -m "add gämmâ" &&
: TODO git config i18n.commitencoding latin-1 &&
- echo delta > delta &&
+ echo delta >delta &&
git add delta &&
git commit -m "add déltà"
) &&
@@ -105,8 +107,8 @@ test_expect_success 'encoding' '
git_clone hgrepo gitrepo2 &&
hg_clone gitrepo2 hgrepo2 &&
- HGENCODING=utf-8 hg_log hgrepo > expected &&
- HGENCODING=utf-8 hg_log hgrepo2 > actual &&
+ HGENCODING=utf-8 hg_log hgrepo >expected &&
+ HGENCODING=utf-8 hg_log hgrepo2 >actual &&
test_cmp expected actual
'
@@ -117,14 +119,14 @@ test_expect_success 'file removal' '
(
git init -q gitrepo &&
cd gitrepo &&
- echo alpha > alpha &&
+ echo alpha >alpha &&
git add alpha &&
git commit -m "add alpha" &&
- echo beta > beta &&
+ echo beta >beta &&
git add beta &&
git commit -m "add beta"
mkdir foo &&
- echo blah > foo/bar &&
+ echo blah >foo/bar &&
git add foo &&
git commit -m "add foo" &&
git rm alpha &&
@@ -137,8 +139,8 @@ test_expect_success 'file removal' '
git_clone hgrepo gitrepo2 &&
hg_clone gitrepo2 hgrepo2 &&
- hg_log hgrepo > expected &&
- hg_log hgrepo2 > actual &&
+ hg_log hgrepo >expected &&
+ hg_log hgrepo2 >actual &&
test_cmp expected actual
'
@@ -150,12 +152,12 @@ test_expect_success 'git tags' '
git init -q gitrepo &&
cd gitrepo &&
git config receive.denyCurrentBranch ignore &&
- echo alpha > alpha &&
+ echo alpha >alpha &&
git add alpha &&
git commit -m "add alpha" &&
git tag alpha &&
- echo beta > beta &&
+ echo beta >beta &&
git add beta &&
git commit -m "add beta" &&
git tag -a -m "added tag beta" beta
@@ -165,8 +167,8 @@ test_expect_success 'git tags' '
git_clone hgrepo gitrepo2 &&
hg_clone gitrepo2 hgrepo2 &&
- hg_log hgrepo > expected &&
- hg_log hgrepo2 > actual &&
+ hg_log hgrepo >expected &&
+ hg_log hgrepo2 >actual &&
test_cmp expected actual
'
@@ -178,7 +180,7 @@ test_expect_success 'hg branch' '
git init -q gitrepo &&
cd gitrepo &&
- echo alpha > alpha &&
+ echo alpha >alpha &&
git add alpha &&
git commit -q -m "add alpha" &&
git checkout -q -b not-master
@@ -201,8 +203,8 @@ test_expect_success 'hg branch' '
: Back to the common revision &&
(cd hgrepo && hg checkout default) &&
- hg_log hgrepo > expected &&
- hg_log hgrepo2 > actual &&
+ hg_log hgrepo >expected &&
+ hg_log hgrepo2 >actual &&
test_cmp expected actual
'
@@ -214,7 +216,7 @@ test_expect_success 'hg tags' '
git init -q gitrepo &&
cd gitrepo &&
- echo alpha > alpha &&
+ echo alpha >alpha &&
git add alpha &&
git commit -m "add alpha" &&
git checkout -q -b not-master
@@ -231,8 +233,8 @@ test_expect_success 'hg tags' '
hg_push hgrepo gitrepo &&
hg_clone gitrepo hgrepo2 &&
- hg_log hgrepo > expected &&
- hg_log hgrepo2 > actual &&
+ hg_log hgrepo >expected &&
+ hg_log hgrepo2 >actual &&
test_cmp expected actual
'
diff --git a/contrib/remote-helpers/test-hg-hg-git.sh b/contrib/remote-helpers/test-hg-hg-git.sh
index 2219284382..6dcd95d10f 100755
--- a/contrib/remote-helpers/test-hg-hg-git.sh
+++ b/contrib/remote-helpers/test-hg-hg-git.sh
@@ -10,17 +10,20 @@ test_description='Test remote-hg output compared to hg-git'
. ./test-lib.sh
-if ! test_have_prereq PYTHON; then
+if ! test_have_prereq PYTHON
+then
skip_all='skipping remote-hg tests; python not available'
test_done
fi
-if ! python -c 'import mercurial'; then
+if ! python -c 'import mercurial'
+then
skip_all='skipping remote-hg tests; mercurial not available'
test_done
fi
-if ! python -c 'import hggit'; then
+if ! python -c 'import hggit'
+then
skip_all='skipping remote-hg tests; hg-git not available'
test_done
fi
@@ -66,7 +69,7 @@ hg_push_git () {
git fetch -q "hg::../$1" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*' &&
git branch -D default &&
git checkout -q @{-1} &&
- git branch -q -D tmp 2> /dev/null || true
+ git branch -q -D tmp 2>/dev/null || true
)
}
@@ -100,7 +103,7 @@ setup () {
echo "hgext.bookmarks ="
echo "hggit ="
echo "graphlog ="
- ) >> "$HOME"/.hgrc &&
+ ) >>"$HOME"/.hgrc &&
git config --global receive.denycurrentbranch warn
git config --global remote-hg.hg-git-compat true
git config --global remote-hg.track-branches false
@@ -121,7 +124,7 @@ test_expect_success 'executable bit' '
(
git init -q gitrepo &&
cd gitrepo &&
- echo alpha > alpha &&
+ echo alpha >alpha &&
chmod 0644 alpha &&
git add alpha &&
git commit -m "add alpha" &&
@@ -133,17 +136,18 @@ test_expect_success 'executable bit' '
git commit -m "clear executable bit"
) &&
- for x in hg git; do
+ for x in hg git
+ do
(
hg_clone_$x gitrepo hgrepo-$x &&
cd hgrepo-$x &&
hg_log . &&
hg manifest -r 1 -v &&
hg manifest -v
- ) > output-$x &&
+ ) >"output-$x" &&
git_clone_$x hgrepo-$x gitrepo2-$x &&
- git_log gitrepo2-$x > log-$x
+ git_log gitrepo2-$x >"log-$x"
done &&
test_cmp output-hg output-git &&
@@ -156,7 +160,7 @@ test_expect_success 'symlink' '
(
git init -q gitrepo &&
cd gitrepo &&
- echo alpha > alpha &&
+ echo alpha >alpha &&
git add alpha &&
git commit -m "add alpha" &&
ln -s alpha beta &&
@@ -164,16 +168,17 @@ test_expect_success 'symlink' '
git commit -m "add beta"
) &&
- for x in hg git; do
+ for x in hg git
+ do
(
hg_clone_$x gitrepo hgrepo-$x &&
cd hgrepo-$x &&
hg_log . &&
hg manifest -v
- ) > output-$x &&
+ ) >"output-$x" &&
git_clone_$x hgrepo-$x gitrepo2-$x &&
- git_log gitrepo2-$x > log-$x
+ git_log gitrepo2-$x >"log-$x"
done &&
test_cmp output-hg output-git &&
@@ -186,28 +191,29 @@ test_expect_success 'merge conflict 1' '
(
hg init hgrepo1 &&
cd hgrepo1 &&
- echo A > afile &&
+ echo A >afile &&
hg add afile &&
hg ci -m "origin" &&
- echo B > afile &&
+ echo B >afile &&
hg ci -m "A->B" &&
hg up -r0 &&
- echo C > afile &&
+ echo C >afile &&
hg ci -m "A->C" &&
hg merge -r1 &&
- echo C > afile &&
+ echo C >afile &&
hg resolve -m afile &&
hg ci -m "merge to C"
) &&
- for x in hg git; do
+ for x in hg git
+ do
git_clone_$x hgrepo1 gitrepo-$x &&
hg_clone_$x gitrepo-$x hgrepo2-$x &&
- hg_log hgrepo2-$x > hg-log-$x &&
- git_log gitrepo-$x > git-log-$x
+ hg_log hgrepo2-$x >"hg-log-$x" &&
+ git_log gitrepo-$x >"git-log-$x"
done &&
test_cmp hg-log-hg hg-log-git &&
@@ -220,28 +226,29 @@ test_expect_success 'merge conflict 2' '
(
hg init hgrepo1 &&
cd hgrepo1 &&
- echo A > afile &&
+ echo A >afile &&
hg add afile &&
hg ci -m "origin" &&
- echo B > afile &&
+ echo B >afile &&
hg ci -m "A->B" &&
hg up -r0 &&
- echo C > afile &&
+ echo C >afile &&
hg ci -m "A->C" &&
hg merge -r1 || true &&
- echo B > afile &&
+ echo B >afile &&
hg resolve -m afile &&
hg ci -m "merge to B"
) &&
- for x in hg git; do
+ for x in hg git
+ do
git_clone_$x hgrepo1 gitrepo-$x &&
hg_clone_$x gitrepo-$x hgrepo2-$x &&
- hg_log hgrepo2-$x > hg-log-$x &&
- git_log gitrepo-$x > git-log-$x
+ hg_log hgrepo2-$x >"hg-log-$x" &&
+ git_log gitrepo-$x >"git-log-$x"
done &&
test_cmp hg-log-hg hg-log-git &&
@@ -254,29 +261,30 @@ test_expect_success 'converged merge' '
(
hg init hgrepo1 &&
cd hgrepo1 &&
- echo A > afile &&
+ echo A >afile &&
hg add afile &&
hg ci -m "origin" &&
- echo B > afile &&
+ echo B >afile &&
hg ci -m "A->B" &&
- echo C > afile &&
+ echo C >afile &&
hg ci -m "B->C" &&
hg up -r0 &&
- echo C > afile &&
+ echo C >afile &&
hg ci -m "A->C" &&
hg merge -r2 || true &&
hg ci -m "merge"
) &&
- for x in hg git; do
+ for x in hg git
+ do
git_clone_$x hgrepo1 gitrepo-$x &&
hg_clone_$x gitrepo-$x hgrepo2-$x &&
- hg_log hgrepo2-$x > hg-log-$x &&
- git_log gitrepo-$x > git-log-$x
+ hg_log hgrepo2-$x >"hg-log-$x" &&
+ git_log gitrepo-$x >"git-log-$x"
done &&
test_cmp hg-log-hg hg-log-git &&
@@ -290,32 +298,33 @@ test_expect_success 'encoding' '
git init -q gitrepo &&
cd gitrepo &&
- echo alpha > alpha &&
+ echo alpha >alpha &&
git add alpha &&
git commit -m "add älphà" &&
GIT_AUTHOR_NAME="tést èncödîng" &&
export GIT_AUTHOR_NAME &&
- echo beta > beta &&
+ echo beta >beta &&
git add beta &&
git commit -m "add beta" &&
- echo gamma > gamma &&
+ echo gamma >gamma &&
git add gamma &&
git commit -m "add gämmâ" &&
: TODO git config i18n.commitencoding latin-1 &&
- echo delta > delta &&
+ echo delta >delta &&
git add delta &&
git commit -m "add déltà"
) &&
- for x in hg git; do
+ for x in hg git
+ do
hg_clone_$x gitrepo hgrepo-$x &&
git_clone_$x hgrepo-$x gitrepo2-$x &&
- HGENCODING=utf-8 hg_log hgrepo-$x > hg-log-$x &&
- git_log gitrepo2-$x > git-log-$x
+ HGENCODING=utf-8 hg_log hgrepo-$x >"hg-log-$x" &&
+ git_log gitrepo2-$x >"git-log-$x"
done &&
test_cmp hg-log-hg hg-log-git &&
@@ -328,14 +337,14 @@ test_expect_success 'file removal' '
(
git init -q gitrepo &&
cd gitrepo &&
- echo alpha > alpha &&
+ echo alpha >alpha &&
git add alpha &&
git commit -m "add alpha" &&
- echo beta > beta &&
+ echo beta >beta &&
git add beta &&
git commit -m "add beta"
mkdir foo &&
- echo blah > foo/bar &&
+ echo blah >foo/bar &&
git add foo &&
git commit -m "add foo" &&
git rm alpha &&
@@ -344,17 +353,18 @@ test_expect_success 'file removal' '
git commit -m "remove foo/bar"
) &&
- for x in hg git; do
+ for x in hg git
+ do
(
hg_clone_$x gitrepo hgrepo-$x &&
cd hgrepo-$x &&
hg_log . &&
hg manifest -r 3 &&
hg manifest
- ) > output-$x &&
+ ) >"output-$x" &&
git_clone_$x hgrepo-$x gitrepo2-$x &&
- git_log gitrepo2-$x > log-$x
+ git_log gitrepo2-$x >"log-$x"
done &&
test_cmp output-hg output-git &&
@@ -368,20 +378,21 @@ test_expect_success 'git tags' '
git init -q gitrepo &&
cd gitrepo &&
git config receive.denyCurrentBranch ignore &&
- echo alpha > alpha &&
+ echo alpha >alpha &&
git add alpha &&
git commit -m "add alpha" &&
git tag alpha &&
- echo beta > beta &&
+ echo beta >beta &&
git add beta &&
git commit -m "add beta" &&
git tag -a -m "added tag beta" beta
) &&
- for x in hg git; do
+ for x in hg git
+ do
hg_clone_$x gitrepo hgrepo-$x &&
- hg_log hgrepo-$x > log-$x
+ hg_log hgrepo-$x >"log-$x"
done &&
test_cmp log-hg log-git
@@ -390,12 +401,13 @@ test_expect_success 'git tags' '
test_expect_success 'hg author' '
test_when_finished "rm -rf gitrepo* hgrepo*" &&
- for x in hg git; do
+ for x in hg git
+ do
(
git init -q gitrepo-$x &&
cd gitrepo-$x &&
- echo alpha > alpha &&
+ echo alpha >alpha &&
git add alpha &&
git commit -m "add alpha" &&
git checkout -q -b not-master
@@ -406,38 +418,38 @@ test_expect_success 'hg author' '
cd hgrepo-$x &&
hg co master &&
- echo beta > beta &&
+ echo beta >beta &&
hg add beta &&
hg commit -u "test" -m "add beta" &&
- echo gamma >> beta &&
+ echo gamma >>beta &&
hg commit -u "test <test@example.com> (comment)" -m "modify beta" &&
- echo gamma > gamma &&
+ echo gamma >gamma &&
hg add gamma &&
hg commit -u "<test@example.com>" -m "add gamma" &&
- echo delta > delta &&
+ echo delta >delta &&
hg add delta &&
hg commit -u "name<test@example.com>" -m "add delta" &&
- echo epsilon > epsilon &&
+ echo epsilon >epsilon &&
hg add epsilon &&
hg commit -u "name <test@example.com" -m "add epsilon" &&
- echo zeta > zeta &&
+ echo zeta >zeta &&
hg add zeta &&
hg commit -u " test " -m "add zeta" &&
- echo eta > eta &&
+ echo eta >eta &&
hg add eta &&
hg commit -u "test < test@example.com >" -m "add eta" &&
- echo theta > theta &&
+ echo theta >theta &&
hg add theta &&
hg commit -u "test >test@example.com>" -m "add theta" &&
- echo iota > iota &&
+ echo iota >iota &&
hg add iota &&
hg commit -u "test <test <at> example <dot> com>" -m "add iota"
) &&
@@ -445,8 +457,8 @@ test_expect_success 'hg author' '
hg_push_$x hgrepo-$x gitrepo-$x &&
hg_clone_$x gitrepo-$x hgrepo2-$x &&
- hg_log hgrepo2-$x > hg-log-$x &&
- git_log gitrepo-$x > git-log-$x
+ hg_log hgrepo2-$x >"hg-log-$x" &&
+ git_log gitrepo-$x >"git-log-$x"
done &&
test_cmp hg-log-hg hg-log-git &&
@@ -456,12 +468,13 @@ test_expect_success 'hg author' '
test_expect_success 'hg branch' '
test_when_finished "rm -rf gitrepo* hgrepo*" &&
- for x in hg git; do
+ for x in hg git
+ do
(
git init -q gitrepo-$x &&
cd gitrepo-$x &&
- echo alpha > alpha &&
+ echo alpha >alpha &&
git add alpha &&
git commit -q -m "add alpha" &&
git checkout -q -b not-master
@@ -481,8 +494,8 @@ test_expect_success 'hg branch' '
hg_push_$x hgrepo-$x gitrepo-$x &&
hg_clone_$x gitrepo-$x hgrepo2-$x &&
- hg_log hgrepo2-$x > hg-log-$x &&
- git_log gitrepo-$x > git-log-$x
+ hg_log hgrepo2-$x >"hg-log-$x" &&
+ git_log gitrepo-$x >"git-log-$x"
done &&
test_cmp hg-log-hg hg-log-git &&
@@ -492,12 +505,13 @@ test_expect_success 'hg branch' '
test_expect_success 'hg tags' '
test_when_finished "rm -rf gitrepo* hgrepo*" &&
- for x in hg git; do
+ for x in hg git
+ do
(
git init -q gitrepo-$x &&
cd gitrepo-$x &&
- echo alpha > alpha &&
+ echo alpha >alpha &&
git add alpha &&
git commit -m "add alpha" &&
git checkout -q -b not-master
@@ -518,7 +532,7 @@ test_expect_success 'hg tags' '
git --git-dir=gitrepo-$x/.git tag -l &&
hg_log hgrepo2-$x &&
cat hgrepo2-$x/.hgtags
- ) > output-$x
+ ) >"output-$x"
done &&
test_cmp output-hg output-git
diff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh
index f7ce8aa853..72f745d63f 100755
--- a/contrib/remote-helpers/test-hg.sh
+++ b/contrib/remote-helpers/test-hg.sh
@@ -10,40 +10,44 @@ test_description='Test remote-hg'
. ./test-lib.sh
-if ! test_have_prereq PYTHON; then
+if ! test_have_prereq PYTHON
+then
skip_all='skipping remote-hg tests; python not available'
test_done
fi
-if ! python -c 'import mercurial'; then
+if ! python -c 'import mercurial'
+then
skip_all='skipping remote-hg tests; mercurial not available'
test_done
fi
check () {
- echo $3 > expected &&
- git --git-dir=$1/.git log --format='%s' -1 $2 > actual
+ echo $3 >expected &&
+ git --git-dir=$1/.git log --format='%s' -1 $2 >actual
test_cmp expected actual
}
check_branch () {
- if [ -n "$3" ]; then
- echo $3 > expected &&
- hg -R $1 log -r $2 --template '{desc}\n' > actual &&
+ if test -n "$3"
+ then
+ echo $3 >expected &&
+ hg -R $1 log -r $2 --template '{desc}\n' >actual &&
test_cmp expected actual
else
- hg -R $1 branches > out &&
+ hg -R $1 branches >out &&
! grep $2 out
fi
}
check_bookmark () {
- if [ -n "$3" ]; then
- echo $3 > expected &&
- hg -R $1 log -r "bookmark('$2')" --template '{desc}\n' > actual &&
+ if test -n "$3"
+ then
+ echo $3 >expected &&
+ hg -R $1 log -r "bookmark('$2')" --template '{desc}\n' >actual &&
test_cmp expected actual
else
- hg -R $1 bookmarks > out &&
+ hg -R $1 bookmarks >out &&
! grep $2 out
fi
}
@@ -52,7 +56,7 @@ check_push () {
local expected_ret=$1 ret=0 ref_ret=0 IFS=':'
shift
- git push origin "$@" 2> error
+ git push origin "$@" 2>error
ret=$?
cat error
@@ -75,10 +79,10 @@ check_push () {
grep "^ [a-f0-9]*\.\.[a-f0-9]* *${branch} -> ${branch}$" error || ref_ret=1
;;
esac
- let 'ref_ret' && echo "match for '$branch' failed" && break
+ test $ref_ret -ne 0 && echo "match for '$branch' failed" && break
done
- if let 'expected_ret != ret || ref_ret'
+ if test $expected_ret -ne $ret -o $ref_ret -ne 0
then
return 1
fi
@@ -92,7 +96,7 @@ setup () {
echo "username = H G Wells <wells@example.com>"
echo "[extensions]"
echo "mq ="
- ) >> "$HOME"/.hgrc &&
+ ) >>"$HOME"/.hgrc &&
GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0230" &&
GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE" &&
@@ -107,7 +111,7 @@ test_expect_success 'cloning' '
(
hg init hgrepo &&
cd hgrepo &&
- echo zero > content &&
+ echo zero >content &&
hg add content &&
hg commit -m zero
) &&
@@ -122,7 +126,7 @@ test_expect_success 'cloning with branches' '
(
cd hgrepo &&
hg branch next &&
- echo next > content &&
+ echo next >content &&
hg commit -m next
) &&
@@ -137,7 +141,7 @@ test_expect_success 'cloning with bookmarks' '
cd hgrepo &&
hg checkout default &&
hg bookmark feature-a &&
- echo feature-a > content &&
+ echo feature-a >content &&
hg commit -m feature-a
) &&
@@ -157,7 +161,7 @@ test_expect_success 'update bookmark' '
git clone "hg::hgrepo" gitrepo &&
cd gitrepo &&
git checkout --quiet devel &&
- echo devel > content &&
+ echo devel >content &&
git commit -a -m devel &&
git push --quiet
) &&
@@ -172,7 +176,7 @@ test_expect_success 'new bookmark' '
git clone "hg::hgrepo" gitrepo &&
cd gitrepo &&
git checkout --quiet -b feature-b &&
- echo feature-b > content &&
+ echo feature-b >content &&
git commit -a -m feature-b &&
git push --quiet origin feature-b
) &&
@@ -184,9 +188,9 @@ test_expect_success 'new bookmark' '
rm -rf hgrepo
author_test () {
- echo $1 >> content &&
+ echo $1 >>content &&
hg commit -u "$2" -m "add $1" &&
- echo "$3" >> ../expected
+ echo "$3" >>../expected
}
test_expect_success 'authors' '
@@ -199,7 +203,7 @@ test_expect_success 'authors' '
touch content &&
hg add content &&
- > ../expected &&
+ >../expected &&
author_test alpha "" "H G Wells <wells@example.com>" &&
author_test beta "test" "test <unknown>" &&
author_test beta "test <test@example.com> (comment)" "test <test@example.com>" &&
@@ -214,7 +218,7 @@ test_expect_success 'authors' '
) &&
git clone "hg::hgrepo" gitrepo &&
- git --git-dir=gitrepo/.git log --reverse --format="%an <%ae>" > actual &&
+ git --git-dir=gitrepo/.git log --reverse --format="%an <%ae>" >actual &&
test_cmp expected actual
'
@@ -226,11 +230,11 @@ test_expect_success 'strip' '
hg init hgrepo &&
cd hgrepo &&
- echo one >> content &&
+ echo one >>content &&
hg add content &&
hg commit -m one &&
- echo two >> content &&
+ echo two >>content &&
hg commit -m two
) &&
@@ -240,20 +244,20 @@ test_expect_success 'strip' '
cd hgrepo &&
hg strip 1 &&
- echo three >> content &&
+ echo three >>content &&
hg commit -m three &&
- echo four >> content &&
+ echo four >>content &&
hg commit -m four
) &&
(
cd gitrepo &&
git fetch &&
- git log --format="%s" origin/master > ../actual
+ git log --format="%s" origin/master >../actual
) &&
- hg -R hgrepo log --template "{desc}\n" > expected &&
+ hg -R hgrepo log --template "{desc}\n" >expected &&
test_cmp actual expected
'
@@ -263,18 +267,18 @@ test_expect_success 'remote push with master bookmark' '
(
hg init hgrepo &&
cd hgrepo &&
- echo zero > content &&
+ echo zero >content &&
hg add content &&
hg commit -m zero &&
hg bookmark master &&
- echo one > content &&
+ echo one >content &&
hg commit -m one
) &&
(
git clone "hg::hgrepo" gitrepo &&
cd gitrepo &&
- echo two > content &&
+ echo two >content &&
git commit -a -m two &&
git push
) &&
@@ -282,7 +286,7 @@ test_expect_success 'remote push with master bookmark' '
check_branch hgrepo default two
'
-cat > expected <<EOF
+cat >expected <<\EOF
changeset: 0:6e2126489d3d
tag: tip
user: A U Thor <author@example.com>
@@ -300,13 +304,13 @@ test_expect_success 'remote push from master branch' '
git init gitrepo &&
cd gitrepo &&
git remote add origin "hg::../hgrepo" &&
- echo one > content &&
+ echo one >content &&
git add content &&
git commit -a -m one &&
git push origin master
) &&
- hg -R hgrepo log > actual &&
+ hg -R hgrepo log >actual &&
cat actual &&
test_cmp expected actual &&
@@ -322,7 +326,7 @@ test_expect_success 'remote cloning' '
(
hg init hgrepo &&
cd hgrepo &&
- echo zero > content &&
+ echo zero >content &&
hg add content &&
hg commit -m zero
) &&
@@ -343,7 +347,7 @@ test_expect_success 'remote update bookmark' '
git clone "hg::hgrepo" gitrepo &&
cd gitrepo &&
git checkout --quiet devel &&
- echo devel > content &&
+ echo devel >content &&
git commit -a -m devel &&
git push --quiet
) &&
@@ -358,7 +362,7 @@ test_expect_success 'remote new bookmark' '
git clone "hg::hgrepo" gitrepo &&
cd gitrepo &&
git checkout --quiet -b feature-b &&
- echo feature-b > content &&
+ echo feature-b >content &&
git commit -a -m feature-b &&
git push --quiet origin feature-b
) &&
@@ -374,15 +378,15 @@ test_expect_success 'remote push diverged' '
(
cd hgrepo &&
hg checkout default &&
- echo bump > content &&
+ echo bump >content &&
hg commit -m bump
) &&
(
cd gitrepo &&
- echo diverge > content &&
+ echo diverge >content &&
git commit -a -m diverged &&
- check_push 1 <<-EOF
+ check_push 1 <<-\EOF
master:non-fast-forward
EOF
) &&
@@ -403,16 +407,16 @@ test_expect_success 'remote update bookmark diverge' '
(
cd hgrepo &&
- echo "bump bookmark" > content &&
+ echo "bump bookmark" >content &&
hg commit -m "bump bookmark"
) &&
(
cd gitrepo &&
git checkout --quiet diverge &&
- echo diverge > content &&
+ echo diverge >content &&
git commit -a -m diverge &&
- check_push 1 <<-EOF
+ check_push 1 <<-\EOF
diverge:fetch-first
EOF
) &&
@@ -427,7 +431,7 @@ test_expect_success 'remote new bookmark multiple branch head' '
git clone "hg::hgrepo" gitrepo &&
cd gitrepo &&
git checkout --quiet -b feature-c HEAD^ &&
- echo feature-c > content &&
+ echo feature-c >content &&
git commit -a -m feature-c &&
git push --quiet origin feature-c
) &&
@@ -442,20 +446,20 @@ setup_big_push () {
(
hg init hgrepo &&
cd hgrepo &&
- echo zero > content &&
+ echo zero >content &&
hg add content &&
hg commit -m zero &&
hg bookmark bad_bmark1 &&
- echo one > content &&
+ echo one >content &&
hg commit -m one &&
hg bookmark bad_bmark2 &&
hg bookmark good_bmark &&
hg bookmark -i good_bmark &&
hg -q branch good_branch &&
- echo "good branch" > content &&
+ echo "good branch" >content &&
hg commit -m "good branch" &&
hg -q branch bad_branch &&
- echo "bad branch" > content &&
+ echo "bad branch" >content &&
hg commit -m "bad branch"
) &&
@@ -463,40 +467,40 @@ setup_big_push () {
(
cd gitrepo &&
- echo two > content &&
+ echo two >content &&
git commit -q -a -m two &&
git checkout -q good_bmark &&
- echo three > content &&
+ echo three >content &&
git commit -q -a -m three &&
git checkout -q bad_bmark1 &&
git reset --hard HEAD^ &&
- echo four > content &&
+ echo four >content &&
git commit -q -a -m four &&
git checkout -q bad_bmark2 &&
git reset --hard HEAD^ &&
- echo five > content &&
+ echo five >content &&
git commit -q -a -m five &&
git checkout -q -b new_bmark master &&
- echo six > content &&
+ echo six >content &&
git commit -q -a -m six &&
git checkout -q branches/good_branch &&
- echo seven > content &&
+ echo seven >content &&
git commit -q -a -m seven &&
- echo eight > content &&
+ echo eight >content &&
git commit -q -a -m eight &&
git checkout -q branches/bad_branch &&
git reset --hard HEAD^ &&
- echo nine > content &&
+ echo nine >content &&
git commit -q -a -m nine &&
git checkout -q -b branches/new_branch master &&
- echo ten > content &&
+ echo ten >content &&
git commit -q -a -m ten
)
}
@@ -509,7 +513,7 @@ test_expect_success 'remote big push' '
(
cd gitrepo &&
- check_push 1 --all <<-EOF
+ check_push 1 --all <<-\EOF
master
good_bmark
branches/good_branch
@@ -537,17 +541,17 @@ test_expect_success 'remote big push fetch first' '
(
hg init hgrepo &&
cd hgrepo &&
- echo zero > content &&
+ echo zero >content &&
hg add content &&
hg commit -m zero &&
hg bookmark bad_bmark &&
hg bookmark good_bmark &&
hg bookmark -i good_bmark &&
hg -q branch good_branch &&
- echo "good branch" > content &&
+ echo "good branch" >content &&
hg commit -m "good branch" &&
hg -q branch bad_branch &&
- echo "bad branch" > content &&
+ echo "bad branch" >content &&
hg commit -m "bad branch"
) &&
@@ -556,39 +560,37 @@ test_expect_success 'remote big push fetch first' '
(
cd hgrepo &&
hg bookmark -f bad_bmark &&
- echo update_bmark > content &&
+ echo update_bmark >content &&
hg commit -m "update bmark"
) &&
(
cd gitrepo &&
- echo two > content &&
+ echo two >content &&
git commit -q -a -m two &&
git checkout -q good_bmark &&
- echo three > content &&
+ echo three >content &&
git commit -q -a -m three &&
git checkout -q bad_bmark &&
- echo four > content &&
+ echo four >content &&
git commit -q -a -m four &&
git checkout -q branches/bad_branch &&
- echo five > content &&
+ echo five >content &&
git commit -q -a -m five &&
- check_push 1 --all <<-EOF
+ check_push 1 --all <<-\EOF &&
master
good_bmark
- new_bmark:new
- new_branch:new
bad_bmark:fetch-first
branches/bad_branch:festch-first
EOF
git fetch &&
- check_push 1 --all <<-EOF
+ check_push 1 --all <<-\EOF
master
good_bmark
bad_bmark:non-fast-forward
@@ -605,7 +607,7 @@ test_expect_failure 'remote big push force' '
(
cd gitrepo &&
- check_push 0 --force --all <<-EOF
+ check_push 0 --force --all <<-\EOF
master
good_bmark
branches/good_branch
@@ -635,7 +637,7 @@ test_expect_failure 'remote big push dry-run' '
(
cd gitrepo &&
- check_push 0 --dry-run --all <<-EOF
+ check_push 1 --dry-run --all <<-\EOF &&
master
good_bmark
branches/good_branch
@@ -646,7 +648,7 @@ test_expect_failure 'remote big push dry-run' '
branches/bad_branch:non-fast-forward
EOF
- check_push 0 --dry-run master good_bmark new_bmark branches/good_branch branches/new_branch <<-EOF
+ check_push 0 --dry-run master good_bmark new_bmark branches/good_branch branches/new_branch <<-\EOF
master
good_bmark
branches/good_branch
@@ -671,10 +673,10 @@ test_expect_success 'remote double failed push' '
(
hg init hgrepo &&
cd hgrepo &&
- echo zero > content &&
+ echo zero >content &&
hg add content &&
hg commit -m zero &&
- echo one > content &&
+ echo one >content &&
hg commit -m one
) &&
@@ -682,7 +684,7 @@ test_expect_success 'remote double failed push' '
git clone "hg::hgrepo" gitrepo &&
cd gitrepo &&
git reset --hard HEAD^ &&
- echo two > content &&
+ echo two >content &&
git commit -a -m two &&
test_expect_code 1 git push &&
test_expect_code 1 git push