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