Show More
@@ -1,67 +1,66 b'' | |||||
1 | # Copyright 2010 Pradeepkumar Gayam <in3xes@gmail.com> |
|
1 | # Copyright 2010 Pradeepkumar Gayam <in3xes@gmail.com> | |
2 | # |
|
2 | # | |
3 | # Author(s): |
|
3 | # Author(s): | |
4 | # Pradeepkumar Gayam <in3xes@gmail.com> |
|
4 | # Pradeepkumar Gayam <in3xes@gmail.com> | |
5 | # |
|
5 | # | |
6 | # This software may be used and distributed according to the terms of the |
|
6 | # This software may be used and distributed according to the terms of the | |
7 | # GNU General Public License version 2 or any later version. |
|
7 | # GNU General Public License version 2 or any later version. | |
8 |
|
8 | |||
9 |
|
9 | |||
10 |
from mercurial import hg, |
|
10 | from mercurial import hg, localrepo | |
11 | from mercurial.lock import release |
|
11 | from mercurial.lock import release | |
12 | import weakref |
|
12 | import weakref | |
13 |
|
13 | |||
14 | def compress(ui, repo, dest): |
|
14 | def compress(ui, repo, dest): | |
15 | dest = hg.localpath(ui.expandpath(dest)) |
|
15 | dest = hg.localpath(ui.expandpath(dest)) | |
16 | target = localrepo.instance(ui, dest, create=True) |
|
16 | target = localrepo.instance(ui, dest, create=True) | |
17 |
|
17 | |||
18 | tr = lock = tlock = None |
|
18 | tr = lock = tlock = None | |
19 | try: |
|
19 | try: | |
20 | lock = repo.lock() |
|
20 | lock = repo.lock() | |
21 | tlock = target.lock() |
|
21 | tlock = target.lock() | |
22 | tr = target.transaction("compress") |
|
22 | tr = target.transaction("compress") | |
23 | trp = weakref.proxy(tr) |
|
23 | trp = weakref.proxy(tr) | |
24 |
|
24 | |||
25 | src_cl = repo.changelog |
|
25 | src_cl = repo.changelog | |
26 | tar_cl = target.changelog |
|
26 | tar_cl = target.changelog | |
27 | changedfiles = set() |
|
|||
28 | mmfs = {} |
|
|||
29 | collect = changegroup.collector(src_cl, mmfs, changedfiles) |
|
|||
30 | total = len(repo) |
|
27 | total = len(repo) | |
31 |
|
28 | |||
32 | for r in src_cl: |
|
29 | for r in src_cl: | |
33 | p = [src_cl.node(i) for i in src_cl.parentrevs(r)] |
|
30 | p = [src_cl.node(i) for i in src_cl.parentrevs(r)] | |
34 |
|
|
31 | tar_cl.addrevision(src_cl.revision(src_cl.node(r)), trp, | |
35 |
|
|
32 | src_cl.linkrev(r), p[0], p[1]) | |
36 | collect(nd) |
|
|||
37 | ui.progress(('adding changesets'), r, unit=('revisions'), |
|
33 | ui.progress(('adding changesets'), r, unit=('revisions'), | |
38 | total=total) |
|
34 | total=total) | |
39 |
|
35 | |||
40 | src_mnfst = repo.manifest |
|
36 | src_mnfst = repo.manifest | |
41 | tar_mnfst = target.manifest |
|
37 | tar_mnfst = target.manifest | |
42 | for r in src_mnfst: |
|
38 | for r in src_mnfst: | |
43 | p = [src_mnfst.node(i) for i in src_mnfst.parentrevs(r)] |
|
39 | p = [src_mnfst.node(i) for i in src_mnfst.parentrevs(r)] | |
44 | tar_mnfst.addrevision(src_mnfst.revision(src_mnfst.node(r)), trp, |
|
40 | tar_mnfst.addrevision(src_mnfst.revision(src_mnfst.node(r)), trp, | |
45 | src_mnfst.linkrev(r), p[0], p[1]) |
|
41 | src_mnfst.linkrev(r), p[0], p[1]) | |
46 | ui.progress(('adding manifest'), r, unit=('revisions'), |
|
42 | ui.progress(('adding manifest'), r, unit=('revisions'), | |
47 | total=total) |
|
43 | total=total) | |
48 |
|
44 | |||
49 | total = len(changedfiles) |
|
45 | # only keep indexes and filter "data/" prefix and ".i" suffix | |
50 | for cnt, f in enumerate(changedfiles): |
|
46 | datafiles = [fn[5:-2] for fn, f2, size in repo.store.datafiles() | |
|
47 | if size and fn.endswith('.i')] | |||
|
48 | total = len(datafiles) | |||
|
49 | for cnt, f in enumerate(datafiles): | |||
51 | sf = repo.file(f) |
|
50 | sf = repo.file(f) | |
52 | tf = target.file(f) |
|
51 | tf = target.file(f) | |
53 | for r in sf: |
|
52 | for r in sf: | |
54 | p = [sf.node(i) for i in sf.parentrevs(r)] |
|
53 | p = [sf.node(i) for i in sf.parentrevs(r)] | |
55 | tf.addrevision(sf.revision(sf.node(r)), trp, sf.linkrev(r), |
|
54 | tf.addrevision(sf.revision(sf.node(r)), trp, sf.linkrev(r), | |
56 | p[0], p[1]) |
|
55 | p[0], p[1]) | |
57 | ui.progress(('adding files'), cnt, item=f, unit=('file'), |
|
56 | ui.progress(('adding files'), cnt, item=f, unit=('file'), | |
58 | total=total) |
|
57 | total=total) | |
59 | tr.close() |
|
58 | tr.close() | |
60 | finally: |
|
59 | finally: | |
61 | if tr: |
|
60 | if tr: | |
62 | tr.release() |
|
61 | tr.release() | |
63 | release(tlock, lock) |
|
62 | release(tlock, lock) | |
64 |
|
63 | |||
65 | cmdtable = { |
|
64 | cmdtable = { | |
66 | "compress" : (compress, [], "DEST") |
|
65 | "compress" : (compress, [], "DEST") | |
67 | } |
|
66 | } |
General Comments 0
You need to be logged in to leave comments.
Login now