Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
hg-git
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mercurial
hg-git
Commits
4d2699f8
Commit
4d2699f8
authored
3 years ago
by
Dan Villiom Podlaski Christiansen
Browse files
Options
Downloads
Patches
Plain Diff
gitrepo: move discovery & exchange related logic
parent
cc35f26b
No related branches found
Branches containing commit
Tags
0.4.0
Tags containing commit
1 merge request
!107
Refactor __init__.py to many modules; use exthelper
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
hggit/__init__.py
+0
-87
0 additions, 87 deletions
hggit/__init__.py
hggit/gitrepo.py
+106
-0
106 additions, 0 deletions
hggit/gitrepo.py
with
106 additions
and
87 deletions
hggit/__init__.py
+
0
−
87
View file @
4d2699f8
...
...
@@ -131,6 +131,5 @@
from
.
import
revsets
from
.
import
schemes
from
.
import
templates
from
.
import
util
from
mercurial
import
(
...
...
@@ -135,4 +134,3 @@
from
mercurial
import
(
bundlerepo
,
demandimport
,
...
...
@@ -138,7 +136,4 @@
demandimport
,
discovery
,
exchange
,
extensions
,
pycompat
,
registrar
,
)
...
...
@@ -182,85 +177,3 @@
gitdirstate
.
reposetup
(
ui
,
repo
)
hgrepo
.
reposetup
(
ui
,
repo
)
def
findcommonoutgoing
(
orig
,
repo
,
other
,
*
args
,
**
kwargs
):
if
isinstance
(
other
,
gitrepo
.
gitrepo
):
heads
=
repo
.
githandler
.
get_refs
(
other
.
path
)[
0
]
kw
=
{}
kw
.
update
(
kwargs
)
for
val
,
k
in
zip
(
args
,
(
'
onlyheads
'
,
'
force
'
,
'
commoninc
'
,
'
portable
'
)):
kw
[
k
]
=
val
force
=
kw
.
get
(
'
force
'
,
False
)
commoninc
=
kw
.
get
(
'
commoninc
'
,
None
)
if
commoninc
is
None
:
commoninc
=
discovery
.
findcommonincoming
(
repo
,
other
,
heads
=
heads
,
force
=
force
)
kw
[
'
commoninc
'
]
=
commoninc
return
orig
(
repo
,
other
,
**
kw
)
return
orig
(
repo
,
other
,
*
args
,
**
kwargs
)
extensions
.
wrapfunction
(
discovery
,
b
'
findcommonoutgoing
'
,
findcommonoutgoing
)
def
getremotechanges
(
orig
,
ui
,
repo
,
other
,
*
args
,
**
opts
):
if
isinstance
(
other
,
gitrepo
.
gitrepo
):
if
args
:
revs
=
args
[
0
]
else
:
revs
=
opts
.
get
(
'
onlyheads
'
,
opts
.
get
(
'
revs
'
))
r
,
c
,
cleanup
=
repo
.
githandler
.
getremotechanges
(
other
,
revs
)
# ugh. This is ugly even by mercurial API compatibility standards
if
'
onlyheads
'
not
in
orig
.
__code__
.
co_varnames
:
cleanup
=
None
return
r
,
c
,
cleanup
return
orig
(
ui
,
repo
,
other
,
*
args
,
**
opts
)
extensions
.
wrapfunction
(
bundlerepo
,
b
'
getremotechanges
'
,
getremotechanges
)
@util.transform_notgit
def
exchangepull
(
orig
,
repo
,
remote
,
heads
=
None
,
force
=
False
,
bookmarks
=
(),
**
kwargs
):
if
isinstance
(
remote
,
gitrepo
.
gitrepo
):
pullop
=
exchange
.
pulloperation
(
repo
,
remote
,
heads
,
force
,
bookmarks
=
bookmarks
)
pullop
.
trmanager
=
exchange
.
transactionmanager
(
repo
,
b
'
pull
'
,
remote
.
url
())
wlock
=
repo
.
wlock
()
lock
=
repo
.
lock
()
try
:
pullop
.
cgresult
=
repo
.
githandler
.
fetch
(
remote
.
path
,
heads
)
pullop
.
trmanager
.
close
()
return
pullop
finally
:
pullop
.
trmanager
.
release
()
lock
.
release
()
wlock
.
release
()
else
:
return
orig
(
repo
,
remote
,
heads
,
force
,
bookmarks
=
bookmarks
,
**
kwargs
)
extensions
.
wrapfunction
(
exchange
,
b
'
pull
'
,
exchangepull
)
# TODO figure out something useful to do with the newbranch param
@util.transform_notgit
def
exchangepush
(
orig
,
repo
,
remote
,
force
=
False
,
revs
=
None
,
newbranch
=
False
,
bookmarks
=
(),
opargs
=
None
,
**
kwargs
):
if
isinstance
(
remote
,
gitrepo
.
gitrepo
):
pushop
=
exchange
.
pushoperation
(
repo
,
remote
,
force
,
revs
,
newbranch
,
bookmarks
,
**
pycompat
.
strkwargs
(
opargs
or
{}))
pushop
.
cgresult
=
repo
.
githandler
.
push
(
remote
.
path
,
revs
,
force
)
return
pushop
else
:
return
orig
(
repo
,
remote
,
force
,
revs
,
newbranch
,
bookmarks
=
bookmarks
,
opargs
=
None
,
**
kwargs
)
extensions
.
wrapfunction
(
exchange
,
b
'
push
'
,
exchangepush
)
This diff is collapsed.
Click to expand it.
hggit/gitrepo.py
+
106
−
0
View file @
4d2699f8
...
...
@@ -3,4 +3,6 @@
from
.
import
util
from
.
import
compat
from
mercurial
import
(
bundlerepo
,
discovery
,
error
,
...
...
@@ -6,3 +8,4 @@
error
,
exchange
,
extensions
,
hg
,
...
...
@@ -7,5 +10,6 @@
extensions
,
hg
,
pycompat
,
)
from
mercurial.wireprotov1peer
import
(
batchable
,
...
...
@@ -162,5 +166,103 @@
return
revs
,
co
def
findcommonoutgoing
(
orig
,
repo
,
other
,
*
args
,
**
kwargs
):
if
isinstance
(
other
,
gitrepo
):
heads
=
repo
.
githandler
.
get_refs
(
other
.
path
)[
0
]
kw
=
{}
kw
.
update
(
kwargs
)
for
val
,
k
in
zip
(
args
,
(
'
onlyheads
'
,
'
force
'
,
'
commoninc
'
,
'
portable
'
)
):
kw
[
k
]
=
val
force
=
kw
.
get
(
'
force
'
,
False
)
commoninc
=
kw
.
get
(
'
commoninc
'
,
None
)
if
commoninc
is
None
:
commoninc
=
discovery
.
findcommonincoming
(
repo
,
other
,
heads
=
heads
,
force
=
force
)
kw
[
'
commoninc
'
]
=
commoninc
return
orig
(
repo
,
other
,
**
kw
)
return
orig
(
repo
,
other
,
*
args
,
**
kwargs
)
def
getremotechanges
(
orig
,
ui
,
repo
,
other
,
*
args
,
**
opts
):
if
isinstance
(
other
,
gitrepo
):
if
args
:
revs
=
args
[
0
]
else
:
revs
=
opts
.
get
(
'
onlyheads
'
,
opts
.
get
(
'
revs
'
))
r
,
c
,
cleanup
=
repo
.
githandler
.
getremotechanges
(
other
,
revs
)
# ugh. This is ugly even by mercurial API compatibility standards
if
'
onlyheads
'
not
in
orig
.
__code__
.
co_varnames
:
cleanup
=
None
return
r
,
c
,
cleanup
return
orig
(
ui
,
repo
,
other
,
*
args
,
**
opts
)
@util.transform_notgit
def
exchangepull
(
orig
,
repo
,
remote
,
heads
=
None
,
force
=
False
,
bookmarks
=
(),
**
kwargs
):
if
isinstance
(
remote
,
gitrepo
):
pullop
=
exchange
.
pulloperation
(
repo
,
remote
,
heads
,
force
,
bookmarks
=
bookmarks
)
pullop
.
trmanager
=
exchange
.
transactionmanager
(
repo
,
b
'
pull
'
,
remote
.
url
()
)
wlock
=
repo
.
wlock
()
lock
=
repo
.
lock
()
try
:
pullop
.
cgresult
=
repo
.
githandler
.
fetch
(
remote
.
path
,
heads
)
pullop
.
trmanager
.
close
()
return
pullop
finally
:
pullop
.
trmanager
.
release
()
lock
.
release
()
wlock
.
release
()
else
:
return
orig
(
repo
,
remote
,
heads
,
force
,
bookmarks
=
bookmarks
,
**
kwargs
)
# TODO figure out something useful to do with the newbranch param
@util.transform_notgit
def
exchangepush
(
orig
,
repo
,
remote
,
force
=
False
,
revs
=
None
,
newbranch
=
False
,
bookmarks
=
(),
opargs
=
None
,
**
kwargs
):
if
isinstance
(
remote
,
gitrepo
):
pushop
=
exchange
.
pushoperation
(
repo
,
remote
,
force
,
revs
,
newbranch
,
bookmarks
,
**
pycompat
.
strkwargs
(
opargs
or
{}),
)
pushop
.
cgresult
=
repo
.
githandler
.
push
(
remote
.
path
,
revs
,
force
)
return
pushop
else
:
return
orig
(
repo
,
remote
,
force
,
revs
,
newbranch
,
bookmarks
=
bookmarks
,
opargs
=
None
,
**
kwargs
,
)
def
extsetup
(
ui
):
extensions
.
wrapfunction
(
hg
,
b
'
addbranchrevs
'
,
safebranchrevs
)
...
...
@@ -165,2 +267,6 @@
def
extsetup
(
ui
):
extensions
.
wrapfunction
(
hg
,
b
'
addbranchrevs
'
,
safebranchrevs
)
extensions
.
wrapfunction
(
discovery
,
b
'
findcommonoutgoing
'
,
findcommonoutgoing
)
extensions
.
wrapfunction
(
bundlerepo
,
b
'
getremotechanges
'
,
getremotechanges
)
extensions
.
wrapfunction
(
exchange
,
b
'
pull
'
,
exchangepull
)
extensions
.
wrapfunction
(
exchange
,
b
'
push
'
,
exchangepush
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment