comparison mercurial/merge.py @ 27344:43c00ca887d1

merge: have merge.update use a matcher instead of partial fn This is relatively rarely used functionality, but migrating this to a matcher will make future work on narrow clones more feasible.
author Augie Fackler <augie@google.com>
date Mon, 14 Dec 2015 18:54:03 -0500
parents 777f668eca70
children 98266b1d144d
comparison
equal deleted inserted replaced
27343:c59647c6694d 27344:43c00ca887d1
1264 repo.dirstate.add(f) 1264 repo.dirstate.add(f)
1265 repo.dirstate.copy(f0, f) 1265 repo.dirstate.copy(f0, f)
1266 else: 1266 else:
1267 repo.dirstate.normal(f) 1267 repo.dirstate.normal(f)
1268 1268
1269 def update(repo, node, branchmerge, force, partial, ancestor=None, 1269 def update(repo, node, branchmerge, force, ancestor=None,
1270 mergeancestor=False, labels=None): 1270 mergeancestor=False, labels=None, matcher=None):
1271 """ 1271 """
1272 Perform a merge between the working directory and the given node 1272 Perform a merge between the working directory and the given node
1273 1273
1274 node = the node to update to, or None if unspecified 1274 node = the node to update to, or None if unspecified
1275 branchmerge = whether to merge between branches 1275 branchmerge = whether to merge between branches
1276 force = whether to force branch merging or file overwriting 1276 force = whether to force branch merging or file overwriting
1277 partial = a function to filter file lists (dirstate not updated) 1277 matcher = a matcher to filter file lists (dirstate not updated)
1278 mergeancestor = whether it is merging with an ancestor. If true, 1278 mergeancestor = whether it is merging with an ancestor. If true,
1279 we should accept the incoming changes for any prompts that occur. 1279 we should accept the incoming changes for any prompts that occur.
1280 If false, merging with an ancestor (fast-forward) is only allowed 1280 If false, merging with an ancestor (fast-forward) is only allowed
1281 between different named branches. This flag is used by rebase extension 1281 between different named branches. This flag is used by rebase extension
1282 as a temporary fix and should be avoided in general. 1282 as a temporary fix and should be avoided in general.
1311 Return the same tuple as applyupdates(). 1311 Return the same tuple as applyupdates().
1312 """ 1312 """
1313 1313
1314 onode = node 1314 onode = node
1315 wlock = repo.wlock() 1315 wlock = repo.wlock()
1316 # If we're doing a partial update, we need to skip updating
1317 # the dirstate, so make a note of any partial-ness to the
1318 # update here.
1319 if matcher is None or matcher.always():
1320 partial = False
1321 else:
1322 partial = True
1316 try: 1323 try:
1317 wc = repo[None] 1324 wc = repo[None]
1318 pl = wc.parents() 1325 pl = wc.parents()
1319 p1 = pl[0] 1326 p1 = pl[0]
1320 pas = [None] 1327 pas = [None]
1405 pass 1412 pass
1406 elif pas[0] and repo.ui.configbool('merge', 'followcopies', True): 1413 elif pas[0] and repo.ui.configbool('merge', 'followcopies', True):
1407 followcopies = True 1414 followcopies = True
1408 1415
1409 ### calculate phase 1416 ### calculate phase
1417 if matcher is None or matcher.always():
1418 partial = False
1419 else:
1420 partial = matcher.matchfn
1410 actionbyfile, diverge, renamedelete = calculateupdates( 1421 actionbyfile, diverge, renamedelete = calculateupdates(
1411 repo, wc, p2, pas, branchmerge, force, partial, mergeancestor, 1422 repo, wc, p2, pas, branchmerge, force, partial, mergeancestor,
1412 followcopies) 1423 followcopies)
1413 # Convert to dictionary-of-lists format 1424 # Convert to dictionary-of-lists format
1414 actions = dict((m, []) for m in 'a am f g cd dc r dm dg m e k'.split()) 1425 actions = dict((m, []) for m in 'a am f g cd dc r dm dg m e k'.split())
1514 # to copy commits), and 2) informs update that the incoming changes are 1525 # to copy commits), and 2) informs update that the incoming changes are
1515 # newer than the destination so it doesn't prompt about "remote changed foo 1526 # newer than the destination so it doesn't prompt about "remote changed foo
1516 # which local deleted". 1527 # which local deleted".
1517 mergeancestor = repo.changelog.isancestor(repo['.'].node(), ctx.node()) 1528 mergeancestor = repo.changelog.isancestor(repo['.'].node(), ctx.node())
1518 1529
1519 stats = update(repo, ctx.node(), True, True, False, pctx.node(), 1530 stats = update(repo, ctx.node(), True, True, pctx.node(),
1520 mergeancestor=mergeancestor, labels=labels) 1531 mergeancestor=mergeancestor, labels=labels)
1521 1532
1522 pother = nullid 1533 pother = nullid
1523 parents = ctx.parents() 1534 parents = ctx.parents()
1524 if keepparent and len(parents) == 2 and pctx in parents: 1535 if keepparent and len(parents) == 2 and pctx in parents: