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