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
Service Desk
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
dd6fc894
Commit
dd6fc894
authored
4 years ago
by
Georges Racinet
Browse files
Options
Downloads
Patches
Plain Diff
Moved latest_unique_successor in a common obsutil module
It will also be useful elsewhere
parent
4aabd418
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
hgext3rd/heptapod/git.py
+3
-24
3 additions, 24 deletions
hgext3rd/heptapod/git.py
hgext3rd/heptapod/obsutil.py
+27
-0
27 additions, 0 deletions
hgext3rd/heptapod/obsutil.py
with
30 additions
and
24 deletions
hgext3rd/heptapod/git.py
+
3
−
24
View file @
dd6fc894
...
@@ -18,10 +18,9 @@
...
@@ -18,10 +18,9 @@
from
mercurial
import
(
from
mercurial
import
(
error
,
error
,
hg
,
hg
,
obsutil
,
phases
,
phases
,
pycompat
,
pycompat
,
)
)
import
re
import
re
import
traceback
import
traceback
...
@@ -22,9 +21,11 @@
...
@@ -22,9 +21,11 @@
phases
,
phases
,
pycompat
,
pycompat
,
)
)
import
re
import
re
import
traceback
import
traceback
from
.
import
obsutil
class
MultipleDescendants
(
LookupError
):
class
MultipleDescendants
(
LookupError
):
pass
pass
...
@@ -295,7 +296,7 @@
...
@@ -295,7 +296,7 @@
return
self
.
published_topic_latest_hg_sha
(
topic
,
before_ctx
)
return
self
.
published_topic_latest_hg_sha
(
topic
,
before_ctx
)
try
:
try
:
succctx
=
self
.
latest_unique_successor
(
before_ctx
)
succctx
=
obsutil
.
latest_unique_successor
(
before_ctx
)
except
error
.
Abort
as
exc
:
except
error
.
Abort
as
exc
:
if
initial_import
:
if
initial_import
:
# we don't want to break an initial import because
# we don't want to break an initial import because
...
@@ -596,25 +597,3 @@
...
@@ -596,25 +597,3 @@
"
Can
'
t find public descendants of %r in topic %r
"
%
(
"
Can
'
t find public descendants of %r in topic %r
"
%
(
ctx
.
hex
(),
topic
))
ctx
.
hex
(),
topic
))
return
self
.
repo
[
rev
]
return
self
.
repo
[
rev
]
def
latest_unique_successor
(
self
,
ctx
):
"""
Return the latest of unique set of successors of a changeset.
The changeset is given by its context, and a context is also returned,
or `None` if there is no successor.
`Abort` gets raised if there are several sets of successors.
"""
successorssets
=
obsutil
.
successorssets
(
self
.
repo
,
ctx
.
node
())
if
not
successorssets
:
return
None
if
len
(
successorssets
)
>
1
:
# There is more than one set of successors, so we have
# a divergence, and we cannot handle it automatically
raise
error
.
Abort
((
"
Changeset %r evolved into a
"
"
divergent state
"
)
%
ctx
.
hex
())
# Single successor set: it can be one or many (split)
# In all cases, we can take the last one.
return
self
.
repo
[
successorssets
[
0
][
-
1
]]
This diff is collapsed.
Click to expand it.
hgext3rd/heptapod/obsutil.py
0 → 100644
+
27
−
0
View file @
dd6fc894
from
mercurial
import
(
error
,
obsutil
as
hgobsutil
,
)
def
latest_unique_successor
(
ctx
):
"""
Return the latest of unique set of successors of a changeset.
The changeset is given by its context, and a context is also returned,
or `None` if there is no successor.
`Abort` gets raised if there are several sets of successors.
"""
repo
=
ctx
.
repo
()
successorssets
=
hgobsutil
.
successorssets
(
repo
,
ctx
.
node
())
if
not
successorssets
:
return
None
if
len
(
successorssets
)
>
1
:
# There is more than one set of successors, so we have
# a divergence, and we cannot handle it automatically
raise
error
.
Abort
((
"
Changeset %r evolved into a
"
"
divergent state
"
)
%
ctx
.
hex
())
# Single successor set: it can be one or many (split)
# In all cases, we can take the last one.
return
repo
[
successorssets
[
0
][
-
1
]]
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