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

[PATCH] Show more information in diff labels in mailer.py

From: Mathias Weinert <wein_at_mccw.de>
Date: 2006-09-13 16:24:29 CEST

Hi,

Please find attached a patch that makes mailer.py show more and
specific information in the labels of the diffs.

Examples to show changes in detail:

Added file:
old: --- (empty file)
     +++ dir1/file3 Sun Sep 9 01:46:40 2001

new: --- (empty, because file is newly added)
     +++ dir1/file3 r1 Sun Sep 9 01:46:40 2001

Modified file:
old: --- dir2/file5 (original)
     +++ dir2/file5 Sun Sep 9 04:33:20 2001

new: --- dir2/file5 r1 Sun Sep 9 01:46:40 2001 (original)
     +++ dir2/file5 r2 Sun Sep 9 04:33:20 2001

Unchanged copied file:
old: --- file1 (original)
     +++ dir2/file7 Sun Sep 9 07:20:00 2001

new: --- file1 r1 Sun Sep 9 01:46:40 2001 (copy source)
     +++ dir2/file7 r3 Sun Sep 9 07:20:00 2001 (unchanged copied file)

Copied and changed file:
old: --- file1 (original)
     +++ dir3/file8 Sun Sep 9 10:06:40 2001

new: --- file1 r1 Sun Sep 9 01:46:40 2001 (copy source)
     +++ dir3/file8 r4 Sun Sep 9 10:06:40 2001

Deleted file:
old: --- file2 Sun Sep 9 15:40:00 2001
     +++ (empty file)

new: --- file2 r5 Sun Sep 9 15:40:00 2001 (original)
     +++ (empty, because file is deleted)

If there are no objections against this change I will commit it.

Mathias

[[[

Enhance labels of diffs in mailer.py to contain more information:
- always show the according revision number
- if available show date and time of the file
  (e. g. for source of modified file)
- add more and specific hints about the file included in brackets
  (e. g. show special texts for copied files)

* tools/hook-scripts/mailer/mailer.py
  (DiffGenerator.__getitem__):
    Get date of base revision (if available) and enhance diff labels with
    more information (as listed above).
  (Repository.get_rev_prop):
    Add optional second parameter to specify a revision for which the
    revision property shall be fetched (default: current revision).

* tools/hook-scripts/mailer/tests/mailer-t1.output
  Adjust to new diff labels.

]]]

--- mailer.py.orig 2006-09-13 08:50:25.167052100 +0200
+++ mailer.py 2006-09-13 15:54:14.377447900 +0200
@@ -759,6 +759,14 @@
       if self.paths.has_key(path) != self.in_paths:
         continue
 
+ if change.base_rev != -1:
+ svndate = self.repos.get_rev_prop(svn.core.SVN_PROP_REVISION_DATE,
+ change.base_rev)
+ ### pick a different date format?
+ base_date = time.ctime(svn.core.secs_from_timestr(svndate, self.pool))
+ else:
+ base_date = ''
+
       # figure out if/how to generate a diff
 
       base_path = remove_leading_slashes(change.base_path)
@@ -774,8 +782,8 @@
           diff = svn.fs.FileDiff(self.repos.get_root(change.base_rev),
                                  base_path, None, None, self.pool)
 
- label1 = '%s\t%s' % (base_path, self.date)
- label2 = '(empty file)'
+ label1 = '%s\tr%s\t%s (original)' % (base_path, change.base_rev, self.date)
+ label2 = '(empty, because file is deleted)'
           singular = True
 
       elif change.action == svn.repos.CHANGE_ACTION_ADD \
@@ -796,8 +804,8 @@
                                      base_path,
                                      self.repos.root_this, change.path,
                                      self.pool)
- label1 = base_path + '\t(original)'
- label2 = '%s\t%s' % (change.path, self.date)
+ label1 = '%s\tr%s\t%s (copy source)' % (base_path, change.base_rev, base_date)
+ label2 = '%s\tr%s\t%s' % (change.path, self.repos.rev, self.date)
               singular = False
           else:
             # this file was copied.
@@ -805,8 +813,8 @@
             if self.diffsels.copy:
               diff = svn.fs.FileDiff(None, None, self.repos.root_this,
                                      change.path, self.pool)
