diff --git a/README b/README index 5405fbf..cf2ad2e 100644 --- a/README +++ b/README @@ -131,6 +131,10 @@ Available configuration variables: function will be called recursively! svn: Specify the path to the native Subversion executable. If not specified, the first 'svn' in $PATH will be used. + ignore_executable_extensions: A list of extensions (including the '.') + for newly added files which should not automatically have the + svn:executable property added for them even if the files are + executable. The default value is ['.c', '.cc', '.h', '.txt']. Configuration Examples: pager = 'less -FRXi' # enable case-insensitive searching in less diff --git a/jsvn b/jsvn index aaba0aa..e43a5f9 100755 --- a/jsvn +++ b/jsvn @@ -70,6 +70,8 @@ def get_config(svn): 'tags': 'tag', 'branches': 'branch'}, 'svn': '', + 'ignore_executable_extensions': + ['.c', '.cc', '.h', '.txt'] } global_user_config_fname = os.path.expanduser('~/.jsvn') @@ -542,21 +544,37 @@ def find_common_ancestor(svn, url1, path1, url2, path2): r, path = find_branched_revision(svn, url2, path2, path1) return r, path +def filter_add_output(fh, out, svn, config): + for line in iter(fh.readline, ''): + line = line.strip() + m = re.match('A\s+(.*)$', line) + if m is not None: + path = m.group(1) + for ext in config['ignore_executable_extensions']: + if path.endswith(ext): + del_svn_property(svn, 'svn:executable', path) + out.write(line) + out.write('\n') + ########################################################################### # Subcommand Handlers # ########################################################################### def add_h(argv, svn, out, config): - if len(argv) < 2: + argv = argv[1:] # strip off 'add' + if len(argv) == 0: # do not handle if no targets are passed + # no output filtering needed since nothing will be added return RET_REEXEC if len(filter(lambda x: x.startswith('-'), argv)) != 0: # do not handle if any options are passed - return RET_REEXEC + p = Popen([svn, 'add'] + argv, stdout=PIPE) + filter_add_output(p.stdout, out, svn, config) + return RET_OK # for each target specified, check if there are unversioned items # underneath it (for directories) and add them as well # if none are found, fall back to the native svn add unknowns = get_unknowns(svn) - for path in argv[1:]: + for path in argv: if path == '.': path = os.getcwd() if path.endswith('/'): @@ -564,10 +582,12 @@ def add_h(argv, svn, out, config): found_one = False for u in unknowns: if descendant_path(u, path): - Popen([svn, 'add', u], stdout=out).wait() + p = Popen([svn, 'add', u], stdout=PIPE) + filter_add_output(p.stdout, out, svn, config) found_one = True if not found_one: - Popen([svn, 'add', path], stdout=out).wait() + p = Popen([svn, 'add', path], stdout=PIPE) + filter_add_output(p.stdout, out, svn, config) return RET_OK def bisect_h(argv, svn, out, config):