Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/cmdutil.py @ 35213:4ee493ea1c13
py3: use pycompat.bytestr() or '%d' in place of str()
Differential Revision: https://phab.mercurial-scm.org/D1556
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Wed, 29 Nov 2017 08:39:48 +0530 |
parents | bfd072c52e03 |
children | 1df2f0e1dfd2 |
comparison
equal
deleted
inserted
replaced
35212:760fef6aca74 | 35213:4ee493ea1c13 |
---|---|
821 | 821 |
822 def makefilename(repo, pat, node, desc=None, | 822 def makefilename(repo, pat, node, desc=None, |
823 total=None, seqno=None, revwidth=None, pathname=None): | 823 total=None, seqno=None, revwidth=None, pathname=None): |
824 node_expander = { | 824 node_expander = { |
825 'H': lambda: hex(node), | 825 'H': lambda: hex(node), |
826 'R': lambda: str(repo.changelog.rev(node)), | 826 'R': lambda: '%d' % repo.changelog.rev(node), |
827 'h': lambda: short(node), | 827 'h': lambda: short(node), |
828 'm': lambda: re.sub('[^\w]', '_', str(desc)) | 828 'm': lambda: re.sub('[^\w]', '_', desc or '') |
829 } | 829 } |
830 expander = { | 830 expander = { |
831 '%': lambda: '%', | 831 '%': lambda: '%', |
832 'b': lambda: os.path.basename(repo.root), | 832 'b': lambda: os.path.basename(repo.root), |
833 } | 833 } |
835 try: | 835 try: |
836 if node: | 836 if node: |
837 expander.update(node_expander) | 837 expander.update(node_expander) |
838 if node: | 838 if node: |
839 expander['r'] = (lambda: | 839 expander['r'] = (lambda: |
840 str(repo.changelog.rev(node)).zfill(revwidth or 0)) | 840 ('%d' % repo.changelog.rev(node)).zfill(revwidth or 0)) |
841 if total is not None: | 841 if total is not None: |
842 expander['N'] = lambda: str(total) | 842 expander['N'] = lambda: '%d' % total |
843 if seqno is not None: | 843 if seqno is not None: |
844 expander['n'] = lambda: str(seqno) | 844 expander['n'] = lambda: '%d' % seqno |
845 if total is not None and seqno is not None: | 845 if total is not None and seqno is not None: |
846 expander['n'] = lambda: str(seqno).zfill(len(str(total))) | 846 expander['n'] = (lambda: ('%d' % seqno).zfill(len('%d' % total))) |
847 if pathname is not None: | 847 if pathname is not None: |
848 expander['s'] = lambda: os.path.basename(pathname) | 848 expander['s'] = lambda: os.path.basename(pathname) |
849 expander['d'] = lambda: os.path.dirname(pathname) or '.' | 849 expander['d'] = lambda: os.path.dirname(pathname) or '.' |
850 expander['p'] = lambda: pathname | 850 expander['p'] = lambda: pathname |
851 | 851 |