comparison mercurial/revlog.py @ 34160:c8b6ed51386b

changegroup: remove changegroup dependency from revlog.addgroup Previously revlog.addgroup would accept a changegroup and a linkmapper and use it to iterate of the deltas. As part of untangling the revlog-changegroup interdependency, let's move the changegroup delta iteration logic to it's own function and pass the simple iterator to the revlog instead. This will make it easier to introduce non-revlogs stores in the future, without reinventing any changegroup specific logic. Differential Revision: https://phab.mercurial-scm.org/D688
author Durham Goode <durham@fb.com>
date Wed, 13 Sep 2017 10:43:44 -0700
parents b96cfc309ac5
children 448725a2ef73
comparison
equal deleted inserted replaced
34159:b96cfc309ac5 34160:c8b6ed51386b
1870 ifh.write(entry) 1870 ifh.write(entry)
1871 ifh.write(data[0]) 1871 ifh.write(data[0])
1872 ifh.write(data[1]) 1872 ifh.write(data[1])
1873 self.checkinlinesize(transaction, ifh) 1873 self.checkinlinesize(transaction, ifh)
1874 1874
1875 def addgroup(self, cg, linkmapper, transaction, addrevisioncb=None): 1875 def addgroup(self, deltas, transaction, addrevisioncb=None):
1876 """ 1876 """
1877 add a delta group 1877 add a delta group
1878 1878
1879 given a set of deltas, add them to the revision log. the 1879 given a set of deltas, add them to the revision log. the
1880 first delta is against its parent, which should be in our 1880 first delta is against its parent, which should be in our
1903 if dfh: 1903 if dfh:
1904 dfh.flush() 1904 dfh.flush()
1905 ifh.flush() 1905 ifh.flush()
1906 try: 1906 try:
1907 # loop through our set of deltas 1907 # loop through our set of deltas
1908 chain = None 1908 for data in deltas:
1909 for chunkdata in iter(lambda: cg.deltachunk(chain), {}): 1909 node, p1, p2, link, deltabase, delta, flags = data
1910 node = chunkdata['node'] 1910 flags = flags or REVIDX_DEFAULT_FLAGS
1911 p1 = chunkdata['p1']
1912 p2 = chunkdata['p2']
1913 cs = chunkdata['cs']
1914 deltabase = chunkdata['deltabase']
1915 delta = chunkdata['delta']
1916 flags = chunkdata['flags'] or REVIDX_DEFAULT_FLAGS
1917 1911
1918 nodes.append(node) 1912 nodes.append(node)
1919 chain = node 1913
1920
1921 link = linkmapper(cs)
1922 if node in self.nodemap: 1914 if node in self.nodemap:
1923 # this can happen if two branches make the same change 1915 # this can happen if two branches make the same change
1924 continue 1916 continue
1925 1917
1926 for p in (p1, p2): 1918 for p in (p1, p2):