Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
mercurial-devel
Manage
Activity
Members
Labels
Plan
Wiki
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
Environments
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
mercurial-devel
Commits
c0ccd70df52c
Commit
c0ccd70df52c
authored
13 years ago
by
Stefano Tortarolo
Browse files
Options
Downloads
Patches
Plain Diff
rebase: reset bookmarks (issue2265 and issue2873)
parent
bb2cffe81a94
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
hgext/rebase.py
+26
-1
26 additions, 1 deletion
hgext/rebase.py
tests/test-rebase-bookmarks.t
+85
-0
85 additions, 0 deletions
tests/test-rebase-bookmarks.t
with
111 additions
and
1 deletion
hgext/rebase.py
+
26
−
1
View file @
c0ccd70d
...
...
@@ -14,7 +14,7 @@
http://mercurial.selenic.com/wiki/RebaseExtension
'''
from
mercurial
import
hg
,
util
,
repair
,
merge
,
cmdutil
,
commands
from
mercurial
import
hg
,
util
,
repair
,
merge
,
cmdutil
,
commands
,
bookmarks
from
mercurial
import
extensions
,
copies
,
patch
from
mercurial.commands
import
templateopts
from
mercurial.node
import
nullrev
...
...
@@ -181,6 +181,9 @@
targetancestors
=
set
(
repo
.
changelog
.
ancestors
(
target
))
targetancestors
.
add
(
target
)
# Keep track of the current bookmarks in order to reset them later
currentbookmarks
=
repo
.
_bookmarks
.
copy
()
sortedstate
=
sorted
(
state
)
total
=
len
(
sortedstate
)
pos
=
0
...
...
@@ -241,6 +244,13 @@
if
'
qtip
'
in
repo
.
tags
():
updatemq
(
repo
,
state
,
skipped
,
**
opts
)
if
currentbookmarks
:
# Nodeids are needed to reset bookmarks
nstate
=
{}
for
k
,
v
in
state
.
iteritems
():
if
v
!=
nullmerge
:
nstate
[
repo
[
k
].
node
()]
=
repo
[
v
].
node
()
if
not
keepf
:
# Remove no more useful revisions
rebased
=
[
rev
for
rev
in
state
if
state
[
rev
]
!=
nullmerge
]
...
...
@@ -252,6 +262,9 @@
# backup the old csets by default
repair
.
strip
(
ui
,
repo
,
repo
[
min
(
rebased
)].
node
(),
"
all
"
)
if
currentbookmarks
:
updatebookmarks
(
repo
,
nstate
,
currentbookmarks
,
**
opts
)
clearstatus
(
repo
)
ui
.
note
(
_
(
"
rebase completed
\n
"
))
if
os
.
path
.
exists
(
repo
.
sjoin
(
'
undo
'
)):
...
...
@@ -401,6 +414,18 @@
mq
.
series_dirty
=
True
mq
.
savedirty
()
def
updatebookmarks
(
repo
,
nstate
,
originalbookmarks
,
**
opts
):
'
Move bookmarks to their correct changesets
'
current
=
repo
.
_bookmarkcurrent
for
k
,
v
in
originalbookmarks
.
iteritems
():
if
v
in
nstate
:
if
nstate
[
v
]
!=
nullmerge
:
# reset the pointer if the bookmark was moved incorrectly
if
k
!=
current
:
repo
.
_bookmarks
[
k
]
=
nstate
[
v
]
bookmarks
.
write
(
repo
)
def
storestatus
(
repo
,
originalwd
,
target
,
state
,
collapse
,
keep
,
keepbranches
,
external
):
'
Store the current status to allow recovery
'
...
...
This diff is collapsed.
Click to expand it.
tests/test-rebase-bookmarks.t
0 → 100644
+
85
−
0
View file @
c0ccd70d
$
cat
>>
$HGRCPATH
<<
EOF
>
[
extensions
]
>
graphlog
=
>
rebase
=
>
>
[
alias
]
>
tglog
=
log
-
G
--
template
"
{rev}: '{desc}' bookmarks: {bookmarks}
\n
"
>
EOF
Create
a
repo
with
several
bookmarks
$
hg
init
a
$
cd
a
$
echo
a
>
a
$
hg
ci
-
Am
A
adding
a
$
echo
b
>
b
$
hg
ci
-
Am
B
adding
b
$
hg
book
'
X
'
$
hg
book
'
Y
'
$
echo
c
>
c
$
hg
ci
-
Am
C
adding
c
$
hg
book
'
Z
'
$
hg
up
-
q 0
$
echo
d
>
d
$
hg
ci
-
Am
D
adding
d
created
new
head
$
hg
tglog
@
3
:
'
D
'
bookmarks:
|
|
o
2
:
'
C
'
bookmarks:
Y
Z
|
|
|
o
1
:
'
B
'
bookmarks:
X
|/
o
0
:
'
A
'
bookmarks:
Move
only
rebased
bookmarks
$
cd
..
$
hg
clone
-
q a
a1
$
cd
a1
$
hg
up
-
q Z
$
hg
rebase
--
detach
-
s Y -d 3
saved backup bundle to $TESTTMP/a1/.hg/strip-backup/*-backup.hg (glob)
$ hg tglog
@ 3: 'C' bookmarks: Y Z
|
o 2: 'D' bookmarks:
|
| o 1: 'B' bookmarks: X
|/
o 0: 'A' bookmarks:
Keep bookmarks to the correct rebased changeset
$ cd ..
$ hg clone -q a a2
$ cd a2
$ hg up -q Z
$ hg rebase -s 1 -d 3
saved backup bundle to $TESTTMP/a2/.hg/strip-backup/*-backup.hg (glob)
$ hg tglog
@ 3: 'C' bookmarks: Y
Z
|
o
2
:
'
B
'
bookmarks:
X
|
o
1
:
'
D
'
bookmarks:
|
o
0
:
'
A
'
bookmarks:
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