Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: 45104b572f
Fetching contributors…

Cannot retrieve contributors at this time

executable file 42 lines (33 sloc) 1.137 kB
#!/bin/bash
set -e
hg_repo=$1
git_commit_id=$2
if [[ "$git_commit_id" == "" ]]; then
git_commit_id="HEAD"
fi
if [[ "$git_commit_id" == "" || "$hg_repo" == "" ]]; then
echo "Usage: $(basename $0) path-to-hg-repo [git-commit-id] [path-to-git-repo]" 1>&2
exit 255
fi
function git_log()
{
# $1: The format to pass to git log.
git log -n1 "$git_commit_id" --pretty="format:$1"
}
# If git doesn't have an e-mail address, it substitutes "<none@none>", which will mess us up.
commit_user=$(git_log '%an <%ae>' | sed -e 's/ <none@none>//')
commit_date=$(git_log '%aD')
search_str=$(git_log ' %B' | head -n1)
# Locate the hg {desc}|{node} pair containing the commit message from search_str.
hg_str=$(hg log -R "$hg_repo" --user "$commit_user" --date "$commit_date" --template '{node} {desc|firstline}\n' | grep -F "$search_str") || true
if [[ "$hg_str" == "" ]]; then
echo "No matching commit found." 1>&2
exit 1
elif (( "$(echo "$hg_str" | wc -l)" > 1 )); then
echo "Uh oh; multiple matching commits!" 1>&2
echo "$hg_str" 1>&2
exit 2
fi
# Cool; we found it!
hg_node=$(echo "$hg_str" | cut -f 1 -d ' ')
echo "$hg_node"
Jump to Line
Something went wrong with that request. Please try again.