Commit d898bc06 authored by Dan Villiom Podlaski Christiansen's avatar Dan Villiom Podlaski Christiansen
Browse files

worktree: add default ignores for .git and .hg

Without this, users would have to adjust the ignores to keep them
clean.
parent cf9690f5b372
Pipeline #54842 passed with stages
in 11 minutes and 18 seconds
......@@ -98,6 +98,9 @@
if name == b'ignore' or name.startswith(b'ignore.'):
files.append(util.expandpath(path))
patterns = []
# Suppress .git when located in repository root
if self._ui.configbool(b"hggit", b"worktree"):
patterns.append(br"re:^\.git$")
# Only use .gitignore if there's no .hgignore
if not os.access(files[0], os.R_OK):
for fn in self._finddotgitignores():
......
......@@ -2,7 +2,7 @@
import os
import dulwich
import dulwich.ignore
from mercurial import bookmarks
from mercurial.node import hex
......@@ -49,6 +49,8 @@
if not has_head:
del gh.git.refs[b"HEAD"]
gh.git._put_named_file(os.path.join("info", "exclude"), b"/.hg\n")
if bookmarks.isactivewdirparent(repo):
bookmark = repo._bookmarks._active
suffix = gh.branch_bookmark_suffix
......
......@@ -28,7 +28,7 @@
We should also ignore the file in a shared repository:
$ hg share hgrepo sharerepo
$ hg share --bookmarks hgrepo sharerepo
updating working directory
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cd sharerepo
......@@ -38,3 +38,17 @@
ignored
$ touch ignored
$ hg status
check behaviour with worktree
$ hg up null
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ hg --config hggit.worktree=yes up master
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(activating bookmark master)
$ hg st
? .git
$ hg --config hggit.worktree=yes st
$ git status
On branch master
nothing to commit, working tree clean
Load commonly used test logic
$ . "$TESTDIR/testutil"
$ hg init repo
$ cd repo
$ hg init hgrepo
$ cd hgrepo
Create a commit that we can export later on
......@@ -155,7 +155,8 @@
? dir/bar
? foo
? foobar
$ cd ..
show pattern error in hgignore file as expected (issue197)
----------------------------------------------------------
......@@ -158,7 +159,8 @@
show pattern error in hgignore file as expected (issue197)
----------------------------------------------------------
$ cd hgrepo
$ cat > $TESTTMP/invalidhgignore <<EOF
> # invalid syntax in regexp
> foo(
......@@ -172,5 +174,5 @@
> foo(
> EOF
$ hg status
abort: $TESTTMP/repo/.hgignore: invalid pattern (relre): foo(
abort: $TESTTMP/hgrepo/.hgignore: invalid pattern (relre): foo(
[255]
......@@ -176,1 +178,36 @@
[255]
$ cd ..
check behaviour with worktree
-----------------------------
$ git init -q --bare repo.git
$ cd hgrepo
$ hg book -r tip master
$ hg push ../repo.git
pushing to ../repo.git
searching for changes
adding objects
added 2 commits with 2 trees and 2 blobs
adding reference refs/heads/master
$ cd ..
$ hg --config hggit.worktree=yes clone repo.git worktree
importing 2 git commits
new changesets 69cb9b83bde4:c6a4b5109a96 (2 drafts)
updating to bookmark master (hg57 !)
updating to branch default (no-hg57 !)
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cd worktree
$ ls -A
.git
.gitignore
.hg
thefile
$ hg st
? .git
$ hg --config hggit.worktree=yes st
$ git status
On branch master
nothing to commit, working tree clean
$ cd ..
$ rm -rf worktree
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment