Source

hg-importfs / test-importfs-permissions.t

Full commit
Load the extension:

  $ echo "[extensions]" >> $HGRCPATH
  $ echo "importfs = $TESTDIR/importfs.py" >> $HGRCPATH

Create files and directories to import:

  $ mkdir -p d1/{d2,d3}
  $ echo c1 > d1/f1
  $ echo c2 > d1/d2/f2
  $ echo c3 > d1/d3/f3

Remove execute permissions from directory d3:

  $ chmod u-X d1/d3

Perform the import, fails because execute permissions are denied:

  $ hg importfs r1 d1
  created repository $TESTTMP/r1
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  abort: Failed to copy d1/d3/f3 to $TESTTMP/r1/d3/f3 ([Errno 13] Permission denied: 'd1/d3/f3').
  
  [255]

Add execute permissions again and remove read permissions from directory d3:

  $ chmod u+X d1/d3
  $ chmod u-r d1/d3

Perform the import, fails because read permissions are denied:

  $ hg importfs r1 d1
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  abort: Permission denied: d1/d3
  [255]

Import also fails if directory d3 is ignored:

  $ hg importfs r1 d1 --exclude-path d1/d3
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  abort: Permission denied: d1/d3
  [255]

This import should succeed because of the --ignore-copy-errors option:

  $ hg importfs r1 d1 --ignore-copy-errors
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  Warning: Failed to copy d1/d3 to $TESTTMP/r1/d3 ([Errno 13] Permission denied: 'd1/d3').
  adding d2/f2
  adding f1

Now test everything again with a directory one level deeper:

  $ chmod u+r d1/d3
  $ mkdir d1/d3/d4
  $ echo c4 > d1/d3/d4/f4
  $ chmod u-X d1/d3/d4

  $ hg importfs r2 d1
  created repository $TESTTMP/r2
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  abort: Failed to copy d1/d3/d4/f4 to $TESTTMP/r2/d3/d4/f4 ([Errno 13] Permission denied: 'd1/d3/d4/f4').
  
  [255]

  $ chmod u+X d1/d3/d4
  $ chmod u-r d1/d3/d4

  $ hg importfs r2 d1
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  abort: Failed to copy d1/d3/d4 to $TESTTMP/r2/d3/d4 ([Errno 13] Permission denied: 'd1/d3/d4').
  
  [255]

  $ hg importfs r2 d1 --exclude-path d1/d3/d4
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  abort: Failed to copy d1/d3/d4 to $TESTTMP/r2/d3/d4 ([Errno 13] Permission denied: 'd1/d3/d4').
  
  [255]

  $ hg importfs r2 d1 --ignore-copy-errors
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  Warning: Failed to copy d1/d3/d4 to $TESTTMP/r2/d3/d4 ([Errno 13] Permission denied: 'd1/d3/d4').
  adding d2/f2
  adding d3/f3
  adding f1