mercurial/hgweb/webcommands.py
changeset 21123 92fab48dfec1
parent 21121 8c9e84b44221
child 22199 b3e51675f98e
equal deleted inserted replaced
21122:50981ce36236 21123:92fab48dfec1
     6 # GNU General Public License version 2 or any later version.
     6 # GNU General Public License version 2 or any later version.
     7 
     7 
     8 import os, mimetypes, re, cgi, copy
     8 import os, mimetypes, re, cgi, copy
     9 import webutil
     9 import webutil
    10 from mercurial import error, encoding, archival, templater, templatefilters
    10 from mercurial import error, encoding, archival, templater, templatefilters
    11 from mercurial.node import short, hex, nullid
    11 from mercurial.node import short, hex
    12 from mercurial import util
    12 from mercurial import util
    13 from common import paritygen, staticfile, get_contact, ErrorResponse
    13 from common import paritygen, staticfile, get_contact, ErrorResponse
    14 from common import HTTP_OK, HTTP_FORBIDDEN, HTTP_NOT_FOUND
    14 from common import HTTP_OK, HTTP_FORBIDDEN, HTTP_NOT_FOUND
    15 from mercurial import graphmod, patch
    15 from mercurial import graphmod, patch
    16 from mercurial import help as helpmod
    16 from mercurial import help as helpmod
   710             if not mt:
   710             if not mt:
   711                 mt = 'application/octet-stream'
   711                 mt = 'application/octet-stream'
   712             return [_('(binary file %s, hash: %s)') % (mt, hex(f.filenode()))]
   712             return [_('(binary file %s, hash: %s)') % (mt, hex(f.filenode()))]
   713         return f.data().splitlines()
   713         return f.data().splitlines()
   714 
   714 
       
   715     parent = ctx.p1()
       
   716     leftrev = parent.rev()
       
   717     leftnode = parent.node()
       
   718     rightrev = ctx.rev()
       
   719     rightnode = ctx.node()
   715     if path in ctx:
   720     if path in ctx:
   716         fctx = ctx[path]
   721         fctx = ctx[path]
   717         rightrev = fctx.filerev()
       
   718         rightnode = fctx.filenode()
       
   719         rightlines = filelines(fctx)
   722         rightlines = filelines(fctx)
   720         parent = ctx.p1()
       
   721         if path not in parent:
   723         if path not in parent:
   722             leftrev = -1
       
   723             leftnode = nullid
       
   724             leftlines = ()
   724             leftlines = ()
   725         else:
   725         else:
   726             pfctx = parent[path]
   726             pfctx = parent[path]
   727             leftrev = pfctx.filerev()
       
   728             leftnode = pfctx.filenode()
       
   729             leftlines = filelines(pfctx)
   727             leftlines = filelines(pfctx)
   730     else:
   728     else:
   731         rightrev = -1
       
   732         rightnode = nullid
       
   733         rightlines = ()
   729         rightlines = ()
   734         fctx = ctx.parents()[0][path]
   730         fctx = ctx.parents()[0][path]
   735         leftrev = fctx.filerev()
       
   736         leftnode = fctx.filenode()
       
   737         leftlines = filelines(fctx)
   731         leftlines = filelines(fctx)
   738 
   732 
   739     comparison = webutil.compare(tmpl, context, leftlines, rightlines)
   733     comparison = webutil.compare(tmpl, context, leftlines, rightlines)
   740     return tmpl('filecomparison',
   734     return tmpl('filecomparison',
   741                 file=path,
   735                 file=path,