Annotation of embedaddon/rsync/patches/source-backup.diff, revision 1.1

1.1     ! misho       1: This patch adds a --source-backup option that backs up source files
        !             2: removed due to --remove-source-files.
        !             3: 
        !             4: To use this patch, run these commands for a successful build:
        !             5: 
        !             6:     patch -p1 <patches/source-backup.diff
        !             7:     ./configure                         (optional if already run)
        !             8:     make
        !             9: 
        !            10: -- Matt McCutchen <hashproduct@gmail.com>
        !            11: 
        !            12: based-on: e94bad1c156fc3910f24e2b3b71a81b0b0bdeb70
        !            13: diff --git a/options.c b/options.c
        !            14: --- a/options.c
        !            15: +++ b/options.c
        !            16: @@ -32,6 +32,7 @@ extern filter_rule_list filter_list;
        !            17:  extern filter_rule_list daemon_filter_list;
        !            18:  
        !            19:  int make_backups = 0;
        !            20: +int make_source_backups = 0;
        !            21:  
        !            22:  /**
        !            23:   * If 1, send the whole file as literal data rather than trying to
        !            24: @@ -767,6 +768,7 @@ static struct poptOption long_options[] = {
        !            25:    {"bwlimit",          0,  POPT_ARG_STRING, &bwlimit_arg, OPT_BWLIMIT, 0, 0 },
        !            26:    {"no-bwlimit",       0,  POPT_ARG_VAL,    &bwlimit, 0, 0, 0 },
        !            27:    {"backup",          'b', POPT_ARG_VAL,    &make_backups, 1, 0, 0 },
        !            28: +  {"source-backup",    0,  POPT_ARG_NONE,   &make_source_backups, 0, 0, 0},
        !            29:    {"no-backup",        0,  POPT_ARG_VAL,    &make_backups, 0, 0, 0 },
        !            30:    {"backup-dir",       0,  POPT_ARG_STRING, &backup_dir, 0, 0, 0 },
        !            31:    {"suffix",           0,  POPT_ARG_STRING, &backup_suffix, 0, 0, 0 },
        !            32: @@ -2768,6 +2770,8 @@ void server_options(char **args, int *argc_p)
        !            33:                                goto oom;
        !            34:                        args[ac++] = arg;
        !            35:                }
        !            36: +              if (make_source_backups)
        !            37: +                      args[ac++] = "--source-backup";
        !            38:        }
        !            39:  
        !            40:        if (max_alloc_arg && max_alloc != DEFAULT_MAX_ALLOC) {
        !            41: diff --git a/rsync.1.md b/rsync.1.md
        !            42: --- a/rsync.1.md
        !            43: +++ b/rsync.1.md
        !            44: @@ -391,6 +391,7 @@ detailed description below for a complete description.
        !            45:  --existing               skip creating new files on receiver
        !            46:  --ignore-existing        skip updating files that exist on receiver
        !            47:  --remove-source-files    sender removes synchronized files (non-dir)
        !            48: +--source-backup          ... and backs up those files
        !            49:  --del                    an alias for --delete-during
        !            50:  --delete                 delete extraneous files from dest dirs
        !            51:  --delete-before          receiver deletes before xfer, not during
        !            52: @@ -1620,6 +1621,16 @@ your home directory (remove the '=' for that).
        !            53:      Starting with 3.1.0, rsync will skip the sender-side removal (and output an
        !            54:      error) if the file's size or modify time has not stayed unchanged.
        !            55:  
        !            56: +0.  `--source-backup`
        !            57: +
        !            58: +    Makes the sender back up the source files it removes due to
        !            59: +    `--remove-source-files`.  This option is independent of `--backup` but uses
        !            60: +    the same `--backup-dir` and `--suffix` settings, if any.  With
        !            61: +    `--backup-dir`, rsync looks for each file's backup dir relative to the
        !            62: +    source argument the file came from.  Consequently, if the `--backup-dir`
        !            63: +    path is relative, each source argument gets a separate backup dir at that
        !            64: +    path relative to the argument.
        !            65: +
        !            66:  0.  `--delete`
        !            67:  
        !            68:      This tells rsync to delete extraneous files from the receiving side (ones
        !            69: diff --git a/sender.c b/sender.c
        !            70: --- a/sender.c
        !            71: +++ b/sender.c
        !            72: @@ -41,6 +41,7 @@ extern int protocol_version;
        !            73:  extern int remove_source_files;
        !            74:  extern int updating_basis_file;
        !            75:  extern int make_backups;
        !            76: +extern int make_source_backups;
        !            77:  extern int inplace;
        !            78:  extern int inplace_partial;
        !            79:  extern int batch_fd;
        !            80: @@ -127,6 +128,7 @@ void successful_send(int ndx)
        !            81:        struct file_struct *file;
        !            82:        struct file_list *flist;
        !            83:        STRUCT_STAT st;
        !            84: +      int result;
        !            85:  
        !            86:        if (!remove_source_files)
        !            87:                return;
        !            88: @@ -151,7 +153,11 @@ void successful_send(int ndx)
        !            89:                return;
        !            90:        }
        !            91:  
        !            92: -      if (do_unlink(fname) < 0) {
        !            93: +      if (make_source_backups)
        !            94: +              result = !make_backup(fname, True);
        !            95: +      else
        !            96: +              result = do_unlink(fname);
        !            97: +      if (result < 0) {
        !            98:                failed_op = "remove";
        !            99:          failed:
        !           100:                if (errno == ENOENT)
        !           101: diff -Nurp a/rsync.1 b/rsync.1
        !           102: --- a/rsync.1
        !           103: +++ b/rsync.1
        !           104: @@ -467,6 +467,7 @@ detailed description below for a complet
        !           105:  --existing               skip creating new files on receiver
        !           106:  --ignore-existing        skip updating files that exist on receiver
        !           107:  --remove-source-files    sender removes synchronized files (non-dir)
        !           108: +--source-backup          ... and backs up those files
        !           109:  --del                    an alias for --delete-during
        !           110:  --delete                 delete extraneous files from dest dirs
        !           111:  --delete-before          receiver deletes before xfer, not during
        !           112: @@ -1679,6 +1680,14 @@ rsync transfer).
        !           113:  .IP
        !           114:  Starting with 3.1.0, rsync will skip the sender-side removal (and output an
        !           115:  error) if the file's size or modify time has not stayed unchanged.
        !           116: +.IP "\fB\-\-source-backup\fP"
        !           117: +Makes the sender back up the source files it removes due to
        !           118: +\fB\-\-remove-source-files\fP.  This option is independent of \fB\-\-backup\fP but uses
        !           119: +the same \fB\-\-backup-dir\fP and \fB\-\-suffix\fP settings, if any.  With
        !           120: +\fB\-\-backup-dir\fP, rsync looks for each file's backup dir relative to the
        !           121: +source argument the file came from.  Consequently, if the \fB\-\-backup-dir\fP
        !           122: +path is relative, each source argument gets a separate backup dir at that
        !           123: +path relative to the argument.
        !           124:  .IP "\fB\-\-delete\fP"
        !           125:  This tells rsync to delete extraneous files from the receiving side (ones
        !           126:  that aren't on the sending side), but only for the directories that are
        !           127: diff -Nurp a/rsync.1.html b/rsync.1.html
        !           128: --- a/rsync.1.html
        !           129: +++ b/rsync.1.html
        !           130: @@ -382,6 +382,7 @@ detailed description below for a complet
        !           131:  --existing               skip creating new files on receiver
        !           132:  --ignore-existing        skip updating files that exist on receiver
        !           133:  --remove-source-files    sender removes synchronized files (non-dir)
        !           134: +--source-backup          ... and backs up those files
        !           135:  --del                    an alias for --delete-during
        !           136:  --delete                 delete extraneous files from dest dirs
        !           137:  --delete-before          receiver deletes before xfer, not during
        !           138: @@ -1549,6 +1550,16 @@ rsync transfer).</p>
        !           139:  error) if the file's size or modify time has not stayed unchanged.</p>
        !           140:  </dd>
        !           141:  
        !           142: +<dt><code>--source-backup</code></dt><dd>
        !           143: +<p>Makes the sender back up the source files it removes due to
        !           144: +<code>--remove-source-files</code>.  This option is independent of <code>--backup</code> but uses
        !           145: +the same <code>--backup-dir</code> and <code>--suffix</code> settings, if any.  With
        !           146: +<code>--backup-dir</code>, rsync looks for each file's backup dir relative to the
        !           147: +source argument the file came from.  Consequently, if the <code>--backup-dir</code>
        !           148: +path is relative, each source argument gets a separate backup dir at that
        !           149: +path relative to the argument.</p>
        !           150: +</dd>
        !           151: +
        !           152:  <dt><code>--delete</code></dt><dd>
        !           153:  <p>This tells rsync to delete extraneous files from the receiving side (ones
        !           154:  that aren't on the sending side), but only for the directories that are

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>