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

Re: Change in svn/repos.py for recognition of replaced paths in mailer.py

From: C. Michael Pilato <cmpilato_at_collab.net>
Date: 2006-09-06 21:56:58 CEST

C. Michael Pilato wrote:
> Mathias Weinert wrote:
>> Hi,
>>
>> I still like to implement the recognition of replaced paths in
>> mailer.py. In order to achieve this I need a change of
>> subversion/bindings/swig/python/svn/repos.py which I already posted
>> to the dev list and for which I already got replies - but no commit.
>>
>> So if there is anybody out there willing to commit my patch (with or
>> without the change proposed by cmpilato) please commit it.
>>
>> Original patch/post:
>> http://svn.haxx.se/dev/archive-2006-08/0612.shtml
>>
>> Last patch provided by me:
>> http://svn.haxx.se/dev/archive-2006-08/0956.shtml
>>
>> cmpilato's reply:
>> http://svn.haxx.se/dev/archive-2006-08/0969.shtml
>>
>> Thank you very much!
>
> Attached is an updated patch that has my proposed change. I'm not able
> to clearly think through the compatibility issues here, but I *think*
> that making the new parameter optional buys us all that we need.

Ooh. And attached to *this* mail is alternative (much older) patch that
I just found in my ~/misc/PATCHES directory which takes this problem a
different direction altogether. Rather than continuing to grow these
custom action fields (added, replaced, etc.) it just adds an 'action'
field and a list of testable actions.

-- 
C. Michael Pilato <cmpilato@collab.net>
CollabNet   <>   www.collab.net   <>   Distributed Development On Demand

* subversion/bindings/swig/python/svn/repos.py
  (ChangedPath.__init__): Add 'action' parameter.
  (ChangeCollector.delete_entry, ChangeCollector.add_directory,
   ChangeCollector.change_dir_prop, ChangeCollector.add_file,
   ChangeCollector.apply_textdelta, ChangeCollector.change_file_prop):
    Update calls to ChangedPath().

Index: subversion/bindings/swig/python/svn/repos.py
===================================================================
--- subversion/bindings/swig/python/svn/repos.py (revision 12960)
+++ subversion/bindings/swig/python/svn/repos.py (working copy)
@@ -26,6 +26,10 @@
 # Names that are not to be exported
 import core as _core, fs as _fs, delta as _delta
 
+CHANGE_ACTION_MODIFY = 0
+CHANGE_ACTION_ADD = 1
+CHANGE_ACTION_DELETE = 2
+CHANGE_ACTION_REPLACE = 3
 
 class ChangedPath:
   __slots__ = [ 'item_kind', 'prop_changes', 'text_changed',
@@ -33,13 +37,17 @@
                 ]
   def __init__(self,
                item_kind, prop_changes, text_changed, base_path, base_rev,
- path, added):
+ path, added, action=None):
     self.item_kind = item_kind
     self.prop_changes = prop_changes
     self.text_changed = text_changed
     self.base_path = base_path
     self.base_rev = base_rev
     self.path = path
+ if action not in [None, CHANGE_ACTION_MODIFY, CHANGE_ACTION_ADD,
+ CHANGE_ACTION_DELETE, CHANGE_ACTION_REPLACE]:
+ raise Exception, "unsupported change type"
+ self.action = action
 
     ### it would be nice to avoid this flag. however, without it, it would
     ### be quite difficult to distinguish between a change to the previous
@@ -51,7 +59,6 @@
     ### created or time-of-checkout rev. so... we use a flag (for now)
     self.added = added
 
-
 class ChangeCollector(_delta.Editor):
   """Available Since: 1.2.0
   """
@@ -124,11 +131,14 @@
                                      parent_baton[2], # base_rev
                                      None, # (new) path
                                      False, # added
+ CHANGE_ACTION_DELETE,
                                      )
     self._send_change(path)
 
   def add_directory(self, path, parent_baton,
                     copyfrom_path, copyfrom_revision, dir_pool):
+ action = self.changes.has_key(path) and CHANGE_ACTION_REPLACE \
+ or CHANGE_ACTION_ADD
     self.changes[path] = ChangedPath(_core.svn_node_dir,
                                      False,
                                      False,
@@ -136,6 +146,7 @@
                                      copyfrom_revision, # base_rev
                                      path, # path
                                      True, # added
+ action,
                                      )
     if copyfrom_path and (copyfrom_revision != -1):
       base_path = copyfrom_path
@@ -161,10 +172,13 @@
                                            dir_baton[2], # base_rev
                                            dir_path, # path
                                            False, # added
+ CHANGE_ACTION_MODIFY,
                                            )
 
   def add_file(self, path, parent_baton,
                copyfrom_path, copyfrom_revision, file_pool):
+ action = self.changes.has_key(path) and CHANGE_ACTION_REPLACE \
+ or CHANGE_ACTION_ADD
     self.changes[path] = ChangedPath(_core.svn_node_file,
                                      False,
                                      False,
@@ -172,6 +186,7 @@
                                      copyfrom_revision, # base_rev
                                      path, # path
                                      True, # added
+ action,
                                      )
     if copyfrom_path and (copyfrom_revision != -1):
       base_path = copyfrom_path
@@ -198,6 +213,7 @@
                                             file_baton[2], # base_rev
                                             file_path, # path
                                             False, # added
+ CHANGE_ACTION_MODIFY,
                                             )
 
     # no handler
@@ -217,6 +233,7 @@
                                             file_baton[2], # base_rev
                                             file_path, # path
                                             False, # added
+ CHANGE_ACTION_MODIFY,
                                             )
   def close_directory(self, dir_baton):
     self._send_change(dir_baton[0])

Received on Wed Sep 6 21:58:20 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.