common/bin/unshuffle_patch.sh
author brutisso
Wed, 09 Mar 2016 14:54:18 +0100
changeset 37049 76b0378cf033
parent 27595 cff167b3bfa2
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25854
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
     1
#!/bin/sh
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
     2
#
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
     3
# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
     4
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
     5
#
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
     6
# This code is free software; you can redistribute it and/or modify it
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
     7
# under the terms of the GNU General Public License version 2 only, as
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
     8
# published by the Free Software Foundation.
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
     9
#
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    10
# This code is distributed in the hope that it will be useful, but WITHOUT
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    11
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    12
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    13
# version 2 for more details (a copy is included in the LICENSE file that
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    14
# accompanied this code).
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    15
#
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    16
# You should have received a copy of the GNU General Public License version
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    17
# 2 along with this work; if not, write to the Free Software Foundation,
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    18
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    19
#
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    20
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    21
# or visit www.oracle.com if you need additional information or have any
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    22
# questions.
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    23
#
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    24
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    25
# Script for updating a patch file as per the shuffled/unshuffled source location.
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    26
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    27
usage() {
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    28
      echo "Usage: $0 [-h|--help] [-v|--verbose] <repo> <input_patch> <output_patch>"
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    29
      echo "where:"
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    30
      echo "  <repo>          is one of: corba, jaxp, jaxws, jdk, langtools, nashorn"
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    31
      echo "                  [Note: patches from other repos do not need updating]"
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    32
      echo "  <input_patch>   is the input patch file, that needs shuffling/unshuffling"
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    33
      echo "  <output_patch>  is the updated patch file "
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    34
      echo " "
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    35
      exit 1
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    36
}
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    37
26674
b002f9eb2b5e 8059101: unshuffle_patch.sh should be able to deal with stdin/stdout
igerasim
parents: 25854
diff changeset
    38
SCRIPT_DIR=`dirname $0`
25854
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    39
UNSHUFFLE_LIST=$SCRIPT_DIR"/unshuffle_list.txt"
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    40
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    41
if [ ! -f "$UNSHUFFLE_LIST" ] ; then
26674
b002f9eb2b5e 8059101: unshuffle_patch.sh should be able to deal with stdin/stdout
igerasim
parents: 25854
diff changeset
    42
  echo "FATAL: cannot find $UNSHUFFLE_LIST" >&2
