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

[PATCH] recognize replaced paths in mailer.py (needs change in svn/repos.py)

From: Mathias Weinert <mathias.weinert_at_gfa-net.de>
Date: 2006-08-21 09:05:38 CEST

Hi,

With the included patch mailer.py will report replaced paths as
'Replaced' and not as 'Added' any more.

In order to achieve this I also had to patch
subversion/bindings/swig/python/svn/repos.py. Any ideas how to do this
in a better way are very welcome.

If there are neither objections against this patch nor better ideas to
do it, I ask someone with commit access to
subversion/bindings/swig/python to commit the patch. Thanks.

Mathias

[[[
Add support for replaced paths to mailer.py. These paths are now
reported as 'Replaced' and not as 'Added' any more. In order to achieve
this in subversion/bindings/swig/python/svn/repos.py an additional flag
'replaced' is now set in case of replaced paths.

* subversion/bindings/swig/python/svn/repos.py
  Set an additional flag 'Replaced' if a path has been replaced in
  addition to the already set 'Added' flag.

* tools/hook-scripts/mailer/mailer.py
  Report replaced paths as 'Replaced' and not as 'Added' any more.

* tools/hook-scripts/mailer/tests/mailer-t1.output
  Replaced path in revision 7 now appears as 'Replaced' instead of
  'Added'.
]]]

--- subversion/bindings/swig/python/svn/repos.py.orig 2005-09-22 23:11:13.000000000 +0200
+++ subversion/bindings/swig/python/svn/repos.py 2006-08-14 10:40:52.406481800 +0200
@@ -29,11 +29,11 @@
 
 class ChangedPath:
   __slots__ = [ 'item_kind', 'prop_changes', 'text_changed',
- 'base_path', 'base_rev', 'path', 'added',
+ 'base_path', 'base_rev', 'path', 'added', 'replaced',
                 ]
   def __init__(self,
                item_kind, prop_changes, text_changed, base_path, base_rev,
- path, added):
+ path, added, replaced):
     self.item_kind = item_kind
     self.prop_changes = prop_changes
     self.text_changed = text_changed
@@ -50,6 +50,10 @@
     ### if the rev is always repos.rev - 1, or whether it represents the
     ### created or time-of-checkout rev. so... we use a flag (for now)
     self.added = added
+
+ ### this additional flag is needed to store information if a path was
+ ### a newly added one or if it was a replace action
+ self.replaced = replaced
 
 
 class ChangeCollector(_delta.Editor):
@@ -121,11 +125,17 @@
                                      parent_baton[2], # base_rev
                                      None, # (new) path
                                      False, # added
+ False, # replaced
                                      )
     self._send_change(path)
 
   def add_directory(self, path, parent_baton,
                     copyfrom_path, copyfrom_revision, dir_pool=None):
+ replaced = False
+ if self.changes.has_key(path):
+ # if this add is a replace there is already a change record inserted
+ # by a delete, so in this case set replaced to True.
+ replaced = True
     self.changes[path] = ChangedPath(_core.svn_node_dir,
                                      False,
                                      False,
@@ -133,6 +143,7 @@
                                      copyfrom_revision, # base_rev
                                      path, # path
                                      True, # added
+ replaced, # replaced
                                      )
     if copyfrom_path and (copyfrom_revision != -1):
       base_path = copyfrom_path
@@ -158,10 +169,16 @@
                                            dir_baton[2], # base_rev
                                            dir_path, # path
                                            False, # added
+ False, # replaced
                                            )
 
   def add_file(self, path, parent_baton,
                copyfrom_path, copyfrom_revision, file_pool=None):
+ replaced = False
+ if self.changes.has_key(path):
+ # if this add is a replace there is already a change record inserted
+ # by a delete, so in this case set replaced to True.
+ replaced = True
     self.changes[path] = ChangedPath(_core.svn_node_file,
                                      False,
                                      False,
@@ -169,6 +186,7 @@
                                      copyfrom_revision, # base_rev
                                      path, # path
                                      True, # added
+ replaced, # replaced
                                      )
     if copyfrom_path and (copyfrom_revision != -1):
       base_path = copyfrom_path
