bundlerepo: handle changegroup induced phase movement in the associated method
These movement comes from handling the changegroup part, so we keeps the code
grouped. This will be important when handling more part (and more changegroup
part in the future)
This induce a small code duplication, but it does not looks terrible.
--- a/mercurial/bundlerepo.py Thu Feb 23 19:06:24 2023 +0100
+++ b/mercurial/bundlerepo.py Thu Feb 23 19:07:58 2023 +0100
@@ -327,6 +327,14 @@
_(b'bundle type %s cannot be read') % type(bundle)
)
+ def _handle_bundle1(self, bundle, bundlepath):
+ if bundle.compressed():
+ f = self._writetempbundle(bundle.read, b'.hg10un', header=b'HG10UN')
+ bundle = exchange.readbundle(self.ui, f, bundlepath, self.vfs)
+
+ self._bundlefile = bundle
+ self._cgunpacker = bundle
+
self.firstnewrev = self.changelog.repotiprev + 1
phases.retractboundary(
self,
@@ -335,14 +343,6 @@
[ctx.node() for ctx in self[self.firstnewrev :]],
)
- def _handle_bundle1(self, bundle, bundlepath):
- if bundle.compressed():
- f = self._writetempbundle(bundle.read, b'.hg10un', header=b'HG10UN')
- bundle = exchange.readbundle(self.ui, f, bundlepath, self.vfs)
-
- self._bundlefile = bundle
- self._cgunpacker = bundle
-
def _handle_bundle2_cg_part(self, bundle, part):
assert part.type == b'changegroup'
cgstream = part
@@ -356,6 +356,14 @@
self._cgunpacker = changegroup.getunbundler(version, cgstream, b'UN')
+ self.firstnewrev = self.changelog.repotiprev + 1
+ phases.retractboundary(
+ self,
+ None,
+ phases.draft,
+ [ctx.node() for ctx in self[self.firstnewrev :]],
+ )
+
def _writetempbundle(self, readfn, suffix, header=b''):
"""Write a temporary file to disk"""
fdtemp, temp = self.vfs.mkstemp(prefix=b"hg-bundle-", suffix=suffix)