Mercurial > hg
annotate contrib/compress.py @ 12015:73940fe84cbf
contrib/compress: remove unused variables
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Sun, 22 Aug 2010 18:18:36 +0200 |
parents | 293afcfb66a8 |
children | 705425f297a8 |
rev | line source |
---|---|
11933
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
1 # Copyright 2010 Pradeepkumar Gayam <in3xes@gmail.com> |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
2 # |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
3 # Author(s): |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
4 # Pradeepkumar Gayam <in3xes@gmail.com> |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
5 # |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
6 # This software may be used and distributed according to the terms of the |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
7 # GNU General Public License version 2 or any later version. |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
8 |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
9 |
12015
73940fe84cbf
contrib/compress: remove unused variables
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
11933
diff
changeset
|
10 from mercurial import transaction, util, changegroup, localrepo |
11933
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
11 import sys, os |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
12 |
12015
73940fe84cbf
contrib/compress: remove unused variables
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
11933
diff
changeset
|
13 def compress(ui, repo, dest): |
11933
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
14 dest = os.path.realpath(util.expandpath(dest)) |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
15 target = localrepo.instance(ui, dest, create=1) |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
16 tr = transaction.transaction(sys.stderr.write, |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
17 util.opener('.', False), "compress") |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
18 src_cl = repo.changelog |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
19 tar_cl = target.changelog |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
20 changedfiles = set() |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
21 mmfs = {} |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
22 collect = changegroup.collector(src_cl, mmfs, changedfiles) |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
23 total = len(repo) |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
24 |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
25 for r in src_cl: |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
26 p = [src_cl.node(i) for i in src_cl.parentrevs(r)] |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
27 nd = tar_cl.addrevision(src_cl.revision(src_cl.node(r)), tr, |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
28 src_cl.linkrev(r), p[0], p[1]) |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
29 collect(nd) |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
30 ui.progress(('adding changesets'), r, unit=('revisions'), |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
31 total=total) |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
32 |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
33 src_mnfst = repo.manifest |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
34 tar_mnfst = target.manifest |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
35 for r in src_mnfst: |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
36 p = [src_mnfst.node(i) for i in src_mnfst.parentrevs(r)] |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
37 tar_mnfst.addrevision(src_mnfst.revision(src_mnfst.node(r)), tr, |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
38 src_mnfst.linkrev(r), p[0], p[1]) |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
39 ui.progress(('adding manifest'), r, unit=('revisions'), |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
40 total=total) |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
41 |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
42 total = len(changedfiles) |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
43 for cnt, f in enumerate(changedfiles): |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
44 sf = repo.file(f) |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
45 tf = target.file(f) |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
46 for r in sf: |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
47 p = [sf.node(i) for i in sf.parentrevs(r)] |
12015
73940fe84cbf
contrib/compress: remove unused variables
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
11933
diff
changeset
|
48 tf.addrevision(sf.revision(sf.node(r)), tr, sf.linkrev(r), |
11933
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
49 p[0], p[1]) |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
50 ui.progress(('adding files'), cnt, item=f, unit=('file'), total=total) |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
51 |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
52 tr.close() |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
53 |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
54 cmdtable = { |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
55 "compress" : (compress, [], "DEST") |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
56 } |