Patchwork [1,of,2,V2] tests: replace "cp -r" with "cp -R"

login
register
mail settings
Submitter Jun Wu
Date Nov. 30, 2016, 7:26 p.m.
Message ID <830986c78bb969705776.1480534003@x1c>
Download mbox | patch
Permalink /patch/17804/
State Accepted
Headers show

Comments

Jun Wu - Nov. 30, 2016, 7:26 p.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1480533918 0
#      Wed Nov 30 19:25:18 2016 +0000
# Node ID 830986c78bb9697057768d64c8556d1dc03c0674
# Parent  9e29d4e4e08b5996adda49cdd0b497d89e2b16ee
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 830986c78bb9
tests: replace "cp -r" with "cp -R"

The POSIX documentation about "cp" [1] says:

  ....

  RATIONALE
    ....
    Earlier versions of this standard included support for the -r option to
    copy file hierarchies. The -r option is historical practice on BSD and
    BSD-derived systems. This option is no longer specified by POSIX.1-2008
    but may be present in some implementations. The -R option was added as a
    close synonym to the -r option, selected for consistency with all other
    options in this volume of POSIX.1-2008 that do recursive directory
    descent.

    The difference between -R and the removed -r option is in the treatment
    by cp of file types other than regular and directory. It was
    implementation-defined how the - option treated special files to allow
    both historical implementations and those that chose to support -r with
    the same abilities as -R defined by this volume of POSIX.1-2008. The
    original -r flag, for historic reasons, did not handle special files any
    differently from regular files, but always read the file and copied its
    contents. This had obvious problems in the presence of special file
    types; for example, character devices, FIFOs, and sockets.
    ....

  ....

  Issue 6
    The -r option is marked obsolescent.
    ....

  Issue 7
    ....
    The obsolescent -r option is removed.
    ....

  (No "Issue 8" yet)

Therefore it's clear that "cp -R" is strictly better than "cp -r".

The issue was discovered when running tests on OS X after 0d87b1caed92.

[1]: pubs.opengroup.org/onlinepubs/9699919799/utilities/cp.html

Patch

diff --git a/tests/test-bookmarks.t b/tests/test-bookmarks.t
--- a/tests/test-bookmarks.t
+++ b/tests/test-bookmarks.t
@@ -573,6 +573,6 @@  pull --update works the same as pull && 
   $ hg bookmark -r3 Y
   moving bookmark 'Y' forward from db815d6d32e6
-  $ cp -r  ../cloned-bookmarks-update ../cloned-bookmarks-manual-update
-  $ cp -r  ../cloned-bookmarks-update ../cloned-bookmarks-manual-update-with-divergence
+  $ cp -R ../cloned-bookmarks-update ../cloned-bookmarks-manual-update
+  $ cp -R ../cloned-bookmarks-update ../cloned-bookmarks-manual-update-with-divergence
 
 (manual version)
diff --git a/tests/test-histedit-obsolete.t b/tests/test-histedit-obsolete.t
--- a/tests/test-histedit-obsolete.t
+++ b/tests/test-histedit-obsolete.t
@@ -340,5 +340,5 @@  phases.new-commit option is.
 New-commit as draft (default)
 
-  $ cp -r base simple-draft
+  $ cp -R base simple-draft
   $ cd simple-draft
   $ hg histedit -r 'b449568bf7fc' --commands - << EOF
@@ -379,5 +379,5 @@  New-commit as draft (default)
 New-commit as secret (config)
 
-  $ cp -r base simple-secret
+  $ cp -R base simple-secret
   $ cd simple-secret
   $ cat >> .hg/hgrc << EOF
@@ -426,5 +426,5 @@  If a secret changeset is put before a dr
 It seems more important to present the secret phase.
 
-  $ cp -r base reorder
+  $ cp -R base reorder
   $ cd reorder
   $ hg histedit -r 'b449568bf7fc' --commands - << EOF
@@ -463,5 +463,5 @@  better safe than sorry). Folding between
 Note that there is a few reordering in this series for more extensive test
 
