mercurial/revlog.py
changeset 42732 6d61be152c55
parent 42731 5109217a9ab6
child 42768 5a8f2c8edff6
equal deleted inserted replaced
42731:5109217a9ab6 42732:6d61be152c55
   122 ellipsisprocessor = (
   122 ellipsisprocessor = (
   123     ellipsisreadprocessor,
   123     ellipsisreadprocessor,
   124     ellipsiswriteprocessor,
   124     ellipsiswriteprocessor,
   125     ellipsisrawprocessor,
   125     ellipsisrawprocessor,
   126 )
   126 )
   127 
       
   128 def addflagprocessor(flag, processor):
       
   129     """Register a flag processor on a revision data flag.
       
   130 
       
   131     Invariant:
       
   132     - Flags need to be defined in REVIDX_KNOWN_FLAGS and REVIDX_FLAGS_ORDER,
       
   133       and REVIDX_RAWTEXT_CHANGING_FLAGS if they can alter rawtext.
       
   134     - Only one flag processor can be registered on a specific flag.
       
   135     - flagprocessors must be 3-tuples of functions (read, write, raw) with the
       
   136       following signatures:
       
   137           - (read)  f(self, rawtext) -> text, bool
       
   138           - (write) f(self, text) -> rawtext, bool
       
   139           - (raw)   f(self, rawtext) -> bool
       
   140       "text" is presented to the user. "rawtext" is stored in revlog data, not
       
   141       directly visible to the user.
       
   142       The boolean returned by these transforms is used to determine whether
       
   143       the returned text can be used for hash integrity checking. For example,
       
   144       if "write" returns False, then "text" is used to generate hash. If
       
   145       "write" returns True, that basically means "rawtext" returned by "write"
       
   146       should be used to generate hash. Usually, "write" and "read" return
       
   147       different booleans. And "raw" returns a same boolean as "write".
       
   148 
       
   149       Note: The 'raw' transform is used for changegroup generation and in some
       
   150       debug commands. In this case the transform only indicates whether the
       
   151       contents can be used for hash integrity checks.
       
   152     """
       
   153     flagutil.insertflagprocessor(flag, processor, flagutil.flagprocessors)
       
   154 
   127 
   155 def getoffset(q):
   128 def getoffset(q):
   156     return int(q >> 16)
   129     return int(q >> 16)
   157 
   130 
   158 def gettype(q):
   131 def gettype(q):
  2607             #  3. L3: len(text), stored in revlog data if flags==0, or
  2580             #  3. L3: len(text), stored in revlog data if flags==0, or
  2608             #     possibly somewhere else if flags!=0
  2581             #     possibly somewhere else if flags!=0
  2609             #
  2582             #
  2610             # L1 should be equal to L2. L3 could be different from them.
  2583             # L1 should be equal to L2. L3 could be different from them.
  2611             # "text" may or may not affect commit hash depending on flag
  2584             # "text" may or may not affect commit hash depending on flag
  2612             # processors (see revlog.addflagprocessor).
  2585             # processors (see flagutil.addflagprocessor).
  2613             #
  2586             #
  2614             #              | common  | rename | meta  | ext
  2587             #              | common  | rename | meta  | ext
  2615             # -------------------------------------------------
  2588             # -------------------------------------------------
  2616             #    rawsize() | L1      | L1     | L1    | L1
  2589             #    rawsize() | L1      | L1     | L1    | L1
  2617             #       size() | L1      | L2-LM  | L1(*) | L1 (?)
  2590             #       size() | L1      | L2-LM  | L1(*) | L1 (?)