##// END OF EJS Templates
cmdutil: build "%m" (desc|firstline) in makefilename()
Yuya Nishihara -
r36225:cc46e68f default
parent child Browse files
Show More
@@ -891,13 +891,14 b' def getcommiteditor(edit=False, finishde'
891 else:
891 else:
892 return commiteditor
892 return commiteditor
893
893
894 def makefilename(ctx, pat, desc=None,
894 def makefilename(ctx, pat,
895 total=None, seqno=None, revwidth=None, pathname=None):
895 total=None, seqno=None, revwidth=None, pathname=None):
896 expander = {
896 expander = {
897 'H': lambda: ctx.hex(),
897 'H': lambda: ctx.hex(),
898 'R': lambda: '%d' % ctx.rev(),
898 'R': lambda: '%d' % ctx.rev(),
899 'h': lambda: short(ctx.node()),
899 'h': lambda: short(ctx.node()),
900 'm': lambda: re.sub('[^\w]', '_', desc or ''),
900 'm': lambda: re.sub('[^\w]', '_',
901 ctx.description().rstrip().splitlines()[0]),
901 'r': lambda: ('%d' % ctx.rev()).zfill(revwidth or 0),
902 'r': lambda: ('%d' % ctx.rev()).zfill(revwidth or 0),
902 '%': lambda: '%',
903 '%': lambda: '%',
903 'b': lambda: os.path.basename(ctx.repo().root),
904 'b': lambda: os.path.basename(ctx.repo().root),
@@ -954,7 +955,7 b' class _unclosablefile(object):'
954 def __exit__(self, exc_type, exc_value, exc_tb):
955 def __exit__(self, exc_type, exc_value, exc_tb):
955 pass
956 pass
956
957
957 def makefileobj(ctx, pat, desc=None, total=None,
958 def makefileobj(ctx, pat, total=None,
958 seqno=None, revwidth=None, mode='wb', modemap=None,
959 seqno=None, revwidth=None, mode='wb', modemap=None,
959 pathname=None):
960 pathname=None):
960
961
@@ -967,7 +968,7 b' def makefileobj(ctx, pat, desc=None, tot'
967 else:
968 else:
968 fp = repo.ui.fin
969 fp = repo.ui.fin
969 return _unclosablefile(fp)
970 return _unclosablefile(fp)
970 fn = makefilename(ctx, pat, desc, total, seqno, revwidth, pathname)
971 fn = makefilename(ctx, pat, total, seqno, revwidth, pathname)
971 if modemap is not None:
972 if modemap is not None:
972 mode = modemap.get(fn, mode)
973 mode = modemap.get(fn, mode)
973 if mode == 'wb':
974 if mode == 'wb':
@@ -1542,9 +1543,7 b" def export(repo, revs, fntemplate='hg-%h"
1542 ctx = repo[rev]
1543 ctx = repo[rev]
1543 fo = None
1544 fo = None
1544 if not fp and fntemplate:
1545 if not fp and fntemplate:
1545 desc_lines = ctx.description().rstrip().split('\n')
1546 fo = makefileobj(ctx, fntemplate,
1546 desc = desc_lines[0] #Commit always has a first line.
1547 fo = makefileobj(ctx, fntemplate, desc=desc,
1548 total=total, seqno=seqno, revwidth=revwidth,
1547 total=total, seqno=seqno, revwidth=revwidth,
1549 mode='wb', modemap=filemode)
1548 mode='wb', modemap=filemode)
1550 dest = fo.name
1549 dest = fo.name
General Comments 0
You need to be logged in to leave comments. Login now