mercurial/localrepo.py
changeset 2395 8ed45fb1053a
parent 2362 482d3fb47d80
child 2424 092039246d73
equal deleted inserted replaced
2394:a8f1049d1d2d 2395:8ed45fb1053a
  1496 
  1496 
  1497         changesets = files = revisions = 0
  1497         changesets = files = revisions = 0
  1498 
  1498 
  1499         tr = self.transaction()
  1499         tr = self.transaction()
  1500 
  1500 
  1501         # write changelog and manifest data to temp files so
  1501         # write changelog data to temp files so concurrent readers will not see
  1502         # concurrent readers will not see inconsistent view
  1502         # inconsistent view
  1503         cl = None
  1503         cl = None
  1504         try:
  1504         try:
  1505             cl = appendfile.appendchangelog(self.opener, self.changelog.version)
  1505             cl = appendfile.appendchangelog(self.opener, self.changelog.version)
  1506 
  1506 
  1507             oldheads = len(cl.heads())
  1507             oldheads = len(cl.heads())
  1513             if cl.addgroup(chunkiter, csmap, tr, 1) is None:
  1513             if cl.addgroup(chunkiter, csmap, tr, 1) is None:
  1514                 raise util.Abort(_("received changelog group is empty"))
  1514                 raise util.Abort(_("received changelog group is empty"))
  1515             cnr = cl.count() - 1
  1515             cnr = cl.count() - 1
  1516             changesets = cnr - cor
  1516             changesets = cnr - cor
  1517 
  1517 
  1518             mf = None
  1518             # pull off the manifest group
  1519             try:
  1519             self.ui.status(_("adding manifests\n"))
  1520                 mf = appendfile.appendmanifest(self.opener,
  1520             chunkiter = changegroup.chunkiter(source)
  1521                                                self.manifest.version)
  1521             # no need to check for empty manifest group here:
  1522 
  1522             # if the result of the merge of 1 and 2 is the same in 3 and 4,
  1523                 # pull off the manifest group
  1523             # no new manifest will be created and the manifest group will
  1524                 self.ui.status(_("adding manifests\n"))
  1524             # be empty during the pull
       
  1525             self.manifest.addgroup(chunkiter, revmap, tr)
       
  1526 
       
  1527             # process the files
       
  1528             self.ui.status(_("adding file changes\n"))
       
  1529             while 1:
       
  1530                 f = changegroup.getchunk(source)
       
  1531                 if not f:
       
  1532                     break
       
  1533                 self.ui.debug(_("adding %s revisions\n") % f)
       
  1534                 fl = self.file(f)
       
  1535                 o = fl.count()
  1525                 chunkiter = changegroup.chunkiter(source)
  1536                 chunkiter = changegroup.chunkiter(source)
  1526                 # no need to check for empty manifest group here:
  1537                 if fl.addgroup(chunkiter, revmap, tr) is None:
  1527                 # if the result of the merge of 1 and 2 is the same in 3 and 4,
  1538                     raise util.Abort(_("received file revlog group is empty"))
  1528                 # no new manifest will be created and the manifest group will
  1539                 revisions += fl.count() - o
  1529                 # be empty during the pull
  1540                 files += 1
  1530                 mf.addgroup(chunkiter, revmap, tr)
  1541 
  1531 
       
  1532                 # process the files
       
  1533                 self.ui.status(_("adding file changes\n"))
       
  1534                 while 1:
       
  1535                     f = changegroup.getchunk(source)
       
  1536                     if not f:
       
  1537                         break
       
  1538                     self.ui.debug(_("adding %s revisions\n") % f)
       
  1539                     fl = self.file(f)
       
  1540                     o = fl.count()
       
  1541                     chunkiter = changegroup.chunkiter(source)
       
  1542                     if fl.addgroup(chunkiter, revmap, tr) is None:
       
  1543                         raise util.Abort(_("received file revlog group is empty"))
       
  1544                     revisions += fl.count() - o
       
  1545                     files += 1
       
  1546 
       
  1547                 # write order here is important so concurrent readers will see
       
  1548                 # consistent view of repo
       
  1549                 mf.writedata()
       
  1550             finally:
       
  1551                 if mf:
       
  1552                     mf.cleanup()
       
  1553             cl.writedata()
  1542             cl.writedata()
  1554         finally:
  1543         finally:
  1555             if cl:
  1544             if cl:
  1556                 cl.cleanup()
  1545                 cl.cleanup()
  1557 
  1546 
  1558         # make changelog and manifest see real files again
  1547         # make changelog see real files again
  1559         self.changelog = changelog.changelog(self.opener, self.changelog.version)
  1548         self.changelog = changelog.changelog(self.opener, self.changelog.version)
  1560         self.manifest = manifest.manifest(self.opener, self.manifest.version)
       
  1561         self.changelog.checkinlinesize(tr)
  1549         self.changelog.checkinlinesize(tr)
  1562         self.manifest.checkinlinesize(tr)
       
  1563 
  1550 
  1564         newheads = len(self.changelog.heads())
  1551         newheads = len(self.changelog.heads())
  1565         heads = ""
  1552         heads = ""
  1566         if oldheads and newheads > oldheads:
  1553         if oldheads and newheads > oldheads:
  1567             heads = _(" (+%d heads)") % (newheads - oldheads)
  1554             heads = _(" (+%d heads)") % (newheads - oldheads)