Hi,
Source code of svnlook.rb can be more compact.
Since methods except for 'dir_changed' in 'SvnLook::DirsChangedEditor' is
also defined in the class 'Svn::Delta::ChangedDirsEditor' exactly
in the same way, it should inherit that class.
Please review my patch.
Thanks,
-nori
Log:
[[[
Refactor tools/examples/svnlook.rb a little.
* tools/examples/svnlook.rb
(DirsChangedEditor): Inherit Svn::Delta::ChangedDirsEditor instead of
Svn::Delta::BaseEditor.
(DirsChangedEditor#open_root,
DirsChangedEditor#delete_entry,
DirsChangedEditor#add_directory,
DirsChangedEditor#open_directory,
DirsChangedEditor#change_dir_prop,
DirsChangedEditor#add_file,
DirsChangedEditor#open_file): Removed.
]]]
Index: tools/examples/svnlook.rb
===================================================================
--- tools/examples/svnlook.rb (revision 16932)
+++ tools/examples/svnlook.rb (working copy)
@@ -244,57 +244,17 @@
end
- # Output directories that have been changed
- class DirsChangedEditor < Svn::Delta::BaseEditor
+ # Output directories that have been changed.
+ # In this class, methods such as open_root and add_file
+ # are inherited from Svn::Delta::ChangedDirsEditor.
+ class DirsChangedEditor < Svn::Delta::ChangedDirsEditor
- # Recurse through the root node
- def open_root(base_revision)
- [true, '']
- end
-
- # If a file is deleted, output that its parent has
- # been changed
- def delete_entry(path, revision, parent_baton)
- dir_changed(parent_baton)
- end
-
- # If a directory is added, output that its parent has been
- # changed and recurse through the child directory's contents
- def add_directory(path, parent_baton,
- copyfrom_path, copyfrom_revision)
- dir_changed(parent_baton)
- [true, path]
- end
-
- # Recurse through directories
- def open_directory(path, parent_baton, base_revision)
- [true, path]
- end
-
- # If the properties of this directory have been changed,
- # output that the directory has been changed
- def change_dir_prop(dir_baton, name, value)
- dir_changed(dir_baton)
- end
-
- # If a file is added to this directory,
- # output that the directory has been changed
- def add_file(path, parent_baton,
- copyfrom_path, copyfrom_revision)
- dir_changed(parent_baton)
- end
-
- # If a file is opened in this directory,
- # output that the directory has been changed
- def open_file(path, parent_baton, base_revision)
- dir_changed(parent_baton)
- end
-
# Private functions
private
# Print out the name of a directory if it has been changed.
# But only do so once.
+ # This behaves in a way like a callback function.
def dir_changed(baton)
if baton[0]
# The directory hasn't been printed yet,
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sun Oct 23 11:06:59 2005