author | Matt Mackall <mpm@selenic.com> |
Fri, 20 Aug 2010 21:23:47 -0500 | |
changeset 12006 | af00e58bd383 |
parent 11933 | 293afcfb66a8 |
child 12015 | 73940fe84cbf |
permissions | -rw-r--r-- |
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 |
|
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
10 |
from mercurial import hg, ui, transaction, util, changegroup, localrepo, merge |
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 |
|
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
13 |
def compress(ui, repo, dest, **opts): |
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 |
opener = target.sopener |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
25 |
|
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
26 |
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
|
27 |
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
|
28 |
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
|
29 |
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
|
30 |
collect(nd) |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
31 |
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
|
32 |
total=total) |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
33 |
|
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
34 |
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
|
35 |
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
|
36 |
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
|
37 |
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
|
38 |
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
|
39 |
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
|
40 |
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
|
41 |
total=total) |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
42 |
|
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
43 |
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
|
44 |
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
|
45 |
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
|
46 |
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
|
47 |
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
|
48 |
p = [sf.node(i) for i in sf.parentrevs(r)] |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
49 |
a = tf.addrevision(sf.revision(sf.node(r)), tr, sf.linkrev(r), |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
50 |
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
|
51 |
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
|
52 |
|
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
53 |
tr.close() |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
54 |
|
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
55 |
cmdtable = { |
293afcfb66a8
contrib: simple extension to practically convert a repo from tip delta to parentdelta
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
diff
changeset
|
56 |
"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
|
57 |
} |