[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] Extend svnlook.py to output property changes when running the diff command

From: Jeremy Whitlock <jcscoobyrs_at_gmail.com>
Date: Fri, 12 Sep 2008 14:50:36 -0600

Hi All,
    As the title suggests, I have attached, and pasted below, a patch
to extend tools/examples/svnlook.py so that it outputs property
changes when running the diff command. Please feel free to let me
know if there is anything I can do to get this patch approved.

-- 
Take care,
Jeremy Whitlock
http://www.thoughtspark.org
[[[
Extend svnlook.py to list property changes when using the diff command.
* tools/examples/svnlook.py (DiffEditor._do_prop_diff,
   DiffEditor.open_root, DiffEditor.open_directory, DiffEditor.add_directory,
   DiffEditor.change_file_prop, DiffEditor.change_dir_prop,
   DiffEditor.set_target_revision): Added.
  (DiffEditor.__init__): Added variable for the target revision.
]]]
Index: tools/examples/svnlook.py
===================================================================
--- tools/examples/svnlook.py	(revision 33042)
+++ tools/examples/svnlook.py	(working copy)
@@ -165,7 +165,6 @@
       return ' <%s>' % fs.unparse_id(id)
     return ''
-
 class DirsChangedEditor(delta.Editor):
   def open_root(self, base_revision, dir_pool):
     return [ 1, '' ]
@@ -198,7 +197,6 @@
       print baton[1] + '/'
       baton[0] = 0
-
 class ChangedEditor(delta.Editor):
   def __init__(self, root, base_root):
     self.root = root
@@ -259,6 +257,7 @@
   def __init__(self, root, base_root):
     self.root = root
     self.base_root = base_root
+    self.target_revision = 0
   def _do_diff(self, base_path, path):
     if base_path is None:
@@ -288,16 +287,52 @@
       print line,
     print ""
+  def _do_prop_diff(self, path, prop_name, prop_val, pool):
+    print "Property changes on: " + path
+    print "_______________________________________________________________" + \
+          "_______________"
+
+    old_prop_val = None
+
+    try:
+      old_prop_val = fs.node_prop(self.base_root, path, prop_name, pool)
+    except core.SubversionException:
+      pass # Must be a new path
+
+    if old_prop_val:
+      if prop_val:
+        print "Modified: " + prop_name
+        print "   - " + str(old_prop_val)
+        print "   + " + str(prop_val)
+      else:
+        print "Deleted: " + prop_name
+        print "   - " + str(old_prop_val)
+    else:
+      print "Added: " + prop_name
+      print "   + " + str(prop_val)
+
+    print ""
+
   def delete_entry(self, path, revision, parent_baton, pool):
     ### need more logic to detect 'replace'
     if not fs.is_dir(self.base_root, '/' + path):
       self._do_diff(path, None)
+  def add_directory(self, path, parent_baton, copyfrom_path,
+                    copyfrom_revision, dir_pool):
+    return [ 1, path ]
+
   def add_file(self, path, parent_baton,
                copyfrom_path, copyfrom_revision, file_pool):
     self._do_diff(None, path)
     return [ '_', ' ', None ]
+  def open_root(self, base_revision, dir_pool):
+    return [ 1, '' ]
+
+  def open_directory(self, path, parent_baton, base_revision, dir_pool):
+    return [ 1, path ]
+
   def open_file(self, path, parent_baton, base_revision, file_pool):
     return [ '_', ' ', path ]
@@ -306,6 +341,19 @@
       self._do_diff(file_baton[2], file_baton[2])
     return None
+  def change_file_prop(self, file_baton, name, value, pool):
+    if file_baton[2] is not None:
+      self._do_prop_diff(file_baton[2], name, value, pool)
+    return None
+
+  def change_dir_prop(self, dir_baton, name, value, pool):
+    if dir_baton[1] is not None:
+      self._do_prop_diff(dir_baton[1], name, value, pool)
+    return None
+
+  def set_target_revision(self, target_revision):
+    self.target_revision = target_revision
+
 def _basename(path):
   "Return the basename for a '/'-separated path."
   idx = path.rfind('/')


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: dev-help_at_subversion.tigris.org

Received on 2008-09-12 22:50:51 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.