- label1 = base_path + '\t(original)'
- label2 = '%s\t%s' % (change.path, self.date)
+ label1 = '%s\tr%s\t%s (copy source)' % (base_path, change.base_rev, base_date)
+ label2 = '%s\tr%s\t%s (unchanged copied file)' % (change.path, self.repos.rev, self.date)
               singular = False
         else:
           # the file was added.
@@ -819,8 +827,8 @@
           if self.diffsels.add:
             diff = svn.fs.FileDiff(None, None, self.repos.root_this,
                                    change.path, self.pool)
- label1 = '(empty file)'
- label2 = '%s\t%s' % (change.path, self.date)
+ label1 = '(empty, because file is newly added)'
+ label2 = '%s\tr%s\t%s' % (change.path, self.repos.rev, self.date)
             singular = True
 
       elif not change.text_changed:
@@ -839,8 +847,8 @@
                                  base_path,
                                  self.repos.root_this, change.path,
                                  self.pool)
- label1 = base_path + '\t(original)'
- label2 = '%s\t%s' % (change.path, self.date)
+ label1 = '%s\tr%s\t%s (original)' % (base_path, change.base_rev, base_date)
+ label2 = '%s\tr%s\t%s' % (change.path, self.repos.rev, self.date)
           singular = False
 
       if diff:
@@ -1061,8 +1069,10 @@
 
     self.author = self.get_rev_prop(svn.core.SVN_PROP_REVISION_AUTHOR)
 
- def get_rev_prop(self, propname):
- return svn.fs.revision_prop(self.fs_ptr, self.rev, propname, self.pool)
+ def get_rev_prop(self, propname, rev = None):
+ if rev == None:
+ rev = self.rev
+ return svn.fs.revision_prop(self.fs_ptr, rev, propname, self.pool)
 
   def get_root(self, rev):
     try:
--- tests/mailer-t1.output.orig 2006-09-12 14:42:29.674890200 +0200
+++ tests/mailer-t1.output 2006-09-13 15:54:31.486822900 +0200
@@ -20,43 +20,43 @@
 
 Added: dir1/file3
 ==============================================================================
---- (empty file)
-+++ dir1/file3 Sun Sep 9 01:46:40 2001
+--- (empty, because file is newly added)
++++ dir1/file3 r1 Sun Sep 9 01:46:40 2001
 @@ -0,0 +1 @@
 +file3
 
 Added: dir1/file4
 ==============================================================================
---- (empty file)
-+++ dir1/file4 Sun Sep 9 01:46:40 2001
+--- (empty, because file is newly added)
++++ dir1/file4 r1 Sun Sep 9 01:46:40 2001
 @@ -0,0 +1 @@
 +file4
 
 Added: dir2/file5
 ==============================================================================
---- (empty file)
-+++ dir2/file5 Sun Sep 9 01:46:40 2001
+--- (empty, because file is newly added)
++++ dir2/file5 r1 Sun Sep 9 01:46:40 2001
 @@ -0,0 +1 @@
 +file5
 
 Added: dir2/file6
 ==============================================================================
---- (empty file)
-+++ dir2/file6 Sun Sep 9 01:46:40 2001
+--- (empty, because file is newly added)
++++ dir2/file6 r1 Sun Sep 9 01:46:40 2001
 @@ -0,0 +1 @@
 +file6
 
 Added: file1
 ==============================================================================
---- (empty file)
-+++ file1 Sun Sep 9 01:46:40 2001
+--- (empty, because file is newly added)
++++ file1 r1 Sun Sep 9 01:46:40 2001
 @@ -0,0 +1 @@
 +file1
 
 Added: file2
 ==============================================================================
---- (empty file)
-+++ file2 Sun Sep 9 01:46:40 2001
+--- (empty, because file is newly added)
++++ file2 r1 Sun Sep 9 01:46:40 2001
 @@ -0,0 +1 @@
 +file2
 Group: defaults
@@ -75,16 +75,16 @@
 
 Modified: dir2/file5
 ==============================================================================
