diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
index db50385257182e14639169b246c7e578e26472ca_bWVyY3VyaWFsL2J1bmRsZTIucHk=..2b72bc88043f858cfc4b5a8fb679949091838a81_bWVyY3VyaWFsL2J1bmRsZTIucHk= 100644
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -859,9 +859,7 @@
             # Ensure part is fully consumed so we can start reading the next
             # part.
             part.consume()
-            # But then seek back to the beginning so the code consuming this
-            # generator has a part that starts at 0.
-            part.seek(0, os.SEEK_SET)
+
             headerblock = self._readpartheader()
         indebug(self.ui, 'end of bundle2 stream')
 
diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
index db50385257182e14639169b246c7e578e26472ca_bWVyY3VyaWFsL2J1bmRsZXJlcG8ucHk=..2b72bc88043f858cfc4b5a8fb679949091838a81_bWVyY3VyaWFsL2J1bmRsZXJlcG8ucHk= 100644
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -288,6 +288,6 @@
             self._bundlefile = bundle
             self._cgunpacker = None
 
-            hadchangegroup = False
+            cgpart = None
             for part in bundle.iterparts():
                 if part.type == 'changegroup':
@@ -292,5 +292,5 @@
             for part in bundle.iterparts():
                 if part.type == 'changegroup':
-                    if hadchangegroup:
+                    if cgpart:
                         raise NotImplementedError("can't process "
                                                   "multiple changegroups")
@@ -295,6 +295,6 @@
                         raise NotImplementedError("can't process "
                                                   "multiple changegroups")
-                    hadchangegroup = True
+                    cgpart = part
 
                 self._handlebundle2part(bundle, part)
 
@@ -298,5 +298,5 @@
 
                 self._handlebundle2part(bundle, part)
 
-            if not hadchangegroup:
+            if not cgpart:
                 raise error.Abort(_("No changegroups found"))
@@ -302,4 +302,12 @@
                 raise error.Abort(_("No changegroups found"))
+
+            # This is required to placate a later consumer, which expects
+            # the payload offset to be at the beginning of the changegroup.
+            # We need to do this after the iterparts() generator advances
+            # because iterparts() will seek to end of payload after the
+            # generator returns control to iterparts().
+            cgpart.seek(0, os.SEEK_SET)
+
         elif isinstance(bundle, changegroup.cg1unpacker):
             if bundle.compressed():
                 f = self._writetempbundle(bundle.read, '.hg10un',