Changes between Initial Version and Version 2 of Ticket #16944


Ignore:
Timestamp:
2018-11-04T19:58:13+01:00 (7 years ago)
Author:
wiktorn
Comment:

Split to 4 scripts. Apart from 1, all may be restarted.

I'll also try to check if JOSM actually builds from this (like every 100 commit or so).

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #16944 – Description

    initial v2  
    1 
     1Split to 4 scripts to make it easier to restart script on errors
     2* git_migrate-1-init.sh
    23{{{#!bash
    3 #!/usr/bin/env bash
     4#!/bin/sh
    45
    56set -e
     
    1415###
    1516
    16 git svn init --trunk=. --prefix=svn_jmapviewer -R jmapviewer \
    17    https://svn.openstreetmap.org/applications/viewer/jmapviewer
     17git svn init --trunk=. --prefix=svn_jmapviewer -R jmapviewer https://svn.openstreetmap.org/applications/viewer/jmapviewer
    1818git svn init --trunk=. --prefix=svn_josm -R josm https://josm.openstreetmap.de/svn/trunk
    1919# two separate remotes for commons as this is 2x ~10 minutes instead of 2+ houres to fetch
    20 git svn init --trunk=. --include-paths='commons/proper/jcs/trunk/.*src/main/java/org/apache/commons/jcs' \
    21   --prefix=svn_commons_jcs -R svn_commons_jcs https://svn.apache.org/repos/asf/commons/proper/jcs/
    22 git svn init --trunk=. --include-paths='commons/proper/logging/trunk/src/main/java/org/apache/commons/logging' \
    23   --prefix=svn_commons_logging -R svn_commons_logging https://svn.apache.org/repos/asf/commons/proper/logging/trunk/
     20git svn init --trunk=. --include-paths='commons/proper/jcs/trunk/.*src/main/java/org/apache/commons/jcs' --prefix=svn_commons_jcs -R svn_commons_jcs https://svn.apache.org/repos/asf/commons/proper/jcs/
     21git svn init --trunk=. --include-paths='commons/proper/logging/trunk/src/main/java/org/apache/commons/logging' --prefix=svn_commons_logging -R svn_commons_logging https://svn.apache.org/repos/asf/commons/proper/logging/trunk/
    2422git remote add commons_compress https://github.com/apache/commons-compress.git
    2523
     24echo Done
     25}}}
     26* git_migrate-2-fetch.sh
     27{{{#!bash
     28#!/bin/sh
     29
     30set -e
     31
     32cd josm-tests
    2633###
    2734# fetch from remotes
     
    3542git fetch commons_compress
    3643
     44echo Done
     45}}}
     46* git_migrate-3-prepare.sh
     47{{{#!bash
     48#!/bin/sh
    3749
     50set -e
     51
     52cd josm-tests
    3853###
    3954# Reorganize externals
     
    4156
    4257# JMapViewer
    43 git branch svn_jmapviewer_rewrite remotes/svn_jmapviewertrunk
     58git branch -f svn_jmapviewer_rewrite remotes/svn_jmapviewertrunk
    4459git filter-branch -f --tree-filter '
    4560  if [ -d src/org/openstreetmap/gui/jmapviewer ] ; then
     
    6277# compress is already on git, need first to somehow mix with other repositories (using commit date, not author date)
    6378# as commits sorted by date do not constitue the history.
    64 # So first - order by commit date and mix, then filter the content
    65 # For now it generates a few merge conflicts
    66 # TODO: can it be done using --index-filter?
    67 git branch svn_commons_compress_rewrite remotes/commons_compress/master
    68 git filter-branch -f --tree-filter '
    69   if [ -d src/main/java ] ; then
    70       git mv src src.new &&
    71       find . -depth 1 |
    72       grep -v ^./src.new | grep -v ^./.git$ |
    73       xargs -r git rm -fr &&
    74       git mv src.new/main/java src &&
    75       git rm -rf --ignore-unmatch src.new
    76   else
    77       find . -depth 1 |
    78       grep -v ^./.git$ |
    79       xargs -r git rm -fr
    80   fi' \
     79# first - create subdirectory where all commons-compress files will go
     80git branch -f svn_commons_compress_rewrite remotes/commons_compress/master
     81git filter-branch -f --index-filter "
     82  git ls-files -s | sed -e \$'s#\t#\tcommons-compress/#' |
     83      GIT_INDEX_FILE=\$GIT_INDEX_FILE.new git update-index --index-info &&
     84      if [ -f \$GIT_INDEX_FILE.new ] ; then mv \$GIT_INDEX_FILE.new \$GIT_INDEX_FILE ; fi" \
    8185  svn_commons_compress_rewrite
     86
    8287# Apache Commons JCS
    83 git branch svn_commons_jcstrunk_rewrite remotes/svn_commons_jcstrunk
     88git branch -f svn_commons_jcstrunk_rewrite remotes/svn_commons_jcstrunk
    8489git filter-branch -f --tree-filter '
    8590  if [ -d trunk/commons-jcs-core/src/main/java/ ] ; then
     
    97102
    98103# Apache Commons Logging
    99 git branch svn_commons_loggingtrunk_rewrite remotes/svn_commons_loggingtrunk
     104git branch -f svn_commons_loggingtrunk_rewrite remotes/svn_commons_loggingtrunk
    100105git filter-branch -f --tree-filter '
    101106  if [ -d src/main/java ] ; then
     
    114119
    115120###
     121# Linearlize commons_compress history
     122###
     123
     124git branch -f svn_commons_compress_clean svn_commons_compress_rewrite
     125git filter-branch -f --parent-filter 'cut -f 2,3 -d " "' svn_commons_compress_clean
     126
     127###
    116128# Remove empty commits
    117129###
    118130
    119 for i in svn_jmapviewer svn_commons_compress  svn_commons_jcstrunk svn_commons_loggingtrunk ; do
    120   git branch "${i}_clean" "${i}_rewrite"
     131for i in svn_jmapviewer svn_commons_jcstrunk svn_commons_loggingtrunk ; do
     132  git branch -f "${i}_clean" "${i}_rewrite"
    121133  git rebase $(git log --reverse --oneline --no-abbrev-commit "${i}_clean" | head -n 1 | cut -d ' ' -f 1) "${i}_clean" || exit 1
    122134done
     135}}}
     136* git_migrate-4-merge.sh
     137{{{#!bash
     138#!/bin/sh
     139
     140set -e
     141
     142cd josm-tests
    123143
    124144###
     
    134154JOSM_EPOCH=$(head -n 1 ${REBASE_CONF} | cut -d ' ' -f1 )
    135155(
    136   git log --pretty="format:%at %H %s" svn_commons_compress_rewrite
    137   git log --pretty="format:%at %H %s" svn_commons_jcstrunk_rewrite
    138   git log --pretty="format:%at %H %s" svn_commons_loggingtrunk_rewrite
    139 ) | awk -F ' ' "\$1 > ${JOSM_EPOCH} {print \$1 \" \" \$2} {}" >> "${REBASE_CONF}"
     156  #git log --ancestry-path  --pretty="format:%ct %H %s" \
     157  #   $(git log --reverse --oneline --no-abbrev-commit svn_commons_compress_rewrite |
     158  #   head -n 1 | cut -d ' ' -f 1)..svn_commons_compress_rewrite # we are not rebasing this, to preserve commit timestamps which we use here
     159  git log --first-parent --pretty="format:%at %H %s" svn_commons_compress_clean
     160  git log --pretty="format:%at %H %s" svn_commons_jcstrunk_clean
     161  git log --pretty="format:%at %H %s" svn_commons_loggingtrunk_clean
     162  # could use it:
     163  # | awk -F ' ' "\$1 > ${JOSM_EPOCH} {print \$1 \" \" \$2} {}" >> "${REBASE_CONF}"
     164  # to keep only history after fist JOSM commit, but we would need to squash all the previous history into one commit
     165) >> "${REBASE_CONF}"
    140166
    141167sort -n ${REBASE_CONF} | cut -d ' ' -f2 | sed -e 's/^/p /' > ../rebase_config
     
    144170git checkout master
    145171git rebase --keep-empty -i $(git log --reverse --oneline --no-abbrev-commit | head -n 1 | cut -d ' ' -f 1)
     172
     173# fix Apache Commons Compress paths
     174git filter-branch -f --tree-filter '
     175  if [ -d commons-compress/src/main/java ] ; then
     176      mkdir -p src/java/org/apache/commons/
     177      git mv commons-compress/src/main/java/org/apache/commons/compress src/java/org/apache/commons/ &&
     178      find commons-compress -depth 1 |
     179      xargs -r git rm -fr
     180  else
     181      find commons-compress -depth 1 |
     182      xargs -r git rm -fr
     183  fi' \
     184  master
    146185
    147186# helpful one-liner: git diff --name-only --diff-filter=U | xargs git checkout  ...