comparison mercurial/filemerge.py @ 26070:e15966216aec

filemerge: split internal merge into api entry point and internal helper This is a step toward adding 'union merge' to the internal merge tool. 'union merge' is a merge strategy which adds both left and right hand side of a conflict region. Git implements this merge strategy which is very practical to have for merging to e.g. the Changelog file.
author Erik Huelsmann <ehuels@gmail.com>
date Sun, 16 Aug 2015 00:24:29 +0200
parents 80aba76e29c1
children ff12a6c63c3d
comparison
equal deleted inserted replaced
26069:09d6725cbc60 26070:e15966216aec
225 return 0 225 return 0
226 if premerge not in validkeep: 226 if premerge not in validkeep:
227 util.copyfile(back, a) # restore from backup and try again 227 util.copyfile(back, a) # restore from backup and try again
228 return 1 # continue merging 228 return 1 # continue merging
229 229
230 @internaltool('merge', True, 230 def _merge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels, mode):
231 _("merging %s incomplete! "
232 "(edit conflicts, then use 'hg resolve --mark')\n"))
233 def _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
234 """ 231 """
235 Uses the internal non-interactive simple merge algorithm for merging 232 Uses the internal non-interactive simple merge algorithm for merging
236 files. It will fail if there are any conflicts and leave markers in 233 files. It will fail if there are any conflicts and leave markers in
237 the partially merged file. Markers will have two sections, one for each side 234 the partially merged file. Markers will have two sections, one for each side
238 of merge.""" 235 of merge, unless mode equals 'union' which suppresses the markers."""
239 tool, toolpath, binary, symlink = toolconf 236 tool, toolpath, binary, symlink = toolconf
240 if symlink: 237 if symlink:
241 repo.ui.warn(_('warning: internal :merge cannot merge symlinks ' 238 repo.ui.warn(_('warning: internal :merge cannot merge symlinks '
242 'for %s\n') % fcd.path()) 239 'for %s\n') % fcd.path())
243 return False, 1 240 return False, 1
245 if r: 242 if r:
246 a, b, c, back = files 243 a, b, c, back = files
247 244
248 ui = repo.ui 245 ui = repo.ui
249 246
250 r = simplemerge.simplemerge(ui, a, b, c, label=labels) 247 r = simplemerge.simplemerge(ui, a, b, c, label=labels, mode=mode)
251 return True, r 248 return True, r
252 return False, 0 249 return False, 0
250
251 @internaltool('merge', True,
252 _("merging %s incomplete! "
253 "(edit conflicts, then use 'hg resolve --mark')\n"))
254 def _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
255 """
256 Uses the internal non-interactive simple merge algorithm for merging
257 files. It will fail if there are any conflicts and leave markers in
258 the partially merged file. Markers will have two sections, one for each side
259 of merge."""
260 return _merge(repo, mynode, orig, fcd, fco, fca, toolconf,
261 files, labels, 'merge')
253 262
254 @internaltool('merge3', True, 263 @internaltool('merge3', True,
255 _("merging %s incomplete! " 264 _("merging %s incomplete! "
256 "(edit conflicts, then use 'hg resolve --mark')\n")) 265 "(edit conflicts, then use 'hg resolve --mark')\n"))
257 def _imerge3(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None): 266 def _imerge3(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):