<commit_before>/*
 * feedback.c:  feedback handlers for cmdline client.
 *
 * ====================================================================
 * Copyright (c) 2000-2004 CollabNet.  All rights reserved.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution.  The terms
 * are also available at http://subversion.tigris.org/license-1.html.
 * If newer versions of this license are posted there, you may use a
 * newer version instead, at your option.
 *
 * This software consists of voluntary contributions made by many
 * individuals.  For exact contribution history, see the revision
 * history and logs, available at http://subversion.tigris.org/.
 * ====================================================================
 */

/* ==================================================================== */




/*** Includes. ***/

#define APR_WANT_STDIO
#define APR_WANT_STRFUNC
#include <apr_want.h>

#include "svn_cmdline.h"
#include "svn_pools.h"
#include "svn_path.h"
#include "cl.h"

#include "svn_private_config.h"



/* Baton for notify and friends. */
struct notify_baton
{
  svn_boolean_t received_some_change;
  svn_boolean_t is_checkout;
  svn_boolean_t is_export;
  svn_boolean_t suppress_final_line;
  svn_boolean_t sent_first_txdelta;
  svn_boolean_t in_external;
  svn_boolean_t had_print_error; /* Used to not keep printing error messages
                                    when we've already had one print error. */
};


/* This implements `svn_wc_notify_func2_t'.
 * NOTE: This function can't fail, so we just ignore any print errors. */
