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