Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/revlog.py @ 34159:b96cfc309ac5
revlog: refactor chain variable
Previously the addgroup loop would set chain to be the result of
self._addrevision(node,...). Since _addrevision now always returns the passed in
node, we can drop that behavior and just always set chain = node in the loop.
This will be useful in a future patch where we refactor the cg.deltachunk logic
to another function and therefore chain disappears entirely from this function.
Differential Revision: https://phab.mercurial-scm.org/D699
author | Durham Goode <durham@fb.com> |
---|---|
date | Wed, 13 Sep 2017 10:43:16 -0700 |
parents | bfb38c5cebf4 |
children | c8b6ed51386b |
comparison
equal
deleted
inserted
replaced
34158:9e4f82bc2b0b | 34159:b96cfc309ac5 |
---|---|
1914 deltabase = chunkdata['deltabase'] | 1914 deltabase = chunkdata['deltabase'] |
1915 delta = chunkdata['delta'] | 1915 delta = chunkdata['delta'] |
1916 flags = chunkdata['flags'] or REVIDX_DEFAULT_FLAGS | 1916 flags = chunkdata['flags'] or REVIDX_DEFAULT_FLAGS |
1917 | 1917 |
1918 nodes.append(node) | 1918 nodes.append(node) |
1919 chain = node | |
1919 | 1920 |
1920 link = linkmapper(cs) | 1921 link = linkmapper(cs) |
1921 if node in self.nodemap: | 1922 if node in self.nodemap: |
1922 # this can happen if two branches make the same change | 1923 # this can happen if two branches make the same change |
1923 chain = node | |
1924 continue | 1924 continue |
1925 | 1925 |
1926 for p in (p1, p2): | 1926 for p in (p1, p2): |
1927 if p not in self.nodemap: | 1927 if p not in self.nodemap: |
1928 raise LookupError(p, self.indexfile, | 1928 raise LookupError(p, self.indexfile, |
1952 # revision(). revision() will fast path if there is a cache | 1952 # revision(). revision() will fast path if there is a cache |
1953 # hit. So, we tell _addrevision() to always cache in this case. | 1953 # hit. So, we tell _addrevision() to always cache in this case. |
1954 # We're only using addgroup() in the context of changegroup | 1954 # We're only using addgroup() in the context of changegroup |
1955 # generation so the revision data can always be handled as raw | 1955 # generation so the revision data can always be handled as raw |
1956 # by the flagprocessor. | 1956 # by the flagprocessor. |
1957 chain = self._addrevision(node, None, transaction, link, | 1957 self._addrevision(node, None, transaction, link, |
1958 p1, p2, flags, (baserev, delta), | 1958 p1, p2, flags, (baserev, delta), |
1959 ifh, dfh, | 1959 ifh, dfh, |
1960 alwayscache=bool(addrevisioncb)) | 1960 alwayscache=bool(addrevisioncb)) |
1961 | 1961 |
1962 if addrevisioncb: | 1962 if addrevisioncb: |
1963 addrevisioncb(self, chain) | 1963 addrevisioncb(self, node) |
1964 | 1964 |
1965 if not dfh and not self._inline: | 1965 if not dfh and not self._inline: |
1966 # addrevision switched from inline to conventional | 1966 # addrevision switched from inline to conventional |
1967 # reopen the index | 1967 # reopen the index |
1968 ifh.close() | 1968 ifh.close() |