##// END OF EJS Templates
merge with stable
Matt Mackall -
r14885:50b67d5c merge default
parent child Browse files
Show More
@@ -0,0 +1,85 b''
1 $ cat >> $HGRCPATH <<EOF
2 > [extensions]
3 > graphlog=
4 > rebase=
5 >
6 > [alias]
7 > tglog = log -G --template "{rev}: '{desc}' bookmarks: {bookmarks}\n"
8 > EOF
9
10 Create a repo with several bookmarks
11 $ hg init a
12 $ cd a
13
14 $ echo a > a
15 $ hg ci -Am A
16 adding a
17
18 $ echo b > b
19 $ hg ci -Am B
20 adding b
21 $ hg book 'X'
22 $ hg book 'Y'
23
24 $ echo c > c
25 $ hg ci -Am C
26 adding c
27 $ hg book 'Z'
28
29 $ hg up -q 0
30
31 $ echo d > d
32 $ hg ci -Am D
33 adding d
34 created new head
35
36 $ hg tglog
37 @ 3: 'D' bookmarks:
38 |
39 | o 2: 'C' bookmarks: Y Z
40 | |
41 | o 1: 'B' bookmarks: X
42 |/
43 o 0: 'A' bookmarks:
44
45
46 Move only rebased bookmarks
47
48 $ cd ..
49 $ hg clone -q a a1
50
51 $ cd a1
52 $ hg up -q Z
53
54 $ hg rebase --detach -s Y -d 3
55 saved backup bundle to $TESTTMP/a1/.hg/strip-backup/*-backup.hg (glob)
56
57 $ hg tglog
58 @ 3: 'C' bookmarks: Y Z
59 |
60 o 2: 'D' bookmarks:
61 |
62 | o 1: 'B' bookmarks: X
63 |/
64 o 0: 'A' bookmarks:
65
66 Keep bookmarks to the correct rebased changeset
67
68 $ cd ..
69 $ hg clone -q a a2
70
71 $ cd a2
72 $ hg up -q Z
73
74 $ hg rebase -s 1 -d 3
75 saved backup bundle to $TESTTMP/a2/.hg/strip-backup/*-backup.hg (glob)
76
77 $ hg tglog
78 @ 3: 'C' bookmarks: Y Z
79 |
80 o 2: 'B' bookmarks: X
81 |
82 o 1: 'D' bookmarks:
83 |
84 o 0: 'A' bookmarks:
85
@@ -14,7 +14,7 b' For more information:'
14 14 http://mercurial.selenic.com/wiki/RebaseExtension
15 15 '''
16 16
17 from mercurial import hg, util, repair, merge, cmdutil, commands
17 from mercurial import hg, util, repair, merge, cmdutil, commands, bookmarks
18 18 from mercurial import extensions, copies, patch
19 19 from mercurial.commands import templateopts
20 20 from mercurial.node import nullrev
@@ -181,6 +181,9 b' def rebase(ui, repo, **opts):'
181 181 targetancestors = set(repo.changelog.ancestors(target))
182 182 targetancestors.add(target)
183 183
184 # Keep track of the current bookmarks in order to reset them later
185 currentbookmarks = repo._bookmarks.copy()
186
184 187 sortedstate = sorted(state)
185 188 total = len(sortedstate)
186 189 pos = 0
@@ -241,6 +244,13 b' def rebase(ui, repo, **opts):'
241 244 if 'qtip' in repo.tags():
242 245 updatemq(repo, state, skipped, **opts)
243 246
247 if currentbookmarks:
248 # Nodeids are needed to reset bookmarks
249 nstate = {}
250 for k, v in state.iteritems():
251 if v != nullmerge:
252 nstate[repo[k].node()] = repo[v].node()
253
244 254 if not keepf:
245 255 # Remove no more useful revisions
246 256 rebased = [rev for rev in state if state[rev] != nullmerge]
@@ -252,6 +262,9 b' def rebase(ui, repo, **opts):'
252 262 # backup the old csets by default
253 263 repair.strip(ui, repo, repo[min(rebased)].node(), "all")
254 264
265 if currentbookmarks:
266 updatebookmarks(repo, nstate, currentbookmarks, **opts)
267
255 268 clearstatus(repo)
256 269 ui.note(_("rebase completed\n"))
257 270 if os.path.exists(repo.sjoin('undo')):
@@ -401,6 +414,18 b' def updatemq(repo, state, skipped, **opt'
401 414 mq.series_dirty = True
402 415 mq.savedirty()
403 416
417 def updatebookmarks(repo, nstate, originalbookmarks, **opts):
418 'Move bookmarks to their correct changesets'
419 current = repo._bookmarkcurrent
420 for k, v in originalbookmarks.iteritems():
421 if v in nstate:
422 if nstate[v] != nullmerge:
423 # reset the pointer if the bookmark was moved incorrectly
424 if k != current:
425 repo._bookmarks[k] = nstate[v]
426
427 bookmarks.write(repo)
428
404 429 def storestatus(repo, originalwd, target, state, collapse, keep, keepbranches,
405 430 external):
406 431 'Store the current status to allow recovery'
General Comments 0
You need to be logged in to leave comments. Login now