static void
notify (void *baton, const svn_wc_notify_t *n, apr_pool_t *pool)
{
  struct notify_baton *nb = baton;
  char statchar_buf[5] = "    ";
  const char *path_local;
  svn_error_t *err;

  path_local = svn_path_local_style (n->path, pool);

  switch (n->action)
    {
    case svn_wc_notify_skip:
      if (n->content_state == svn_wc_notify_state_missing)
        {
          if ((err = svn_cmdline_printf
               (pool, _("Skipped missing target: '%s'\n"),
                path_local)))
            goto print_error;
        }
      else
        {
          if ((err = svn_cmdline_printf
               (pool, _("Skipped '%s'\n"), path_local)))
            goto print_error;
        }
      break;

    case svn_wc_notify_update_delete:
      nb->received_some_change = TRUE;
      if ((err = svn_cmdline_printf (pool, "D    %s\n", path_local)))
        goto print_error;
      break;

    case svn_wc_notify_update_add:
      nb->received_some_change = TRUE;
      if ((err = svn_cmdline_printf (pool, "A    %s\n", path_local)))
        goto print_error;
      break;

    case svn_wc_notify_restore:
      if ((err = svn_cmdline_printf (pool, _("Restored '%s'\n"),
                                     path_local)))
        goto print_error;
      break;

    case svn_wc_notify_revert:
      if ((err = svn_cmdline_printf (pool, _("Reverted '%s'\n"),
                                     path_local)))
        goto print_error;
      break;

    case svn_wc_notify_failed_revert:
      if (( err = svn_cmdline_printf (pool, _("Failed to revert '%s' -- "
                                              "try updating instead.\n"), 
                                      path_local)))
        goto print_error;
      break;

    case svn_wc_notify_resolved:
      if ((err = svn_cmdline_printf (pool,
                                     _("Resolved conflicted state of '%s'\n"),
                                     path_local)))
        goto print_error;
      break;

    case svn_wc_notify_add:
      /* We *should* only get the MIME_TYPE if PATH is a file.  If we
         do get it, and the mime-type is not textual, note that this
         is a binary addition. */
      if (n->mime_type && (svn_mime_type_is_binary (n->mime_type)))
        {
          if ((err = svn_cmdline_printf (pool, "A  (bin)  %s\n",
                                         path_local)))
            goto print_error;
        }
      else
        {
          if ((err = svn_cmdline_printf (pool, "A         %s\n",
                                         path_local)))
            goto print_error;
        }
      break;

    case svn_wc_notify_delete:
      nb->received_some_change = TRUE;
      if ((err = svn_cmdline_printf (pool, "D         %s\n",
                                     path_local)))
        goto print_error;
      break;

    case svn_wc_notify_update_update:
      {
        /* If this is an inoperative dir change, do no notification.
           An inoperative dir change is when a directory gets closed
           without any props having been changed. */
        if (! ((n->kind == svn_node_dir)
               && ((n->prop_state == svn_wc_notify_state_inapplicable)
                   || (n->prop_state == svn_wc_notify_state_unknown)
                   || (n->prop_state == svn_wc_notify_state_unchanged))))
          {
            nb->received_some_change = TRUE;
            
            if (n->kind == svn_node_file)
              {
                if (n->content_state == svn_wc_notify_state_conflicted)
                  statchar_buf[0] = 'C';
                else if (n->content_state == svn_wc_notify_state_merged)
                  statchar_buf[0] = 'G';
                else if (n->content_state == svn_wc_notify_state_changed)
                  statchar_buf[0] = 'U';
              }
            
            if (n->prop_state == svn_wc_notify_state_conflicted)
              statchar_buf[1] = 'C';
            else if (n->prop_state == svn_wc_notify_state_merged)
              statchar_buf[1] = 'G';
            else if (n->prop_state == svn_wc_notify_state_changed)
              statchar_buf[1] = 'U';

            if (n->lock_state == svn_wc_notify_lock_state_unlocked)
              statchar_buf[2] = 'B';

            if (! ((n->content_state == svn_wc_notify_state_unchanged
                    || n->content_state == svn_wc_notify_state_unknown)
                   && (n->prop_state == svn_wc_notify_state_unchanged
                       || n->prop_state == svn_wc_notify_state_unknown)))
              {
                if ((err = svn_cmdline_printf (pool, "%s %s\n",
                                               statchar_buf, path_local)))
                  goto print_error;
              }
          }
      }
      break;

    case svn_wc_notify_update_external:
      /* Remember that we're now "inside" an externals definition. */
      nb->in_external = TRUE;

      /* Currently this is used for checkouts and switches too.  If we
         want different output, we'll have to add new actions. */
      if ((err = svn_cmdline_printf (pool,
                                     _("\nFetching external item into '%s'\n"),
                                     path_local)))
        goto print_error;
      break;

    case svn_wc_notify_update_completed:
      {<commit_msg>Make notification work correctly for broken locks on update when no changes were received.<commit_after>/*
 * feedback.c:  feedback handlers for cmdline client.
 *
 * ====================================================================
 * Copyright (c) 2000-2004 CollabNet.  All rights reserved.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution.  The terms
 * are also available at http://subversion.tigris.org/license-1.html.
 * If newer versions of this license are posted there, you may use a
 * newer version instead, at your option.
 *
 * This software consists of voluntary contributions made by many
 * individuals.  For exact contribution history, see the revision
 * history and logs, available at http://subversion.tigris.org/.
 * ====================================================================
 */

/* ==================================================================== */




/*** Includes. ***/

#define APR_WANT_STDIO
#define APR_WANT_STRFUNC
#include <apr_want.h>

#include "svn_cmdline.h"
#include "svn_pools.h"
#include "svn_path.h"
#include "cl.h"

#include "svn_private_config.h"



/* Baton for notify and friends. */
struct notify_baton
{
  svn_boolean_t received_some_change;
  svn_boolean_t is_checkout;
  svn_boolean_t is_export;
  svn_boolean_t suppress_final_line;
  svn_boolean_t sent_first_txdelta;
  svn_boolean_t in_external;
  svn_boolean_t had_print_error; /* Used to not keep printing error messages
                                    when we've already had one print error. */
};


/* This implements `svn_wc_notify_func2_t'.
 * NOTE: This function can't fail, so we just ignore any print errors. */
static void
notify (void *baton, const svn_wc_notify_t *n, apr_pool_t *pool)
{
  struct notify_baton *nb = baton;
  char statchar_buf[5] = "    ";
  const char *path_local;
  svn_error_t *err;

  path_local = svn_path_local_style (n->path, pool);

  switch (n->action)
    {
    case svn_wc_notify_skip:
      if (n->content_state == svn_wc_notify_state_missing)
        {
          if ((err = svn_cmdline_printf
               (pool, _("Skipped missing target: '%s'\n"),
                path_local)))
            goto print_error;
        }
      else
        {
          if ((err = svn_cmdline_printf
               (pool, _("Skipped '%s'\n"), path_local)))
            goto print_error;
        }
      break;

    case svn_wc_notify_update_delete:
      nb->received_some_change = TRUE;
      if ((err = svn_cmdline_printf (pool, "D    %s\n", path_local)))
        goto print_error;
      break;

    case svn_wc_notify_update_add:
      nb->received_some_change = TRUE;
      if ((err = svn_cmdline_printf (pool, "A    %s\n", path_local)))
        goto print_error;
      break;

    case svn_wc_notify_restore:
      if ((err = svn_cmdline_printf (pool, _("Restored '%s'\n"),
                                     path_local)))
        goto print_error;
      break;

    case svn_wc_notify_revert:
      if ((err = svn_cmdline_printf (pool, _("Reverted '%s'\n"),
                                     path_local)))
        goto print_error;
      break;

    case svn_wc_notify_failed_revert:
      if (( err = svn_cmdline_printf (pool, _("Failed to revert '%s' -- "
                                              "try updating instead.\n"), 
                                      path_local)))
        goto print_error;
      break;

    case svn_wc_notify_resolved:
      if ((err = svn_cmdline_printf (pool,
                                     _("Resolved conflicted state of '%s'\n"),
                                     path_local)))
        goto print_error;
      break;

    case svn_wc_notify_add:
      /* We *should* only get the MIME_TYPE if PATH is a file.  If we
         do get it, and the mime-type is not textual, note that this
         is a binary addition. */
      if (n->mime_type && (svn_mime_type_is_binary (n->mime_type)))
        {
          if ((err = svn_cmdline_printf (pool, "A  (bin)  %s\n",
                                         path_local)))
            goto print_error;
        }
      else
        {
          if ((err = svn_cmdline_printf (pool, "A         %s\n",
                                         path_local)))
            goto print_error;
        }
      break;

    case svn_wc_notify_delete:
      nb->received_some_change = TRUE;
      if ((err = svn_cmdline_printf (pool, "D         %s\n",
                                     path_local)))
        goto print_error;
      break;

    case svn_wc_notify_update_update:
      {
        /* If this is an inoperative dir change, do no notification.
           An inoperative dir change is when a directory gets closed
           without any props having been changed. */
        if (! ((n->kind == svn_node_dir)
               && ((n->prop_state == svn_wc_notify_state_inapplicable)
                   || (n->prop_state == svn_wc_notify_state_unknown)
                   || (n->prop_state == svn_wc_notify_state_unchanged))))
          {
            if (n->kind == svn_node_file)
              {
                if (n->content_state == svn_wc_notify_state_conflicted)
                  statchar_buf[0] = 'C';
                else if (n->content_state == svn_wc_notify_state_merged)
                  statchar_buf[0] = 'G';
                else if (n->content_state == svn_wc_notify_state_changed)
                  statchar_buf[0] = 'U';
              }
            
            if (n->prop_state == svn_wc_notify_state_conflicted)
              statchar_buf[1] = 'C';
            else if (n->prop_state == svn_wc_notify_state_merged)
              statchar_buf[1] = 'G';
            else if (n->prop_state == svn_wc_notify_state_changed)
              statchar_buf[1] = 'U';

            if (n->lock_state == svn_wc_notify_lock_state_unlocked)
              statchar_buf[2] = 'B';

            if (statchar_buf[0] != ' ' || statchar_buf[1] != ' ')
              nb->received_some_change = TRUE;

            if (statchar_buf[0] != ' ' || statchar_buf[1] != ' '
                || statchar_buf[2] != ' ')
              {
                if ((err = svn_cmdline_printf (pool, "%s %s\n",
                                               statchar_buf, path_local)))
                  goto print_error;
              }
          }
      }
      break;

    case svn_wc_notify_update_external:
      /* Remember that we're now "inside" an externals definition. */
      nb->in_external = TRUE;

      /* Currently this is used for checkouts and switches too.  If we
         want different output, we'll have to add new actions. */
      if ((err = svn_cmdline_printf (pool,
                                     _("\nFetching external item into '%s'\n"),
                                     path_local)))
        goto print_error;
      break;

    case svn_wc_notify_update_completed:
      {
{'fraction_non_alphanumeric': 0.12383767029481726, 'fraction_numerical': 0.0029553809558134506, 'mean_word_length': 1.8922243068584532, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 36, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2997763', 'n_tokens_mistral': 4245, 'n_tokens_neox': 4069, 'n_words': 1023}