##// END OF EJS Templates
destutil: add the ability to specify a search space for rebase destination...
Pierre-Yves David -
r29043:cf7de4ae stable
parent child Browse files
Show More
@@ -69,12 +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, sourceset):
72 def _destrebase(repo, sourceset, destspace=None):
73 """small wrapper around destmerge to pass the right extra args
73 """small wrapper around destmerge to pass the right extra args
74
74
75 Please wrap destutil.destmerge instead."""
75 Please wrap destutil.destmerge instead."""
76 return destutil.destmerge(repo, action='rebase', sourceset=sourceset,
76 return destutil.destmerge(repo, action='rebase', sourceset=sourceset,
77 onheadcheck=False)
77 onheadcheck=False, destspace=destspace)
78
78
79 revsetpredicate = registrar.revsetpredicate()
79 revsetpredicate = registrar.revsetpredicate()
80
80
@@ -222,6 +222,9 b' def rebase(ui, repo, **opts):'
222 srcf = opts.get('source', None)
222 srcf = opts.get('source', None)
223 basef = opts.get('base', None)
223 basef = opts.get('base', None)
224 revf = opts.get('rev', [])
224 revf = opts.get('rev', [])
225 # search default destination in this space
226 # used in the 'hg pull --rebase' case, see issue 5214.
227 destspace = opts.get('_destspace')
225 contf = opts.get('continue')
228 contf = opts.get('continue')
226 abortf = opts.get('abort')
229 abortf = opts.get('abort')
227 collapsef = opts.get('collapse', False)
230 collapsef = opts.get('collapse', False)
@@ -296,7 +299,8 b' def rebase(ui, repo, **opts):'
296 _checkobsrebase(repo, ui, rebaseobsrevs, rebasesetrevs,
299 _checkobsrebase(repo, ui, rebaseobsrevs, rebasesetrevs,
297 rebaseobsskipped)
300 rebaseobsskipped)
298 else:
301 else:
299 dest, rebaseset = _definesets(ui, repo, destf, srcf, basef, revf)
302 dest, rebaseset = _definesets(ui, repo, destf, srcf, basef, revf,
303 destspace=destspace)
300 if dest is None:
304 if dest is None:
301 return _nothingtorebase()
305 return _nothingtorebase()
302
306
@@ -525,9 +529,12 b' def rebase(ui, repo, **opts):'
525 finally:
529 finally:
526 release(lock, wlock)
530 release(lock, wlock)
527
531
528 def _definesets(ui, repo, destf=None, srcf=None, basef=None, revf=[]):
532 def _definesets(ui, repo, destf=None, srcf=None, basef=None, revf=[],
533 destspace=None):
529 """use revisions argument to define destination and rebase set
534 """use revisions argument to define destination and rebase set
530 """
535 """
536 # destspace is here to work around issues with `hg pull --rebase` see
537 # issue5214 for details
531 if srcf and basef:
538 if srcf and basef:
532 raise error.Abort(_('cannot specify both a source and a base'))
539 raise error.Abort(_('cannot specify both a source and a base'))
533 if revf and basef:
540 if revf and basef:
@@ -560,7 +567,7 b' def _definesets(ui, repo, destf=None, sr'
560 "can't compute rebase set\n"))
567 "can't compute rebase set\n"))
561 return None, None
568 return None, None
562 if not destf:
569 if not destf:
563 dest = repo[_destrebase(repo, base)]
570 dest = repo[_destrebase(repo, base, destspace=destspace)]
564 destf = str(dest)
571 destf = str(dest)
565
572
566 commonanc = repo.revs('ancestor(%ld, %d)', base, dest).first()
573 commonanc = repo.revs('ancestor(%ld, %d)', base, dest).first()
@@ -598,7 +605,7 b' def _definesets(ui, repo, destf=None, sr'
598 return None, None
605 return None, None
599
606
600 if not destf:
607 if not destf:
601 dest = repo[_destrebase(repo, rebaseset)]
608 dest = repo[_destrebase(repo, rebaseset, destspace=destspace)]
602 destf = str(dest)
609 destf = str(dest)
603
610
604 return dest, rebaseset
611 return dest, rebaseset
@@ -256,7 +256,7 b' msgdestmerge = {'
256 },
256 },
257 }
257 }
258
258
259 def _destmergebook(repo, action='merge', sourceset=None):
259 def _destmergebook(repo, action='merge', sourceset=None, destspace=None):
260 """find merge destination in the active bookmark case"""
260 """find merge destination in the active bookmark case"""
261 node = None
261 node = None
262 bmheads = repo.bookmarkheads(repo._activebookmark)
262 bmheads = repo.bookmarkheads(repo._activebookmark)
@@ -275,7 +275,8 b" def _destmergebook(repo, action='merge',"
275 assert node is not None
275 assert node is not None
276 return node
276 return node
277
277
278 def _destmergebranch(repo, action='merge', sourceset=None, onheadcheck=True):
278 def _destmergebranch(repo, action='merge', sourceset=None, onheadcheck=True,
279 destspace=None):
279 """find merge destination based on branch heads"""
280 """find merge destination based on branch heads"""
280 node = None
281 node = None
281
282
@@ -308,6 +309,12 b" def _destmergebranch(repo, action='merge"
308 bheads = list(repo.revs('%ln - (%ld::)', bheads, sourceset))
309 bheads = list(repo.revs('%ln - (%ld::)', bheads, sourceset))
309 # filters out bookmarked heads
310 # filters out bookmarked heads
310 nbhs = list(repo.revs('%ld - bookmark()', bheads))
311 nbhs = list(repo.revs('%ld - bookmark()', bheads))
312
313 if destspace is not None:
314 # restrict search space
315 # used in the 'hg pull --rebase' case, see issue 5214.
316 nbhs = list(repo.revs('%ld and %ld', destspace, nbhs))
317
311 if len(nbhs) > 1:
318 if len(nbhs) > 1:
312 # Case B: There is more than 1 other anonymous heads
319 # Case B: There is more than 1 other anonymous heads
313 #
320 #
@@ -339,18 +346,22 b" def _destmergebranch(repo, action='merge"
339 assert node is not None
346 assert node is not None
340 return node
347 return node
341
348
342 def destmerge(repo, action='merge', sourceset=None, onheadcheck=True):
349 def destmerge(repo, action='merge', sourceset=None, onheadcheck=True,
350 destspace=None):
343 """return the default destination for a merge
351 """return the default destination for a merge
344
352
345 (or raise exception about why it can't pick one)
353 (or raise exception about why it can't pick one)
346
354
347 :action: the action being performed, controls emitted error message
355 :action: the action being performed, controls emitted error message
348 """
356 """
357 # destspace is here to work around issues with `hg pull --rebase` see
358 # issue5214 for details
349 if repo._activebookmark:
359 if repo._activebookmark:
350 node = _destmergebook(repo, action=action, sourceset=sourceset)
360 node = _destmergebook(repo, action=action, sourceset=sourceset,
361 destspace=destspace)
351 else:
362 else:
352 node = _destmergebranch(repo, action=action, sourceset=sourceset,
363 node = _destmergebranch(repo, action=action, sourceset=sourceset,
353 onheadcheck=onheadcheck)
364 onheadcheck=onheadcheck, destspace=destspace)
354 return repo[node].rev()
365 return repo[node].rev()
355
366
356 histeditdefaultrevset = 'reverse(only(.) and not public() and not ::merge())'
367 histeditdefaultrevset = 'reverse(only(.) and not public() and not ::merge())'
General Comments 0
You need to be logged in to leave comments. Login now