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

Re: [PATCH] Add Commandline Option '--no-diffs-added' to svnlook

From: Max Bernhardt - extern TAGP - Tel. 3749 <Max.Bernhardt_at_vodafone.com>
Date: 2004-12-10 09:13:00 CET

Hi Philip,

thanks a lot for the pointers.

>"Max Bernhardt - extern TAGP - Tel. 3749" <Max.Bernhardt@vodafone.com> writes:
>
>
>
>>Added a new Commandline Option to svnlook that allows users
>>to suppress the full listing of added files.
>>--no-diffs-added behaves just like --no-diffs-deleted
>>
>>
>
>Could you write a full log message? See the HACKING file or run svn
>log on the repository.
>
>
>
Find the attached file PATCH_LOG

>>Index: main.c
>>===================================================================
>>--- main.c (revision 12259)
>>+++ main.c (working copy)
>>
>>
>
>Patches from the trunk directory are better, we have more than one
>main.c file.
>
>
I changed the diff: find the attached file PATCH_SVN_LOOK_MAIN.

> <>
> Have you looked at the regression tests? Could you write a basic
> "this feature works" test? Take a look at the existing tests in
> subversion/tests/clients/cmdline/svnlook_tests.py

I'd love to, but that will have to wait because I really don't know
enough about python yet ... ;-)
I will try to get to it as soon as have a better understanding about
python and the testframework
subversion uses. Then i would probably add a test for --no-diffs-deleted
as well ...

> <>The patch changes looks OK, is there support for adding this feature?
> (Obviously Max wants it :)

I think this feature makes sense regarding oost commit emails. It's just
a little annoying to get
a mail that is a couple of hundred kB or even a few MB everytime
somebody checks in a new file.

Hence i add another patch for commit-email.pl.in (PATCH_COMMIT_EMAIL).

CU
Max

Index: tools/hook-scripts/commit-email.pl.in
===================================================================
--- tools/hook-scripts/commit-email.pl.in (revision 12270)
+++ tools/hook-scripts/commit-email.pl.in (working copy)
@@ -51,6 +51,11 @@
 # in the log and email messages by not printing the file, then set
 # $no_diff_deleted to 1.
 my $no_diff_deleted = 0;
+# By default, when a file is added to the repository, svnlook diff
+# prints the entire contents of the file. If you want to save space
+# in the log and email messages by not printing the file, then set
+# $no_diff_added to 1.
+my $no_diff_added = 0;
 
 # Since the path to svnlook depends upon the local installation
 # preferences, check that the required programs exist to insure that
@@ -277,8 +282,10 @@
 
 # Get the diff from svnlook.
 my @no_diff_deleted = $no_diff_deleted ? ('--no-diff-deleted') : ();
+my @no_diff_added = $no_diff_added ? ('--no-diff-added') : ();
 my @difflines = &read_from_process($svnlook, 'diff', $repos,
- '-r', $rev, @no_diff_deleted);
+ '-r', $rev, @no_diff_deleted,
+ @no_diff_added);
 
 ######################################################################
 # Modified directory name collapsing.

