comparison mercurial/merge.py @ 28011:8abd9f785030

merge: add file ancestor linknode to mergestate During a merge, each file has a current commitnode+filenode, an other commitnode+filenode, and an ancestor commitnode+filenode. The ancestor commitnode is not stored though, and we rely on the ability for the filectx() to look up the commitnode by using the filenode's linkrev. In alternative backends (like remotefilelog), linkrevs may have restriction that prevent arbitrary linkrev look up given a filenode. This patch accounts for that by storing the ancestor commitnode in the merge state so that it is available later at resolve time. This results in some test changes because the ancestor commitnode we're using at resolve time changes slightly. Before, we used the linkrev commit, which is the earliest commit that introduced that particular filenode (which may not be the latest common ancestor of the commits being merged). Now we use the latest common ancestor of the merged commits as the commitnode. This is fine though, because that commit contains the same filenode as the linkrev'd commit.
author Durham Goode <durham@fb.com>
date Fri, 05 Feb 2016 10:22:14 -0800
parents 4a25e91fa55d
children 3feadb0b6c34
comparison
equal deleted inserted replaced
28010:eb22def9db3b 28011:8abd9f785030
403 self._repo.vfs.write('merge/' + hash, fcl.data()) 403 self._repo.vfs.write('merge/' + hash, fcl.data())
404 self._state[fd] = ['u', hash, fcl.path(), 404 self._state[fd] = ['u', hash, fcl.path(),
405 fca.path(), hex(fca.filenode()), 405 fca.path(), hex(fca.filenode()),
406 fco.path(), hex(fco.filenode()), 406 fco.path(), hex(fco.filenode()),
407 fcl.flags()] 407 fcl.flags()]
408 self._stateextras[fd] = { 'ancestorlinknode' : hex(fca.node()) }
408 self._dirty = True 409 self._dirty = True
409 410
410 def __contains__(self, dfile): 411 def __contains__(self, dfile):
411 return dfile in self._state 412 return dfile in self._state
412 413
448 if self[dfile] in 'rd': 449 if self[dfile] in 'rd':
449 return True, 0 450 return True, 0
450 stateentry = self._state[dfile] 451 stateentry = self._state[dfile]
451 state, hash, lfile, afile, anode, ofile, onode, flags = stateentry 452 state, hash, lfile, afile, anode, ofile, onode, flags = stateentry
452 octx = self._repo[self._other] 453 octx = self._repo[self._other]
454 extras = self.extras(dfile)
455 anccommitnode = extras.get('ancestorlinknode')
456 if anccommitnode:
457 actx = self._repo[anccommitnode]
458 else:
459 actx = None
453 fcd = self._filectxorabsent(hash, wctx, dfile) 460 fcd = self._filectxorabsent(hash, wctx, dfile)
454 fco = self._filectxorabsent(onode, octx, ofile) 461 fco = self._filectxorabsent(onode, octx, ofile)
455 # TODO: move this to filectxorabsent 462 # TODO: move this to filectxorabsent
456 fca = self._repo.filectx(afile, fileid=anode) 463 fca = self._repo.filectx(afile, fileid=anode, changeid=actx)
457 # "premerge" x flags 464 # "premerge" x flags
458 flo = fco.flags() 465 flo = fco.flags()
459 fla = fca.flags() 466 fla = fca.flags()
460 if 'x' in flags + flo + fla and 'l' not in flags + flo + fla: 467 if 'x' in flags + flo + fla and 'l' not in flags + flo + fla:
461 if fca.node() == nullid: 468 if fca.node() == nullid: