~ubuntu-branches/ubuntu/trusty/subversion/trusty-proposed

« back to all changes in this revision

Viewing changes to subversion/libsvn_ra_svn/editorp.c

  • Committer: Package Import Robot
  • Author(s): Andy Whitcroft
  • Date: 2012-06-21 15:36:36 UTC
  • mfrom: (0.4.13 sid)
  • Revision ID: package-import@ubuntu.com-20120621153636-amqqmuidgwgxz1ly
Tags: 1.7.5-1ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - Create pot file on build.
  - Build a python-subversion-dbg package.
  - Build-depend on python-dbg.
  - Build-depend on default-jre-headless/-jdk.
  - Do not apply java-build patch.
  - debian/rules: Manually create the doxygen output directory, otherwise
    we get weird build failures when running parallel builds.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * editorp.c :  Driving and consuming an editor across an svn connection
3
3
 *
4
4
 * ====================================================================
5
 
 * Copyright (c) 2000-2006, 2008 CollabNet.  All rights reserved.
6
 
 *
7
 
 * This software is licensed as described in the file COPYING, which
8
 
 * you should have received as part of this distribution.  The terms
9
 
 * are also available at http://subversion.tigris.org/license-1.html.
10
 
 * If newer versions of this license are posted there, you may use a
11
 
 * newer version instead, at your option.
12
 
 *
13
 
 * This software consists of voluntary contributions made by many
14
 
 * individuals.  For exact contribution history, see the revision
15
 
 * history and logs, available at http://subversion.tigris.org/.
 
5
 *    Licensed to the Apache Software Foundation (ASF) under one
 
6
 *    or more contributor license agreements.  See the NOTICE file
 
7
 *    distributed with this work for additional information
 
8
 *    regarding copyright ownership.  The ASF licenses this file
 
9
 *    to you under the Apache License, Version 2.0 (the
 
10
 *    "License"); you may not use this file except in compliance
 
11
 *    with the License.  You may obtain a copy of the License at
 
12
 *
 
13
 *      http://www.apache.org/licenses/LICENSE-2.0
 
14
 *
 
15
 *    Unless required by applicable law or agreed to in writing,
 
16
 *    software distributed under the License is distributed on an
 
17
 *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 
18
 *    KIND, either express or implied.  See the License for the
 
19
 *    specific language governing permissions and limitations
 
20
 *    under the License.
16
21
 * ====================================================================
17
22
 */
18
23
 
26
31
#include "svn_types.h"
27
32
#include "svn_string.h"
28
33
#include "svn_error.h"
29
 
#include "svn_path.h"
30
34
#include "svn_delta.h"
 
35
#include "svn_dirent_uri.h"
31
36
#include "svn_ra_svn.h"
 
37
#include "svn_path.h"
32
38
#include "svn_pools.h"
33
39
#include "svn_private_config.h"
34
40
 
 
41
#include "private/svn_fspath.h"
 
42
 
35
43
#include "ra_svn.h"
36
44
 
37
45
/*
43
51
 * connection; both ends are useful for both server and client.
44
52
 */
45
53
 
46
 
