comparison mercurial/subrepo.py @ 24470:76b0b0fed2e3

subrepo: add dirtyreason to centralize composing dirty reason message This patch newly adds "dirtyreason()" to centralize composing dirty reason message like "uncommitted changes in subrepository 'xxxx'". There are 3 similar messages below, and this patch is a part of preparations for unifying them into (1), too. 1. uncommitted changes in subrepository 'XXXX' 2. uncommitted changes in subrepository XXXX 3. uncommitted changes in subrepo XXXX This patch chooses adding new method "dirtyreason()" instead of making "dirty()" return "reason string", because: - some of existing "dirty()" implementation is too complicated to do so simply, and - ill-mannered 3rd party subrepo classes, of which "dirty()" doesn't return "reason string", cause meaningless message (even though it is rare case)
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Wed, 25 Mar 2015 13:55:32 +0900
parents a8595176dd64
children 1ff35d76421c
comparison
equal deleted inserted replaced
24469:e71053ef0c46 24470:76b0b0fed2e3
388 match current stored state. If ignoreupdate is true, only check 388 match current stored state. If ignoreupdate is true, only check
389 whether the subrepo has uncommitted changes in its dirstate. 389 whether the subrepo has uncommitted changes in its dirstate.
390 """ 390 """
391 raise NotImplementedError 391 raise NotImplementedError
392 392
393 def dirtyreason(self, ignoreupdate=False):
394 """return reason string if it is ``dirty()``
395
396 Returned string should have enough information for the message
397 of exception.
398
399 This returns None, otherwise.
400 """
401 if self.dirty(ignoreupdate=ignoreupdate):
402 return _("uncommitted changes in subrepository '%s'"
403 ) % subrelpath(self)
404
393 def basestate(self): 405 def basestate(self):
394 """current working directory base state, disregarding .hgsubstate 406 """current working directory base state, disregarding .hgsubstate
395 state and working directory modifications""" 407 state and working directory modifications"""
396 raise NotImplementedError 408 raise NotImplementedError
397 409