Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>In response to sigjuice's request in the comments, I'm posting my script solution. It isn't 100% bullet proof, and I'll probably use <code>filterdiff</code> instead.</p> <pre><code>base_usage_str=r''' python %prog index_regex patch_file description: Extracts all indices from a patch-file matching 'index_regex' e.g. python %prog '^evc_lib' p.patch &gt; evc_lib_p.patch Will extract all indices which begin with evc_lib. -or- python %prog '^(?!evc_lib)' p.patch &gt; not_evc_lib_p.patch Will extract all indices which do *not* begin with evc_lib. authors: Ross Rogers, 2009.04.02 ''' import re,os,sys from optparse import OptionParser def main(): parser = OptionParser(usage=base_usage_str) (options, args) = parser.parse_args(args=sys.argv[1:]) if len(args) != 2: parser.print_help() if len(args) == 0: sys.exit(0) else: sys.exit(1) (index_regex,patch_file) = args sys.stderr.write('Extracting patches for indices found by regex:%s\n'%index_regex) #print 'user_regex',index_regex user_index_match_regex = re.compile(index_regex) # Index: verification/ring_td_cte/tests/mmio_wr_td_target.e # --- sw/cfg/foo.xml 2009-04-30 17:59:11 -07:00 # +++ sw/cfg/foo.xml 2009-05-11 09:26:58 -07:00 index_cre = re.compile(r'''(?:(?&lt;=^)|(?&lt;=\n))(--- (?:.*\n){2,}?(?![ @\+\-]))''') patch_file = open(patch_file,'r') all_patch_sets = index_cre.findall(patch_file.read()) patch_file.close() for file_edit in all_patch_sets: # extract index subset index_path = re.compile('\+\+\+ (?P&lt;index&gt;[\w_\-/\.]+)').search(file_edit).group('index').strip() if user_index_match_regex.search(index_path): sys.stderr.write("Index regex matched index: "+index_path+"\n") print file_edit, if __name__ == '__main__': main() </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload