mercurial/merge.py
changeset 27022 35102876d648
parent 27006 9d58dc193c46
child 27027 a01ecbcfaf84
equal deleted inserted replaced
27021:f2554154509f 27022:35102876d648
    40     return '\0'.join(bits)
    40     return '\0'.join(bits)
    41 
    41 
    42 class mergestate(object):
    42 class mergestate(object):
    43     '''track 3-way merge state of individual files
    43     '''track 3-way merge state of individual files
    44 
    44 
    45     it is stored on disk when needed. Two file are used, one with an old
    45     The merge state is stored on disk when needed. Two files are used: one with
    46     format, one with a new format. Both contains similar data, but the new
    46     an old format (version 1), and one with a new format (version 2). Version 2
    47     format can store new kinds of field.
    47     stores a superset of the data in version 1, including new kinds of records
    48 
    48     in the future. For more about the new format, see the documentation for
    49     Current new format is a list of arbitrary record of the form:
    49     `_readrecordsv2`.
    50 
    50 
    51         [type][length][content]
    51     Each record can contain arbitrary content, and has an associated type. This
    52 
    52     `type` should be a letter. If `type` is uppercase, the record is mandatory:
    53     Type is a single character, length is a 4 bytes integer, content is an
    53     versions of Mercurial that don't support it should abort. If `type` is
    54     arbitrary suites of bytes of length `length`.
    54     lowercase, the record can be safely ignored.
    55 
    55 
    56     Type should be a letter. Capital letter are mandatory record, Mercurial
    56     Currently known records:
    57     should abort if they are unknown. lower case record can be safely ignored.
       
    58 
       
    59     Currently known record:
       
    60 
    57 
    61     L: the node of the "local" part of the merge (hexified version)
    58     L: the node of the "local" part of the merge (hexified version)
    62     O: the node of the "other" part of the merge (hexified version)
    59     O: the node of the "other" part of the merge (hexified version)
    63     F: a file to be merged entry
    60     F: a file to be merged entry
    64     D: a file that the external merge driver will merge internally
    61     D: a file that the external merge driver will merge internally
    69     Merge driver run states (experimental):
    66     Merge driver run states (experimental):
    70     u: driver-resolved files unmarked -- needs to be run next time we're about
    67     u: driver-resolved files unmarked -- needs to be run next time we're about
    71        to resolve or commit
    68        to resolve or commit
    72     m: driver-resolved files marked -- only needs to be run before commit
    69     m: driver-resolved files marked -- only needs to be run before commit
    73     s: success/skipped -- does not need to be run any more
    70     s: success/skipped -- does not need to be run any more
       
    71 
    74     '''
    72     '''
    75     statepathv1 = 'merge/state'
    73     statepathv1 = 'merge/state'
    76     statepathv2 = 'merge/state2'
    74     statepathv2 = 'merge/state2'
    77 
    75 
    78     @staticmethod
    76     @staticmethod
   224         return records
   222         return records
   225 
   223 
   226     def _readrecordsv2(self):
   224     def _readrecordsv2(self):
   227         """read on disk merge state for version 2 file
   225         """read on disk merge state for version 2 file
   228 
   226 
   229         returns list of record [(TYPE, data), ...]
   227         This format is a list of arbitrary records of the form:
   230         """
   228 
       
   229           [type][length][content]
       
   230 
       
   231         `type` is a single character, `length` is a 4 byte integer, and
       
   232         `content` is an arbitrary byte sequence of length `length`.
       
   233 
       
   234         Returns list of records [(TYPE, data), ...]."""
   231         records = []
   235         records = []
   232         try:
   236         try:
   233             f = self._repo.vfs(self.statepathv2)
   237             f = self._repo.vfs(self.statepathv2)
   234             data = f.read()
   238             data = f.read()
   235             off = 0
   239             off = 0