Add an option to disable `svnlook diff' from printing diffs on files
that are added to the repository.

* subversion/svnlook/main.c:
  (option enumeration): Add svnlook__no_diff_added
  (options_table): Add no-diff-added option.
  (cmd_table): Add svnlook__no_diff_added to diff subcommand.
  (svnlook_opt_state): Add svn_boolean_t no_diff_added.
  (svnlook_ctxt_t): Add svn_boolean_t no_diff_added.
  (print_diff_tree): New svn_boolean_t no_diff_added argument.
    Change if statement that allows the diff to happen
      to include no_diff_added
    Change all recursive calls.
  (do_diff): Pass svnlook_ctxt_t->no_diff_added to print_diff_tree.
  (get_ctxt_baton): Copy no_diff_added to context baton.
  (main): Set no_diff_added option.
  
* tools/hook-scripts/commit-email.pl:
  (main) Add new option variable $no_diff_added to disable diffs
    of added files.

Index: subversion/svnlook/main.c
===================================================================
--- subversion/svnlook/main.c (revision 12259)
+++ subversion/svnlook/main.c (working copy)
@@ -72,7 +72,8 @@
   {
     svnlook__version = SVN_OPT_FIRST_LONGOPT_ID,
     svnlook__show_ids,
- svnlook__no_diff_deleted
+ svnlook__no_diff_deleted,
+ svnlook__no_diff_added
   };
 
 /*
@@ -107,6 +108,9 @@
     {"no-diff-deleted", svnlook__no_diff_deleted, 0,
      N_("do not print differences for deleted files")},
 
+ {"no-diff-added", svnlook__no_diff_added, 0,
+ N_("do not print differences for added files")},
+
     {0, 0, 0, 0}
   };
 
@@ -140,7 +144,7 @@
     {"diff", subcommand_diff, {0},
      N_("usage: svnlook diff REPOS_PATH\n\n"
         "Print GNU-style diffs of changed files and properties.\n"),
- {'r', 't', svnlook__no_diff_deleted} },
+ {'r', 't', svnlook__no_diff_deleted, svnlook__no_diff_added} },
 
     {"dirs-changed", subcommand_dirschanged, {0},
      N_("usage: svnlook dirs-changed REPOS_PATH\n\n"
@@ -212,6 +216,7 @@
   svn_boolean_t show_ids; /* --show-ids */
   svn_boolean_t help; /* --help */
   svn_boolean_t no_diff_deleted; /* --no-diff-deleted */
+ svn_boolean_t no_diff_added; /* --no-diff-added */
   svn_boolean_t verbose; /* --verbose */
 };
 
@@ -223,6 +228,7 @@
   svn_boolean_t is_revision;
   svn_boolean_t show_ids;
   svn_boolean_t no_diff_deleted;
+ svn_boolean_t no_diff_added;
   svn_revnum_t rev_id;
   svn_fs_txn_t *txn;
   const char *txn_name /* UTF-8! */;
@@ -786,6 +792,7 @@
                  const char *path /* UTF-8! */,
                  const char *base_path /* UTF-8! */,
                  svn_boolean_t no_diff_deleted,
+ svn_boolean_t no_diff_added,
                  const char *tmpdir,
                  apr_pool_t *pool)
 {
@@ -886,7 +893,7 @@
                                         : _("Index")))),
                                      path));
 
- if ((! no_diff_deleted) || (node->action != 'D'))
+ if (!(node->action == 'D' && no_diff_deleted) && !(node->action == 'A' && no_diff_added))
         {
           svn_diff_t *diff;
 
@@ -965,6 +972,7 @@
                             svn_path_join (path, node->name, subpool),
                             svn_path_join (base_path, node->name, subpool),
                             no_diff_deleted,
+ no_diff_added,
                             tmpdir,
                             subpool));
   while (node->sibling)
@@ -975,6 +983,7 @@
                                 svn_path_join (path, node->name, subpool),
                                 svn_path_join (base_path, node->name, subpool),
                                 no_diff_deleted,
+ no_diff_added,
                                 tmpdir,
                                 subpool));
     }
@@ -1326,7 +1335,7 @@
       SVN_ERR (svn_fs_revision_root (&base_root, c->fs, base_rev_id, pool));
       SVN_ERR (create_unique_tmpdir (&tmpdir, pool));
       err = print_diff_tree (root, base_root, tree, "", "",
- c->no_diff_deleted, tmpdir, pool);
+ c->no_diff_deleted, c->no_diff_added, tmpdir, pool);
       if (err)
         {
           svn_error_clear (svn_io_remove_dir (tmpdir, pool));
@@ -1552,6 +1561,7 @@
   svn_fs_set_warning_func (baton->fs, warning_func, NULL);
   baton->show_ids = opt_state->show_ids;
   baton->no_diff_deleted = opt_state->no_diff_deleted;
+ baton->no_diff_added = opt_state->no_diff_added;
   baton->is_revision = opt_state->txn ? FALSE : TRUE;
   baton->rev_id = opt_state->rev;
   baton->txn_name = apr_pstrdup (pool, opt_state->txn);
@@ -1910,6 +1920,10 @@
           opt_state.no_diff_deleted = TRUE;
           break;
 
+ case svnlook__no_diff_added:
+ opt_state.no_diff_added = TRUE;
+ break;
+
         default:
           subcommand_help (NULL, NULL, pool);
           svn_pool_destroy (pool);

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Dec 10 09:14:33 2004

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.