~bmerry/duplicity/pydrive-regular

« back to all changes in this revision

Viewing changes to duplicity/commandline.py

* Merged in lp:~aaron-whitehouse/duplicity/filelist_combine
  - Merged globbing and non-globbing filelists to use the same code path
    and all accept globbing characters. Added deprecation warning to the
    --exclude-globbing-filelist and include-globbing-filelist options in
    commandline.py and hid them from help output. Updated the manual
    (and unit tests) accordingly.
  - Note that this does trigger a change in behaviour for duplicity.
    Previously, include patterns in include-filelist did not match files
    in a directory that was included, so /usr/local in an include file
    would not have matched /usr/local/doc. Now, this folder would be
    included, as would occur if --include or the old
    --include-globbing-filelist was used. Additional lines will therefore
    need to be added to filelists to unambiguously exclude unwanted
    subfolders, if this is intended.
  - Mark --include-filelist-stdin and --exclude-fielist-stdin for
    deprecation and hide from --help output.

Show diffs side-by-side

added added

removed removed

Lines of Context:
74
74
            log.ERROR, force_print=True)
75
75
 
76
76
 
 
77
def old_globbing_filelist_deprecation(opt):
 
78
    log.Log(_("Warning: Option %s is pending deprecation and will be removed in a future release.\n"
 
79
              "--include-filelist and --exclude-filelist now accept globbing characters and should "
 
80
              "be used instead.") % opt,
 
81
            log.ERROR, force_print=True)
 
82
 
 
83
 
 
84
def stdin_deprecation(opt):
 
85
    # See https://bugs.launchpad.net/duplicity/+bug/1423367
 
86
    # In almost all Linux distros stdin is a file represented by /dev/stdin,
 
87
    # so --exclude-file=/dev/stdin will work as a substitute.
 
88
    log.Log(_("Warning: Option %s is pending deprecation and will be removed in a future release.\n"
 
89
              "On many GNU/Linux systems, stdin is represented by /dev/stdin and\n"
 
90
              "--include-filelist=/dev/stdin or --exclude-filelist=/dev/stdin could\n"
 
91
              "be used as a substitute.") % opt,
 
92
            log.ERROR, force_print=True)
 
93
 
 
94
 
77
95
def expand_fn(filename):
78
96
    return os.path.expanduser(os.path.expandvars(filename))
79
97
 
307
325
 
308
326
    parser.add_option("--exclude-filelist-stdin", action="callback", dest="",
309
327
                      callback=lambda o, s, v, p: (select_opts.append(("--exclude-filelist", "standard input")),
310
 
                                                   select_files.append(sys.stdin)))
 
328
                                                   select_files.append(sys.stdin),
 
329
                                                   stdin_deprecation(o)),
 
330
                      help=optparse.SUPPRESS_HELP)
311
331
 
312
332
    parser.add_option("--exclude-globbing-filelist", type="file", metavar=_("filename"),
313
 
                      dest="", action="callback", callback=add_filelist)
 
333
                      dest="", action="callback", callback=lambda o, s, v, p: (add_filelist(o, s, v, p),
 
334
                                                                               old_globbing_filelist_deprecation(s)),
 
335
                      help=optparse.SUPPRESS_HELP)
314
336
 
315
337
    # TRANSL: Used in usage help to represent the name of a file. Example:
316
338
    # --log-file <filename>
409
431
                      dest="", action="callback", callback=add_filelist)
410
432
    parser.add_option("--include-filelist-stdin", action="callback", dest="",
411
433
                      callback=lambda o, s, v, p: (select_opts.append(("--include-filelist", "standard input")),
412
 
                                                   select_files.append(sys.stdin)))
 
434
                                                   select_files.append(sys.stdin),
 
435
                                                   stdin_deprecation(o)),
 
436
                      help=optparse.SUPPRESS_HELP)
413
437
    parser.add_option("--include-globbing-filelist", type="file", metavar=_("filename"),
414
 
                      dest="", action="callback", callback=add_filelist)
 
438
                      dest="", action="callback", callback=lambda o, s, v, p: (add_filelist(o, s, v, p),
 
439
                                                                               old_globbing_filelist_deprecation(s)),
 
440
                      help=optparse.SUPPRESS_HELP)
415
441
    parser.add_option("--include-regexp", metavar=_("regular_expression"), dest="",
416
442
                      type="string", action="callback", callback=add_selection)
417
443