Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
py-heptapod
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
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
heptapod
py-heptapod
Commits
fdb1704a
Commit
fdb1704a
authored
4 years ago
by
Georges Racinet
Browse files
Options
Downloads
Patches
Plain Diff
GitLabStateMaintainer: adopted validate_obsolescence()
parent
798e60fa
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!50
Separation of hg-git and generic parts in "mirroring" code
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
hgext3rd/heptapod/git.py
+0
-47
0 additions, 47 deletions
hgext3rd/heptapod/git.py
hgext3rd/heptapod/state_maintainer.py
+44
-1
44 additions, 1 deletion
hgext3rd/heptapod/state_maintainer.py
with
44 additions
and
48 deletions
hgext3rd/heptapod/git.py
+
0
−
47
View file @
fdb1704a
...
...
@@ -13,9 +13,6 @@
from
dulwich.repo
import
check_ref_format
from
hggit.git_handler
import
GitHandler
from
heptapod
import
(
util
,
)
from
heptapod.gitlab.branch
import
(
gitlab_branch_ref
as
git_branch_ref
,
gitlab_branch_from_ref
as
git_branch_from_ref
,
...
...
@@ -41,7 +38,6 @@
WildHeadResolved
,
)
from
hgext3rd.evolve
import
headchecking
from
mercurial.i18n
import
_
from
mercurial.node
import
hex
from
mercurial
import
(
error
,
...
...
@@ -108,49 +104,6 @@
hg_sha_from_gitlab_sha
=
GitHandler
.
map_hg_get
gitlab_sha_from_hg_sha
=
GitHandler
.
map_git_get
def
validate_obsolescence
(
self
,
txn
):
"""
Abort if the given transaction creates unwanted obsolescence.
Most GitLab refs must not be to obsolete changesets, but we don
'
t
want to create blocking situations for repos with long history
where this may already be the case.
See heptapod#393
We are at the end of the transaction, hence we can assume that
consequences of new obsmarkers have already been applied (e.g, moving
a bookmark if possible)
"""
unfi
=
self
.
repo
.
unfiltered
()
for
new_obsmarker
in
txn
.
changes
[
b
'
obsmarkers
'
]:
try
:
obsolete_ctx
=
unfi
[
new_obsmarker
[
0
]]
except
error
.
RepoLookupError
:
continue
bookmarks
=
obsolete_ctx
.
bookmarks
()
if
bookmarks
:
hint
=
_
(
b
"
If this isn
'
t a mistake, you may need to also
"
b
"
update the bookmark(s).
"
)
msg
=
_
(
b
"
Refusing these changes, as they would make
"
b
"
bookmark(s) %s point to the
"
b
"
obsolete changeset %s
"
)
%
(
util
.
format_bytes_list
(
bookmarks
),
obsolete_ctx
.
hex
())
raise
error
.
Abort
(
msg
,
hint
=
hint
)
tags
=
[
t
for
t
in
obsolete_ctx
.
tags
()
if
unfi
.
tagtype
(
t
)
==
b
'
global
'
]
if
tags
:
hint
=
_
(
b
"
If this isn
'
t a mistake, you may need to also
"
b
"
update the tag(s).
"
)
msg
=
_
(
b
"
Refusing these changes, as they would make
"
b
"
tag(s) %s point to the
"
b
"
obsolete changeset %s
"
)
%
(
util
.
format_bytes_list
(
tags
),
obsolete_ctx
.
hex
())
raise
error
.
Abort
(
msg
,
hint
=
hint
)
def
get_exportable
(
self
):
"""
Heptapod version, including named branches and topics.
...
...
This diff is collapsed.
Click to expand it.
hgext3rd/heptapod/state_maintainer.py
+
44
−
1
View file @
fdb1704a
...
...
@@ -160,7 +160,7 @@
After all other rules have been applied, this handles the cases
where there are 0, 1 or several heads for the given branch.
storing at most one head in ``git_refs`` for the
storing at most one head in ``git
lab
_refs`` for the
given ``branch`` either enforcing the rejection of multiple heads or
stoging extra heads in the ``wild`` namespace, according to
configuration.
...
...
@@ -247,3 +247,46 @@
except
error
.
RepoLookupError
:
return
None
return
repo
[
rev
].
hex
()
def
validate_obsolescence
(
self
,
txn
):
"""
Abort if the given transaction creates unwanted obsolescence.
Most GitLab refs must not be to obsolete changesets, but we don
'
t
want to create blocking situations for repos with long history
where this may already be the case.
See heptapod#393
We are at the end of the transaction, hence we can assume that
consequences of new obsmarkers have already been applied (e.g, moving
a bookmark if possible)
"""
unfi
=
self
.
repo
.
unfiltered
()
for
new_obsmarker
in
txn
.
changes
[
b
'
obsmarkers
'
]:
try
:
obsolete_ctx
=
unfi
[
new_obsmarker
[
0
]]
except
error
.
RepoLookupError
:
continue
bookmarks
=
obsolete_ctx
.
bookmarks
()
if
bookmarks
:
hint
=
_
(
b
"
If this isn
'
t a mistake, you may need to also
"
b
"
update the bookmark(s).
"
)
msg
=
_
(
b
"
Refusing these changes, as they would make
"
b
"
bookmark(s) %s point to the
"
b
"
obsolete changeset %s
"
)
%
(
util
.
format_bytes_list
(
bookmarks
),
obsolete_ctx
.
hex
())
raise
error
.
Abort
(
msg
,
hint
=
hint
)
tags
=
[
t
for
t
in
obsolete_ctx
.
tags
()
if
unfi
.
tagtype
(
t
)
==
b
'
global
'
]
if
tags
:
hint
=
_
(
b
"
If this isn
'
t a mistake, you may need to also
"
b
"
update the tag(s).
"
)
msg
=
_
(
b
"
Refusing these changes, as they would make
"
b
"
tag(s) %s point to the
"
b
"
obsolete changeset %s
"
)
%
(
util
.
format_bytes_list
(
tags
),
obsolete_ctx
.
hex
())
raise
error
.
Abort
(
msg
,
hint
=
hint
)
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