25854
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    43
  exit 1
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    44
fi
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    45
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    46
vflag="false"
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    47
while [ $# -gt 0 ]
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    48
do
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    49
  case $1 in
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    50
    -h | --help )
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    51
      usage
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    52
      ;;
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    53
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    54
    -v | --verbose )
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    55
      vflag="true"
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    56
      ;;
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    57
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    58
    -*)  # bad option
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    59
      usage
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    60
      ;;
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    61
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    62
     * )  # non option
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    63
      break
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    64
      ;;
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    65
  esac
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    66
  shift
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    67
done
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    68
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    69
# Make sure we have the right number of arguments
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    70
if [ ! $# -eq 3 ] ; then
26674
b002f9eb2b5e 8059101: unshuffle_patch.sh should be able to deal with stdin/stdout
igerasim
parents: 25854
diff changeset
    71
  echo "ERROR: Invalid number of arguments." >&2
25854
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    72
  usage
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    73
fi
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    74
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    75
# Check the given repo
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    76
repos="corba jaxp jaxws jdk langtools nashorn"
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    77
repo="$1"
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    78
found="false"
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    79
for r in $repos ; do
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    80
  if [ $repo = "$r" ] ; then
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    81
    found="true"
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    82
    break;
27595
cff167b3bfa2 8065914: Various improvements and cleanup of build system
ihse
parents: 26674
diff changeset
    83
  fi
25854
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    84
done
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    85
if [ $found = "false" ] ; then
26674
b002f9eb2b5e 8059101: unshuffle_patch.sh should be able to deal with stdin/stdout
igerasim
parents: 25854
diff changeset
    86
  echo "ERROR: Unknown repo: $repo. Should be one of [$repos]." >&2
25854
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    87
  usage
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    88
fi
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    89
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    90
# Check given input/output files
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    91
input="$2"
26674
b002f9eb2b5e 8059101: unshuffle_patch.sh should be able to deal with stdin/stdout
igerasim
parents: 25854
diff changeset
    92
if [ "x$input" = "x-" ] ; then
b002f9eb2b5e 8059101: unshuffle_patch.sh should be able to deal with stdin/stdout
igerasim
parents: 25854
diff changeset
    93
  input="/dev/stdin"
b002f9eb2b5e 8059101: unshuffle_patch.sh should be able to deal with stdin/stdout
igerasim
parents: 25854
diff changeset
    94
fi
25854
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    95
26674
b002f9eb2b5e 8059101: unshuffle_patch.sh should be able to deal with stdin/stdout
igerasim
parents: 25854
diff changeset
    96
if [ ! -f $input -a "x$input" != "x/dev/stdin" ] ; then
b002f9eb2b5e 8059101: unshuffle_patch.sh should be able to deal with stdin/stdout
igerasim
parents: 25854
diff changeset
    97
  echo "ERROR: Cannot find input patch file: $input" >&2
25854
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    98
  exit 1
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
    99
fi
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   100
26674
b002f9eb2b5e 8059101: unshuffle_patch.sh should be able to deal with stdin/stdout
igerasim
parents: 25854
diff changeset
   101
output="$3"
b002f9eb2b5e 8059101: unshuffle_patch.sh should be able to deal with stdin/stdout
igerasim
parents: 25854
diff changeset
   102
if [ "x$output" = "x-" ] ; then
b002f9eb2b5e 8059101: unshuffle_patch.sh should be able to deal with stdin/stdout
igerasim
parents: 25854
diff changeset
   103
  output="/dev/stdout"
b002f9eb2b5e 8059101: unshuffle_patch.sh should be able to deal with stdin/stdout
igerasim
parents: 25854
diff changeset
   104
fi
b002f9eb2b5e 8059101: unshuffle_patch.sh should be able to deal with stdin/stdout
igerasim
parents: 25854
diff changeset
   105
b002f9eb2b5e 8059101: unshuffle_patch.sh should be able to deal with stdin/stdout
igerasim
parents: 25854
diff changeset
   106
if [ -f $output -a "x$output" != "x/dev/stdout" ] ; then
b002f9eb2b5e 8059101: unshuffle_patch.sh should be able to deal with stdin/stdout
igerasim
parents: 25854
diff changeset
   107
  echo "ERROR: Output patch already exists: $output" >&2
25854
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   108
  exit 1
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   109
fi
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   110
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   111
what=""  ## shuffle or unshuffle
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   112
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   113
verbose() {
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   114
  if [ ${vflag} = "true" ] ; then
26674
b002f9eb2b5e 8059101: unshuffle_patch.sh should be able to deal with stdin/stdout
igerasim
parents: 25854
diff changeset
   115
    echo "$@" >&2
25854
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   116
  fi
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   117
}
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   118
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   119
unshuffle() {
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   120
  line=$@
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   121
  verbose "Attempting to rewrite: \"$line\""
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   122
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   123
  # Retrieve the file name
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   124
  path=
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   125
  if echo "$line" | egrep '^diff' > /dev/null ; then
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   126
    if ! echo "$line" | egrep '\-\-git' > /dev/null ; then
26674
b002f9eb2b5e 8059101: unshuffle_patch.sh should be able to deal with stdin/stdout
igerasim
parents: 25854
diff changeset
   127
      echo "ERROR: Only git patches supported. Please use 'hg export --git ...'." >&2
25854
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   128
      exit 1
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   129
    fi
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   130
    path="`echo "$line" | sed -e s@'diff --git a/'@@ -e s@' b/.*$'@@`"
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   131
  elif echo "$line" | egrep '^\-\-\-' > /dev/null ; then
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   132
    path="`echo "$line" | sed -e s@'--- a/'@@`"
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   133
  elif echo "$line" | egrep '^\+\+\+' > /dev/null ; then
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   134
    path="`echo "$line" | sed s@'+++ b/'@@`"
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   135
  fi
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   136
  verbose "Extracted path: \"$path\""
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   137
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   138
  # Only source can be shuffled, or unshuffled
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   139
  if ! echo "$path" | egrep '^src/.*' > /dev/null ; then
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   140
    verbose "Not a src path, skipping."
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   141
    echo "$line" >> $output
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   142
    return
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   143
  fi
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   144
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   145
  # Shuffle or unshuffle?
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   146
  if [ "${what}" = "" ] ; then
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   147
    if echo "$path" | egrep '^src/java\..*|^src/jdk\..*' > /dev/null ; then
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   148
      what="unshuffle"
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   149
    else
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   150
      what="shuffle"
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   151
    fi
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   152
    verbose "Shuffle or unshuffle: $what"
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   153
  fi
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   154
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   155
  # Find the most specific matches in the shuffle list
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   156
  matches=
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   157
  matchpath="$repo"/"$path"/x
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   158
  while [ "$matchpath" != "" ] ; do
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   159
    matchpath="`echo $matchpath | sed s@'\(.*\)/.*$'@'\1'@`"
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   160
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   161
    if [ "${what}" =  "shuffle" ] ; then
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   162
      pattern=": $matchpath$"
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   163
    else
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   164
      pattern="^$matchpath :"
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   165
    fi
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   166
    verbose "Attempting to find \"$matchpath\""
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   167
    matches=`egrep "$pattern" "$UNSHUFFLE_LIST"`
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   168
    if ! [ "x${matches}" = "x" ] ; then
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   169
      verbose "Got matches: [$matches]"
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   170
      break;
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   171
    fi
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   172
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   173
    if ! echo "$matchpath" | egrep '.*/.*' > /dev/null ; then
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   174
      break;
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   175
    fi
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   176
  done
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   177
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   178
  # Rewrite the line, if we have a match
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   179
  if ! [ "x${matches}" = "x" ] ; then
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   180
    shuffled="`echo "$matches" | sed -e s@' : .*'@@g -e s@'^[a-z]*\/'@@`"
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   181
    unshuffled="`echo "$matches" | sed -e s@'.* : '@@g -e s@'^[a-z]*\/'@@`"
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   182
    if [ "${what}" =  "shuffle" ] ; then
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   183
      newline="`echo "$line" | sed -e s@"$unshuffled"@"$shuffled"@g`"
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   184
    else
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   185
      newline="`echo "$line" | sed -e s@"$shuffled"@"$unshuffled"@g`"
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   186
    fi
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   187
    verbose "Rewriting to \"$newline\""
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   188
    echo "$newline" >> $output
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   189
  else
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   190
    echo "WARNING: no match found for $path"
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   191
    echo "$line" >> $output
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   192
  fi
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   193
}
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   194
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   195
while IFS= read -r line
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   196
do
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   197
  if echo "$line" | egrep '^diff|^\-\-\-|^\+\+\+' > /dev/null ; then
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   198
    unshuffle "$line"
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   199
  else
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   200
    printf "%s\n" "$line" >> $output
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   201
  fi
98ce0879ab4c 8054834: Modular Source Code
chegar
parents:
diff changeset
   202
done < "$input"