Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
mercurial
hg-git
Commits
d898bc060cee
Commit
d898bc06
authored
May 18, 2022
by
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
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
hggit/gitdirstate.py
View file @
d898bc06
...
...
@@ -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
():
...
...
hggit/worktree.py
View file @
d898bc06
...
...
@@ -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
...
...
tests/test-gitignore-share.t
View file @
d898bc06
...
...
@@ -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
tests/test-gitignore.t
View file @
d898bc06
Load
commonly
used
test
logic
$
.
"
$TESTDIR
/testutil
"
$
hg
init
repo
$
cd
repo
$
hg
init
hg
repo
$
cd
hg
repo
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/
hg
repo/.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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment