Show More
@@ -8,46 +8,59 b'' | |||
|
8 | 8 | |
|
9 | 9 | |
|
10 | 10 | from mercurial import hg, changegroup, localrepo |
|
11 | from mercurial.lock import release | |
|
12 | import weakref | |
|
11 | 13 | |
|
12 | 14 | def compress(ui, repo, dest): |
|
13 | 15 | dest = hg.localpath(ui.expandpath(dest)) |
|
14 | 16 | target = localrepo.instance(ui, dest, create=True) |
|
15 | tr = target.transaction("compress") | |
|
16 | src_cl = repo.changelog | |
|
17 | tar_cl = target.changelog | |
|
18 | changedfiles = set() | |
|
19 | mmfs = {} | |
|
20 | collect = changegroup.collector(src_cl, mmfs, changedfiles) | |
|
21 | total = len(repo) | |
|
17 | ||
|
18 | tr = lock = tlock = None | |
|
19 | try: | |
|
20 | lock = repo.lock() | |
|
21 | tlock = target.lock() | |
|
22 | tr = target.transaction("compress") | |
|
23 | trp = weakref.proxy(tr) | |
|
22 | 24 | |
|
23 | for r in src_cl: | |
|
24 | p = [src_cl.node(i) for i in src_cl.parentrevs(r)] | |
|
25 | nd = tar_cl.addrevision(src_cl.revision(src_cl.node(r)), tr, | |
|
26 | src_cl.linkrev(r), p[0], p[1]) | |
|
27 | collect(nd) | |
|
28 | ui.progress(('adding changesets'), r, unit=('revisions'), | |
|
29 | total=total) | |
|
25 | src_cl = repo.changelog | |
|
26 | tar_cl = target.changelog | |
|
27 | changedfiles = set() | |
|
28 | mmfs = {} | |
|
29 | collect = changegroup.collector(src_cl, mmfs, changedfiles) | |
|
30 | total = len(repo) | |
|
31 | ||
|
32 | for r in src_cl: | |
|
33 | p = [src_cl.node(i) for i in src_cl.parentrevs(r)] | |
|
34 | nd = tar_cl.addrevision(src_cl.revision(src_cl.node(r)), trp, | |
|
35 | src_cl.linkrev(r), p[0], p[1]) | |
|
36 | collect(nd) | |
|
37 | ui.progress(('adding changesets'), r, unit=('revisions'), | |
|
38 | total=total) | |
|
30 | 39 | |
|
31 | src_mnfst = repo.manifest | |
|
32 | tar_mnfst = target.manifest | |
|
33 | for r in src_mnfst: | |
|
34 | p = [src_mnfst.node(i) for i in src_mnfst.parentrevs(r)] | |
|
35 | tar_mnfst.addrevision(src_mnfst.revision(src_mnfst.node(r)), tr, | |
|
36 | src_mnfst.linkrev(r), p[0], p[1]) | |
|
37 | ui.progress(('adding manifest'), r, unit=('revisions'), | |
|
38 | total=total) | |
|
40 | src_mnfst = repo.manifest | |
|
41 | tar_mnfst = target.manifest | |
|
42 | for r in src_mnfst: | |
|
43 | p = [src_mnfst.node(i) for i in src_mnfst.parentrevs(r)] | |
|
44 | tar_mnfst.addrevision(src_mnfst.revision(src_mnfst.node(r)), trp, | |
|
45 | src_mnfst.linkrev(r), p[0], p[1]) | |
|
46 | ui.progress(('adding manifest'), r, unit=('revisions'), | |
|
47 | total=total) | |
|
39 | 48 | |
|
40 | total = len(changedfiles) | |
|
41 | for cnt, f in enumerate(changedfiles): | |
|
42 | sf = repo.file(f) | |
|
43 | tf = target.file(f) | |
|
44 | for r in sf: | |
|
45 | p = [sf.node(i) for i in sf.parentrevs(r)] | |
|
46 | tf.addrevision(sf.revision(sf.node(r)), tr, sf.linkrev(r), | |
|
49 | total = len(changedfiles) | |
|
50 | for cnt, f in enumerate(changedfiles): | |
|
51 | sf = repo.file(f) | |
|
52 | tf = target.file(f) | |
|
53 | for r in sf: | |
|
54 | p = [sf.node(i) for i in sf.parentrevs(r)] | |
|
55 | tf.addrevision(sf.revision(sf.node(r)), trp, sf.linkrev(r), | |
|
47 | 56 | p[0], p[1]) |
|
48 |
ui.progress(('adding files'), cnt, item=f, unit=('file'), |
|
|
49 | ||
|
50 | tr.close() | |
|
57 | ui.progress(('adding files'), cnt, item=f, unit=('file'), | |
|
58 | total=total) | |
|
59 | tr.close() | |
|
60 | finally: | |
|
61 | if tr: | |
|
62 | tr.release() | |
|
63 | release(tlock, lock) | |
|
51 | 64 | |
|
52 | 65 | cmdtable = { |
|
53 | 66 | "compress" : (compress, [], "DEST") |
General Comments 0
You need to be logged in to leave comments.
Login now