mercurial/merge.py
changeset 45338 72b8c082676b
parent 45337 5ce63ee1fe3d
child 45340 cdc50e1929b0
equal deleted inserted replaced
45337:5ce63ee1fe3d 45338:72b8c082676b
   620                 for f, (args, msg) in pycompat.iteritems(
   620                 for f, (args, msg) in pycompat.iteritems(
   621                     self._actionmapping[a]
   621                     self._actionmapping[a]
   622                 ):
   622                 ):
   623                     res.append((f, args, msg))
   623                     res.append((f, args, msg))
   624         return res
   624         return res
       
   625 
       
   626     def len(self, actions=None):
       
   627         """ returns number of files which needs actions
       
   628 
       
   629         if actions is passed, total of number of files in that action
       
   630         only is returned """
       
   631 
       
   632         if actions is None:
       
   633             return len(self._filemapping)
       
   634 
       
   635         return sum(len(self._actionmapping[a]) for a in actions)
   625 
   636 
   626     @property
   637     @property
   627     def actions(self):
   638     def actions(self):
   628         return self._filemapping
   639         return self._filemapping
   629 
   640 
  1407         if wctx[f].lexists():
  1418         if wctx[f].lexists():
  1408             repo.ui.debug(b"removing %s\n" % f)
  1419             repo.ui.debug(b"removing %s\n" % f)
  1409             wctx[f].audit()
  1420             wctx[f].audit()
  1410             wctx[f].remove()
  1421             wctx[f].remove()
  1411 
  1422 
  1412     numupdates = len(mresult.actions) - len(
  1423     numupdates = mresult.len() - mresult.len((mergestatemod.ACTION_KEEP,))
  1413         mresult._actionmapping[mergestatemod.ACTION_KEEP]
       
  1414     )
       
  1415     progress = repo.ui.makeprogress(
  1424     progress = repo.ui.makeprogress(
  1416         _(b'updating'), unit=_(b'files'), total=numupdates
  1425         _(b'updating'), unit=_(b'files'), total=numupdates
  1417     )
  1426     )
  1418 
  1427 
  1419     if b'.hgsubstate' in mresult._actionmapping[mergestatemod.ACTION_REMOVE]:
  1428     if b'.hgsubstate' in mresult._actionmapping[mergestatemod.ACTION_REMOVE]:
  1452         (repo, wctx),
  1461         (repo, wctx),
  1453         mresult.getactions([mergestatemod.ACTION_REMOVE], sort=True),
  1462         mresult.getactions([mergestatemod.ACTION_REMOVE], sort=True),
  1454     )
  1463     )
  1455     for i, item in prog:
  1464     for i, item in prog:
  1456         progress.increment(step=i, item=item)
  1465         progress.increment(step=i, item=item)
  1457     removed = len(mresult._actionmapping[mergestatemod.ACTION_REMOVE])
  1466     removed = mresult.len((mergestatemod.ACTION_REMOVE,))
  1458 
  1467 
  1459     # resolve path conflicts (must come before getting)
  1468     # resolve path conflicts (must come before getting)
  1460     for f, args, msg in mresult.getactions(
  1469     for f, args, msg in mresult.getactions(
  1461         [mergestatemod.ACTION_PATH_CONFLICT_RESOLVE], sort=True
  1470         [mergestatemod.ACTION_PATH_CONFLICT_RESOLVE], sort=True
  1462     ):
  1471     ):
  1487         if final:
  1496         if final:
  1488             getfiledata = res
  1497             getfiledata = res
  1489         else:
  1498         else:
  1490             i, item = res
  1499             i, item = res
  1491             progress.increment(step=i, item=item)
  1500             progress.increment(step=i, item=item)
  1492     updated = len(mresult._actionmapping[mergestatemod.ACTION_GET])
  1501     updated = mresult.len((mergestatemod.ACTION_GET,))
  1493 
  1502 
  1494     if b'.hgsubstate' in mresult._actionmapping[mergestatemod.ACTION_GET]:
  1503     if b'.hgsubstate' in mresult._actionmapping[mergestatemod.ACTION_GET]:
  1495         subrepoutil.submerge(repo, wctx, mctx, wctx, overwrite, labels)
  1504         subrepoutil.submerge(repo, wctx, mctx, wctx, overwrite, labels)
  1496 
  1505 
  1497     # forget (manifest only, just log it) (must come first)
  1506     # forget (manifest only, just log it) (must come first)
  1662             if a[0] not in mfiles:
  1671             if a[0] not in mfiles:
  1663                 mresult.removefile(a[0])
  1672                 mresult.removefile(a[0])
  1664 
  1673 
  1665     progress.complete()
  1674     progress.complete()
  1666     assert len(getfiledata) == (
  1675     assert len(getfiledata) == (
  1667         len(mresult._actionmapping[mergestatemod.ACTION_GET])
  1676         mresult.len((mergestatemod.ACTION_GET,)) if wantfiledata else 0
  1668         if wantfiledata
       
  1669         else 0
       
  1670     )
  1677     )
  1671     return updateresult(updated, merged, removed, unresolved), getfiledata
  1678     return updateresult(updated, merged, removed, unresolved), getfiledata
  1672 
  1679 
  1673 
  1680 
  1674 def _advertisefsmonitor(repo, num_gets, p1node):
  1681 def _advertisefsmonitor(repo, num_gets, p1node):
  2029         if updatedirstate:
  2036         if updatedirstate:
  2030             repo.hook(b'preupdate', throw=True, parent1=xp1, parent2=xp2)
  2037             repo.hook(b'preupdate', throw=True, parent1=xp1, parent2=xp2)
  2031             # note that we're in the middle of an update
  2038             # note that we're in the middle of an update
  2032             repo.vfs.write(b'updatestate', p2.hex())
  2039             repo.vfs.write(b'updatestate', p2.hex())
  2033 
  2040 
  2034         # Convert to dictionary-of-lists format
       
  2035         actions = mresult.actionsdict
       
  2036 
       
  2037         _advertisefsmonitor(
  2041         _advertisefsmonitor(
  2038             repo, len(actions[mergestatemod.ACTION_GET]), p1.node()
  2042             repo, mresult.len((mergestatemod.ACTION_GET,)), p1.node()
  2039         )
  2043         )
  2040 
  2044 
  2041         wantfiledata = updatedirstate and not branchmerge
  2045         wantfiledata = updatedirstate and not branchmerge
  2042         stats, getfiledata = applyupdates(
  2046         stats, getfiledata = applyupdates(
  2043             repo,
  2047             repo,