mercurial/cmdutil.py
changeset 26086 3670efdc7088
parent 26085 1de0b66b65c5
child 26098 ce26928cbe41
equal deleted inserted replaced
26085:1de0b66b65c5 26086:3670efdc7088
  1412         if tmpl:
  1412         if tmpl:
  1413             self.t.cache['changeset'] = tmpl
  1413             self.t.cache['changeset'] = tmpl
  1414 
  1414 
  1415         self.cache = {}
  1415         self.cache = {}
  1416 
  1416 
       
  1417         # find correct templates for current mode
       
  1418         tmplmodes = [
       
  1419             (True, None),
       
  1420             (self.ui.verbose, 'verbose'),
       
  1421             (self.ui.quiet, 'quiet'),
       
  1422             (self.ui.debugflag, 'debug'),
       
  1423         ]
       
  1424 
       
  1425         self._parts = {'header': '', 'footer': '', 'changeset': 'changeset'}
       
  1426         for mode, postfix in tmplmodes:
       
  1427             for t in self._parts:
       
  1428                 cur = t
       
  1429                 if postfix:
       
  1430                     cur += "_" + postfix
       
  1431                 if mode and cur in self.t:
       
  1432                     self._parts[t] = cur
       
  1433 
  1417     def _show(self, ctx, copies, matchfn, props):
  1434     def _show(self, ctx, copies, matchfn, props):
  1418         '''show a single changeset or file revision'''
  1435         '''show a single changeset or file revision'''
  1419 
  1436 
  1420         showlist = templatekw.showlist
  1437         showlist = templatekw.showlist
  1421 
  1438 
  1438         props['ctx'] = ctx
  1455         props['ctx'] = ctx
  1439         props['repo'] = self.repo
  1456         props['repo'] = self.repo
  1440         props['revcache'] = {'copies': copies}
  1457         props['revcache'] = {'copies': copies}
  1441         props['cache'] = self.cache
  1458         props['cache'] = self.cache
  1442 
  1459 
  1443         # find correct templates for current mode
       
  1444         tmplmodes = [
       
  1445             (True, None),
       
  1446             (self.ui.verbose, 'verbose'),
       
  1447             (self.ui.quiet, 'quiet'),
       
  1448             (self.ui.debugflag, 'debug'),
       
  1449         ]
       
  1450 
       
  1451         types = {'header': '', 'footer': '', 'changeset': 'changeset'}
       
  1452         for mode, postfix in tmplmodes:
       
  1453             for t in types:
       
  1454                 cur = t
       
  1455                 if postfix:
       
  1456                     cur += "_" + postfix
       
  1457                 if mode and cur in self.t:
       
  1458                     types[t] = cur
       
  1459 
       
  1460         try:
  1460         try:
  1461             # write header
  1461             # write header
  1462             if types['header']:
  1462             if self._parts['header']:
  1463                 h = templater.stringify(self.t(types['header'], **props))
  1463                 h = templater.stringify(self.t(self._parts['header'], **props))
  1464                 if self.buffered:
  1464                 if self.buffered:
  1465                     self.header[ctx.rev()] = h
  1465                     self.header[ctx.rev()] = h
  1466                 else:
  1466                 else:
  1467                     if self.lastheader != h:
  1467                     if self.lastheader != h:
  1468                         self.lastheader = h
  1468                         self.lastheader = h
  1469                         self.ui.write(h)
  1469                         self.ui.write(h)
  1470 
  1470 
  1471             # write changeset metadata, then patch if requested
  1471             # write changeset metadata, then patch if requested
  1472             key = types['changeset']
  1472             key = self._parts['changeset']
  1473             self.ui.write(templater.stringify(self.t(key, **props)))
  1473             self.ui.write(templater.stringify(self.t(key, **props)))
  1474             self.showpatch(ctx.node(), matchfn)
  1474             self.showpatch(ctx.node(), matchfn)
  1475 
  1475 
  1476             if types['footer']:
  1476             if self._parts['footer']:
  1477                 if not self.footer:
  1477                 if not self.footer:
  1478                     self.footer = templater.stringify(self.t(types['footer'],
  1478                     self.footer = templater.stringify(
  1479                                                       **props))
  1479                         self.t(self._parts['footer'], **props))
  1480         except KeyError as inst:
  1480         except KeyError as inst:
  1481             msg = _("%s: no key named '%s'")
  1481             msg = _("%s: no key named '%s'")
  1482             raise util.Abort(msg % (self.t.mapfile, inst.args[0]))
  1482             raise util.Abort(msg % (self.t.mapfile, inst.args[0]))
  1483         except SyntaxError as inst:
  1483         except SyntaxError as inst:
  1484             raise util.Abort('%s: %s' % (self.t.mapfile, inst.args[0]))
  1484             raise util.Abort('%s: %s' % (self.t.mapfile, inst.args[0]))