##// END OF EJS Templates
merge: use constants for merge record state...
Gregory Szorc -
r37129:aa5199c7 default
parent child Browse files
Show More
@@ -65,6 +65,12 b" MERGE_DRIVER_STATE_UNMARKED = b'u'"
65 65 MERGE_DRIVER_STATE_MARKED = b'm'
66 66 MERGE_DRIVER_STATE_SUCCESS = b's'
67 67
68 MERGE_RECORD_UNRESOLVED = b'u'
69 MERGE_RECORD_RESOLVED = b'r'
70 MERGE_RECORD_UNRESOLVED_PATH = b'pu'
71 MERGE_RECORD_RESOLVED_PATH = b'pr'
72 MERGE_RECORD_DRIVER_RESOLVED = b'd'
73
68 74 class mergestate(object):
69 75 '''track 3-way merge state of individual files
70 76
@@ -391,11 +397,12 b' class mergestate(object):'
391 397 # to prevent older versions of Mercurial that do not support the feature
392 398 # from loading them.
393 399 for filename, v in self._state.iteritems():
394 if v[0] == 'd':
400 if v[0] == MERGE_RECORD_DRIVER_RESOLVED:
395 401 # Driver-resolved merge. These are stored in 'D' records.
396 402 records.append((RECORD_MERGE_DRIVER_MERGE,
397 403 '\0'.join([filename] + v)))
398 elif v[0] in ('pu', 'pr'):
404 elif v[0] in (MERGE_RECORD_UNRESOLVED_PATH,
405 MERGE_RECORD_RESOLVED_PATH):
399 406 # Path conflicts. These are stored in 'P' records. The current
400 407 # resolution state ('pu' or 'pr') is stored within the record.
401 408 records.append((RECORD_PATH_CONFLICT,
@@ -467,7 +474,7 b' class mergestate(object):'
467 474 else:
468 475 hash = hex(hashlib.sha1(fcl.path()).digest())
469 476 self._repo.vfs.write('merge/' + hash, fcl.data())
470 self._state[fd] = ['u', hash, fcl.path(),
477 self._state[fd] = [MERGE_RECORD_UNRESOLVED, hash, fcl.path(),
471 478 fca.path(), hex(fca.filenode()),
472 479 fco.path(), hex(fco.filenode()),
473 480 fcl.flags()]
@@ -480,7 +487,7 b' class mergestate(object):'
480 487 frename: the filename the conflicting file was renamed to
481 488 forigin: origin of the file ('l' or 'r' for local/remote)
482 489 """
483 self._state[path] = ['pu', frename, forigin]
490 self._state[path] = [MERGE_RECORD_UNRESOLVED_PATH, frename, forigin]
484 491 self._dirty = True
485 492
486 493 def __contains__(self, dfile):
@@ -506,14 +513,15 b' class mergestate(object):'
506 513 """Obtain the paths of unresolved files."""
507 514
508 515 for f, entry in self._state.iteritems():
509 if entry[0] in ('u', 'pu'):
516 if entry[0] in (MERGE_RECORD_UNRESOLVED,
517 MERGE_RECORD_UNRESOLVED_PATH):
510 518 yield f
511 519
512 520 def driverresolved(self):
513 521 """Obtain the paths of driver-resolved files."""
514 522
515 523 for f, entry in self._state.items():
516 if entry[0] == 'd':
524 if entry[0] == MERGE_RECORD_DRIVER_RESOLVED:
517 525 yield f
518 526
519 527 def extras(self, filename):
@@ -521,7 +529,8 b' class mergestate(object):'
521 529
522 530 def _resolve(self, preresolve, dfile, wctx):
523 531 """rerun merge process for file path `dfile`"""
524 if self[dfile] in 'rd':
532 if self[dfile] in (MERGE_RECORD_RESOLVED,
533 MERGE_RECORD_DRIVER_RESOLVED):
525 534 return True, 0
526 535 stateentry = self._state[dfile]
527 536 state, hash, lfile, afile, anode, ofile, onode, flags = stateentry
@@ -571,7 +580,7 b' class mergestate(object):'
571 580 self._stateextras.pop(dfile, None)
572 581 self._dirty = True
573 582 elif not r:
574 self.mark(dfile, 'r')
583 self.mark(dfile, MERGE_RECORD_RESOLVED)
575 584
576 585 if complete:
577 586 action = None
General Comments 0
You need to be logged in to leave comments. Login now