##// END OF EJS Templates
contrib/compress: refactor revlog copying
contrib/compress: refactor revlog copying

File last commit:

r12020:69498b1b default
r12020:69498b1b default
Show More
compress.py
59 lines | 1.8 KiB | text/x-python | PythonLexer
Pradeepkumar Gayam
contrib: simple extension to practically convert a repo from tip delta to parentdelta
r11933 # Copyright 2010 Pradeepkumar Gayam <in3xes@gmail.com>
#
# Author(s):
# Pradeepkumar Gayam <in3xes@gmail.com>
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
Benoit Boissinot
contrib/compress: use store API instead of a collector
r12019 from mercurial import hg, localrepo
Benoit Boissinot
contrib/compress: proper lock handling...
r12018 from mercurial.lock import release
import weakref
Pradeepkumar Gayam
contrib: simple extension to practically convert a repo from tip delta to parentdelta
r11933
Benoit Boissinot
contrib/compress: refactor revlog copying
r12020 def _copyrevlog(ui, src, dst, tr, progress=None):
if progress:
desc = 'adding %s' % progress
total = len(src)
def progress(count):
ui.progress(desc, count, unit=('revisions'), total=total)
else:
progress = lambda x: None
for r in src:
p = [src.node(i) for i in src.parentrevs(r)]
dst.addrevision(src.revision(src.node(r)), tr, src.linkrev(r),
p[0], p[1])
progress(r)
Benoit Boissinot
contrib/compress: remove unused variables
r12015 def compress(ui, repo, dest):
Benoit Boissinot
contrib/compress: use hg API to compute the destination path
r12017 dest = hg.localpath(ui.expandpath(dest))
target = localrepo.instance(ui, dest, create=True)
Benoit Boissinot
contrib/compress: proper lock handling...
r12018
tr = lock = tlock = None
try:
lock = repo.lock()
tlock = target.lock()
tr = target.transaction("compress")
trp = weakref.proxy(tr)
Pradeepkumar Gayam
contrib: simple extension to practically convert a repo from tip delta to parentdelta
r11933
Benoit Boissinot
contrib/compress: refactor revlog copying
r12020 _copyrevlog(ui, repo.changelog, target.changelog, trp, 'changesets')
_copyrevlog(ui, repo.manifest, target.manifest, trp, 'manifest')
Pradeepkumar Gayam
contrib: simple extension to practically convert a repo from tip delta to parentdelta
r11933
Benoit Boissinot
contrib/compress: use store API instead of a collector
r12019 # only keep indexes and filter "data/" prefix and ".i" suffix
datafiles = [fn[5:-2] for fn, f2, size in repo.store.datafiles()
if size and fn.endswith('.i')]
total = len(datafiles)
for cnt, f in enumerate(datafiles):
Benoit Boissinot
contrib/compress: refactor revlog copying
r12020 _copyrevlog(ui, repo.file(f), target.file(f), trp)
Benoit Boissinot
contrib/compress: proper lock handling...
r12018 ui.progress(('adding files'), cnt, item=f, unit=('file'),
total=total)
Benoit Boissinot
contrib/compress: refactor revlog copying
r12020
Benoit Boissinot
contrib/compress: proper lock handling...
r12018 tr.close()
finally:
if tr:
tr.release()
release(tlock, lock)
Pradeepkumar Gayam
contrib: simple extension to practically convert a repo from tip delta to parentdelta
r11933
cmdtable = {
"compress" : (compress, [], "DEST")
}