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
6b4b0970a69d
Commit
6b4b0970
authored
May 07, 2021
by
Pierre-Yves David
🐙
Browse files
phases: allow selecting branches and remotes with path options
parent
6790525bb9a0
Pipeline
#53738
passed with stages
in 17 minutes and 2 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
hggit/config.py
View file @
6b4b0970
from
__future__
import
generator_stop
from
mercurial
import
exthelper
from
mercurial.utils
import
stringutil
from
.
import
compat
eh
=
exthelper
.
exthelper
()
...
...
@@ -33,3 +36,14 @@
for
section
,
items
in
CONFIG_DEFAULTS
.
items
():
for
item
,
default
in
items
.
items
():
eh
.
configitem
(
section
,
item
,
default
=
default
)
@
eh
.
extsetup
def
extsetup
(
ui
):
@
compat
.
pathsuboption
(
b
'hg-git.publish'
,
b
'hggit_publish'
)
def
pathsuboption
(
ui
,
path
,
value
):
b
=
stringutil
.
parsebool
(
value
)
if
b
is
not
None
:
return
b
else
:
return
compat
.
parselist
(
value
)
hggit/git2hg.py
View file @
6b4b0970
...
...
@@ -17,8 +17,7 @@
def
get_public
(
ui
,
refs
,
remote_name
=
None
):
if
not
ui
.
configbool
(
b
'hggit'
,
b
'usephases'
):
return
{}
use_phases
=
ui
.
configbool
(
b
'hggit'
,
b
'usephases'
)
refs_to_publish
=
set
(
ui
.
configlist
(
b
'git'
,
b
'public'
))
...
...
@@ -26,6 +25,30 @@
# and tags
publish_defaults
=
not
refs_to_publish
paths
=
ui
.
paths
.
get
(
remote_name
)
msg
=
_
(
'multiple paths is not supported if they use hg-git.publish (yet)'
)
if
isinstance
(
paths
,
list
):
# paths became lists in mercurial 5.9; but how do we pick
# the right one?
if
len
(
paths
)
>
1
:
for
p
in
paths
:
if
getattr
(
p
,
'hggit_publish'
):
raise
error
.
Abort
(
msg
)
path
=
paths
[
0
]
else
:
path
=
paths
if
path
and
getattr
(
path
,
'hggit_publish'
)
is
not
None
:
use_phases
=
bool
(
path
.
hggit_publish
)
publish_defaults
=
path
.
hggit_publish
is
True
refs_to_publish
=
set
(
path
.
hggit_publish
if
isinstance
(
path
.
hggit_publish
,
list
)
else
[]
)
if
not
use_phases
:
return
{}
to_publish
=
set
()
if
remote_name
is
not
None
:
...
...
tests/test-phases-remote.t
0 → 100644
View file @
6b4b0970
Load
commonly
used
test
logic
$
.
"
$TESTDIR
/testutil
"
$
git
init
gitrepo
Initialized
empty
Git
repository
in
$TESTTMP
/gitrepo/
.
git
/
$
cd
gitrepo
$
git
config
receive
.
denyCurrentBranch
ignore
$
echo
alpha
>
alpha
$
git
add
alpha
$
fn_git_commit
-
m "add alpha"
$
git
checkout
-
q master
$
echo
beta
>
beta
$
git
add
beta
$
fn_git_commit
-
m 'add beta'
$
git
checkout
-
b
not
-
master
master
~
1
Switched
to
a
new
branch
'
not-master
'
$
echo
gamma
>
gamma
$
git
add
gamma
$
fn_git_commit
-
m 'add gamma'
$
git
checkout
-
qd
master
~
1
$
echo
delta
>
delta
$
git
add
delta
$
fn_git_commit
-
m 'add delta'
$
git
tag
thetag
$
git
checkout
-
q master
$
cd
..
$
hg
clone
--
config
hggit
.
usephases
=
True
-
U
gitrepo
hgrepo
importing
4
git
commits
new
changesets
ff7a2f2d8d70:25eed24f5e8f
(
1
drafts
)
$
cd
hgrepo
$
hg
log
-
G
-
T
'
{rev}|{phase}|{bookmarks}|{tags}\n
'
o
3
|
public
||
thetag
tip
|
|
o
2
|
draft
|
not
-
master
|
default
/
not
-
master
|/
|
o
1
|
public
|
master
|
default
/
master
|/
o
0
|
public
||
$
hg
phase
-
r
'
all()
'
|
tee
$TESTTMP
/
after
-
clone
0
:
public
1
:
public
2
:
draft
3
:
public
$
cat
>>
.
hg
/
hgrc
<<
EOF
>
[
paths
]
>
other
=
$TESTTMP
/gitrepo/
.
git
>
other:hg
-
git
.
publish
=
no
>
EOF
$
cd
..
that
disables
publishing
from
that
remote
$
cd
hgrepo
$
hg
phase
-
fd
'
all()
'
$
hg
pull
other
pulling
from
$TESTTMP
/gitrepo/
.
git
no
changes
found
$
hg
log
-
qr 'public()'
$
hg
pull
-
v
--
config
hggit
.
usephases
=
True
other
pulling
from
$TESTTMP
/gitrepo/
.
git
publishing
remote
HEAD
publishing
tag
thetag
no
changes
found
processing
commits
in
batches
of
1000
bookmark
master
is
up
-
to
-
date
bookmark
not
-
master
is
up
-
to
-
date
$
hg
log
-
qr 'public()'
$
cd
..
but
not
default
when
enable
by
the
global
setting
$
cd
hgrepo
$
hg
phase
-
fd
'
all()
'
no
phases
changed
$
hg
pull
-
v
--
config
hggit
.
usephases
=
True
pulling
from
$TESTTMP
/
gitrepo
publishing
remote
HEAD
publishing
tag
thetag
no
changes
found
processing
commits
in
batches
of
1000
bookmark
master
is
up
-
to
-
date
bookmark
not
-
master
is
up
-
to
-
date
publishing
remote
HEAD
publishing
tag
thetag
3
local
changesets
published
$
hg
phase
-
r
'
all()
'
>
$TESTTMP
/
after
-
pull
$
cmp
$TESTTMP
/after-clone $TESTTMP/a
fter
-
pull
$
cd
..
or
the
path
option
$
cd
hgrepo
$
hg
phase
-
fd
'
all()
'
$
hg
pull
-
v
--
config
paths
.
default:hg
-
git
.
publish
=
yes
pulling
from
$TESTTMP
/
gitrepo
no
changes
found
processing
commits
in
batches
of
1000
bookmark
master
is
up
-
to
-
date
bookmark
not
-
master
is
up
-
to
-
date
publishing
remote
HEAD
publishing
tag
thetag
3
local
changesets
published
$
hg
phase
-
r
'
all()
'
>
$TESTTMP
/
after
-
pull
$
cmp
$TESTTMP
/after-clone $TESTTMP/a
fter
-
pull
$
cd
..
but
we
can
specify
individual
branches
$
cd
hgrepo
$
hg
phase
-
fd
'
all()
'
$
hg
pull
-
v
--
config
paths
.
default:hg
-
git
.
publish
=
not
-
master
pulling
from
$TESTTMP
/
gitrepo
no
changes
found
processing
commits
in
batches
of
1000
bookmark
master
is
up
-
to
-
date
bookmark
not
-
master
is
up
-
to
-
date
publishing
branch
not
-
master
2
local
changesets
published
$
hg
phase
-
r
master
-
r
not
-
master
-
r
thetag
1
:
draft
2
:
public
3
:
draft
$
cd
..
and
we
can
also
specify
the
tag
$
cd
hgrepo
$
hg
phase
-
fd
'
all()
'
$
hg
pull
-
v
--
config
paths
.
default:hg
-
git
.
publish
=
thetag
pulling
from
$TESTTMP
/
gitrepo
no
changes
found
processing
commits
in
batches
of
1000
bookmark
master
is
up
-
to
-
date
bookmark
not
-
master
is
up
-
to
-
date
publishing
tag
thetag
2
local
changesets
published
$
hg
phase
-
r
master
-
r
not
-
master
-
r
thetag
1
:
draft
2
:
draft
3
:
public
$
cd
..
#if hg59
Check
multiple
paths
behavior
=============================
$
cd
hgrepo
$
cat
>>
.
hg
/
hgrc
<<
EOF
>
[
paths
]
>
multi:multi
-
urls
=
yes
>
multi
=
path:
//o
ther
,
path:
//d
efault
>
recursive:multi
-
urls
=
yes
>
recursive
=
path:
//mul
ti
,
default
>
EOF
Using
multiple
path
works
fine:
$
hg
pull
multi
--
config
paths
.
default:hg
-
git
.
publish
=
yes
abort:
cannot
use
`
path://multi
`,
"
multi
"
is
also
defined
as
a
`
path://
`
[
255
]
Recursive
multiple
path
are
tricker
,
but
Mercurial
don
'
t work with them either.
This test exist to make sure we bail out on our own.
`yes` should abort (until we implement it)
$ hg pull multi --config paths.default:hg-git.publish=yes
abort: cannot use `path://multi`, "multi" is also defined as a `path://`
[255]
`some-value` should abort (until we implement it)
$ hg pull multi --config paths.default:hg-git.publish=thetag
abort: cannot use `path://multi`, "multi" is also defined as a `path://`
[255]
`no` is fine
$ hg pull multi --config paths.default:hg-git.publish=no
abort: cannot use `path://multi`, "multi" is also defined as a `path://`
[255]
#endif
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