Show More
@@ -1,54 +1,67 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 | 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) |
|
17 | ||
|
18 | tr = lock = tlock = None | |
|
19 | try: | |
|
20 | lock = repo.lock() | |
|
21 | tlock = target.lock() | |
|
15 | 22 | tr = target.transaction("compress") |
|
23 | trp = weakref.proxy(tr) | |
|
24 | ||
|
16 | 25 | src_cl = repo.changelog |
|
17 | 26 | tar_cl = target.changelog |
|
18 | 27 | changedfiles = set() |
|
19 | 28 | mmfs = {} |
|
20 | 29 | collect = changegroup.collector(src_cl, mmfs, changedfiles) |
|
21 | 30 | total = len(repo) |
|
22 | 31 | |
|
23 | 32 | for r in src_cl: |
|
24 | 33 | 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, | |
|
34 | nd = tar_cl.addrevision(src_cl.revision(src_cl.node(r)), trp, | |
|
26 | 35 | src_cl.linkrev(r), p[0], p[1]) |
|
27 | 36 | collect(nd) |
|
28 | 37 | ui.progress(('adding changesets'), r, unit=('revisions'), |
|
29 | 38 | total=total) |
|
30 | 39 | |
|
31 | 40 | src_mnfst = repo.manifest |
|
32 | 41 | tar_mnfst = target.manifest |
|
33 | 42 | for r in src_mnfst: |
|
34 | 43 | p = [src_mnfst.node(i) for i in src_mnfst.parentrevs(r)] |
|
35 | tar_mnfst.addrevision(src_mnfst.revision(src_mnfst.node(r)), tr, | |
|
44 | tar_mnfst.addrevision(src_mnfst.revision(src_mnfst.node(r)), trp, | |
|
36 | 45 | src_mnfst.linkrev(r), p[0], p[1]) |
|
37 | 46 | ui.progress(('adding manifest'), r, unit=('revisions'), |
|
38 | 47 | total=total) |
|
39 | 48 | |
|
40 | 49 | total = len(changedfiles) |
|
41 | 50 | for cnt, f in enumerate(changedfiles): |
|
42 | 51 | sf = repo.file(f) |
|
43 | 52 | tf = target.file(f) |
|
44 | 53 | for r in sf: |
|
45 | 54 | p = [sf.node(i) for i in sf.parentrevs(r)] |
|
46 | tf.addrevision(sf.revision(sf.node(r)), tr, sf.linkrev(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 | ||
|
57 | ui.progress(('adding files'), cnt, item=f, unit=('file'), | |
|
58 | total=total) | |
|
50 | 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") |
|
54 | 67 | } |
General Comments 0
You need to be logged in to leave comments.
Login now