Show More
@@ -301,6 +301,15 b' def _getfilestatus(context, mapping, lis' | |||
|
301 | 301 | revcache['filestatusall'] = listall |
|
302 | 302 | return revcache['filestatus'] |
|
303 | 303 | |
|
304 | def _getfilestatusmap(context, mapping, listall=False): | |
|
305 | revcache = context.resource(mapping, 'revcache') | |
|
306 | if 'filestatusmap' not in revcache or revcache['filestatusall'] < listall: | |
|
307 | stat = _getfilestatus(context, mapping, listall=listall) | |
|
308 | revcache['filestatusmap'] = statmap = {} | |
|
309 | for char, files in zip(pycompat.iterbytestr('MAR!?IC'), stat): | |
|
310 | statmap.update((f, char) for f in files) | |
|
311 | return revcache['filestatusmap'] # {path: statchar} | |
|
312 | ||
|
304 | 313 | def _showfilesbystat(context, mapping, name, index): |
|
305 | 314 | stat = _getfilestatus(context, mapping) |
|
306 | 315 | files = stat[index] |
@@ -595,6 +604,19 b' def showsize(context, mapping):' | |||
|
595 | 604 | fctx = context.resource(mapping, 'fctx') |
|
596 | 605 | return fctx.size() |
|
597 | 606 | |
|
607 | # requires 'fctx' to denote {status} depends on (ctx, path) pair | |
|
608 | @templatekeyword('status', requires={'ctx', 'fctx', 'revcache'}) | |
|
609 | def showstatus(context, mapping): | |
|
610 | """String. Status code of the current file. (EXPERIMENTAL)""" | |
|
611 | path = templateutil.runsymbol(context, mapping, 'path') | |
|
612 | path = templateutil.stringify(context, mapping, path) | |
|
613 | if not path: | |
|
614 | return | |
|
615 | statmap = _getfilestatusmap(context, mapping) | |
|
616 | if path not in statmap: | |
|
617 | statmap = _getfilestatusmap(context, mapping, listall=True) | |
|
618 | return statmap.get(path) | |
|
619 | ||
|
598 | 620 | @templatekeyword("successorssets", requires={'repo', 'ctx'}) |
|
599 | 621 | def showsuccessorssets(context, mapping): |
|
600 | 622 | """Returns a string of sets of successors for a changectx. Format used |
@@ -789,12 +789,19 b' Test file copies dict:' | |||
|
789 | 789 | |
|
790 | 790 | Test file attributes: |
|
791 | 791 | |
|
792 | $ hg log -l1 -T '{files % "{pad(size, 3, left=True)} {path}\n"}' | |
|
793 | a | |
|
794 | 0 b | |
|
795 | 7 fifth | |
|
796 | fourth | |
|
797 | 13 third | |
|
792 | $ hg log -l1 -T '{files % "{status} {pad(size, 3, left=True)} {path}\n"}' | |
|
793 | R a | |
|
794 | A 0 b | |
|
795 | A 7 fifth | |
|
796 | R fourth | |
|
797 | M 13 third | |
|
798 | ||
|
799 | Test file status including clean ones: | |
|
800 | ||
|
801 | $ hg log -r9 -T '{files("**") % "{status} {path}\n"}' | |
|
802 | A a | |
|
803 | C fourth | |
|
804 | C third | |
|
798 | 805 | |
|
799 | 806 | Test index keyword: |
|
800 | 807 |
General Comments 0
You need to be logged in to leave comments.
Login now