Show More
@@ -69,11 +69,12 def _makeextrafn(copiers): | |||
|
69 | 69 | c(ctx, extra) |
|
70 | 70 | return extrafn |
|
71 | 71 | |
|
72 | def _destrebase(repo): | |
|
73 | # Destination defaults to the latest revision in the | |
|
74 | # current branch | |
|
75 | branch = repo[None].branch() | |
|
76 | return repo[branch].rev() | |
|
72 | def _destrebase(repo, sourceset): | |
|
73 | """small wrapper around destmerge to pass the right extra args | |
|
74 | ||
|
75 | Please wrap destutil.destmerge instead.""" | |
|
76 | return destutil.destmerge(repo, action='rebase', sourceset=sourceset, | |
|
77 | onheadcheck=False) | |
|
77 | 78 | |
|
78 | 79 | revsetpredicate = revset.extpredicate() |
|
79 | 80 | |
@@ -83,12 +84,12 def _revsetdestrebase(repo, subset, x): | |||
|
83 | 84 | |
|
84 | 85 | # default destination for rebase. |
|
85 | 86 | # # XXX: Currently private because I expect the signature to change. |
|
86 | # # XXX: - taking rev as arguments, | |
|
87 | 87 | # # XXX: - bailing out in case of ambiguity vs returning all data. |
|
88 | # # XXX: - probably merging with the merge destination. | |
|
89 | 88 | # i18n: "_rebasedefaultdest" is a keyword |
|
90 | revset.getargs(x, 0, 0, _("_rebasedefaultdest takes no arguments")) | |
|
91 | return subset & revset.baseset([_destrebase(repo)]) | |
|
89 | sourceset = None | |
|
90 | if x is not None: | |
|
91 | sourceset = revset.getset(repo, revset.fullreposet(repo), x) | |
|
92 | return subset & revset.baseset([_destrebase(repo, sourceset)]) | |
|
92 | 93 | |
|
93 | 94 | @command('rebase', |
|
94 | 95 | [('s', 'source', '', |
@@ -127,10 +128,13 def rebase(ui, repo, **opts): | |||
|
127 | 128 | Published commits cannot be rebased (see :hg:`help phases`). |
|
128 | 129 | To copy commits, see :hg:`help graft`. |
|
129 | 130 | |
|
130 | If you don't specify a destination changeset (``-d/--dest``), | |
|
131 | rebase uses the current branch tip as the destination. (The | |
|
132 | destination changeset is not modified by rebasing, but new | |
|
133 | changesets are added as its descendants.) | |
|
131 | If you don't specify a destination changeset (``-d/--dest``), rebase | |
|
132 | will use the same logic as :hg:`merge` to pick a destination. if | |
|
133 | the current branch contains exactly one other head, the other head | |
|
134 | is merged with by default. Otherwise, an explicit revision with | |
|
135 | which to merge with must be provided. (destination changeset is not | |
|
136 | modified by rebasing, but new changesets are added as its | |
|
137 | descendants.) | |
|
134 | 138 | |
|
135 | 139 | Here are the ways to select changesets: |
|
136 | 140 | |
@@ -544,9 +548,6 def _definesets(ui, repo, destf=None, sr | |||
|
544 | 548 | |
|
545 | 549 | if destf: |
|
546 | 550 | dest = scmutil.revsingle(repo, destf) |
|
547 | else: | |
|
548 | dest = repo[_destrebase(repo)] | |
|
549 | destf = str(dest) | |
|
550 | 551 | |
|
551 | 552 | if revf: |
|
552 | 553 | rebaseset = scmutil.revrange(repo, revf) |
@@ -566,6 +567,10 def _definesets(ui, repo, destf=None, sr | |||
|
566 | 567 | ui.status(_('empty "base" revision set - ' |
|
567 | 568 | "can't compute rebase set\n")) |
|
568 | 569 | return None, None |
|
570 | if not destf: | |
|
571 | dest = repo[_destrebase(repo, base)] | |
|
572 | destf = str(dest) | |
|
573 | ||
|
569 | 574 | commonanc = repo.revs('ancestor(%ld, %d)', base, dest).first() |
|
570 | 575 | if commonanc is not None: |
|
571 | 576 | rebaseset = repo.revs('(%d::(%ld) - %d)::', |
@@ -599,6 +604,11 def _definesets(ui, repo, destf=None, sr | |||
|
599 | 604 | ui.status(_('nothing to rebase from %s to %s\n') % |
|
600 | 605 | ('+'.join(str(repo[r]) for r in base), dest)) |
|
601 | 606 | return None, None |
|
607 | ||
|
608 | if not destf: | |
|
609 | dest = repo[_destrebase(repo, rebaseset)] | |
|
610 | destf = str(dest) | |
|
611 | ||
|
602 | 612 | return dest, rebaseset |
|
603 | 613 | |
|
604 | 614 | def externalparent(repo, state, targetancestors): |
@@ -1198,9 +1208,15 def pullrebase(orig, ui, repo, *args, ** | |||
|
1198 | 1208 | # --source. |
|
1199 | 1209 | if 'source' in opts: |
|
1200 | 1210 | del opts['source'] |
|
1201 | if rebase(ui, repo, **opts) == _nothingtorebase(): | |
|
1211 | try: | |
|
1212 | rebase(ui, repo, **opts) | |
|
1213 | except error.NoMergeDestAbort: | |
|
1214 | # we can maybe update instead | |
|
1202 | 1215 | rev, _a, _b = destutil.destupdate(repo) |
|
1203 |
if rev |
|
|
1216 | if rev == repo['.'].rev(): | |
|
1217 | ui.status(_('nothing to rebase\n')) | |
|
1218 | else: | |
|
1219 | ui.status(_('nothing to rebase - updating instead\n')) | |
|
1204 | 1220 | # not passing argument to get the bare update behavior |
|
1205 | 1221 | # with warning and trumpets |
|
1206 | 1222 | commands.update(ui, repo) |
@@ -141,6 +141,10 msgdestmerge = { | |||
|
141 | 141 | (_("multiple matching bookmarks to merge -" |
|
142 | 142 | " please merge with an explicit rev or bookmark"), |
|
143 | 143 | _("run 'hg heads' to see all heads")), |
|
144 | 'rebase': | |
|
145 | (_("multiple matching bookmarks to rebase -" | |
|
146 | " please rebase to an explicit rev or bookmark"), | |
|
147 | _("run 'hg heads' to see all heads")), | |
|
144 | 148 | }, |
|
145 | 149 | # no other matching divergent bookmark |
|
146 | 150 | 'nootherbookmarks': |
@@ -148,52 +152,80 msgdestmerge = { | |||
|
148 | 152 | (_("no matching bookmark to merge - " |
|
149 | 153 | "please merge with an explicit rev or bookmark"), |
|
150 | 154 | _("run 'hg heads' to see all heads")), |
|
155 | 'rebase': | |
|
156 | (_("no matching bookmark to rebase - " | |
|
157 | "please rebase to an explicit rev or bookmark"), | |
|
158 | _("run 'hg heads' to see all heads")), | |
|
151 | 159 | }, |
|
152 | 160 | # branch have too many unbookmarked heads, no obvious destination |
|
153 | 161 | 'toomanyheads': |
|
154 | 162 | {'merge': |
|
155 | 163 | (_("branch '%s' has %d heads - please merge with an explicit rev"), |
|
156 | 164 | _("run 'hg heads .' to see heads")), |
|
165 | 'rebase': | |
|
166 | (_("branch '%s' has %d heads - please rebase to an explicit rev"), | |
|
167 | _("run 'hg heads .' to see heads")), | |
|
157 | 168 | }, |
|
158 | 169 | # branch have no other unbookmarked heads |
|
159 | 170 | 'bookmarkedheads': |
|
160 | 171 | {'merge': |
|
161 | 172 | (_("heads are bookmarked - please merge with an explicit rev"), |
|
162 | 173 | _("run 'hg heads' to see all heads")), |
|
174 | 'rebase': | |
|
175 | (_("heads are bookmarked - please rebase to an explicit rev"), | |
|
176 | _("run 'hg heads' to see all heads")), | |
|
163 | 177 | }, |
|
164 | 178 | # branch have just a single heads, but there is other branches |
|
165 | 179 | 'nootherbranchheads': |
|
166 | 180 | {'merge': |
|
167 | 181 | (_("branch '%s' has one head - please merge with an explicit rev"), |
|
168 | 182 | _("run 'hg heads' to see all heads")), |
|
183 | 'rebase': | |
|
184 | (_("branch '%s' has one head - please rebase to an explicit rev"), | |
|
185 | _("run 'hg heads' to see all heads")), | |
|
169 | 186 | }, |
|
170 | 187 | # repository have a single head |
|
171 | 188 | 'nootherheads': |
|
172 | 189 |
|
|
173 | 190 |
|
|
174 | 191 | None), |
|
192 | 'rebase': | |
|
193 | (_('nothing to rebase'), | |
|
194 | None), | |
|
175 | 195 | }, |
|
176 | 196 | # repository have a single head and we are not on it |
|
177 | 197 | 'nootherheadsbehind': |
|
178 | 198 | {'merge': |
|
179 | 199 | (_('nothing to merge'), |
|
180 | 200 | _("use 'hg update' instead")), |
|
201 | 'rebase': | |
|
202 | (_('nothing to rebase'), | |
|
203 | _("use 'hg update' instead")), | |
|
181 | 204 | }, |
|
182 | 205 | # We are not on a head |
|
183 | 206 | 'notatheads': |
|
184 | 207 | {'merge': |
|
185 | 208 | (_('working directory not at a head revision'), |
|
186 | _("use 'hg update' or merge with an explicit revision")) | |
|
209 | _("use 'hg update' or merge with an explicit revision")), | |
|
210 | 'rebase': | |
|
211 | (_('working directory not at a head revision'), | |
|
212 | _("use 'hg update' or rebase to an explicit revision")) | |
|
187 | 213 | }, |
|
188 | 214 | 'emptysourceset': |
|
189 | 215 | {'merge': |
|
190 | 216 | (_('source set is empty'), |
|
191 | None) | |
|
217 | None), | |
|
218 | 'rebase': | |
|
219 | (_('source set is empty'), | |
|
220 | None), | |
|
192 | 221 | }, |
|
193 | 222 | 'multiplebranchessourceset': |
|
194 | 223 | {'merge': |
|
195 | 224 | (_('source set is rooted in multiple branches'), |
|
196 | None) | |
|
225 | None), | |
|
226 | 'rebase': | |
|
227 | (_('rebaseset is rooted in multiple named branches'), | |
|
228 | _('specify an explicit destination with --dest')), | |
|
197 | 229 | }, |
|
198 | 230 | } |
|
199 | 231 |
@@ -1095,7 +1095,7 Test "pull --rebase" when rebase is enab | |||
|
1095 | 1095 | adding manifests |
|
1096 | 1096 | adding file changes |
|
1097 | 1097 | added 1 changesets with 1 changes to 1 files |
|
1098 | nothing to rebase - working directory parent is already an ancestor of destination bf5e395ced2c | |
|
1098 | nothing to rebase - updating instead | |
|
1099 | 1099 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1100 | 1100 | |
|
1101 | 1101 | $ cd .. |
@@ -327,14 +327,13 rebase 'b2' to another lower branch head | |||
|
327 | 327 | |
|
328 | 328 | $ hg up -qr 2 |
|
329 | 329 | $ hg rebase |
|
330 | nothing to rebase - working directory parent is also destination | |
|
331 | [1] | |
|
330 | rebasing 2:792845bb77ee "b2" | |
|
331 | note: rebase of 2:792845bb77ee created no changes to commit | |
|
332 | saved backup bundle to $TESTTMP/case1/.hg/strip-backup/792845bb77ee-627120ee-backup.hg (glob) | |
|
332 | 333 | $ hg tglog |
|
333 |
o |
|
|
334 | o 2: 'c1' c | |
|
334 | 335 | | |
|
335 |
| @ |
|
|
336 | |/ | |
|
337 | | o 1: 'b1' b | |
|
336 | | @ 1: 'b1' b | |
|
338 | 337 | |/ |
|
339 | 338 | o 0: '0' |
|
340 | 339 | |
@@ -373,8 +372,9 rebase 'c1' to the branch head 'c2' that | |||
|
373 | 372 | o 0: '0' |
|
374 | 373 | |
|
375 | 374 | $ hg rebase |
|
376 | nothing to rebase - working directory parent is also destination | |
|
377 | [1] | |
|
375 | abort: branch 'c' has one head - please rebase to an explicit rev | |
|
376 | (run 'hg heads' to see all heads) | |
|
377 | [255] | |
|
378 | 378 | $ hg tglog |
|
379 | 379 | _ 4: 'c2 closed' c |
|
380 | 380 | | |
@@ -85,7 +85,7 Invoke pull --rebase and nothing to reba | |||
|
85 | 85 | adding manifests |
|
86 | 86 | adding file changes |
|
87 | 87 | added 1 changesets with 1 changes to 1 files |
|
88 | nothing to rebase - working directory parent is already an ancestor of destination 77ae9631bcca | |
|
88 | nothing to rebase - updating instead | |
|
89 | 89 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
90 | 90 | updating bookmark norebase |
|
91 | 91 | |
@@ -285,7 +285,7 pull --rebase update (no rebase) use pro | |||
|
285 | 285 | adding manifests |
|
286 | 286 | adding file changes |
|
287 | 287 | added 1 changesets with 1 changes to 1 files (+1 heads) |
|
288 | nothing to rebase - working directory parent is already an ancestor of destination 65bc164c1d9b | |
|
288 | nothing to rebase - updating instead | |
|
289 | 289 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
290 | 290 | 1 other heads for branch "default" |
|
291 | 291 | $ hg tglog |
@@ -818,13 +818,17 Testing from lower head | |||
|
818 | 818 | |
|
819 | 819 | Testing from upper head |
|
820 | 820 | |
|
821 | $ hg log -r '_destrebase(4)' | |
|
822 | changeset: 3:1910d5ff34ea | |
|
823 | user: test | |
|
824 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
825 | summary: second source with subdir | |
|
826 | ||
|
821 | 827 | $ hg up 4 |
|
822 | 828 | 1 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
823 | 829 | $ hg log -r '_destrebase()' |
|
824 |
changeset: |
|
|
825 | tag: tip | |
|
826 | parent: 1:58d79cc1cf43 | |
|
830 | changeset: 3:1910d5ff34ea | |
|
827 | 831 | user: test |
|
828 | 832 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
829 | summary: aaa | |
|
833 | summary: second source with subdir | |
|
830 | 834 |
General Comments 0
You need to be logged in to leave comments.
Login now