Package pybaz :: Module _deprecated_helpers
[frames] | no frames]

Source Code for Module pybaz._deprecated_helpers

  1  # arch-tag: c1237fa7-e976-4668-b8d8-59cde0007fc8 
  2  # Copyright (C) 2003 David Allouche <david@allouche.net> 
  3  # 
  4  #    This program is free software; you can redistribute it and/or modify 
  5  #    it under the terms of the GNU General Public License as published by 
  6  #    the Free Software Foundation; either version 2 of the License, or 
  7  #    (at your option) any later version. 
  8  # 
  9  #    This program is distributed in the hope that it will be useful, 
 10  #    but WITHOUT ANY WARRANTY; without even the implied warranty of 
 11  #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 12  #    GNU General Public License for more details. 
 13  # 
 14  #    You should have received a copy of the GNU General Public License 
 15  #    along with this program; if not, write to the Free Software 
 16  #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
 17   
 18  """Deprecated helper functions.""" 
 19   
 20  import re 
 21  from deprecation import deprecated_usage, deprecated_callable 
 22   
 23  __all__ = [ 
 24      'filter_archive_logs', 
 25      'filter_revisions', 
 26      'grep_summary', 
 27      'grep_summary_interactive', 
 28      'suspected_move', 
 29      'revisions_merging', 
 30      'temphack', 
 31      'revision_which_created', 
 32      'last_revision', 
 33      'map_name_id', 
 34      ] 
 35   
 36   
37 -def filter_archive_logs(limit, pred):
38 deprecated_callable(filter_archive_logs, 39 because='It does not belong here.') 40 for r in limit.iter_revisions(): 41 if pred(r.patchlog): yield r
42 43
44 -def filter_revisions(limit, pred):
45 deprecated_callable(filter_archive_logs, 46 because='It does not belong here.') 47 for r in limit.iter_revisions(): 48 if pred(r): yield r
49
50 -def grep_summary(limit, rx):
51 deprecated_callable(grep_summary, 52 because='It does not belong here.') 53 crx = re.compile(rx) 54 def pred(p): 55 return crx.search(p['Summary'])
56 return filter_archive_logs(limit, pred) 57 58
59 -def grep_summary_interactive(limit):
60 deprecated_callable(grep_summary_interactive, 61 because='It does not belong here.') 62 while True: 63 try: 64 rx = raw_input('search> ') 65 except KeyboardInterrupt: 66 break 67 if not rx: break 68 for r in grep_summary(limit, rx): 69 p = r.patchlog 70 print 'Revision:', p['Revision'] 71 print 'Summary: ', p['Summary']
72 73
74 -def suspected_move(limit):
75 deprecated_callable(suspected_move, 76 because='It does not belong here.') 77 def pred(p): return bool(p['New-files'] and p['Removed-files']) 78 return filter_archive_logs(limit, pred)
79 80
81 -def revisions_merging(limit, rev):
82 deprecated_callable(revisions_merging, 83 because='It does not belong here.') 84 def pred(p): 85 return rev in p.merged_patches
86 return filter_archive_logs(limit, pred) 87 88
89 -def temphack(revision):
90 deprecated_callable(temphack, 91 because='It does not belong here.') 92 import sets 93 retval = sets.Set() 94 for ancstr in revision.iter_ancestors(metoo=True): 95 for k in ancstr.patchlog.keys(): 96 retval.add(k) 97 return retval
98 99
100 -def revision_which_created(file, revision):
101 deprecated_callable(revision_which_created, 102 because='It does not belong here.') 103 for ancstr in revision.iter_ancestors(metoo=True): 104 if file in ancstr.patchlog.new_files: 105 return ancstr 106 return None
107
108 -def last_revision(tree):
109 import _builtin 110 deprecated_callable(last_revision, 111 (_builtin.ArchSourceTree, 'tree_revision')) 112 tree = _builtin.SourceTree(tree) 113 return tree.iter_logs(reverse=True).next().revision
114 115
116 -def map_name_id(tree):
117 import _builtin 118 deprecated_callable(map_name_id, 119 because='It does not belong here.') 120 if not isinstance(tree, _builtin.SourceTree): 121 tree = _builtin.SourceTree(tree) 122 retval = {} 123 for id_, name in tree.iter_inventory_ids(source=True, files=True): 124 retval[name] = id_ 125 return retval
126