After lots of discussion (big thanks to everybody contributing!) about
changes to the labels of the diffs generated by mailer.py I want to make
a (hopefully) final proposal.
The patch is made under the following premises:
- the patch is primarly focussed on human readers of mailer.py's output
- nevertheless it will still be possible to use the patches by a patch
program (the patch even enhanced the number of cases for which it will
work)
- it would be useful to have a diff output that allows a special
Subversion patch program to apply all changes made to a path
(renaming, properties etc.) to a wc, but that's not part of this patch
These are examples of how the patch will change the output of mailer.py:
Added file:
old: --- (empty file)
+++ dir1/file3 Sun Sep 9 01:46:40 2001
new: --- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ dir1/file3 Sun Sep 9 01:46:40 2001 (r1)
Modified file:
old: --- dir2/file5 (original)
+++ dir2/file5 Sun Sep 9 04:33:20 2001
new: --- dir2/file5 Sun Sep 9 01:46:40 2001 (r1)
+++ dir2/file5 Sun Sep 9 04:33:20 2001 (r2)
Unchanged copied file:
old: --- file1 (original)
+++ dir2/file7 Sun Sep 9 07:20:00 2001
new: --- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ dir2/file7 Sun Sep 9 07:20:00 2001 (r3, copy of r2, file1)
Copied and changed file:
old: --- file1 (original)
+++ dir3/file8 Sun Sep 9 10:06:40 2001
new: --- file1 Sun Sep 9 04:33:20 2001 (r2, copy source)
+++ dir3/file8 Sun Sep 9 10:06:40 2001 (r4)
Deleted file:
old: --- file2 Sun Sep 9 18:26:40 2001
+++ (empty file)
new: --- file2 Sun Sep 9 18:26:40 2001 (r6)
+++ /dev/null 00:00:00 1970 (deleted)
I hope that everybody can live with this change and will commit it if
there are no objections against the patch.
Mathias
[[[
Enhance labels of diffs in mailer.py to contain more information and to
be of better use for patch programs:
- always show the according revision number in brackets after the date
- 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 after
the date (e. g. show special texts for copied files)
- use /dev/null and 00:00:00 1970 for empty files so that patch programs
recognize that the file is new/deleted
* 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-21 11:30:19.732547400 +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\t%s\t(r%s)' % (base_path, self.date, change.base_rev)
+ label2 = '/dev/null\t00:00:00 1970\t(deleted)'
singular = True
elif change.action == svn.repos.CHANGE_ACTION_ADD \
@@ -796,8 +804,10 @@
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\t%s\t(r%s, copy source)' \
+ % (base_path, base_date, change.base_rev)
+ label2 = '%s\t%s\t(r%s)' \
+ % (change.path, self.date, self.repos.rev)
singular = False
else:
# this file was copied.
@@ -805,8 +815,11 @@
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 = '/dev/null\t00:00:00 1970\t' \
+ '(empty, because file is newly added)'
+ label2 = '%s\t%s\t(r%s, copy of r%s, %s)' \
+ % (change.path, self.date, self.repos.rev, \
+ change.base_rev, base_path)
singular = False
else:
# the file was added.
@@ -819,8 +832,10 @@
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 = '/dev/null\t00:00:00 1970\t' \
+ '(empty, because file is newly added)'
+ label2 = '%s\t%s\t(r%s)' \
+ % (change.path, self.date, self.repos.rev)
singular = True
elif not change.text_changed:
@@ -839,8 +854,10 @@
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\t%s\t(r%s)' \
+ % (base_path, base_date, change.base_rev)
+ label2 = '%s\t%s\t(r%s)' \
+ % (change.path, self.date, self.repos.rev)
singular = False
if diff:
@@ -1061,8 +1078,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 not rev:
+ 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-15 08:27:33.057603900 +0200
+++ tests/mailer-t1.output 2006-09-21 11:31:18.607547400 +0200
@@ -23,15 +23,15 @@
Added: file1
==============================================================================
---- (empty file)
-+++ file1 Sun Sep 9 01:46:40 2001
+--- /dev/null 00:00:00 1970 (empty, because file is newly added)
++++ file1 Sun Sep 9 01:46:40 2001 (r1)
@@ -0,0 +1 @@
+file1
Added: file2
==============================================================================
---- (empty file)
-+++ file2 Sun Sep 9 01:46:40 2001
+--- /dev/null 00:00:00 1970 (empty, because file is newly added)
++++ file2 Sun Sep 9 01:46:40 2001 (r1)
@@ -0,0 +1 @@
+file2
@@ -39,29 +39,29 @@
Added: dir1/file3
==============================================================================
---- (empty file)
-+++ dir1/file3 Sun Sep 9 01:46:40 2001
+--- /dev/null 00:00:00 1970 (empty, because file is newly added)
++++ dir1/file3 Sun Sep 9 01:46:40 2001 (r1)
@@ -0,0 +1 @@
+file3
Added: dir1/file4
==============================================================================
---- (empty file)
-+++ dir1/file4 Sun Sep 9 01:46:40 2001
+--- /dev/null 00:00:00 1970 (empty, because file is newly added)
++++ dir1/file4 Sun Sep 9 01:46:40 2001 (r1)
@@ -0,0 +1 @@
+file4
Added: dir2/file5
==============================================================================
---- (empty file)
-+++ dir2/file5 Sun Sep 9 01:46:40 2001
+--- /dev/null 00:00:00 1970 (empty, because file is newly added)
++++ dir2/file5 Sun Sep 9 01:46:40 2001 (r1)
@@ -0,0 +1 @@
+file5
Added: dir2/file6
==============================================================================
---- (empty file)
-+++ dir2/file6 Sun Sep 9 01:46:40 2001
+--- /dev/null 00:00:00 1970 (empty, because file is newly added)
++++ dir2/file6 Sun Sep 9 01:46:40 2001 (r1)
@@ -0,0 +1 @@
+file6
Group: All
@@ -86,43 +86,43 @@
Added: dir1/file3
==============================================================================
---- (empty file)
-+++ dir1/file3 Sun Sep 9 01:46:40 2001
+--- /dev/null 00:00:00 1970 (empty, because file is newly added)
++++ dir1/file3 Sun Sep 9 01:46:40 2001 (r1)
@@ -0,0 +1 @@
+file3
Added: dir1/file4
==============================================================================
---- (empty file)
-+++ dir1/file4 Sun Sep 9 01:46:40 2001
+--- /dev/null 00:00:00 1970 (empty, because file is newly added)
++++ dir1/file4 Sun Sep 9 01:46:40 2001 (r1)
@@ -0,0 +1 @@
+file4
Added: dir2/file5
==============================================================================
---- (empty file)
-+++ dir2/file5 Sun Sep 9 01:46:40 2001
+--- /dev/null 00:00:00 1970 (empty, because file is newly added)
++++ dir2/file5 Sun Sep 9 01:46:40 2001 (r1)
@@ -0,0 +1 @@
+file5
Added: dir2/file6
==============================================================================
---- (empty file)
-+++ dir2/file6 Sun Sep 9 01:46:40 2001
+--- /dev/null 00:00:00 1970 (empty, because file is newly added)
++++ dir2/file6 Sun Sep 9 01:46:40 2001 (r1)
@@ -0,0 +1 @@
+file6
Added: file1
==============================================================================
---- (empty file)
-+++ file1 Sun Sep 9 01:46:40 2001
+--- /dev/null 00:00:00 1970 (empty, because file is newly added)
++++ file1 Sun Sep 9 01:46:40 2001 (r1)
@@ -0,0 +1 @@
+file1
Added: file2
==============================================================================
---- (empty file)
-+++ file2 Sun Sep 9 01:46:40 2001
+--- /dev/null 00:00:00 1970 (empty, because file is newly added)
++++ file2 Sun Sep 9 01:46:40 2001 (r1)
@@ -0,0 +1 @@
+file2
Group: file
@@ -141,15 +141,15 @@
Added: file1
==============================================================================
---- (empty file)
-+++ file1 Sun Sep 9 01:46:40 2001
+--- /dev/null 00:00:00 1970 (empty, because file is newly added)
++++ file1 Sun Sep 9 01:46:40 2001 (r1)
@@ -0,0 +1 @@
+file1
Added: file2
==============================================================================
---- (empty file)
-+++ file2 Sun Sep 9 01:46:40 2001
+--- /dev/null 00:00:00 1970 (empty, because file is newly added)
++++ file2 Sun Sep 9 01:46:40 2001 (r1)
@@ -0,0 +1 @@
+file2
Group: file plus other areas
@@ -173,8 +173,8 @@
Modified: file2
==============================================================================
---- file2 (original)
-+++ file2 Sun Sep 9 04:33:20 2001
+--- file2 Sun Sep 9 01:46:40 2001 (r1)
++++ file2 Sun Sep 9 04:33:20 2001 (r2)
@@ -1 +1,2 @@
file2
+change C1
@@ -183,8 +183,8 @@
Modified: dir2/file5
==============================================================================
---- dir2/file5 (original)
-+++ dir2/file5 Sun Sep 9 04:33:20 2001
+--- dir2/file5 Sun Sep 9 01:46:40 2001 (r1)
++++ dir2/file5 Sun Sep 9 04:33:20 2001 (r2)
@@ -1 +1,2 @@
file5
+change C2
@@ -206,16 +206,16 @@
Modified: dir2/file5
==============================================================================
---- dir2/file5 (original)
-+++ dir2/file5 Sun Sep 9 04:33:20 2001
+--- dir2/file5 Sun Sep 9 01:46:40 2001 (r1)
++++ dir2/file5 Sun Sep 9 04:33:20 2001 (r2)
@@ -1 +1,2 @@
file5
+change C2
Modified: file2
==============================================================================
---- file2 (original)
-+++ file2 Sun Sep 9 04:33:20 2001
+--- file2 Sun Sep 9 01:46:40 2001 (r1)
++++ file2 Sun Sep 9 04:33:20 2001 (r2)
@@ -1 +1,2 @@
file2
+change C1
@@ -235,8 +235,8 @@
Modified: file2
==============================================================================
---- file2 (original)
-+++ file2 Sun Sep 9 04:33:20 2001
+--- file2 Sun Sep 9 01:46:40 2001 (r1)
++++ file2 Sun Sep 9 04:33:20 2001 (r2)
@@ -1 +1,2 @@
file2
+change C1
@@ -258,8 +258,8 @@
Copied: dir2/file7 (from r2, file1)
==============================================================================
---- file1 (original)
-+++ dir2/file7 Sun Sep 9 07:20:00 2001
+--- /dev/null 00:00:00 1970 (empty, because file is newly added)
++++ dir2/file7 Sun Sep 9 07:20:00 2001 (r3, copy of r2, file1)
@@ -0,0 +1 @@
+file1
Group: All
@@ -278,8 +278,8 @@
Copied and modified: dir3/file8 (from r2, file1)
==============================================================================
---- file1 (original)
-+++ dir3/file8 Sun Sep 9 10:06:40 2001
+--- file1 Sun Sep 9 04:33:20 2001 (r2, copy source)
++++ dir3/file8 Sun Sep 9 10:06:40 2001 (r4)
@@ -1 +1,2 @@
file1
+change C3
@@ -347,8 +347,8 @@
Added: file9
==============================================================================
---- (empty file)
-+++ file9 Sun Sep 9 15:40:00 2001
+--- /dev/null 00:00:00 1970 (empty, because file is newly added)
++++ file9 Sun Sep 9 15:40:00 2001 (r6)
@@ -0,0 +1 @@
+file9
@@ -356,8 +356,8 @@
Modified: dir1/file3
==============================================================================
---- dir1/file3 (original)
-+++ dir1/file3 Sun Sep 9 15:40:00 2001
+--- dir1/file3 Sun Sep 9 12:53:20 2001 (r5)
++++ dir1/file3 Sun Sep 9 15:40:00 2001 (r6)
@@ -1 +1,2 @@
file3
+change C4
@@ -379,16 +379,16 @@
Modified: dir1/file3
==============================================================================
---- dir1/file3 (original)
-+++ dir1/file3 Sun Sep 9 15:40:00 2001
+--- dir1/file3 Sun Sep 9 12:53:20 2001 (r5)
++++ dir1/file3 Sun Sep 9 15:40:00 2001 (r6)
@@ -1 +1,2 @@
file3
+change C4
Added: file9
==============================================================================
---- (empty file)
-+++ file9 Sun Sep 9 15:40:00 2001
+--- /dev/null 00:00:00 1970 (empty, because file is newly added)
++++ file9 Sun Sep 9 15:40:00 2001 (r6)
@@ -0,0 +1 @@
+file9
Group: file
@@ -406,8 +406,8 @@
Added: file9
==============================================================================
---- (empty file)
-+++ file9 Sun Sep 9 15:40:00 2001
+--- /dev/null 00:00:00 1970 (empty, because file is newly added)
++++ file9 Sun Sep 9 15:40:00 2001 (r6)
@@ -0,0 +1 @@
+file9
Group: file plus other areas
@@ -434,8 +434,8 @@
Deleted: file2
==============================================================================
---- file2 Sun Sep 9 18:26:40 2001
-+++ (empty file)
+--- file2 Sun Sep 9 18:26:40 2001 (r6)
++++ /dev/null 00:00:00 1970 (deleted)
@@ -1,2 +0,0 @@
-file2
-change C1
@@ -444,15 +444,15 @@
Added: dir1/file10
==============================================================================
---- (empty file)
-+++ dir1/file10 Sun Sep 9 18:26:40 2001
+--- /dev/null 00:00:00 1970 (empty, because file is newly added)
++++ dir1/file10 Sun Sep 9 18:26:40 2001 (r7)
@@ -0,0 +1 @@
+file10
Modified: dir3/file3
==============================================================================
---- dir3/file3 (original)
-+++ dir3/file3 Sun Sep 9 18:26:40 2001
+--- dir3/file3 Sun Sep 9 15:40:00 2001 (r6)
++++ dir3/file3 Sun Sep 9 18:26:40 2001 (r7)
@@ -1 +1,2 @@
file3
+change C5
@@ -477,23 +477,23 @@
Added: dir1/file10
==============================================================================
---- (empty file)
-+++ dir1/file10 Sun Sep 9 18:26:40 2001
+--- /dev/null 00:00:00 1970 (empty, because file is newly added)
++++ dir1/file10 Sun Sep 9 18:26:40 2001 (r7)
@@ -0,0 +1 @@
+file10
Modified: dir3/file3
==============================================================================
---- dir3/file3 (original)
-+++ dir3/file3 Sun Sep 9 18:26:40 2001
+--- dir3/file3 Sun Sep 9 15:40:00 2001 (r6)
++++ dir3/file3 Sun Sep 9 18:26:40 2001 (r7)
@@ -1 +1,2 @@
file3
+change C5
Deleted: file2
==============================================================================
---- file2 Sun Sep 9 18:26:40 2001
-+++ (empty file)
+--- file2 Sun Sep 9 18:26:40 2001 (r6)
++++ /dev/null 00:00:00 1970 (deleted)
@@ -1,2 +0,0 @@
-file2
-change C1
@@ -512,8 +512,8 @@
Deleted: file2
==============================================================================
---- file2 Sun Sep 9 18:26:40 2001
-+++ (empty file)
+--- file2 Sun Sep 9 18:26:40 2001 (r6)
++++ /dev/null 00:00:00 1970 (deleted)
@@ -1,2 +0,0 @@
-file2
-change C1
@@ -540,16 +540,16 @@
Copied: dir6/file3 (from r7, dir3/file3)
==============================================================================
---- dir3/file3 (original)
-+++ dir6/file3 Sun Sep 9 21:13:20 2001
+--- /dev/null 00:00:00 1970 (empty, because file is newly added)
++++ dir6/file3 Sun Sep 9 21:13:20 2001 (r8, copy of r7, dir3/file3)
@@ -0,0 +1,2 @@
+file3
+change C5
Modified: dir6/file4
==============================================================================
---- dir3/file4 (original)
-+++ dir6/file4 Sun Sep 9 21:13:20 2001
+--- dir3/file4 Sun Sep 9 15:40:00 2001 (r6)
++++ dir6/file4 Sun Sep 9 21:13:20 2001 (r8)
@@ -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 Thu Sep 21 12:07:37 2006