@@ -195,6 +213,7 @@
                                             file_baton[2], # base_rev
                                             file_path, # path
                                             False, # added
+ False, # replaced
                                             )
 
     # no handler
@@ -214,6 +233,7 @@
                                             file_baton[2], # base_rev
                                             file_path, # path
                                             False, # added
+ False, # replaced
                                             )
   def close_directory(self, dir_baton):
     self._send_change(dir_baton[0])
--- tools/hook-scripts/mailer/mailer.py.orig 2006-08-21 08:00:05.437465100 +0200
+++ tools/hook-scripts/mailer/mailer.py 2006-08-21 08:42:22.704332500 +0200
@@ -615,9 +615,10 @@
       or 'yes'
 
   # figure out the lists of changes outside the selected path-space
- other_added_data = other_deleted_data = other_modified_data = [ ]
+ other_added_data = other_replaced_data = other_deleted_data = other_modified_data = [ ]
   if len(paths) != len(changelist) and show_nonmatching_paths != 'no':
     other_added_data = generate_list('A', changelist, paths, False)
+ other_replaced_data = generate_list('R', changelist, paths, False)
     other_deleted_data = generate_list('D', changelist, paths, False)
     other_modified_data = generate_list('M', changelist, paths, False)
 
@@ -633,10 +634,12 @@
     rev=repos.rev,
     log=repos.get_rev_prop(svn.core.SVN_PROP_REVISION_LOG) or '',
     added_data=generate_list('A', changelist, paths, True),
+ replaced_data=generate_list('R', changelist, paths, True),
     deleted_data=generate_list('D', changelist, paths, True),
     modified_data=generate_list('M', changelist, paths, True),
     show_nonmatching_paths=show_nonmatching_paths,
     other_added_data=other_added_data,
+ other_replaced_data=other_replaced_data,
     other_deleted_data=other_deleted_data,
     other_modified_data=other_modified_data,
     diffs=DiffGenerator(changelist, paths, True, cfg, repos, date, group,
@@ -648,7 +651,9 @@
 
 def generate_list(changekind, changelist, paths, in_paths):
   if changekind == 'A':
- selection = lambda change: change.added
+ selection = lambda change: change.added and not change.replaced
+ elif changekind == 'R':
+ selection = lambda change: change.replaced
   elif changekind == 'D':
     selection = lambda change: change.path is None
   elif changekind == 'M':
@@ -893,14 +898,16 @@
 
     # print summary sections
     self._render_list('Added', data.added_data)
+ self._render_list('Replaced', data.replaced_data)
     self._render_list('Deleted', data.deleted_data)
     self._render_list('Modified', data.modified_data)
 
- if data.other_added_data or data.other_deleted_data \
- or data.other_modified_data:
+ if data.other_added_data or data.other_replaced_data \
+ or data.other_deleted_data or data.other_modified_data:
       if data.show_nonmatching_paths:
         w('\nChanges in other areas also in this revision:\n')
         self._render_list('Added', data.other_added_data)
+ self._render_list('Replaced', data.other_replaced_data)
         self._render_list('Deleted', data.other_deleted_data)
         self._render_list('Modified', data.other_modified_data)
       else:
--- tools/hook-scripts/mailer/tests/mailer-t1.output.orig 2006-08-14 09:59:20.356194800 +0200
+++ tools/hook-scripts/mailer/tests/mailer-t1.output 2006-08-21 08:44:19.780209600 +0200
@@ -210,6 +210,7 @@
       - copied from r5, /dir3/
    dir6/dir5/
       - copied from r6, /dir3/dir5/
+Replaced:
    dir6/file3
       - copied unchanged from r6, /dir3/file3
 Modified:
 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Aug 21 09:06:18 2006

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.