You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by Michael McCandless <lu...@mikemccandless.com> on 2014/11/15 22:16:43 UTC
Re: svn commit: r1639914 - /lucene/dev/trunk/dev-tools/scripts/createPatch.py
Thanks Ryan!
Mike McCandless
http://blog.mikemccandless.com
On Sat, Nov 15, 2014 at 4:01 PM, <rj...@apache.org> wrote:
> Author: rjernst
> Date: Sat Nov 15 21:01:33 2014
> New Revision: 1639914
>
> URL: http://svn.apache.org/r1639914
> Log:
> Fix patch tool to better compare svn vs git checkouts, and not require comparing roots of checkouts
>
> Modified:
> lucene/dev/trunk/dev-tools/scripts/createPatch.py
>
> Modified: lucene/dev/trunk/dev-tools/scripts/createPatch.py
> URL: http://svn.apache.org/viewvc/lucene/dev/trunk/dev-tools/scripts/createPatch.py?rev=1639914&r1=1639913&r2=1639914&view=diff
> ==============================================================================
> --- lucene/dev/trunk/dev-tools/scripts/createPatch.py (original)
> +++ lucene/dev/trunk/dev-tools/scripts/createPatch.py Sat Nov 15 21:01:33 2014
> @@ -30,10 +30,11 @@ import os
> import subprocess
> import sys
>
> -def make_filter_func(src_dir):
> - if os.path.exists(os.path.join(src_dir, '.git')):
> +def make_filter_func(src_root, src_dir):
> + git_root = os.path.join(src_root, '.git')
> + if os.path.exists(git_root):
> def git_filter(filename):
> - rc = subprocess.call('git --git-dir=%s check-ignore %s' % (src_dir, filename), shell=True)
> + rc = subprocess.call('git --git-dir=%s check-ignore %s' % (git_root, filename), shell=True, stdout=subprocess.DEVNULL)
> return rc == 0
> return git_filter
>
> @@ -89,7 +90,7 @@ def run_diff(from_dir, to_dir, skip_whit
> flags += 'bBw'
>
> args = ['diff', flags]
> - for ignore in ('.svn', '.git', 'build', '.caches'):
> + for ignore in ('.svn', '.git', 'build', '.caches', '.idea', 'idea-build'):
> args.append('-x')
> args.append(ignore)
> args.append(from_dir)
> @@ -97,6 +98,13 @@ def run_diff(from_dir, to_dir, skip_whit
>
> return subprocess.Popen(args, shell=False, stdout=subprocess.PIPE)
>
> +def find_root(path):
> + relative = []
> + while not os.path.exists(os.path.join(path, 'lucene', 'CHANGES.txt')):
> + path, base = os.path.split(path)
> + relative.prepend(base)
> + return path, '' if not relative else os.path.join(relative)
> +
> def parse_config():
> parser = ArgumentParser(description=__doc__, formatter_class=RawTextHelpFormatter)
> parser.add_argument('--skip-whitespace', action='store_true', default=False,
> @@ -107,20 +115,24 @@ def parse_config():
>
> if not os.path.isdir(c.from_dir):
> parser.error('\'from\' path %s is not a valid directory' % c.from_dir)
> - if not os.path.exists(os.path.join(c.from_dir, 'lucene', 'CHANGES.txt')):
> - parser.error('\'from\' path %s is not a valid lucene/solr checkout' % c.from_dir)
> + (c.from_root, from_relative) = find_root(c.from_dir)
> + if c.from_root is None:
> + parser.error('\'from\' path %s is not relative to a lucene/solr checkout' % c.from_dir)
> if not os.path.isdir(c.to_dir):
> parser.error('\'to\' path %s is not a valid directory' % c.to_dir)
> - if not os.path.exists(os.path.join(c.to_dir, 'lucene', 'CHANGES.txt')):
> - parser.error('\'to\' path %s is not a valid lucene/solr checkout' % c.to_dir)
> -
> + (c.to_root, to_relative) = find_root(c.to_dir)
> + if c.to_root is None:
> + parser.error('\'to\' path %s is not relative to a lucene/solr checkout' % c.to_dir)
> + if from_relative != to_relative:
> + parser.error('\'from\' and \'to\' path are not equivalent relative paths within their'
> + ' checkouts: %s != %s' % (from_relative, to_relative))
> return c
>
> def main():
> c = parse_config()
>
> p = run_diff(c.from_dir, c.to_dir, c.skip_whitespace)
> - should_filter = make_filter_func(c.from_dir)
> + should_filter = make_filter_func(c.from_root, c.from_dir)
> print_filtered_output(p.stdout, should_filter)
>
> if __name__ == '__main__':
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org