##// END OF EJS Templates
cmdutil: provide a way to report how to continue...
timeless -
r28120:ed4d06f1 default
parent child Browse files
Show More
@@ -3347,13 +3347,56 afterresolvedstates = [
3347 3347 _('hg graft --continue')),
3348 3348 ]
3349 3349
3350 def checkafterresolved(repo):
3351 contmsg = _("continue: %s\n")
3350 def howtocontinue(repo):
3351 '''Check for an unfinished operation and return the command to finish
3352 it.
3353
3354 afterresolvedstates tupples define a .hg/{file} and the corresponding
3355 command needed to finish it.
3356
3357 Returns a (msg, warning) tuple. 'msg' is a string and 'warning' is
3358 a boolean.
3359 '''
3360 contmsg = _("continue: %s")
3352 3361 for f, msg in afterresolvedstates:
3353 3362 if repo.vfs.exists(f):
3354 repo.ui.warn(contmsg % msg)
3355 return
3356 repo.ui.note(contmsg % _("hg commit"))
3363 return contmsg % msg, True
3364 workingctx = repo[None]
3365 dirty = any(repo.status()) or any(workingctx.sub(s).dirty()
3366 for s in workingctx.substate)
3367 if dirty:
3368 return contmsg % _("hg commit"), False
3369 return None, None
3370
3371 def checkafterresolved(repo):
3372 '''Inform the user about the next action after completing hg resolve
3373
3374 If there's a matching afterresolvedstates, howtocontinue will yield
3375 repo.ui.warn as the reporter.
3376
3377 Otherwise, it will yield repo.ui.note.
3378 '''
3379 msg, warning = howtocontinue(repo)
3380 if msg is not None:
3381 if warning:
3382 repo.ui.warn("%s\n" % msg)
3383 else:
3384 repo.ui.note("%s\n" % msg)
3385
3386 def wrongtooltocontinue(repo, task):
3387 '''Raise an abort suggesting how to properly continue if there is an
3388 active task.
3389
3390 Uses howtocontinue() to find the active task.
3391
3392 If there's no task (repo.ui.note for 'hg commit'), it does not offer
3393 a hint.
3394 '''
3395 after = howtocontinue(repo)
3396 hint = None
3397 if after[1]:
3398 hint = after[0]
3399 raise error.Abort(_('no %s in progress') % task, hint=hint)
3357 3400
3358 3401 class dirstateguard(object):
3359 3402 '''Restore dirstate at unexpected failure.
General Comments 0
You need to be logged in to leave comments. Login now