-  $ cp -r base folding
+  $ cp -R base folding
   $ cd folding
   $ cat >> .hg/hgrc << EOF
diff --git a/tests/test-obsolete-checkheads.t b/tests/test-obsolete-checkheads.t
--- a/tests/test-obsolete-checkheads.t
+++ b/tests/test-obsolete-checkheads.t
@@ -24,5 +24,5 @@  Check that obsolete properly strip heads
   $ hg phase --public .
   $ cd ..
-  $ cp -r remote base
+  $ cp -R remote base
   $ hg clone remote local
   updating to branch default
@@ -55,5 +55,5 @@  setup
   o  b4952fcf48cf (public) add base
   
-  $ cp -r ../remote ../backup1
+  $ cp -R ../remote ../backup1
 
 old exists remotely as draft. It is obsoleted by new that we now push.
@@ -74,5 +74,5 @@  setup
 
   $ rm -fr ../remote
-  $ cp -r ../backup1 ../remote
+  $ cp -R ../backup1 ../remote
   $ hg -R ../remote phase --public c70b08862e08
   $ hg pull -v
@@ -105,5 +105,5 @@  TODO: Not implemented yet.
 #
 #   $ rm -fr ../remote
-#   $ cp -r ../backup1 ../remote
+#   $ cp -R ../backup1 ../remote
 #   $ hg -R ../remote phase --public c70b08862e08
 #   $ hg phase --draft --force c70b08862e08
@@ -132,5 +132,5 @@  setup
 
   $ rm -fr ../remote
-  $ cp -r ../backup1 ../remote
+  $ cp -R ../backup1 ../remote
   $ hg phase --draft --force '(0::) - 0'
   $ hg up -q '.^'
