Mercurial > hg > hg-git
changeset 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 | a55006c9b484 |
children | f34e1dc7314c |
files | hggit/gitdirstate.py tests/test-gitignore.t |
diffstat | 2 files changed, 14 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/hggit/gitdirstate.py +++ b/hggit/gitdirstate.py @@ -101,6 +101,8 @@ for fn in fns: d = os.path.dirname(fn) fn = self.pathto(fn) + if not os.path.exists(fn): + continue fp = open(fn) pats, warnings = gignorepats(None,fp,root=d) for warning in warnings:
--- a/tests/test-gitignore.t +++ b/tests/test-gitignore.t @@ -126,3 +126,15 @@ ? 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