typedef struct {
 
54
typedef struct ra_svn_edit_baton_t {
47
55
  svn_ra_svn_conn_t *conn;
48
56
  svn_ra_svn_edit_callback callback;    /* Called on successful completion. */
49
57
  void *callback_baton;
52
60
} ra_svn_edit_baton_t;
53
61
 
54
62
/* Works for both directories and files. */
55
 
typedef struct {
 
63
typedef struct ra_svn_baton_t {
56
64
  svn_ra_svn_conn_t *conn;
57
65
  apr_pool_t *pool;
58
66
  ra_svn_edit_baton_t *eb;
59
67
  const char *token;
60
68
} ra_svn_baton_t;
61
69
 
62
 
typedef struct {
 
70
typedef struct ra_svn_driver_state_t {
63
71
  const svn_delta_editor_t *editor;
64
72
  void *edit_baton;
65
73
  apr_hash_t *tokens;
80
88
   field in this structure is vestigial for files, and we use it for a
81
89
   different purpose instead: at apply-textdelta time, we set it to a
82
90
   subpool of the file pool, which is destroyed in textdelta-end. */
83
 
typedef struct {
 
91
typedef struct ra_svn_token_entry_t {
84
92
  const char *token;
85
93
  void *baton;
86
94
  svn_boolean_t is_file;
308
316
  diff_stream = svn_stream_create(b, pool);
309
317
  svn_stream_set_write(diff_stream, ra_svn_svndiff_handler);
310
318
  svn_stream_set_close(diff_stream, ra_svn_svndiff_close_handler);
311
 
  if (svn_ra_svn_has_capability(b->conn, SVN_RA_SVN_CAP_SVNDIFF1))
312
 
    svn_txdelta_to_svndiff2(wh, wh_baton, diff_stream, 1, pool);
 
319
 
 
320
  /* If the connection does not support SVNDIFF1 or if we don't want to use
 
321
   * compression, use the non-compressing "version 0" implementation */
 
322
  if (   svn_ra_svn_compression_level(b->conn) > 0
 
323
      && svn_ra_svn_has_capability(b->conn, SVN_RA_SVN_CAP_SVNDIFF1))
 
324
    svn_txdelta_to_svndiff3(wh, wh_baton, diff_stream, 1,
 
325
                            b->conn->compression_level, pool);
313
326
  else
314
 
    svn_txdelta_to_svndiff2(wh, wh_baton, diff_stream, 0, pool);
 
327
    svn_txdelta_to_svndiff3(wh, wh_baton, diff_stream, 0,
 
328
                            b->conn->compression_level, pool);
315
329
  return SVN_NO_ERROR;
316
330
}
317
331
 
456
470
 
457
471
static svn_error_t *ra_svn_handle_target_rev(svn_ra_svn_conn_t *conn,
458
472
                                             apr_pool_t *pool,
459
 
                                             apr_array_header_t *params,
 
473
                                             const apr_array_header_t *params,
460
474
                                             ra_svn_driver_state_t *ds)
461
475
{
462
476
  svn_revnum_t rev;
468
482
 
469
483
static svn_error_t *ra_svn_handle_open_root(svn_ra_svn_conn_t *conn,
470
484
                                            apr_pool_t *pool,
471
 
                                            apr_array_header_t *params,
 
485
                                            const apr_array_header_t *params,
472
486
                                            ra_svn_driver_state_t *ds)
473
487
{
474
488
  svn_revnum_t rev;
486
500
 
487
501
static svn_error_t *ra_svn_handle_delete_entry(svn_ra_svn_conn_t *conn,
488
502
                                               apr_pool_t *pool,
489
 
                                               apr_array_header_t *params,
 
503
                                               const apr_array_header_t *params,
490
504
                                               ra_svn_driver_state_t *ds)
491
505
{
492
506
  const char *path, *token;
495
509
 
496
510
  SVN_ERR(svn_ra_svn_parse_tuple(params, pool, "c(?r)c", &path, &rev, &token));
497
511
  SVN_ERR(lookup_token(ds, token, FALSE, &entry));
498
 
  path = svn_path_canonicalize(path, pool);
 
512
  path = svn_relpath_canonicalize(path, pool);
499
513
  SVN_CMD_ERR(ds->editor->delete_entry(path, rev, entry->baton, pool));
500
514
  return SVN_NO_ERROR;
501
515
}
502
516
 
503
517
static svn_error_t *ra_svn_handle_add_dir(svn_ra_svn_conn_t *conn,
504
518
                                          apr_pool_t *pool,
505
 
                                          apr_array_header_t *params,
 
519
                                          const apr_array_header_t *params,
506
520
                                          ra_svn_driver_state_t *ds)
507
521
{
508
522
  const char *path, *token, *child_token, *copy_path;
515
529
                                 &child_token, &copy_path, &copy_rev));
516
530
  SVN_ERR(lookup_token(ds, token, FALSE, &entry));
517
531
  subpool = svn_pool_create(entry->pool);
518
 
  path = svn_path_canonicalize(path, pool);
 
532
  path = svn_relpath_canonicalize(path, pool);
 
533
 
 
534
  /* Some operations pass COPY_PATH as a full URL (commits, etc.).
 
535
     Others (replay, e.g.) deliver an fspath.  That's ... annoying. */
519
536
  if (copy_path)
520
 
    copy_path = svn_path_canonicalize(copy_path, pool);
 
537
    {
 
538
      if (svn_path_is_url(copy_path))
 
539
        copy_path = svn_uri_canonicalize(copy_path, pool);
 
540
      else
 
541
        copy_path = svn_fspath__canonicalize(copy_path, pool);
 
542
    }
 
543
 
521
544
  SVN_CMD_ERR(ds->editor->add_directory(path, entry->baton, copy_path,
522
545
                                        copy_rev, subpool, &child_baton));
523
546
  store_token(ds, child_baton, child_token, FALSE, subpool);
526
549
 
527
550
static svn_error_t *ra_svn_handle_open_dir(svn_ra_svn_conn_t *conn,
528
551
                                           apr_pool_t *pool,
529
 
                                           apr_array_header_t *params,
 
552
                                           const apr_array_header_t *params,
530
553
                                           ra_svn_driver_state_t *ds)
531
554
{
532
555
  const char *path, *token, *child_token;
539
562
                                 &child_token, &rev));
540
563
  SVN_ERR(lookup_token(ds, token, FALSE, &entry));
541
564
  subpool = svn_pool_create(entry->pool);
542
 
  path = svn_path_canonicalize(path, pool);
 
565
  path = svn_relpath_canonicalize(path, pool);
543
566
  SVN_CMD_ERR(ds->editor->open_directory(path, entry->baton, rev, subpool,
544
567
                                         &child_baton));
545
568
  store_token(ds, child_baton, child_token, FALSE, subpool);
548
571
 
549
572
static svn_error_t *ra_svn_handle_change_dir_prop(svn_ra_svn_conn_t *conn,
550
573
                                                  apr_pool_t *pool,
551
 
                                                  apr_array_header_t *params,
 
574
                                                  const apr_array_header_t *params,
552
575
                                                  ra_svn_driver_state_t *ds)
553
576
{
554
577
  const char *token, *name;
565
588
 
566
589
static svn_error_t *ra_svn_handle_close_dir(svn_ra_svn_conn_t *conn,
567
590
                                            apr_pool_t *pool,
568
 
                                            apr_array_header_t *params,
 
591
                                            const apr_array_header_t *params,
569
592
                                            ra_svn_driver_state_t *ds)
570
593
{
571
594
  const char *token;
584
607
 
585
608
static svn_error_t *ra_svn_handle_absent_dir(svn_ra_svn_conn_t *conn,
586
609
                                             apr_pool_t *pool,
587
 
                                             apr_array_header_t *params,
 
610
                                             const apr_array_header_t *params,
588
611
                                             ra_svn_driver_state_t *ds)
589
612
{
590
613
  const char *path;
602
625
 
603
626
static svn_error_t *ra_svn_handle_add_file(svn_ra_svn_conn_t *conn,
604
627
                                           apr_pool_t *pool,
605
 
                                           apr_array_header_t *params,
 
628
                                           const apr_array_header_t *params,
606
629
                                           ra_svn_driver_state_t *ds)
607
630
{
608
631
  const char *path, *token, *file_token, *copy_path;
613
636
                                 &file_token, &copy_path, &copy_rev));
614
637
  SVN_ERR(lookup_token(ds, token, FALSE, &entry));
615
638
  ds->file_refs++;
616
 
  path = svn_path_canonicalize(path, pool);
 
639
  path = svn_relpath_canonicalize(path, pool);
 
640
 
 
641
  /* Some operations pass COPY_PATH as a full URL (commits, etc.).
 
642
     Others (replay, e.g.) deliver an fspath.  That's ... annoying. */
617
643
  if (copy_path)
618
 
    copy_path = svn_path_canonicalize(copy_path, pool);
 
644
    {
 
645
      if (svn_path_is_url(copy_path))
 
646
        copy_path = svn_uri_canonicalize(copy_path, pool);
 
647
      else
 
648
        copy_path = svn_fspath__canonicalize(copy_path, pool);
 
649
    }
 
650
 
619
651
  file_entry = store_token(ds, NULL, file_token, TRUE, ds->file_pool);
620
652
  SVN_CMD_ERR(ds->editor->add_file(path, entry->baton, copy_path, copy_rev,
621
653
                                   ds->file_pool, &file_entry->baton));
624
656
 
625
657
static svn_error_t *ra_svn_handle_open_file(svn_ra_svn_conn_t *conn,
626
658
                                            apr_pool_t *pool,
627
 
                                            apr_array_header_t *params,
 
659
                                            const apr_array_header_t *params,
628
660
                                            ra_svn_driver_state_t *ds)
629
661
{
630
662
  const char *path, *token, *file_token;
635
667
                                 &file_token, &rev));
636
668
  SVN_ERR(lookup_token(ds, token, FALSE, &entry));
637
669
  ds->file_refs++;
638
 
  path = svn_path_canonicalize(path, pool);
 
670
  path = svn_relpath_canonicalize(path, pool);
639
671
  file_entry = store_token(ds, NULL, file_token, TRUE, ds->file_pool);
640
672
  SVN_CMD_ERR(ds->editor->open_file(path, entry->baton, rev, ds->file_pool,
641
673
                                    &file_entry->baton));
644
676
 
645
677
static svn_error_t *ra_svn_handle_apply_textdelta(svn_ra_svn_conn_t *conn,
646
678
                                                  apr_pool_t *pool,
647
 
                                                  apr_array_header_t *params,
 
679
                                                  const apr_array_header_t *params,
648
680
                                                  ra_svn_driver_state_t *ds)
649
681
{
650
682
  const char *token;
669
701
 
670
702
static svn_error_t *ra_svn_handle_textdelta_chunk(svn_ra_svn_conn_t *conn,
671
703
                                                  apr_pool_t *pool,
672
 
                                                  apr_array_header_t *params,
 
704
                                                  const apr_array_header_t *params,
673
705
                                                  ra_svn_driver_state_t *ds)
674
706
{
675
707
  const char *token;
688
720
 
689
721
static svn_error_t *ra_svn_handle_textdelta_end(svn_ra_svn_conn_t *conn,
690
722
                                                apr_pool_t *pool,
691
 
                                                apr_array_header_t *params,
 
723
                                                const apr_array_header_t *params,
692
724
                                                ra_svn_driver_state_t *ds)
693
725
{
694
726
  const char *token;
708
740
 
709
741
static svn_error_t *ra_svn_handle_change_file_prop(svn_ra_svn_conn_t *conn,
710
742
                                                   apr_pool_t *pool,
711
 
                                                   apr_array_header_t *params,
 
743
                                                   const apr_array_header_t *params,
712
744
                                                   ra_svn_driver_state_t *ds)
713
745
{
714
746
  const char *token, *name;
724
756
 
725
757
static svn_error_t *ra_svn_handle_close_file(svn_ra_svn_conn_t *conn,
726
758
                                             apr_pool_t *pool,
727
 
                                             apr_array_header_t *params,
 
759
                                             const apr_array_header_t *params,
728
760
                                             ra_svn_driver_state_t *ds)
729
761
{
730
762
  const char *token;
746
778
 
747
779
static svn_error_t *ra_svn_handle_absent_file(svn_ra_svn_conn_t *conn,
748
780
                                              apr_pool_t *pool,
749
 
                                              apr_array_header_t *params,
 
781
                                              const apr_array_header_t *params,
750
782
                                              ra_svn_driver_state_t *ds)
751
783
{
752
784
  const char *path;
764
796
 
765
797
static svn_error_t *ra_svn_handle_close_edit(svn_ra_svn_conn_t *conn,
766
798
                                             apr_pool_t *pool,
767
 
                                             apr_array_header_t *params,
 
799
                                             const apr_array_header_t *params,
768
800
                                             ra_svn_driver_state_t *ds)
769
801
{
770
802
  SVN_CMD_ERR(ds->editor->close_edit(ds->edit_baton, pool));
776
808
 
777
809
static svn_error_t *ra_svn_handle_abort_edit(svn_ra_svn_conn_t *conn,
778
810
                                             apr_pool_t *pool,
779
 
                                             apr_array_header_t *params,
 
811
                                             const apr_array_header_t *params,
780
812
                                             ra_svn_driver_state_t *ds)
781
813
{
782
814
  ds->done = TRUE;
788
820
 
789
821
static svn_error_t *ra_svn_handle_finish_replay(svn_ra_svn_conn_t *conn,
790
822
                                                apr_pool_t *pool,
791
 
                                                apr_array_header_t *params,
 
823
                                                const apr_array_header_t *params,
792
824
                                                ra_svn_driver_state_t *ds)
793
825
{
794
826
  if (!ds->for_replay)
804
836
static const struct {
805
837
  const char *cmd;
806
838
  svn_error_t *(*handler)(svn_ra_svn_conn_t *conn, apr_pool_t *pool,
807
 
                          apr_array_header_t *params,
 
839
                          const apr_array_header_t *params,
808
840
                          ra_svn_driver_state_t *ds);
809
841
} ra_svn_edit_cmds[] = {
810
842
  { "target-rev",       ra_svn_handle_target_rev },
882
914
        }
883
915
      if (ra_svn_edit_cmds[i].cmd)
884
916
        err = (*ra_svn_edit_cmds[i].handler)(conn, subpool, params, &state);
 
917
      else if (strcmp(cmd, "failure") == 0)
 
918
        {
 
919
          /* While not really an editor command this can occur when
 
920
             reporter->finish_report() fails before the first editor command */
 
921
          if (aborted)
 
922
            *aborted = TRUE;
 
923
          err = svn_ra_svn__handle_failure_status(params, pool);
 
924
          return svn_error_compose_create(
 
925
                            err,
 
926
                            editor->abort_edit(edit_baton, subpool));
 
927
        }
885
928
      else
886
929
        {
887
930
          err = svn_error_createf(SVN_ERR_RA_SVN_UNKNOWN_CMD, NULL,