comparison hgext/obsolete.py @ 311:5eecfda0a5c7

obsolete: enable rebase --keep again We still never strip anything. But using --keep on the command line dos not lay marker.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Tue, 26 Jun 2012 14:35:09 +0200
parents 2d0dc5c18489
children 63f267bd2176
comparison
equal deleted inserted replaced
310:2d0dc5c18489 311:5eecfda0a5c7
316 nrev = p1 316 nrev = p1
317 repo._rebasestate[rev] = nrev 317 repo._rebasestate[rev] = nrev
318 return newrev 318 return newrev
319 319
320 def cmdrebase(orig, ui, repo, *args, **kwargs): 320 def cmdrebase(orig, ui, repo, *args, **kwargs):
321 if kwargs.get('keep', False): 321
322 raise util.Abort(_('rebase --keep option is unsupported with obsolete ' 322 reallykeep = kwargs.get('keep', False)
323 'extension'), hint=_("see 'hg help obsolete'"))
324 kwargs = dict(kwargs) 323 kwargs = dict(kwargs)
325 kwargs['keep'] = True 324 kwargs['keep'] = True
326 325
327 # We want to mark rebased revision as obsolete and set their 326 # We want to mark rebased revision as obsolete and set their
328 # replacements if any. Doing it in concludenode() prevents 327 # replacements if any. Doing it in concludenode() prevents
333 # added from this state after a successful call. 332 # added from this state after a successful call.
334 repo._rebasestate = {} 333 repo._rebasestate = {}
335 repo._rebasetarget = None 334 repo._rebasetarget = None
336 try: 335 try:
337 res = orig(ui, repo, *args, **kwargs) 336 res = orig(ui, repo, *args, **kwargs)
338 # Filter nullmerge or unrebased entries 337 if not reallykeep:
339 repo._rebasestate = dict(p for p in repo._rebasestate.iteritems() 338 # Filter nullmerge or unrebased entries
340 if p[1] >= 0) 339 repo._rebasestate = dict(p for p in repo._rebasestate.iteritems()
341 if not res and not kwargs.get('abort') and repo._rebasestate: 340 if p[1] >= 0)
342 # Rebased revisions are assumed to be descendants of 341 if not res and not kwargs.get('abort') and repo._rebasestate:
343 # targetrev. If a source revision is mapped to targetrev 342 # Rebased revisions are assumed to be descendants of
344 # or to another rebased revision, it must have been 343 # targetrev. If a source revision is mapped to targetrev
345 # removed. 344 # or to another rebased revision, it must have been
346 targetrev = repo[repo._rebasetarget].rev() 345 # removed.
347 newrevs = set([targetrev]) 346 targetrev = repo[repo._rebasetarget].rev()
348 replacements = {} 347 newrevs = set([targetrev])
349 for rev, newrev in sorted(repo._rebasestate.items()): 348 replacements = {}
350 oldnode = repo[rev].node() 349 for rev, newrev in sorted(repo._rebasestate.items()):
351 if newrev not in newrevs: 350 oldnode = repo[rev].node()
352 newnode = repo[newrev].node() 351 if newrev not in newrevs:
353 newrevs.add(newrev) 352 newnode = repo[newrev].node()
353 newrevs.add(newrev)
354 else:
355 newnode = nullid
356 replacements[oldnode] = newnode
357
358 if kwargs.get('collapse'):
359 newnodes = set(n for n in replacements.values() if n != nullid)
360 if newnodes:
361 # Collapsing into more than one revision?
362 assert len(newnodes) == 1, newnodes
363 newnode = newnodes.pop()
364 else:
365 newnode = nullid
366 repo.addcollapsedobsolete(replacements, newnode)
354 else: 367 else:
355 newnode = nullid 368 for oldnode, newnode in replacements.iteritems():
356 replacements[oldnode] = newnode 369 repo.addobsolete(newnode, oldnode)
357
358 if kwargs.get('collapse'):
359 newnodes = set(n for n in replacements.values() if n != nullid)
360 if newnodes:
361 # Collapsing into more than one revision?
362 assert len(newnodes) == 1, newnodes
363 newnode = newnodes.pop()
364 else:
365 newnode = nullid
366 repo.addcollapsedobsolete(replacements, newnode)
367 else:
368 for oldnode, newnode in replacements.iteritems():
369 repo.addobsolete(newnode, oldnode)
370 return res 370 return res
371 finally: 371 finally:
372 delattr(repo, '_rebasestate') 372 delattr(repo, '_rebasestate')
373 delattr(repo, '_rebasetarget') 373 delattr(repo, '_rebasetarget')
374 374