view tests/test-gitignore.t @ 861:cdf46071a83f

gitdirstate: avoid an abort when a .gitignore is missing Deleting a .gitignore using 'rm' results in 'hg add' or 'hg status' aborting. For example if the top-level .gitignore is removed: > abort: No such file or directory: .gitignore This change avoids that by checking the presence of the .gitignore files.
author Mathias De Maré <mathias.demare@gmail.com>
date Mon, 16 Feb 2015 18:35:35 +0100
parents 9c6f083eecad
children 017db283e685
line wrap: on
line source

  $ python -c 'from mercurial.dirstate import rootcache' || exit 80
  $ python -c 'from mercurial.ignore import readpats' || exit 80

Load commonly used test logic
  $ . "$TESTDIR/testutil"

  $ hg init

  $ touch foo
  $ touch foobar
  $ touch bar
  $ echo 'foo*' > .gitignore
  $ hg status
  ? .gitignore
  ? bar

  $ echo '*bar' > .gitignore
  $ hg status
  ? .gitignore
  ? foo

  $ mkdir dir
  $ touch dir/foo
  $ echo 'foo' > .gitignore
  $ hg status
  ? .gitignore
  ? bar
  ? foobar

  $ echo '/foo' > .gitignore
  $ hg status
  ? .gitignore
  ? bar
  ? dir/foo
  ? foobar

  $ rm .gitignore
  $ echo 'foo' > dir/.gitignore
  $ hg status
  ? bar
  ? dir/.gitignore
  ? foo
  ? foobar

  $ touch dir/bar
  $ echo 'bar' > .gitignore
  $ hg status
  ? .gitignore
  ? dir/.gitignore
  ? foo
  ? foobar

  $ echo '/bar' > .gitignore
  $ hg status
  ? .gitignore
  ? dir/.gitignore
  ? dir/bar
  ? foo
  ? foobar

  $ echo 'foo*' > .gitignore
  $ echo '!*bar' >> .gitignore
  $ hg status
  .gitignore: unsupported ignore pattern '!*bar'
  ? .gitignore
  ? bar
  ? dir/.gitignore
  ? dir/bar

  $ echo '.hg/' > .gitignore
  $ hg status
  ? .gitignore
  ? bar
  ? dir/.gitignore
  ? dir/bar
  ? foo
  ? foobar

  $ echo 'dir/.hg/' > .gitignore
  $ hg status
  ? .gitignore
  ? bar
  ? dir/.gitignore
  ? dir/bar
  ? foo
  ? foobar

  $ echo '.hg/foo' > .gitignore
  $ hg status
  ? .gitignore
  ? bar
  ? dir/.gitignore
  ? dir/bar
  ? foo
  ? foobar

  $ touch foo.hg
  $ echo 'foo.hg' > .gitignore
  $ hg status
  ? .gitignore
  ? bar
  ? dir/.gitignore
  ? dir/bar
  ? foo
  ? foobar
  $ rm foo.hg

  $ touch .hgignore
  $ hg status
  ? .gitignore
  ? .hgignore
  ? bar
  ? dir/.gitignore
  ? dir/bar
  ? dir/foo
  ? foo
  ? foobar

  $ echo 'syntax: re' > .hgignore
  $ echo 'foo.*$(?<!bar)' >> .hgignore
  $ echo 'dir/foo' >> .hgignore
  $ hg status
  ? .gitignore
  ? .hgignore
  ? bar
  ? dir/.gitignore
  ? dir/bar
  ? foobar

  $ hg add .gitignore
  $ hg commit -m "add and commit .gitignore"
  $ rm .gitignore
  $ rm .hgignore
  $ hg status
  ! .gitignore
  ? bar
  ? dir/.gitignore
  ? dir/bar
  ? foo
  ? foobar