Mercurial > public > mercurial-scm > hg-stable
diff hgext/largefiles/lfutil.py @ 23188:94ac64bcf6fe
largefiles: introduce "_lfstatuswriters" to customize status reporting
"lfutil.getstatuswriter" is the utility to get appropriate function to
write largefiles specific status out from "repo._lfstatuswriters".
This patch uses "stack" with an element instead of flag like
"_isXXXXing" or so, because:
- the former works correctly even when customizations are nested, and
- ensuring at least one element can ignore empty check
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Wed, 05 Nov 2014 23:24:47 +0900 |
parents | f726b05ecfe6 |
children | 236c978bceca |
line wrap: on
line diff
--- a/hgext/largefiles/lfutil.py Wed Nov 05 23:24:47 2014 +0900 +++ b/hgext/largefiles/lfutil.py Wed Nov 05 23:24:47 2014 +0900 @@ -557,3 +557,20 @@ return updatestandinsbymatch(repo, match) else: return match + +def getstatuswriter(ui, repo, forcibly=None): + '''Return the function to write largefiles specific status out + + If ``forcibly`` is ``None``, this returns the last element of + ``repo._lfupdatereporters`` as "default" writer function. + + Otherwise, this returns the function to always write out (or + ignore if ``not forcibly``) status. + ''' + if forcibly is None: + return repo._lfstatuswriters[-1] + else: + if forcibly: + return ui.status # forcibly WRITE OUT + else: + return lambda *msg, **opts: None # forcibly IGNORE