Mercurial > hg-stable
comparison mercurial/cmdutil.py @ 36244:9ddc884e9a32
cmdutil: rewrite makefilename() to use ctx methods
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Thu, 02 Apr 2015 23:37:07 +0900 |
parents | 976e1cfb2f64 |
children | cc46e68f050f |
comparison
equal
deleted
inserted
replaced
36243:976e1cfb2f64 | 36244:9ddc884e9a32 |
---|---|
891 else: | 891 else: |
892 return commiteditor | 892 return commiteditor |
893 | 893 |
894 def makefilename(ctx, pat, desc=None, | 894 def makefilename(ctx, pat, desc=None, |
895 total=None, seqno=None, revwidth=None, pathname=None): | 895 total=None, seqno=None, revwidth=None, pathname=None): |
896 repo = ctx.repo() | |
897 node = ctx.node() | |
898 expander = { | 896 expander = { |
899 'H': lambda: hex(node), | 897 'H': lambda: ctx.hex(), |
900 'R': lambda: '%d' % repo.changelog.rev(node), | 898 'R': lambda: '%d' % ctx.rev(), |
901 'h': lambda: short(node), | 899 'h': lambda: short(ctx.node()), |
902 'm': lambda: re.sub('[^\w]', '_', desc or ''), | 900 'm': lambda: re.sub('[^\w]', '_', desc or ''), |
903 'r': lambda: ('%d' % repo.changelog.rev(node)).zfill(revwidth or 0), | 901 'r': lambda: ('%d' % ctx.rev()).zfill(revwidth or 0), |
904 '%': lambda: '%', | 902 '%': lambda: '%', |
905 'b': lambda: os.path.basename(repo.root), | 903 'b': lambda: os.path.basename(ctx.repo().root), |
906 } | 904 } |
907 | 905 |
908 try: | 906 try: |
909 if total is not None: | 907 if total is not None: |
910 expander['N'] = lambda: '%d' % total | 908 expander['N'] = lambda: '%d' % total |