mercurial/filemerge.py
changeset 26979 7b038ec6c5fd
parent 26967 7a8e9a985c3b
child 27032 28ee7af4b685
equal deleted inserted replaced
26978:9b9d4bcc915e 26979:7b038ec6c5fd
    11 import os
    11 import os
    12 import re
    12 import re
    13 import tempfile
    13 import tempfile
    14 
    14 
    15 from .i18n import _
    15 from .i18n import _
    16 from .node import short
    16 from .node import nullid, short
    17 
    17 
    18 from . import (
    18 from . import (
    19     cmdutil,
    19     cmdutil,
    20     error,
    20     error,
    21     match,
    21     match,
    41 
    41 
    42 # internal tool merge types
    42 # internal tool merge types
    43 nomerge = None
    43 nomerge = None
    44 mergeonly = 'mergeonly'  # just the full merge, no premerge
    44 mergeonly = 'mergeonly'  # just the full merge, no premerge
    45 fullmerge = 'fullmerge'  # both premerge and merge
    45 fullmerge = 'fullmerge'  # both premerge and merge
       
    46 
       
    47 class absentfilectx(object):
       
    48     """Represents a file that's ostensibly in a context but is actually not
       
    49     present in it.
       
    50 
       
    51     This is here because it's very specific to the filemerge code for now --
       
    52     other code is likely going to break with the values this returns."""
       
    53     def __init__(self, ctx, f):
       
    54         self._ctx = ctx
       
    55         self._f = f
       
    56 
       
    57     def path(self):
       
    58         return self._f
       
    59 
       
    60     def size(self):
       
    61         return None
       
    62 
       
    63     def data(self):
       
    64         return None
       
    65 
       
    66     def filenode(self):
       
    67         return nullid
       
    68 
       
    69     _customcmp = True
       
    70     def cmp(self, fctx):
       
    71         """compare with other file context
       
    72 
       
    73         returns True if different from fctx.
       
    74         """
       
    75         return not (fctx.isabsent() and
       
    76                     fctx.ctx() == self.ctx() and
       
    77                     fctx.path() == self.path())
       
    78 
       
    79     def flags(self):
       
    80         return ''
       
    81 
       
    82     def changectx(self):
       
    83         return self._ctx
       
    84 
       
    85     def isbinary(self):
       
    86         return False
       
    87 
       
    88     def isabsent(self):
       
    89         return True
    46 
    90 
    47 def internaltool(name, mergetype, onfailure=None, precheck=None):
    91 def internaltool(name, mergetype, onfailure=None, precheck=None):
    48     '''return a decorator for populating internal merge tool table'''
    92     '''return a decorator for populating internal merge tool table'''
    49     def decorator(func):
    93     def decorator(func):
    50         fullname = ':' + name
    94         fullname = ':' + name