mirror of
https://github.com/neovim/neovim.git
synced 2025-11-06 18:54:24 +00:00
vim-patch.sh: update for Vim's hg => git migration
This commit is contained in:
committed by
Justin M. Keyes
parent
9602f0d589
commit
4d39db355b
18
scripts/vim-patch-helper.awk
Normal file
18
scripts/vim-patch-helper.awk
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#/usr/bin/env awk -f
|
||||||
|
BEGIN {
|
||||||
|
FS="|";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
if ($2 == "") {
|
||||||
|
print($1)
|
||||||
|
} else {
|
||||||
|
n=split($2,ary,", ");
|
||||||
|
for (i=1;i<=n;i++) {
|
||||||
|
if (match(ary[i], /tag: /)) {
|
||||||
|
gsub(/[()]/, "", ary[i]);
|
||||||
|
sub(/ *tag: /, "", ary[i]);
|
||||||
|
print(ary[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,7 +20,7 @@ usage() {
|
|||||||
echo " -l Show list of Vim patches missing from Neovim."
|
echo " -l Show list of Vim patches missing from Neovim."
|
||||||
echo " -p {vim-revision} Download and apply the Vim patch vim-revision."
|
echo " -p {vim-revision} Download and apply the Vim patch vim-revision."
|
||||||
echo " vim-revision can be a version number of the "
|
echo " vim-revision can be a version number of the "
|
||||||
echo " format '7.4.xxx' or a Mercurial commit hash."
|
echo " format '7.4.xxx' or a Git commit hash."
|
||||||
echo " -r {pr-number} Review a vim-patch pull request to Neovim."
|
echo " -r {pr-number} Review a vim-patch pull request to Neovim."
|
||||||
echo
|
echo
|
||||||
echo "Set VIM_SOURCE_DIR to change where Vim's sources are stored."
|
echo "Set VIM_SOURCE_DIR to change where Vim's sources are stored."
|
||||||
@@ -36,17 +36,22 @@ check_executable() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get_vim_sources() {
|
get_vim_sources() {
|
||||||
check_executable hg
|
check_executable git
|
||||||
|
|
||||||
echo "Retrieving Vim sources."
|
echo "Retrieving Vim sources."
|
||||||
if [[ ! -d ${VIM_SOURCE_DIR} ]]; then
|
if [[ ! -d ${VIM_SOURCE_DIR} ]]; then
|
||||||
echo "Cloning Vim sources into '${VIM_SOURCE_DIR}'."
|
echo "Cloning Vim sources into '${VIM_SOURCE_DIR}'."
|
||||||
hg clone https://code.google.com/p/vim "${VIM_SOURCE_DIR}"
|
git clone --depth=1000 https://github.com/vim/vim.git "${VIM_SOURCE_DIR}"
|
||||||
cd "${VIM_SOURCE_DIR}"
|
cd "${VIM_SOURCE_DIR}"
|
||||||
else
|
else
|
||||||
|
if [[ ! -d "${VIM_SOURCE_DIR}/.git" ]]; then
|
||||||
|
echo "✘ ${VIM_SOURCE_DIR} does not appear to be a git repository."
|
||||||
|
echo " Please remove it and try again."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
echo "Updating Vim sources in '${VIM_SOURCE_DIR}'."
|
echo "Updating Vim sources in '${VIM_SOURCE_DIR}'."
|
||||||
cd "${VIM_SOURCE_DIR}"
|
cd "${VIM_SOURCE_DIR}"
|
||||||
hg pull --update &&
|
git pull &&
|
||||||
echo "✔ Updated Vim sources." ||
|
echo "✔ Updated Vim sources." ||
|
||||||
echo "✘ Could not update Vim sources; ignoring error."
|
echo "✘ Could not update Vim sources; ignoring error."
|
||||||
fi
|
fi
|
||||||
@@ -64,17 +69,17 @@ assign_commit_details() {
|
|||||||
if [[ ${1} =~ [0-9]\.[0-9]\.[0-9]{3,4} ]]; then
|
if [[ ${1} =~ [0-9]\.[0-9]\.[0-9]{3,4} ]]; then
|
||||||
# Interpret parameter as version number.
|
# Interpret parameter as version number.
|
||||||
vim_version="${1}"
|
vim_version="${1}"
|
||||||
vim_commit="v${1//./-}"
|
vim_commit="v${1}"
|
||||||
local strip_commit_line=true
|
local strip_commit_line=true
|
||||||
vim_commit_url="https://github.com/vim/vim/commit/${vim_commit}"
|
vim_commit_url="https://github.com/vim/vim/tree/${vim_commit}"
|
||||||
else
|
else
|
||||||
# Interpret parameter as commit hash.
|
# Interpret parameter as commit hash.
|
||||||
vim_version="${1:0:7}"
|
vim_version="${1:0:7}"
|
||||||
vim_commit="${1}"
|
vim_commit="${1}"
|
||||||
local strip_commit_line=false
|
local strip_commit_line=false
|
||||||
vim_commit_url="https://code.google.com/p/vim/source/detail?r=${vim_commit}"
|
vim_commit_url="https://github.com/vim/vim/commit/${vim_commit}"
|
||||||
fi
|
fi
|
||||||
vim_message="$(hg log --template "{desc}" --rev "${vim_commit}")"
|
vim_message="$(git log --pretty='format:%B' "${vim_commit}^\!")"
|
||||||
if [[ ${strip_commit_line} == "true" ]]; then
|
if [[ ${strip_commit_line} == "true" ]]; then
|
||||||
# Remove first line of commit message.
|
# Remove first line of commit message.
|
||||||
vim_message="$(echo "${vim_message}" | sed -e '1d')"
|
vim_message="$(echo "${vim_message}" | sed -e '1d')"
|
||||||
@@ -86,7 +91,7 @@ get_vim_patch() {
|
|||||||
|
|
||||||
assign_commit_details "${1}"
|
assign_commit_details "${1}"
|
||||||
|
|
||||||
hg log --rev "${vim_commit}" >/dev/null 2>&1 || {
|
git log "${vim_commit}^\!" -- >/dev/null 2>&1 || {
|
||||||
>&2 echo "✘ Couldn't find Vim revision '${vim_commit}'."
|
>&2 echo "✘ Couldn't find Vim revision '${vim_commit}'."
|
||||||
exit 3
|
exit 3
|
||||||
}
|
}
|
||||||
@@ -94,8 +99,8 @@ get_vim_patch() {
|
|||||||
echo "✔ Found Vim revision '${vim_commit}'."
|
echo "✔ Found Vim revision '${vim_commit}'."
|
||||||
|
|
||||||
# Collect patch details and store into variables.
|
# Collect patch details and store into variables.
|
||||||
vim_full="$(hg log --patch --git --verbose --rev "${vim_commit}")"
|
vim_full="$(git log --pretty=medium "${vim_commit}^\!")"
|
||||||
vim_diff="$(hg diff --show-function --git --change "${vim_commit}" \
|
vim_diff="$(git diff "${vim_commit}^\!" \
|
||||||
| sed -e 's/\( [ab]\/src\)/\1\/nvim/g')" # Change directory to src/nvim.
|
| sed -e 's/\( [ab]\/src\)/\1\/nvim/g')" # Change directory to src/nvim.
|
||||||
neovim_message="$(commit_message)"
|
neovim_message="$(commit_message)"
|
||||||
neovim_pr="
|
neovim_pr="
|
||||||
@@ -162,22 +167,17 @@ list_vim_patches() {
|
|||||||
# runtime patches before between 384 and 442 have already been ported
|
# runtime patches before between 384 and 442 have already been ported
|
||||||
# to Neovim as of the creation of this script.
|
# to Neovim as of the creation of this script.
|
||||||
local vim_commits=$(cd "${VIM_SOURCE_DIR}" && \
|
local vim_commits=$(cd "${VIM_SOURCE_DIR}" && \
|
||||||
hg log --removed --template='{if(startswith("Added tag", firstline(desc)),
|
git log --pretty='tformat:%H|%d' v7.4.442..HEAD | awk -f ${NEOVIM_SOURCE_DIR}/scripts/vim-patch-helper.awk)
|
||||||
"{latesttag}\n",
|
|
||||||
"{if(startswith(\"updated for version\", firstline(desc)),
|
|
||||||
\"\",
|
|
||||||
\"{node}\n\")}")}' -r tip:v7-4-442)
|
|
||||||
# Append remaining vim patches.
|
# Append remaining vim patches.
|
||||||
# Start from 7.4.160, where Neovim was forked.
|
# Start from 7.4.160, where Neovim was forked.
|
||||||
local vim_old_commits=$(cd "${VIM_SOURCE_DIR}" && \
|
local vim_old_commits=$(cd "${VIM_SOURCE_DIR}" && \
|
||||||
hg log --removed --template='{if(startswith("Added tag",
|
git log --pretty='tformat:%d' v7.4.160..v7.4.442 | awk '{ if ($1 != "") { gsub(/[()]/, "", $2); print($2); } }')
|
||||||
firstline(desc)),
|
|
||||||
"{latesttag}\n")}' -r v7-4-442:v7-4-161)
|
|
||||||
|
|
||||||
local vim_commit
|
local vim_commit
|
||||||
for vim_commit in ${vim_commits} ${vim_old_commits}; do
|
for vim_commit in ${vim_commits} ${vim_old_commits}; do
|
||||||
local is_missing
|
local is_missing
|
||||||
if [[ ${vim_commit} =~ v([0-9]-[0-9]-([0-9]{3,4})) ]]; then
|
if [[ ${vim_commit} =~ v([0-9].[0-9].([0-9]{3,4})) ]]; then
|
||||||
local patch_number="${BASH_REMATCH[2]}"
|
local patch_number="${BASH_REMATCH[2]}"
|
||||||
# "Proper" Vim patch
|
# "Proper" Vim patch
|
||||||
# Check version.c:
|
# Check version.c:
|
||||||
@@ -253,9 +253,9 @@ review_pr() {
|
|||||||
echo "✔ Saved pull request diff to '${NEOVIM_SOURCE_DIR}/n${base_name}.diff'."
|
echo "✔ Saved pull request diff to '${NEOVIM_SOURCE_DIR}/n${base_name}.diff'."
|
||||||
echo "${neovim_patch}" > "${NEOVIM_SOURCE_DIR}/n${base_name}.patch"
|
echo "${neovim_patch}" > "${NEOVIM_SOURCE_DIR}/n${base_name}.patch"
|
||||||
echo "✔ Saved full pull request commit details to '${NEOVIM_SOURCE_DIR}/n${base_name}.patch'."
|
echo "✔ Saved full pull request commit details to '${NEOVIM_SOURCE_DIR}/n${base_name}.patch'."
|
||||||
hg diff --show-function --git --change "${vim_commit}" > "${NEOVIM_SOURCE_DIR}/${base_name}.diff"
|
git diff "${vim_commit}^\!" > "${NEOVIM_SOURCE_DIR}/${base_name}.diff"
|
||||||
echo "✔ Saved Vim diff to '${NEOVIM_SOURCE_DIR}/${base_name}.diff'."
|
echo "✔ Saved Vim diff to '${NEOVIM_SOURCE_DIR}/${base_name}.diff'."
|
||||||
hg log --patch --git --verbose --rev "${vim_commit}" > "${NEOVIM_SOURCE_DIR}/${base_name}.patch"
|
git show "${vim_commit}" > "${NEOVIM_SOURCE_DIR}/${base_name}.patch"
|
||||||
echo "✔ Saved full Vim commit details to '${NEOVIM_SOURCE_DIR}/${base_name}.patch'."
|
echo "✔ Saved full Vim commit details to '${NEOVIM_SOURCE_DIR}/${base_name}.patch'."
|
||||||
echo "You can use 'git clean' to remove these files when you're done."
|
echo "You can use 'git clean' to remove these files when you're done."
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user