---- dir2/file5 (original)
-+++ dir2/file5 Sun Sep 9 04:33:20 2001
+--- dir2/file5 r1 Sun Sep 9 01:46:40 2001 (original)
++++ dir2/file5 r2 Sun Sep 9 04:33:20 2001
 @@ -1 +1,2 @@
  file5
 +change C2
 
 Modified: file2
 ==============================================================================
---- file2 (original)
-+++ file2 Sun Sep 9 04:33:20 2001
+--- file2 r1 Sun Sep 9 01:46:40 2001 (original)
++++ file2 r2 Sun Sep 9 04:33:20 2001
 @@ -1 +1,2 @@
  file2
 +change C1
@@ -106,8 +106,8 @@
 
 Copied: dir2/file7 (from r1, file1)
 ==============================================================================
---- file1 (original)
-+++ dir2/file7 Sun Sep 9 07:20:00 2001
+--- file1 r1 Sun Sep 9 01:46:40 2001 (copy source)
++++ dir2/file7 r3 Sun Sep 9 07:20:00 2001 (unchanged copied file)
 @@ -0,0 +1 @@
 +file1
 Group: defaults
@@ -126,8 +126,8 @@
 
 Copied and modified: dir3/file8 (from r1, file1)
 ==============================================================================
---- file1 (original)
-+++ dir3/file8 Sun Sep 9 10:06:40 2001
+--- file1 r1 Sun Sep 9 01:46:40 2001 (copy source)
++++ dir3/file8 r4 Sun Sep 9 10:06:40 2001
 @@ -1 +1,2 @@
  file1
 +change C3
@@ -149,16 +149,16 @@
 
 Modified: dir1/file3
 ==============================================================================
---- dir1/file3 (original)
-+++ dir1/file3 Sun Sep 9 12:53:20 2001
+--- dir1/file3 r4 Sun Sep 9 10:06:40 2001 (original)
++++ dir1/file3 r5 Sun Sep 9 12:53:20 2001
 @@ -1 +1,2 @@
  file3
 +change C4
 
 Added: file9
 ==============================================================================
---- (empty file)
-+++ file9 Sun Sep 9 12:53:20 2001
+--- (empty, because file is newly added)
++++ file9 r5 Sun Sep 9 12:53:20 2001
 @@ -0,0 +1 @@
 +file9
 Group: defaults
@@ -182,23 +182,23 @@
 
 Added: dir1/file10
 ==============================================================================
---- (empty file)
-+++ dir1/file10 Sun Sep 9 15:40:00 2001
+--- (empty, because file is newly added)
++++ dir1/file10 r6 Sun Sep 9 15:40:00 2001
 @@ -0,0 +1 @@
 +file10
 
 Modified: dir3/file3
 ==============================================================================
---- dir3/file3 (original)
-+++ dir3/file3 Sun Sep 9 15:40:00 2001
+--- dir3/file3 r5 Sun Sep 9 12:53:20 2001 (original)
++++ dir3/file3 r6 Sun Sep 9 15:40:00 2001
 @@ -1 +1,2 @@
  file3
 +change C5
 
 Deleted: file2
 ==============================================================================
---- file2 Sun Sep 9 15:40:00 2001
-+++ (empty file)
+--- file2 r5 Sun Sep 9 15:40:00 2001 (original)
++++ (empty, because file is deleted)
 @@ -1,2 +0,0 @@
 -file2
 -change C1
@@ -225,16 +225,16 @@
 
 Copied: dir6/file3 (from r6, dir3/file3)
 ==============================================================================
---- dir3/file3 (original)
-+++ dir6/file3 Sun Sep 9 18:26:40 2001
+--- dir3/file3 r6 Sun Sep 9 15:40:00 2001 (copy source)
++++ dir6/file3 r7 Sun Sep 9 18:26:40 2001 (unchanged copied file)
 @@ -0,0 +1,2 @@
 +file3
 +change C5
 
 Modified: dir6/file4
 ==============================================================================
---- dir3/file4 (original)
-+++ dir6/file4 Sun Sep 9 18:26:40 2001
+--- dir3/file4 r5 Sun Sep 9 12:53:20 2001 (original)
++++ dir6/file4 r7 Sun Sep 9 18:26:40 2001
 @@ -1 +1,2 @@
  file4
 +change C6

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Sep 13 17:35:01 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.