Skip to content

Commit

Permalink
Add an option to store the last unbundled bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
glandium committed Feb 2, 2022
1 parent f0275d6 commit ef23945
Showing 2 changed files with 27 additions and 1 deletion.
25 changes: 25 additions & 0 deletions cinnabar/hg/repo.py
Original file line number Diff line number Diff line change
@@ -678,10 +678,35 @@ def unbundler(bundle):
chunk_type = RawRevChunk01
cg = bundle

if check_enabled('unbundler') and "GIT_DIR" in os.environ:
class BundleSaver(object):
def __init__(self, cg):
self.cg = cg
self.out = open(os.path.join(
os.environ["GIT_DIR"], "cinnabar-last-bundle"), "wb")
self.out.write(b'HG20\0\0\0\0')
self.out.write(b'\0\0\0\x1d\x0bCHANGEGROUP\0\0\0\0')
self.out.write(b'\x01\x00\x07\x02version')
self.out.write(b'01' if chunk_type is RawRevChunk01 else b'02')

def read(self, length=None):
data = self.cg.read(length)
self.out.write(struct.pack('>l', len(data)))
self.out.write(data)
return data

def end_bundle(self):
self.out.write(b'\0\0\0\0\0\0\0\0')

cg = BundleSaver(cg)

yield chunks_in_changegroup(chunk_type, cg, 'changeset')
yield chunks_in_changegroup(chunk_type, cg, 'manifest')
yield iterate_files(chunk_type, cg)

if hasattr(cg, "end_bundle"):
cg.end_bundle()

if unbundle20 and isinstance(bundle, unbundle20):
for part in parts:
logging.getLogger('bundle2').warning(
3 changes: 2 additions & 1 deletion cinnabar/util.py
Original file line number Diff line number Diff line change
@@ -144,7 +144,8 @@ def __call__(self, name):
'cinnabar.check',
('nodeid', 'manifests', 'helper'),
('bundle', 'files', 'memory', 'cpu', 'time', 'traceback', 'no-mercurial',
'no-bundle2', 'cinnabarclone', 'clonebundles', 'no-version-check'),
'no-bundle2', 'cinnabarclone', 'clonebundles', 'no-version-check',
'unbundler'),
)

experiment = ConfigSetFunc(

0 comments on commit ef23945

Please sign in to comment.