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