Show More
@@ -1,57 +1,56 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 |
|
10 | from mercurial import transaction, util, changegroup, localrepo | |
11 | import sys, os |
|
11 | import sys, os | |
12 |
|
12 | |||
13 |
def compress(ui, repo, dest |
|
13 | def compress(ui, repo, dest): | |
14 | dest = os.path.realpath(util.expandpath(dest)) |
|
14 | dest = os.path.realpath(util.expandpath(dest)) | |
15 | target = localrepo.instance(ui, dest, create=1) |
|
15 | target = localrepo.instance(ui, dest, create=1) | |
16 | tr = transaction.transaction(sys.stderr.write, |
|
16 | tr = transaction.transaction(sys.stderr.write, | |
17 | util.opener('.', False), "compress") |
|
17 | util.opener('.', False), "compress") | |
18 | src_cl = repo.changelog |
|
18 | src_cl = repo.changelog | |
19 | tar_cl = target.changelog |
|
19 | tar_cl = target.changelog | |
20 | changedfiles = set() |
|
20 | changedfiles = set() | |
21 | mmfs = {} |
|
21 | mmfs = {} | |
22 | collect = changegroup.collector(src_cl, mmfs, changedfiles) |
|
22 | collect = changegroup.collector(src_cl, mmfs, changedfiles) | |
23 | total = len(repo) |
|
23 | total = len(repo) | |
24 | opener = target.sopener |
|
|||
25 |
|
24 | |||
26 | for r in src_cl: |
|
25 | for r in src_cl: | |
27 | p = [src_cl.node(i) for i in src_cl.parentrevs(r)] |
|
26 | p = [src_cl.node(i) for i in src_cl.parentrevs(r)] | |
28 | nd = tar_cl.addrevision(src_cl.revision(src_cl.node(r)), tr, |
|
27 | nd = tar_cl.addrevision(src_cl.revision(src_cl.node(r)), tr, | |
29 | src_cl.linkrev(r), p[0], p[1]) |
|
28 | src_cl.linkrev(r), p[0], p[1]) | |
30 | collect(nd) |
|
29 | collect(nd) | |
31 | ui.progress(('adding changesets'), r, unit=('revisions'), |
|
30 | ui.progress(('adding changesets'), r, unit=('revisions'), | |
32 | total=total) |
|
31 | total=total) | |
33 |
|
32 | |||
34 | src_mnfst = repo.manifest |
|
33 | src_mnfst = repo.manifest | |
35 | tar_mnfst = target.manifest |
|
34 | tar_mnfst = target.manifest | |
36 | for r in src_mnfst: |
|
35 | for r in src_mnfst: | |
37 | p = [src_mnfst.node(i) for i in src_mnfst.parentrevs(r)] |
|
36 | p = [src_mnfst.node(i) for i in src_mnfst.parentrevs(r)] | |
38 | tar_mnfst.addrevision(src_mnfst.revision(src_mnfst.node(r)), tr, |
|
37 | tar_mnfst.addrevision(src_mnfst.revision(src_mnfst.node(r)), tr, | |
39 | src_mnfst.linkrev(r), p[0], p[1]) |
|
38 | src_mnfst.linkrev(r), p[0], p[1]) | |
40 | ui.progress(('adding manifest'), r, unit=('revisions'), |
|
39 | ui.progress(('adding manifest'), r, unit=('revisions'), | |
41 | total=total) |
|
40 | total=total) | |
42 |
|
41 | |||
43 | total = len(changedfiles) |
|
42 | total = len(changedfiles) | |
44 | for cnt, f in enumerate(changedfiles): |
|
43 | for cnt, f in enumerate(changedfiles): | |
45 | sf = repo.file(f) |
|
44 | sf = repo.file(f) | |
46 | tf = target.file(f) |
|
45 | tf = target.file(f) | |
47 | for r in sf: |
|
46 | for r in sf: | |
48 | p = [sf.node(i) for i in sf.parentrevs(r)] |
|
47 | p = [sf.node(i) for i in sf.parentrevs(r)] | |
49 |
|
|
48 | tf.addrevision(sf.revision(sf.node(r)), tr, sf.linkrev(r), | |
50 | p[0], p[1]) |
|
49 | p[0], p[1]) | |
51 | ui.progress(('adding files'), cnt, item=f, unit=('file'), total=total) |
|
50 | ui.progress(('adding files'), cnt, item=f, unit=('file'), total=total) | |
52 |
|
51 | |||
53 | tr.close() |
|
52 | tr.close() | |
54 |
|
53 | |||
55 | cmdtable = { |
|
54 | cmdtable = { | |
56 | "compress" : (compress, [], "DEST") |
|
55 | "compress" : (compress, [], "DEST") | |
57 | } |
|
56 | } |
General Comments 0
You need to be logged in to leave comments.
Login now