@@ -0,0 +1,2285 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more%0A# contributor license agreements.  See the NOTICE file distributed with%0A# this work for additional information regarding copyright ownership.%0A# The ASF licenses this file to You under the Apache License, Version 2.0%0A# (the %22License%22); you may not use this file except in compliance with%0A# the License.  You may obtain a copy of the License at%0A#%0A#     http://www.apache.org/licenses/LICENSE-2.0%0A#%0A# Unless required by applicable law or agreed to in writing, software%0A# distributed under the License is distributed on an %22AS IS%22 BASIS,%0A# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A# See the License for the specific language governing permissions and%0A# limitations under the License.%0A%0Aimport subprocess%0Aimport sys%0A%0A# recursive, unified output format, treat missing files as present but empty%0ADIFF_FLAGS = '-ruN'%0A%0Aif '-skipWhitespace' in sys.argv:%0A  sys.argv.remove('-skipWhitespace')%0A  # ignores only whitespace changes%0A  DIFF_FLAGS += 'bBw'%0A%0Aif len(sys.argv) != 3:%0A  print%0A  print 'Usage: python -u diffSources.py %3Cdir1%3E %3Cdir2%3E %5B-skipWhitespace%5D'%0A  print%0A  print '''This tool creates an applying patch between two directories.%0A%0AWhile you could use this to make a committable patch from a branch, that approach loses%0Athe svn history from the branch (better to use %22svn merge --reintegrate%22, for example).  This%0Adiff output should not be considered %22authoritative%22 from a merging standpoint as it does%0Anot reflect what svn will do on merge.%0A'''%0A  print%0A  sys.exit(0)%0A%0Ap = subprocess.Popen(%5B'diff', DIFF_FLAGS, '-x', '.svn', '-x', 'build', sys.argv%5B1%5D, sys.argv%5B2%5D%5D, shell=False, stdout=subprocess.PIPE)%0A%0Akeep = False%0Awhile True:%0A  l = p.stdout.readline()%0A  if l == '':%0A    break%0A  if l.endswith('%5Cr%5Cn'):%0A    l = l%5B:-2%5D%0A  elif l.endswith('%5Cn'):%0A    l = l%5B:-1%5D%0A  if l.startswith('diff ') or l.startswith('Binary files '):%0A    keep = l.lower().find('/build/') == -1 and (l.lower().startswith('Only in') or ((l.lower().endswith('.java') or l.lower().endswith('.txt') or l.lower().endswith('.xml') or l.lower().endswith('.iml')) and l.find('/.svn/') == -1))%0A    if keep:%0A      print%0A      print%0A      print l.strip()%0A  elif keep:%0A    print l%0A  elif l.startswith('Only in'):%0A    print l.strip()%0A

add Python script to diff two source trees