@@ -207,5 +207,5 @@  setup. (The obsolete marker is known loc
   @  b4952fcf48cf (public) add base
   
-  $ cp -r ../remote ../backup2
+  $ cp -R ../remote ../backup2
 
 Push should not warn about adding new heads. We create one, but we'll delete
@@ -227,5 +227,5 @@  setup
 
   $ rm -fr ../remote
-  $ cp -r ../backup1 ../remote
+  $ cp -R ../backup1 ../remote
   $ cd ..
   $ rm -rf local
diff --git a/tests/test-revert.t b/tests/test-revert.t
--- a/tests/test-revert.t
+++ b/tests/test-revert.t
@@ -785,5 +785,5 @@  Test revert --all to parent content
 (setup from reference repo)
 
-  $ cp -r revert-ref revert-parent-all
+  $ cp -R revert-ref revert-parent-all
   $ cd revert-parent-all
 
@@ -842,5 +842,5 @@  Test revert --all to "base" content
 (setup from reference repo)
 
-  $ cp -r revert-ref revert-base-all
+  $ cp -R revert-ref revert-base-all
   $ cd revert-base-all
 
@@ -897,5 +897,5 @@  Test revert to parent content with expli
 (setup from reference repo)
 
-  $ cp -r revert-ref revert-parent-explicit
+  $ cp -R revert-ref revert-parent-explicit
   $ cd revert-parent-explicit
 
@@ -990,5 +990,5 @@  Test revert to "base" content with expli
 (setup from reference repo)
 
-  $ cp -r revert-ref revert-base-explicit
+  $ cp -R revert-ref revert-base-explicit
   $ cd revert-base-explicit
 
diff --git a/tests/test-subrepo.t b/tests/test-subrepo.t
--- a/tests/test-subrepo.t
+++ b/tests/test-subrepo.t
@@ -1519,6 +1519,6 @@  Courtesy phases synchronisation to publi
 (issue3781)
 
-  $ cp -r main issue3781
-  $ cp -r main issue3781-dest
+  $ cp -R main issue3781
+  $ cp -R main issue3781-dest
   $ cd issue3781-dest/s
   $ hg phase tip # show we have draft changeset
diff --git a/tests/test-treemanifest.t b/tests/test-treemanifest.t
--- a/tests/test-treemanifest.t
+++ b/tests/test-treemanifest.t
@@ -459,5 +459,5 @@  Excludes with a glob should not exclude 
   b/bar/orange/fly/gnat.py (glob)
   b/bar/orange/fly/housefly.txt (glob)
-  $ cp -r .hg/store .hg/store-copy
+  $ cp -R .hg/store .hg/store-copy
 
 Test files for a subdirectory.
@@ -469,5 +469,5 @@  Test files for a subdirectory.
   b/bar/orange/fly/housefly.txt (glob)
   b/foo/apple/bees/flower.py (glob)
-  $ cp -r .hg/store-copy/. .hg/store
+  $ cp -R .hg/store-copy/. .hg/store
 
 Test files with just includes and excludes.
@@ -478,5 +478,5 @@  Test files with just includes and exclud
   $ hg files -r . -I path:b/bar -X path:b/bar/orange/fly -I path:b/foo -X path:b/foo/apple/bees
   b/bar/fruits.txt (glob)
-  $ cp -r .hg/store-copy/. .hg/store
+  $ cp -R .hg/store-copy/. .hg/store
 
 Test files for a subdirectory, excluding a directory within it.
@@ -488,5 +488,5 @@  Test files for a subdirectory, excluding
   b/bar/orange/fly/gnat.py (glob)
   b/bar/orange/fly/housefly.txt (glob)
-  $ cp -r .hg/store-copy/. .hg/store
+  $ cp -R .hg/store-copy/. .hg/store
 
 Test files for a sub directory, including only a directory within it, and
@@ -498,5 +498,5 @@  including an unrelated directory.
   b/bar/orange/fly/gnat.py (glob)
   b/bar/orange/fly/housefly.txt (glob)
-  $ cp -r .hg/store-copy/. .hg/store
+  $ cp -R .hg/store-copy/. .hg/store
 
 Test files for a pattern, including a directory, and excluding a directory
@@ -508,5 +508,5 @@  within that.
   $ hg files -r . glob:**.txt -I path:b/bar -X path:b/bar/orange
   b/bar/fruits.txt (glob)
-  $ cp -r .hg/store-copy/. .hg/store
+  $ cp -R .hg/store-copy/. .hg/store
 
 Add some more changes to the deep repo
@@ -554,5 +554,5 @@  Finish first server
 
 Back up the recently added revlogs
-  $ cp -r .hg/store .hg/store-newcopy
+  $ cp -R .hg/store .hg/store-newcopy
 
 Verify reports missing dirlog
@@ -583,5 +583,5 @@  Verify reports missing dirlog
   (first damaged changeset appears to be 0)
   [1]
-  $ cp -r .hg/store-newcopy/. .hg/store
+  $ cp -R .hg/store-newcopy/. .hg/store
 
 Verify reports missing dirlog entry
@@ -608,5 +608,5 @@  Verify reports missing dirlog entry
   (first damaged changeset appears to be 1)
   [1]
-  $ cp -r .hg/store-newcopy/. .hg/store
+  $ cp -R .hg/store-newcopy/. .hg/store
 
 Test cloning a treemanifest repo over http.
diff --git a/tests/test-verify.t b/tests/test-verify.t
--- a/tests/test-verify.t
+++ b/tests/test-verify.t
@@ -70,8 +70,8 @@  Set up a repo for testing missing revlog
   $ echo 0 > file
   $ hg ci -Aqm0
-  $ cp -r .hg/store .hg/store-partial
+  $ cp -R .hg/store .hg/store-partial
   $ echo 1 > file
   $ hg ci -Aqm1
-  $ cp -r .hg/store .hg/store-full
+  $ cp -R .hg/store .hg/store-full
 
 Entire changelog missing
@@ -85,5 +85,5 @@  Entire changelog missing
   (first damaged changeset appears to be 0)
   [1]
-  $ cp -r .hg/store-full/. .hg/store
+  $ cp -R .hg/store-full/. .hg/store
 
 Entire manifest log missing
@@ -95,5 +95,5 @@  Entire manifest log missing
   (first damaged changeset appears to be 0)
   [1]
-  $ cp -r .hg/store-full/. .hg/store
+  $ cp -R .hg/store-full/. .hg/store
 
 Entire filelog missing
@@ -110,5 +110,5 @@  Entire filelog missing
   (first damaged changeset appears to be 0)
   [1]
-  $ cp -r .hg/store-full/. .hg/store
+  $ cp -R .hg/store-full/. .hg/store
 
 Entire changelog and manifest log missing
@@ -119,5 +119,5 @@  Entire changelog and manifest log missin
   warning: orphan revlog 'data/file.i'
   1 warnings encountered!
-  $ cp -r .hg/store-full/. .hg/store
+  $ cp -R .hg/store-full/. .hg/store
 
 Entire changelog and filelog missing
@@ -138,5 +138,5 @@  Entire changelog and filelog missing
   (first damaged changeset appears to be 0)
   [1]
-  $ cp -r .hg/store-full/. .hg/store
+  $ cp -R .hg/store-full/. .hg/store
 
 Entire manifest log and filelog missing
@@ -153,5 +153,5 @@  Entire manifest log and filelog missing
   (first damaged changeset appears to be 0)
   [1]
-  $ cp -r .hg/store-full/. .hg/store
+  $ cp -R .hg/store-full/. .hg/store
 
 Changelog missing entry
@@ -166,5 +166,5 @@  Changelog missing entry
   3 integrity errors encountered!
   [1]
-  $ cp -r .hg/store-full/. .hg/store
+  $ cp -R .hg/store-full/. .hg/store
 
 Manifest log missing entry
@@ -177,5 +177,5 @@  Manifest log missing entry
   (first damaged changeset appears to be 1)
   [1]
-  $ cp -r .hg/store-full/. .hg/store
+  $ cp -R .hg/store-full/. .hg/store
 
 Filelog missing entry
@@ -187,5 +187,5 @@  Filelog missing entry
   (first damaged changeset appears to be 1)
   [1]
-  $ cp -r .hg/store-full/. .hg/store
+  $ cp -R .hg/store-full/. .hg/store
 
 Changelog and manifest log missing entry
@@ -200,5 +200,5 @@  Changelog and manifest log missing entry
   2 integrity errors encountered!
   [1]
-  $ cp -r .hg/store-full/. .hg/store
+  $ cp -R .hg/store-full/. .hg/store
 
 Changelog and filelog missing entry
@@ -212,5 +212,5 @@  Changelog and filelog missing entry
   3 integrity errors encountered!
   [1]
-  $ cp -r .hg/store-full/. .hg/store
+  $ cp -R .hg/store-full/. .hg/store
 
 Manifest and filelog missing entry
@@ -223,5 +223,5 @@  Manifest and filelog missing entry
   (first damaged changeset appears to be 1)
   [1]
-  $ cp -r .hg/store-full/. .hg/store
+  $ cp -R .hg/store-full/. .hg/store
 
 Corrupt changelog base node to cause failure to read revision
@@ -239,5 +239,5 @@  Corrupt changelog base node to cause fai
   (first damaged changeset appears to be 0)
   [1]
-  $ cp -r .hg/store-full/. .hg/store
+  $ cp -R .hg/store-full/. .hg/store
 
 Corrupt manifest log base node to cause failure to read revision
@@ -251,5 +251,5 @@  Corrupt manifest log base node to cause 
   (first damaged changeset appears to be 0)
   [1]
-  $ cp -r .hg/store-full/. .hg/store
+  $ cp -R .hg/store-full/. .hg/store
 
 Corrupt filelog base node to cause failure to read revision
@@ -262,5 +262,5 @@  Corrupt filelog base node to cause failu
   (first damaged changeset appears to be 0)
   [1]
-  $ cp -r .hg/store-full/. .hg/store
+  $ cp -R .hg/store-full/. .hg/store
 
   $ cd ..