Source

hg-importfs / test-importfs-copytree.t

Load the extension:

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

Create a simple file system structure for import:

  $ mkdir d1
  $ echo "c1" > d1/f1
  $ echo "c2" > "d1/f 2"
  $ mkdir d1/d2
  $ echo "c3" > d1/d2/f3
  $ mkdir d1/d3
  $ echo "c4" > d1/d3/f4
  $ echo "c5" > d1/d3/f5
  $ mkdir d1/d4
  $ echo "c6" > d1/d4/f6
  $ echo "c7" > d1/d4/f7

Perform an import ignoring the file f 2 and the d3 directory:

  $ hg importfs r1 d1 --exclude-pattern "f 2" --exclude-pattern d3
  created repository $TESTTMP/r1
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  adding d2/f3
  adding d4/f6
  adding d4/f7
  adding f1

Perform an import with a wildcard exclude expression:

  $ hg importfs r2 d1 --exclude-pattern *3
  created repository $TESTTMP/r2
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  adding d4/f6
  adding d4/f7
  adding f 2
  adding f1

Perform an import with an unreadable file with suppressed errors:

  $ chmod u-r d1/d2/f3
  $ hg importfs r3 d1 --ignore-copy-errors
  created repository $TESTTMP/r3
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  Warning: Failed to copy d1/d2/f3 to $TESTTMP/r3/d2/f3 ([Errno 13] Permission denied: 'd1/d2/f3').
  adding d3/f4
  adding d3/f5
  adding d4/f6
  adding d4/f7
  adding f 2
  adding f1

Create a file system structure where a directory name appears twice.

  $ mkdir -p proj/doc/{eggs,spam}
  $ mkdir -p proj/src/{eggs,spam}
  $ echo Index > proj/doc/index
  $ echo "Index eggs" > proj/doc/eggs/index
  $ echo "Index spam" > proj/doc/spam/index
  $ echo "1 + 1 = 2" > proj/src/eggs/calc
  $ echo "1 + 1 = 2" > proj/src/spam/calc

Perform an import ignoring the proj/src/spam directory:

  $ hg importfs r4 proj --exclude-path src/spam
  created repository $TESTTMP/r4
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  adding doc/eggs/index
  adding doc/index
  adding doc/spam/index
  adding src/eggs/calc

Adding another source directory at a deeper level to be ignored:

  $ mkdir proj/src/eggs/db
  $ echo "SELECT * FROM table" > proj/src/eggs/db/sql

Perform an import ignoring the proj/doc/eggs, the proj/src/spam and the
src/eggs/db directories:

  $ hg importfs r5 proj --exclude-path doc/eggs --exclude-path src/spam --exclude-path src/eggs/db
  created repository $TESTTMP/r5
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  adding doc/index
  adding doc/spam/index
  adding src/eggs/calc

See if the --exclude-path options also works at the toplevel:

  $ hg importfs r7 proj/doc --exclude-path eggs
  created repository $TESTTMP/r7
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  adding index
  adding spam/index