Rev 5: Summarize the results. in http://bzr.arbash-meinel.com/plugins/update_copyright
John Arbash Meinel
john at arbash-meinel.com
Thu Jan 7 20:30:44 GMT 2010
At http://bzr.arbash-meinel.com/plugins/update_copyright
------------------------------------------------------------
revno: 5
revision-id: john at arbash-meinel.com-20100107203038-yf4zpl6ikobnlznf
parent: john at arbash-meinel.com-20100107201021-hjrnmy864y2tgb0b
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: update_copyright
timestamp: Thu 2010-01-07 14:30:38 -0600
message:
Summarize the results.
Also, if a file is locally already updated, count it as 'copyright-correct'.
-------------- next part --------------
=== modified file '__init__.py'
--- a/__init__.py 2010-01-07 19:59:57 +0000
+++ b/__init__.py 2010-01-07 20:30:38 +0000
@@ -46,7 +46,11 @@
relpaths = None
if relpaths is not None:
relpaths = osutils.minimum_path_selection(relpaths)
- update_copyright.update_tree_copyright(tree, relpaths)
+ result = update_copyright.update_tree_copyright(tree, relpaths)
+ self.outf.write('Checked %(count)d files\n'
+ 'Updated %(updated)d\n'
+ 'Already correct %(copyright-correct)d\n'
+ 'No copyright %(no-copyright)d\n' % (result))
commands.register_command(cmd_update_copyright)
=== modified file 'update_copyright.py'
--- a/update_copyright.py 2010-01-07 20:10:21 +0000
+++ b/update_copyright.py 2010-01-07 20:30:38 +0000
@@ -40,7 +40,8 @@
tip = (file_id, last_rev_id)
ancestry = graph.Graph(repository.texts).iter_ancestry([tip])
revision_ids = set([k[1] for k,p in ancestry if p is not None])
- # TODO: Cache Revision objects between calls
+ # Oddly enough, caching the Revision object *slows* it down. My guess is
+ # that it interacts poorly with gc
revisions = repository.get_revisions(revision_ids)
# TODO: Should we use utcfromtimestamp?
years = set([datetime.datetime.fromtimestamp(r.timestamp).year
@@ -74,7 +75,8 @@
result['count'] += 1
action = update_copyright(tree, basis_tree, path)
result[action] += 1
- pb.update(action, result[action], result['count'])
+ pb.update('%s %s' % (action, path), result[action],
+ result['count'])
finally:
pb.finished()
finally:
@@ -115,6 +117,9 @@
new_copyright_line = '%s %s %s\n' % (
m.group('prefix').rstrip(), format_years(years),
m.group('suffix'))
+ # It seems this may already be updated
+ if copyright_line == new_copyright_line:
+ return 'copyright-correct'
new_content = new_copyright_line + f.read()
finally:
f.close()
More information about the bazaar-commits
mailing list