|
@@
-8,7
+8,7
b''
|
|
8
|
from node import hex
|
|
8
|
from node import hex
|
|
9
|
import encoding, patch, util, error
|
|
9
|
import encoding, patch, util, error
|
|
10
|
|
|
10
|
|
|
11
|
def showlist(templ, name, values, plural=None, **args):
|
|
11
|
def showlist(name, values, plural=None, **args):
|
|
12
|
'''expand set of values.
|
|
12
|
'''expand set of values.
|
|
13
|
name is name of key in template map.
|
|
13
|
name is name of key in template map.
|
|
14
|
values is list of strings or dicts.
|
|
14
|
values is list of strings or dicts.
|
|
@@
-28,6
+28,7
b' def showlist(templ, name, values, plural'
|
|
28
|
|
|
28
|
|
|
29
|
expand 'end_foos'.
|
|
29
|
expand 'end_foos'.
|
|
30
|
'''
|
|
30
|
'''
|
|
|
|
|
31
|
templ = args['templ']
|
|
31
|
if plural: names = plural
|
|
32
|
if plural: names = plural
|
|
32
|
else: names = name + 's'
|
|
33
|
else: names = name + 's'
|
|
33
|
if not values:
|
|
34
|
if not values:
|
|
@@
-143,11
+144,11
b' def getrenamedfn(repo, endrev=None):'
|
|
143
|
def showauthor(repo, ctx, templ, **args):
|
|
144
|
def showauthor(repo, ctx, templ, **args):
|
|
144
|
return ctx.user()
|
|
145
|
return ctx.user()
|
|
145
|
|
|
146
|
|
|
146
|
def showbranches(repo, ctx, templ, **args):
|
|
147
|
def showbranches(**args):
|
|
147
|
branch = ctx.branch()
|
|
148
|
branch = args['ctx'].branch()
|
|
148
|
if branch != 'default':
|
|
149
|
if branch != 'default':
|
|
149
|
branch = encoding.tolocal(branch)
|
|
150
|
branch = encoding.tolocal(branch)
|
|
150
|
return showlist(templ, 'branch', [branch], plural='branches', **args)
|
|
151
|
return showlist('branch', [branch], plural='branches', **args)
|
|
151
|
|
|
152
|
|
|
152
|
def showdate(repo, ctx, templ, **args):
|
|
153
|
def showdate(repo, ctx, templ, **args):
|
|
153
|
return ctx.date()
|
|
154
|
return ctx.date()
|
|
@@
-164,20
+165,23
b' def showdiffstat(repo, ctx, templ, **arg'
|
|
164
|
removes += i[2]
|
|
165
|
removes += i[2]
|
|
165
|
return '%s: +%s/-%s' % (files, adds, removes)
|
|
166
|
return '%s: +%s/-%s' % (files, adds, removes)
|
|
166
|
|
|
167
|
|
|
167
|
def showextras(repo, ctx, templ, **args):
|
|
168
|
def showextras(**args):
|
|
168
|
for key, value in sorted(ctx.extra().items()):
|
|
169
|
templ = args['templ']
|
|
|
|
|
170
|
for key, value in sorted(args['ctx'].extra().items()):
|
|
169
|
args = args.copy()
|
|
171
|
args = args.copy()
|
|
170
|
args.update(dict(key=key, value=value))
|
|
172
|
args.update(dict(key=key, value=value))
|
|
171
|
yield templ('extra', **args)
|
|
173
|
yield templ('extra', **args)
|
|
172
|
|
|
174
|
|
|
173
|
def showfileadds(repo, ctx, templ, revcache, **args):
|
|
175
|
def showfileadds(**args):
|
|
174
|
return showlist(templ, 'file_add', getfiles(repo, ctx, revcache)[1], **args)
|
|
176
|
repo, ctx, revcache = args['repo'], args['ctx'], args['revcache']
|
|
|
|
|
177
|
return showlist('file_add', getfiles(repo, ctx, revcache)[1], **args)
|
|
175
|
|
|
178
|
|
|
176
|
def showfilecopies(repo, ctx, templ, cache, revcache, **args):
|
|
179
|
def showfilecopies(**args):
|
|
177
|
copies = revcache.get('copies')
|
|
180
|
cache, ctx= args['cache'], args['ctx']
|
|
|
|
|
181
|
copies = args['revcache'].get('copies')
|
|
178
|
if copies is None:
|
|
182
|
if copies is None:
|
|
179
|
if 'getrenamed' not in cache:
|
|
183
|
if 'getrenamed' not in cache:
|
|
180
|
cache['getrenamed'] = getrenamedfn(repo)
|
|
184
|
cache['getrenamed'] = getrenamedfn(args['repo'])
|
|
181
|
copies = []
|
|
185
|
copies = []
|
|
182
|
getrenamed = cache['getrenamed']
|
|
186
|
getrenamed = cache['getrenamed']
|
|
183
|
for fn in ctx.files():
|
|
187
|
for fn in ctx.files():
|
|
@@
-186,24
+190,26
b' def showfilecopies(repo, ctx, templ, cac'
|
|
186
|
copies.append((fn, rename[0]))
|
|
190
|
copies.append((fn, rename[0]))
|
|
187
|
|
|
191
|
|
|
188
|
c = [{'name': x[0], 'source': x[1]} for x in copies]
|
|
192
|
c = [{'name': x[0], 'source': x[1]} for x in copies]
|
|
189
|
return showlist(templ, 'file_copy', c, plural='file_copies', **args)
|
|
193
|
return showlist('file_copy', c, plural='file_copies', **args)
|
|
190
|
|
|
194
|
|
|
191
|
# showfilecopiesswitch() displays file copies only if copy records are
|
|
195
|
# showfilecopiesswitch() displays file copies only if copy records are
|
|
192
|
# provided before calling the templater, usually with a --copies
|
|
196
|
# provided before calling the templater, usually with a --copies
|
|
193
|
# command line switch.
|
|
197
|
# command line switch.
|
|
194
|
def showfilecopiesswitch(repo, ctx, templ, cache, revcache, **args):
|
|
198
|
def showfilecopiesswitch(**args):
|
|
195
|
copies = revcache.get('copies') or []
|
|
199
|
copies = args['revcache'].get('copies') or []
|
|
196
|
c = [{'name': x[0], 'source': x[1]} for x in copies]
|
|
200
|
c = [{'name': x[0], 'source': x[1]} for x in copies]
|
|
197
|
return showlist(templ, 'file_copy', c, plural='file_copies', **args)
|
|
201
|
return showlist('file_copy', c, plural='file_copies', **args)
|
|
198
|
|
|
202
|
|
|
199
|
def showfiledels(repo, ctx, templ, revcache, **args):
|
|
203
|
def showfiledels(**args):
|
|
200
|
return showlist(templ, 'file_del', getfiles(repo, ctx, revcache)[2], **args)
|
|
204
|
repo, ctx, revcache = args['repo'], args['ctx'], args['revcache']
|
|
|
|
|
205
|
return showlist('file_del', getfiles(repo, ctx, revcache)[2], **args)
|
|
201
|
|
|
206
|
|
|
202
|
def showfilemods(repo, ctx, templ, revcache, **args):
|
|
207
|
def showfilemods(**args):
|
|
203
|
return showlist(templ, 'file_mod', getfiles(repo, ctx, revcache)[0], **args)
|
|
208
|
repo, ctx, revcache = args['repo'], args['ctx'], args['revcache']
|
|
|
|
|
209
|
return showlist('file_mod', getfiles(repo, ctx, revcache)[0], **args)
|
|
204
|
|
|
210
|
|
|
205
|
def showfiles(repo, ctx, templ, **args):
|
|
211
|
def showfiles(**args):
|
|
206
|
return showlist(templ, 'file', ctx.files(), **args)
|
|
212
|
return showlist('file', args['ctx'].files(), **args)
|
|
207
|
|
|
213
|
|
|
208
|
def showlatesttag(repo, ctx, templ, cache, **args):
|
|
214
|
def showlatesttag(repo, ctx, templ, cache, **args):
|
|
209
|
return getlatesttags(repo, ctx, cache)[2]
|
|
215
|
return getlatesttags(repo, ctx, cache)[2]
|
|
@@
-211,7
+217,8
b' def showlatesttag(repo, ctx, templ, cach'
|
|
211
|
def showlatesttagdistance(repo, ctx, templ, cache, **args):
|
|
217
|
def showlatesttagdistance(repo, ctx, templ, cache, **args):
|
|
212
|
return getlatesttags(repo, ctx, cache)[1]
|
|
218
|
return getlatesttags(repo, ctx, cache)[1]
|
|
213
|
|
|
219
|
|
|
214
|
def showmanifest(repo, ctx, templ, **args):
|
|
220
|
def showmanifest(**args):
|
|
|
|
|
221
|
repo, ctx, templ = args['repo'], args['ctx'], args['templ']
|
|
215
|
args = args.copy()
|
|
222
|
args = args.copy()
|
|
216
|
args.update(dict(rev=repo.manifest.rev(ctx.changeset()[0]),
|
|
223
|
args.update(dict(rev=repo.manifest.rev(ctx.changeset()[0]),
|
|
217
|
node=hex(ctx.changeset()[0])))
|
|
224
|
node=hex(ctx.changeset()[0])))
|
|
@@
-223,9
+230,17
b' def shownode(repo, ctx, templ, **args):'
|
|
223
|
def showrev(repo, ctx, templ, **args):
|
|
230
|
def showrev(repo, ctx, templ, **args):
|
|
224
|
return ctx.rev()
|
|
231
|
return ctx.rev()
|
|
225
|
|
|
232
|
|
|
226
|
def showtags(repo, ctx, templ, **args):
|
|
233
|
def showtags(**args):
|
|
227
|
return showlist(templ, 'tag', ctx.tags(), **args)
|
|
234
|
return showlist('tag', args['ctx'].tags(), **args)
|
|
228
|
|
|
235
|
|
|
|
|
|
236
|
# keywords are callables like:
|
|
|
|
|
237
|
# fn(repo, ctx, templ, cache, revcache, **args)
|
|
|
|
|
238
|
# with:
|
|
|
|
|
239
|
# repo - current repository instance
|
|
|
|
|
240
|
# ctx - the changectx being displayed
|
|
|
|
|
241
|
# templ - the templater instance
|
|
|
|
|
242
|
# cache - a cache dictionary for the whole templater run
|
|
|
|
|
243
|
# revcache - a cache dictionary for the current revision
|
|
229
|
keywords = {
|
|
244
|
keywords = {
|
|
230
|
'author': showauthor,
|
|
245
|
'author': showauthor,
|
|
231
|
'branches': showbranches,
|
|
246
|
'branches': showbranches,
|