diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py --- a/mercurial/branchmap.py +++ b/mercurial/branchmap.py @@ -517,6 +517,7 @@ # [4 byte hash prefix][4 byte branch name number with sign bit indicating open] _rbcrecfmt = b'>4sI' _rbcrecsize = calcsize(_rbcrecfmt) +_rbcmininc = 64 * _rbcrecsize _rbcnodelen = 4 _rbcbranchidxmask = 0x7FFFFFFF _rbccloseflag = 0x80000000 @@ -656,8 +657,11 @@ self._setcachedata(rev, reponode, branchidx) return b, close - def setdata(self, branch, rev, node, close): + def setdata(self, node, extra): """add new data information to the cache""" + branch = encoding.tolocal(extra.get(b"branch", b"default")) + close = b'close' in extra + if branch in self._namesreverse: branchidx = self._namesreverse[branch] else: @@ -666,7 +670,7 @@ self._namesreverse[branch] = branchidx if close: branchidx |= _rbccloseflag - self._setcachedata(rev, node, branchidx) + self._setcachedata(self._repo.changelog.rev(node), node, branchidx) # If no cache data were readable (non exists, bad permission, etc) # the cache was bypassing itself by setting: # @@ -681,11 +685,10 @@ if rev == nullrev: return rbcrevidx = rev * _rbcrecsize - if len(self._rbcrevs) < rbcrevidx + _rbcrecsize: - self._rbcrevs.extend( - b'\0' - * (len(self._repo.changelog) * _rbcrecsize - len(self._rbcrevs)) - ) + requiredsize = rbcrevidx + _rbcrecsize + rbccur = len(self._rbcrevs) + if rbccur < requiredsize: + self._rbcrevs.extend(b'\0' * max(_rbcmininc, requiredsize)) pack_into(_rbcrecfmt, self._rbcrevs, rbcrevidx, node, branchidx) self._rbcrevslen = min(self._rbcrevslen, rev) diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py --- a/mercurial/bundle2.py +++ b/mercurial/bundle2.py @@ -2478,35 +2478,7 @@ @parthandler(b'cache:rev-branch-cache') def handlerbc(op, inpart): - """receive a rev-branch-cache payload and update the local cache - - The payload is a series of data related to each branch - - 1) branch name length - 2) number of open heads - 3) number of closed heads - 4) open heads nodes - 5) closed heads nodes - """ - total = 0 - rawheader = inpart.read(rbcstruct.size) - cache = op.repo.revbranchcache() - cl = op.repo.unfiltered().changelog - while rawheader: - header = rbcstruct.unpack(rawheader) - total += header[1] + header[2] - utf8branch = inpart.read(header[0]) - branch = encoding.tolocal(utf8branch) - for x in pycompat.xrange(header[1]): - node = inpart.read(20) - rev = cl.rev(node) - cache.setdata(branch, rev, node, False) - for x in pycompat.xrange(header[2]): - node = inpart.read(20) - rev = cl.rev(node) - cache.setdata(branch, rev, node, True) - rawheader = inpart.read(rbcstruct.size) - cache.write() + """Legacy part, ignored for compatibility with older bundles""" @parthandler(b'pushvars') diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py --- a/mercurial/changegroup.py +++ b/mercurial/changegroup.py @@ -323,7 +323,9 @@ cgnodes.append(node) def onchangelog(cl, node): - efilesset.update(cl.readfiles(node)) + ctx = cl.changelogrevision(node) + efilesset.update(ctx.files) + repo.revbranchcache().setdata(node, ctx.extra) self.changelogheader() deltas = self.deltaiter() diff --git a/mercurial/changelog.py b/mercurial/changelog.py --- a/mercurial/changelog.py +++ b/mercurial/changelog.py @@ -601,7 +601,7 @@ This function exists because creating a changectx object just to access this is costly.""" - extra = self.read(rev)[5] + extra = self.changelogrevision(rev).extra return encoding.tolocal(extra.get(b"branch")), b'close' in extra def _nodeduplicatecallback(self, transaction, node): diff --git a/mercurial/commit.py b/mercurial/commit.py --- a/mercurial/commit.py +++ b/mercurial/commit.py @@ -96,6 +96,8 @@ ctx.date(), extra, ) + repo.revbranchcache().setdata(n, extra) + xp1, xp2 = p1.hex(), p2 and p2.hex() or b'' repo.hook( b'pretxncommit', diff --git a/mercurial/exchangev2.py b/mercurial/exchangev2.py --- a/mercurial/exchangev2.py +++ b/mercurial/exchangev2.py @@ -371,6 +371,8 @@ # so we can set the linkrev accordingly when manifests are added. manifestnodes[cl.rev(node)] = revision.manifest + repo.revbranchcache().setdata(node, revision.extra) + nodesbyphase = {phase: set() for phase in phases.phasenames.values()} remotebookmarks = {} diff --git a/tests/test-acl.t b/tests/test-acl.t --- a/tests/test-acl.t +++ b/tests/test-acl.t @@ -204,6 +204,7 @@ bundle2-input-part: "phase-heads" supported bundle2-input-part: total payload size 24 bundle2-input-bundle: 5 parts total + truncating cache/rbc-revs-v1 to 8 updating the branch cache added 3 changesets with 3 changes to 3 files bundle2-output-bundle: "HG20", 1 parts total @@ -283,6 +284,7 @@ bundle2-input-part: "phase-heads" supported bundle2-input-part: total payload size 24 bundle2-input-bundle: 5 parts total + truncating cache/rbc-revs-v1 to 8 updating the branch cache added 3 changesets with 3 changes to 3 files bundle2-output-bundle: "HG20", 1 parts total @@ -806,6 +808,7 @@ acl: acl.deny.bookmarks not enabled acl: bookmark access granted: "ef1ea85a6374b77d6da9dcda9541f498f2d17df7" on bookmark "moving-bookmark" bundle2-input-bundle: 7 parts total + truncating cache/rbc-revs-v1 to 8 updating the branch cache added 1 changesets with 1 changes to 1 files bundle2-output-bundle: "HG20", 1 parts total @@ -981,6 +984,7 @@ bundle2-input-part: "phase-heads" supported bundle2-input-part: total payload size 24 bundle2-input-bundle: 5 parts total + truncating cache/rbc-revs-v1 to 8 updating the branch cache added 3 changesets with 3 changes to 3 files bundle2-output-bundle: "HG20", 1 parts total @@ -1317,6 +1321,7 @@ bundle2-input-part: "phase-heads" supported bundle2-input-part: total payload size 24 bundle2-input-bundle: 5 parts total + truncating cache/rbc-revs-v1 to 8 updating the branch cache added 3 changesets with 3 changes to 3 files bundle2-output-bundle: "HG20", 1 parts total @@ -1407,6 +1412,7 @@ bundle2-input-part: "phase-heads" supported bundle2-input-part: total payload size 24 bundle2-input-bundle: 5 parts total + truncating cache/rbc-revs-v1 to 8 updating the branch cache added 3 changesets with 3 changes to 3 files bundle2-output-bundle: "HG20", 1 parts total @@ -1576,6 +1582,7 @@ bundle2-input-part: "phase-heads" supported bundle2-input-part: total payload size 24 bundle2-input-bundle: 5 parts total + truncating cache/rbc-revs-v1 to 8 updating the branch cache added 3 changesets with 3 changes to 3 files bundle2-output-bundle: "HG20", 1 parts total diff --git a/tests/test-inherit-mode.t b/tests/test-inherit-mode.t --- a/tests/test-inherit-mode.t +++ b/tests/test-inherit-mode.t @@ -134,6 +134,8 @@ 00660 ../push/.hg/00changelog.i 00770 ../push/.hg/cache/ 00660 ../push/.hg/cache/branch2-base + 00660 ../push/.hg/cache/rbc-names-v1 + 00660 ../push/.hg/cache/rbc-revs-v1 00660 ../push/.hg/dirstate 00660 ../push/.hg/requires 00770 ../push/.hg/store/ diff --git a/tests/test-rebase-conflicts.t b/tests/test-rebase-conflicts.t --- a/tests/test-rebase-conflicts.t +++ b/tests/test-rebase-conflicts.t @@ -318,10 +318,10 @@ bundle2-input-part: total payload size 1686 bundle2-input-part: "cache:rev-branch-cache" (advisory) supported bundle2-input-part: total payload size 74 - truncating cache/rbc-revs-v1 to 56 bundle2-input-part: "phase-heads" supported bundle2-input-part: total payload size 24 bundle2-input-bundle: 3 parts total + truncating cache/rbc-revs-v1 to 72 added 2 changesets with 2 changes to 1 files updating the branch cache invalid branch cache (served): tip differs