~ubuntu-branches/debian/sid/subversion/sid

« back to all changes in this revision

Viewing changes to subversion/svn/status.c

  • Committer: Package Import Robot
  • Author(s): James McCoy, Peter Samuelson, James McCoy
  • Date: 2014-01-12 19:48:33 UTC
  • mfrom: (0.2.10)
  • Revision ID: package-import@ubuntu.com-20140112194833-w3axfwksn296jn5x
Tags: 1.8.5-1
[ Peter Samuelson ]
* New upstream release.  (Closes: #725787) Rediff patches:
  - Remove apr-abi1 (applied upstream), rename apr-abi2 to apr-abi
  - Remove loosen-sqlite-version-check (shouldn't be needed)
  - Remove java-osgi-metadata (applied upstream)
  - svnmucc prompts for a changelog if none is provided. (Closes: #507430)
  - Remove fix-bdb-version-detection, upstream uses "apu-config --dbm-libs"
  - Remove ruby-test-wc (applied upstream)
  - Fix “svn diff -r N file” when file has svn:mime-type set.
    (Closes: #734163)
  - Support specifying an encoding for mod_dav_svn's environment in which
    hooks are run.  (Closes: #601544)
  - Fix ordering of “svnadmin dump” paths with certain APR versions.
    (Closes: #687291)
  - Provide a better error message when authentication fails with an
    svn+ssh:// URL.  (Closes: #273874)
  - Updated Polish translations.  (Closes: #690815)

[ James McCoy ]
* Remove all traces of libneon, replaced by libserf.
* patches/sqlite_3.8.x_workaround: Upstream fix for wc-queries-test test
  failurse.
* Run configure with --with-apache-libexecdir, which allows removing part of
  patches/rpath.
* Re-enable auth-test as upstream has fixed the problem of picking up
  libraries from the environment rather than the build tree.
  (Closes: #654172)
* Point LD_LIBRARY_PATH at the built auth libraries when running the svn
  command during the build.  (Closes: #678224)
* Add a NEWS entry describing how to configure mod_dav_svn to understand
  UTF-8.  (Closes: #566148)
* Remove ancient transitional package, libsvn-ruby.
* Enable compatibility with Sqlite3 versions back to Wheezy.
* Enable hardening flags.  (Closes: #734918)
* patches/build-fixes: Enable verbose build logs.
* Build against the default ruby version.  (Closes: #722393)

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
 
28
28
/*** Includes. ***/
 
29
#include "svn_hash.h"
29
30
#include "svn_cmdline.h"
30
31
#include "svn_wc.h"
31
32
#include "svn_dirent_uri.h"
33
34
#include "svn_time.h"
34
35
#include "cl.h"
35
36
#include "svn_private_config.h"
36
 
#include "tree-conflicts.h"
 
37
#include "cl-conflicts.h"
37
38
#include "private/svn_wc_private.h"
38
39
 
39
40
/* Return the single character representation of STATUS */
135
136
    }
136
137
}
137
138
 
 
139
/* Make a relative path containing '..' elements as needed.
 
140
   TARGET_ABSPATH shall be the absolute version of TARGET_PATH.
 
141
   TARGET_ABSPATH, TARGET_PATH and PATH shall be canonical.
 
142
 
 
143
   If above conditions are met, a relative path that leads to PATH
 
144
   from TARGET_PATH is returned, but there is no error checking involved.
 
145
 
 
146
   The returned path is allocated from RESULT_POOL, all other
 
147
   allocations are made in SCRATCH_POOL.  */
 
148
static const char *
 
149
make_relpath(const char *target_abspath,
 
150
             const char *target_path,
 
151
             const char *path,
 
152
             apr_pool_t *result_pool,
 
153
             apr_pool_t *scratch_pool)
 
154
{
 
155
  const char *la;
 
156
  const char *parent_dir_els = "";
 
157
  const char *abspath, *relative;
 
158
  svn_error_t *err = svn_dirent_get_absolute(&abspath, path, scratch_pool);
 
159
 
 
160
  if (err)
 
161
    {
 
162
      /* We probably got passed some invalid path. */
 
163
      svn_error_clear(err);
 
164
      return apr_pstrdup(result_pool, path);
 
165
    }
 
166
 
 
167
  relative = svn_dirent_skip_ancestor(target_abspath, abspath);
 
168
  if (relative)
 
169
    {
 
170
      return svn_dirent_join(target_path, relative, result_pool);
 
171
    }
 
172
 
 
173
  /* An example:
 
174
   *  relative_to_path = /a/b/c
 
175
   *  path             = /a/x/y/z
 
176
   *  result           = ../../x/y/z
 
177
   *
 
178
   * Another example (Windows specific):
 
179
   *  relative_to_path = F:/wc
 
180
   *  path             = C:/wc
 
181
   *  result           = C:/wc
 
182
   */
 
183
 
 
184
  /* Skip the common ancestor of both paths, here '/a'. */
 
185
  la = svn_dirent_get_longest_ancestor(target_abspath, abspath,
 
186
                                       scratch_pool);
 
187
  if (*la == '\0')
 
188
    {
 
189
      /* Nothing in common: E.g. C:/ vs F:/ on Windows */
 
190
      return apr_pstrdup(result_pool, path);
 
191
    }
 
192
  relative = svn_dirent_skip_ancestor(la, target_abspath);
 
193
  path = svn_dirent_skip_ancestor(la, path);
 
194
 
 
195
  /* In above example, we'd now have:
 
196
   *  relative_to_path = b/c
 
197
   *  path             = x/y/z */
 
198
 
 
199
  /* Count the elements of relative_to_path and prepend as many '..' elements
 
200
   * to path. */
 
201
  while (*relative)
 
202
    {
 
203
      svn_dirent_split(&relative, NULL, relative,
 
204
                       scratch_pool);
 
205
      parent_dir_els = svn_dirent_join(parent_dir_els, "..", scratch_pool);
 
206
    }
 
207
 
 
208
  return svn_dirent_join(parent_dir_els, path, result_pool);
 
209
}
 
210
 
138
211
 
139
212
/* Print STATUS and PATH in a format determined by DETAILED and
140
213
   SHOW_LAST_COMMITTED. */
141
214
static svn_error_t *
142
 
print_status(const char *path,
 
215
print_status(const char *target_abspath,
 
216
             const char *target_path,
 
217
             const char *path,
143
218
             svn_boolean_t detailed,
144
219
             svn_boolean_t show_last_committed,
145
220
             svn_boolean_t repos_locks,
154
229
  enum svn_wc_status_kind prop_status = status->prop_status;
155
230
  char tree_status_code = ' ';
156
231
  const char *tree_desc_line = "";
 
232
  const char *moved_from_line = "";
 
233
  const char *moved_to_line = "";
 
234
 
 
235
  path = make_relpath(target_abspath, target_path, path, pool, pool);
157
236
 
158
237
  /* For historic reasons svn ignores the property status for added nodes, even
159
238
     if these nodes were copied and have local property changes.
222
301
        (*prop_conflicts)++;
223
302
    }
224
303
 
 
304
  /* Note that moved-from and moved-to information is only available in STATUS
 
305
   * for (op-)roots of a move. Those are exactly the nodes we want to show
 
306
   * move info for in 'svn status'. See also comments in svn_wc_status3_t. */
 
307
  if (status->moved_from_abspath && status->moved_to_abspath &&
 
308
      strcmp(status->moved_from_abspath, status->moved_to_abspath) == 0)
 
309
    {
 
310
      const char *relpath;
 
311
 
 
312
      relpath = make_relpath(target_abspath, target_path,
 
313
                             status->moved_from_abspath,
 
314
                             pool, pool);
 
315
      relpath = svn_dirent_local_style(relpath, pool);
 
316
      moved_from_line = apr_pstrcat(pool, "\n        > ",
 
317
                                    apr_psprintf(pool,
 
318
                                                 _("swapped places with %s"),
 
319
                                                 relpath),
 
320
                                    (char *)NULL);
 
321
    }
 
322
  else if (status->moved_from_abspath || status->moved_to_abspath)
 
323
    {
 
324
      const char *relpath;
 
325
 
 
326
      if (status->moved_from_abspath)
 
327
        {
 
328
          relpath = make_relpath(target_abspath, target_path,
 
329
                                 status->moved_from_abspath,
 
330
                                 pool, pool);
 
331
          relpath = svn_dirent_local_style(relpath, pool);
 
332
          moved_from_line = apr_pstrcat(pool, "\n        > ",
 
333
                                        apr_psprintf(pool, _("moved from %s"),
 
334
                                                     relpath),
 
335
                                        (char *)NULL);
 
336
        }
 
337
 
 
338
      if (status->moved_to_abspath)
 
339
        {
 
340
          relpath = make_relpath(target_abspath, target_path,
 
341
                                 status->moved_to_abspath,
 
342
                                 pool, pool);
 
343
          relpath = svn_dirent_local_style(relpath, pool);
 
344
          moved_to_line = apr_pstrcat(pool, "\n        > ",
 
345
                                      apr_psprintf(pool, _("moved to %s"),
 
346
                                                   relpath),
 
347
                                      (char *)NULL);
 
348
        }
 
349
    }
 
350
 
 
351
  path = svn_dirent_local_style(path, pool);
 
352
 
225
353
  if (detailed)
226
354
    {
227
355
      char ood_status, lock_status;
284
412
 
285
413
          SVN_ERR
286
414
            (svn_cmdline_printf(pool,
287
 
                                "%c%c%c%c%c%c%c %c   %6s   %6s %-12s %s%s\n",
 
415
                                "%c%c%c%c%c%c%c %c %8s %8s %-12s %s%s%s%s\n",
288
416
                                generate_status_code(combined_status(status)),
289
417
                                generate_status_code(prop_status),
290
418
                                status->wc_is_locked ? 'L' : ' ',
297
425
                                commit_rev,
298
426
                                commit_author,
299
427
                                path,
 
428
                                moved_to_line,
 
429
                                moved_from_line,
300
430
                                tree_desc_line));
301
431
        }
302
432
      else
303
433
        SVN_ERR(
304
 
           svn_cmdline_printf(pool, "%c%c%c%c%c%c%c %c   %6s   %s%s\n",
 
434
           svn_cmdline_printf(pool, "%c%c%c%c%c%c%c %c %8s   %s%s%s%s\n",
305
435
                              generate_status_code(combined_status(status)),
306
436
                              generate_status_code(prop_status),
307
437
                              status->wc_is_locked ? 'L' : ' ',
312
442
                              ood_status,
313
443
                              working_rev,
314
444
                              path,
 
445
                              moved_to_line,
 
446
                              moved_from_line,
315
447
                              tree_desc_line));
316
448
    }
317
449
  else
318
450
    SVN_ERR(
319
 
       svn_cmdline_printf(pool, "%c%c%c%c%c%c%c %s%s\n",
 
451
       svn_cmdline_printf(pool, "%c%c%c%c%c%c%c %s%s%s%s\n",
320
452
                          generate_status_code(combined_status(status)),
321
453
                          generate_status_code(prop_status),
322
454
                          status->wc_is_locked ? 'L' : ' ',
326
458
                           ? 'K' : ' '),
327
459
                          tree_status_code,
328
460
                          path,
 
461
                          moved_to_line,
 
462
                          moved_from_line,
329
463
                          tree_desc_line));
330
464
 
331
465
  return svn_cmdline_fflush(stdout);
333
467
 
334
468
 
335
469
svn_error_t *
336
 
svn_cl__print_status_xml(const char *path,
 
470
svn_cl__print_status_xml(const char *target_abspath,
 
471
                         const char *target_path,
 
472
                         const char *path,
337
473
                         const svn_client_status_t *status,
338
474
                         svn_client_ctx_t *ctx,
339
475
                         apr_pool_t *pool)
340
476
{
341
 
  svn_stringbuf_t *sb = svn_stringbuf_create("", pool);
 
477
  svn_stringbuf_t *sb = svn_stringbuf_create_empty(pool);
342
478
  apr_hash_t *att_hash;
343
479
  const char *local_abspath = status->local_abspath;
344
480
  svn_boolean_t tree_conflicted = FALSE;
351
487
    SVN_ERR(svn_wc_conflicted_p3(NULL, NULL, &tree_conflicted,
352
488
                                 ctx->wc_ctx, local_abspath, pool));
353
489
 
 
490
  path = make_relpath(target_abspath, target_path, path, pool, pool);
 
491
 
354
492
  svn_xml_make_open_tag(&sb, pool, svn_xml_normal, "entry",
355
493
                        "path", svn_dirent_local_style(path, pool), NULL);
356
494
 
357
495
  att_hash = apr_hash_make(pool);
358
 
  apr_hash_set(att_hash, "item", APR_HASH_KEY_STRING,
359
 
               generate_status_desc(combined_status(status)));
 
496
  svn_hash_sets(att_hash, "item",
 
497
                generate_status_desc(combined_status(status)));
360
498
 
361
 
  apr_hash_set(att_hash, "props", APR_HASH_KEY_STRING,
362
 
               generate_status_desc(
363
 
                     (status->node_status != svn_wc_status_deleted)
364
 
                                          ? status->prop_status
365
 
                                          : svn_wc_status_none));
 
499
  svn_hash_sets(att_hash, "props",
 
500
                generate_status_desc(
 
501
                   (status->node_status != svn_wc_status_deleted)
 
502
                   ? status->prop_status
 
503
                   : svn_wc_status_none));
366
504
  if (status->wc_is_locked)
367
 
    apr_hash_set(att_hash, "wc-locked", APR_HASH_KEY_STRING, "true");
 
505
    svn_hash_sets(att_hash, "wc-locked", "true");
368
506
  if (status->copied)
369
 
    apr_hash_set(att_hash, "copied", APR_HASH_KEY_STRING, "true");
 
507
    svn_hash_sets(att_hash, "copied", "true");
370
508
  if (status->switched)
371
 
    apr_hash_set(att_hash, "switched", APR_HASH_KEY_STRING, "true");
 
509
    svn_hash_sets(att_hash, "switched", "true");
372
510
  if (status->file_external)
373
 
    apr_hash_set(att_hash, "file-external", APR_HASH_KEY_STRING, "true");
 
511
    svn_hash_sets(att_hash, "file-external", "true");
374
512
  if (status->versioned && ! status->copied)
375
 
    apr_hash_set(att_hash, "revision", APR_HASH_KEY_STRING,
376
 
                 apr_psprintf(pool, "%ld", status->revision));
 
513
    svn_hash_sets(att_hash, "revision",
 
514
                  apr_psprintf(pool, "%ld", status->revision));
377
515
  if (tree_conflicted)
378
 
    apr_hash_set(att_hash, "tree-conflicted", APR_HASH_KEY_STRING,
379
 
                 "true");
 
516
    svn_hash_sets(att_hash, "tree-conflicted", "true");
 
517
  if (status->moved_from_abspath || status->moved_to_abspath)
 
518
    {
 
519
      const char *relpath;
 
520
 
 
521
      if (status->moved_from_abspath)
 
522
        {
 
523
          relpath = make_relpath(target_abspath, target_path,
 
524
                                 status->moved_from_abspath,
 
525
                                 pool, pool);
 
526
          relpath = svn_dirent_local_style(relpath, pool);
 
527
          svn_hash_sets(att_hash, "moved-from", relpath);
 
528
        }
 
529
      if (status->moved_to_abspath)
 
530
        {
 
531
          relpath = make_relpath(target_abspath, target_path,
 
532
                                 status->moved_to_abspath,
 
533
                                 pool, pool);
 
534
          relpath = svn_dirent_local_style(relpath, pool);
 
535
          svn_hash_sets(att_hash, "moved-to", relpath);
 
536
        }
 
537
    }
380
538
  svn_xml_make_open_tag_hash(&sb, pool, svn_xml_normal, "wc-status",
381
539
                             att_hash);
382
540
 
416
574
 
417
575
/* Called by status-cmd.c */
418
576
svn_error_t *
419
 
svn_cl__print_status(const char *path,
 
577
svn_cl__print_status(const char *target_abspath,
 
578
                     const char *target_path,
 
579
                     const char *path,
420
580
                     const svn_client_status_t *status,
 
581
                     svn_boolean_t suppress_externals_placeholders,
421
582
                     svn_boolean_t detailed,
422
583
                     svn_boolean_t show_last_committed,
423
584
                     svn_boolean_t skip_unrecognized,
437
598
          && status->repos_node_status == svn_wc_status_none))
438
599
    return SVN_NO_ERROR;
439
600
 
440
 
  return print_status(svn_dirent_local_style(path, pool),
 
601
  /* If we're trying not to print boring "X  /path/to/external"
 
602
     lines..." */
 
603
  if (suppress_externals_placeholders)
 
604
    {
 
605
      /* ... skip regular externals unmodified in the repository. */
 
606
      if ((status->node_status == svn_wc_status_external)
 
607
          && (status->repos_node_status == svn_wc_status_none)
 
608
          && (! status->conflicted))
 
609
        return SVN_NO_ERROR;
 
610
 
 
611
      /* ... skip file externals that aren't modified locally or
 
612
         remotely, changelisted, or locked (in either sense of the
 
613
         word). */
 
614
      if ((status->file_external)
 
615
          && (status->repos_node_status == svn_wc_status_none)
 
616
          && ((status->node_status == svn_wc_status_normal)
 
617
              || (status->node_status == svn_wc_status_none))
 
618
          && ((status->prop_status == svn_wc_status_normal)
 
619
              || (status->prop_status == svn_wc_status_none))
 
620
          && (! status->changelist)
 
621
          && (! status->lock)
 
622
          && (! status->wc_is_locked)
 
623
          && (! status->conflicted))
 
624
        return SVN_NO_ERROR;
 
625
    }
 
626
 
 
627
  return print_status(target_abspath, target_path, path,
441
628
                      detailed, show_last_committed, repos_locks, status,
442
629
                      text_conflicts, prop_conflicts, tree_conflicts,
443
630
                      ctx, pool);