mercurial/logcmdutil.py
changeset 41646 d4c9eebdd72d
parent 41630 3d094bfaf885
child 41647 ec37db02fc72
equal deleted inserted replaced
41645:2306158314e9 41646:d4c9eebdd72d
     7 
     7 
     8 from __future__ import absolute_import
     8 from __future__ import absolute_import
     9 
     9 
    10 import itertools
    10 import itertools
    11 import os
    11 import os
       
    12 import posixpath
    12 
    13 
    13 from .i18n import _
    14 from .i18n import _
    14 from .node import (
    15 from .node import (
    15     nullid,
    16     nullid,
    16     wdirid,
    17     wdirid,
    63     if root:
    64     if root:
    64         relroot = pathutil.canonpath(repo.root, repo.getcwd(), root)
    65         relroot = pathutil.canonpath(repo.root, repo.getcwd(), root)
    65     else:
    66     else:
    66         relroot = ''
    67         relroot = ''
    67     copysourcematch = None
    68     copysourcematch = None
       
    69     def pathfn(f):
       
    70         return posixpath.join(prefix, f)
    68     if relroot != '':
    71     if relroot != '':
    69         # XXX relative roots currently don't work if the root is within a
    72         # XXX relative roots currently don't work if the root is within a
    70         # subrepo
    73         # subrepo
    71         uirelroot = match.uipath(relroot)
    74         uirelroot = match.uipath(relroot)
    72         relroot += '/'
    75         relroot += '/'
    77 
    80 
    78         relrootmatch = scmutil.match(ctx2, pats=[relroot], default='path')
    81         relrootmatch = scmutil.match(ctx2, pats=[relroot], default='path')
    79         match = matchmod.intersectmatchers(match, relrootmatch)
    82         match = matchmod.intersectmatchers(match, relrootmatch)
    80         copysourcematch = relrootmatch
    83         copysourcematch = relrootmatch
    81 
    84 
       
    85         checkroot = (repo.ui.configbool('devel', 'all-warnings') or
       
    86                      repo.ui.configbool('devel', 'check-relroot'))
       
    87         def pathfn(f):
       
    88             if checkroot and not f.startswith(relroot):
       
    89                 raise AssertionError(
       
    90                     "file %s doesn't start with relroot %s" % (f, relroot))
       
    91             return posixpath.join(prefix, f[len(relroot):])
       
    92 
    82     if stat:
    93     if stat:
    83         diffopts = diffopts.copy(context=0, noprefix=False)
    94         diffopts = diffopts.copy(context=0, noprefix=False)
    84         width = 80
    95         width = 80
    85         if not ui.plain():
    96         if not ui.plain():
    86             width = ui.termwidth() - graphwidth
    97             width = ui.termwidth() - graphwidth
    87 
    98 
    88     chunks = ctx2.diff(ctx1, match, changes, opts=diffopts, prefix=prefix,
    99     chunks = ctx2.diff(ctx1, match, changes, opts=diffopts, pathfn=pathfn,
    89                        relroot=relroot, copysourcematch=copysourcematch,
   100                        copysourcematch=copysourcematch,
    90                        hunksfilterfn=hunksfilterfn)
   101                        hunksfilterfn=hunksfilterfn)
    91 
   102 
    92     if fp is not None or ui.canwritewithoutlabels():
   103     if fp is not None or ui.canwritewithoutlabels():
    93         out = fp or ui
   104         out = fp or ui
    94         if stat:
   105         if stat: