comparison mercurial/cmdutil.py @ 30755:0fbb3a5c188e

rebase: provide detailed hint to abort message if working dir is not clean Detailed hint message is now provided when 'pull --rebase' operation detects unclean working dir, for example: abort: uncommitted changes (cannot pull with rebase: please commit or shelve your changes first) Added tests for uncommitted merge, and for subrepo support verifying that same hint is also passed to subrepo state check.
author Valters Vingolds <valters@vingolds.ch>
date Tue, 10 Jan 2017 09:32:27 +0100
parents ee47e951c6f9
children bd5e9647f646
comparison
equal deleted inserted replaced
30754:26209cb7184e 30755:0fbb3a5c188e
353 if p == oldp: 353 if p == oldp:
354 return None 354 return None
355 355
356 return p 356 return p
357 357
358 def bailifchanged(repo, merge=True): 358 def bailifchanged(repo, merge=True, hint=None):
359 """ enforce the precondition that working directory must be clean.
360
361 'merge' can be set to false if a pending uncommitted merge should be
362 ignored (such as when 'update --check' runs).
363
364 'hint' is the usual hint given to Abort exception.
365 """
366
359 if merge and repo.dirstate.p2() != nullid: 367 if merge and repo.dirstate.p2() != nullid:
360 raise error.Abort(_('outstanding uncommitted merge')) 368 raise error.Abort(_('outstanding uncommitted merge'), hint=hint)
361 modified, added, removed, deleted = repo.status()[:4] 369 modified, added, removed, deleted = repo.status()[:4]
362 if modified or added or removed or deleted: 370 if modified or added or removed or deleted:
363 raise error.Abort(_('uncommitted changes')) 371 raise error.Abort(_('uncommitted changes'), hint=hint)
364 ctx = repo[None] 372 ctx = repo[None]
365 for s in sorted(ctx.substate): 373 for s in sorted(ctx.substate):
366 ctx.sub(s).bailifchanged() 374 ctx.sub(s).bailifchanged(hint=hint)
367 375
368 def logmessage(ui, opts): 376 def logmessage(ui, opts):
369 """ get the log message according to -m and -l option """ 377 """ get the log message according to -m and -l option """
370 message = opts.get('message') 378 message = opts.get('message')
371 logfile = opts.get('logfile') 379 logfile = opts.get('logfile')