Show More
@@ -0,0 +1,40 | |||||
|
1 | #!/bin/sh | |||
|
2 | ||||
|
3 | cat >> $HGRCPATH <<EOF | |||
|
4 | [extensions] | |||
|
5 | convert= | |||
|
6 | graphlog= | |||
|
7 | EOF | |||
|
8 | ||||
|
9 | hg init t | |||
|
10 | cd t | |||
|
11 | echo a >> a | |||
|
12 | hg ci -Am a0 -d '1 0' | |||
|
13 | hg branch brancha | |||
|
14 | echo a >> a | |||
|
15 | hg ci -m a1 -d '2 0' | |||
|
16 | echo a >> a | |||
|
17 | hg ci -m a2 -d '3 0' | |||
|
18 | echo a >> a | |||
|
19 | hg ci -m a3 -d '4 0' | |||
|
20 | hg up -C 0 | |||
|
21 | hg branch branchb | |||
|
22 | echo b >> b | |||
|
23 | hg ci -Am b0 -d '5 0' | |||
|
24 | hg up -C brancha | |||
|
25 | echo a >> a | |||
|
26 | hg ci -m a4 -d '6 0' | |||
|
27 | echo a >> a | |||
|
28 | hg ci -m a5 -d '7 0' | |||
|
29 | echo a >> a | |||
|
30 | hg ci -m a6 -d '8 0' | |||
|
31 | hg up -C branchb | |||
|
32 | echo b >> b | |||
|
33 | hg ci -m b1 -d '9 0' | |||
|
34 | cd .. | |||
|
35 | ||||
|
36 | echo % convert with datesort | |||
|
37 | hg convert --datesort t t2 | |||
|
38 | echo % graph converted repo | |||
|
39 | hg -R t2 glog --template '#rev# "#desc#"\n' | |||
|
40 |
@@ -0,0 +1,40 | |||||
|
1 | adding a | |||
|
2 | marked working directory as branch brancha | |||
|
3 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
4 | marked working directory as branch branchb | |||
|
5 | adding b | |||
|
6 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved | |||
|
7 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
8 | % convert with datesort | |||
|
9 | initializing destination t2 repository | |||
|
10 | scanning source... | |||
|
11 | sorting... | |||
|
12 | converting... | |||
|
13 | 8 a0 | |||
|
14 | 7 a1 | |||
|
15 | 6 a2 | |||
|
16 | 5 a3 | |||
|
17 | 4 b0 | |||
|
18 | 3 a4 | |||
|
19 | 2 a5 | |||
|
20 | 1 a6 | |||
|
21 | 0 b1 | |||
|
22 | % graph converted repo | |||
|
23 | o 8 "b1" | |||
|
24 | | | |||
|
25 | | o 7 "a6" | |||
|
26 | | | | |||
|
27 | | o 6 "a5" | |||
|
28 | | | | |||
|
29 | | o 5 "a4" | |||
|
30 | | | | |||
|
31 | o | 4 "b0" | |||
|
32 | | | | |||
|
33 | | o 3 "a3" | |||
|
34 | | | | |||
|
35 | | o 2 "a2" | |||
|
36 | | | | |||
|
37 | | o 1 "a1" | |||
|
38 | |/ | |||
|
39 | o 0 "a0" | |||
|
40 |
@@ -110,6 +110,7 class converter(object): | |||||
110 | visit = parents.keys() |
|
110 | visit = parents.keys() | |
111 | seen = {} |
|
111 | seen = {} | |
112 | children = {} |
|
112 | children = {} | |
|
113 | actives = [] | |||
113 |
|
114 | |||
114 | while visit: |
|
115 | while visit: | |
115 | n = visit.pop(0) |
|
116 | n = visit.pop(0) | |
@@ -118,49 +119,59 class converter(object): | |||||
118 | # Ensure that nodes without parents are present in the 'children' |
|
119 | # Ensure that nodes without parents are present in the 'children' | |
119 | # mapping. |
|
120 | # mapping. | |
120 | children.setdefault(n, []) |
|
121 | children.setdefault(n, []) | |
|
122 | hasparent = False | |||
121 | for p in parents[n]: |
|
123 | for p in parents[n]: | |
122 | if not p in self.map: |
|
124 | if not p in self.map: | |
123 | visit.append(p) |
|
125 | visit.append(p) | |
|
126 | hasparent = True | |||
124 | children.setdefault(p, []).append(n) |
|
127 | children.setdefault(p, []).append(n) | |
|
128 | if not hasparent: | |||
|
129 | actives.append(n) | |||
|
130 | ||||
|
131 | del seen | |||
|
132 | del visit | |||
|
133 | ||||
|
134 | if self.opts.get('datesort'): | |||
|
135 | dates = {} | |||
|
136 | def getdate(n): | |||
|
137 | if n not in dates: | |||
|
138 | dates[n] = util.parsedate(self.commitcache[n].date) | |||
|
139 | return dates[n] | |||
|
140 | ||||
|
141 | def picknext(nodes): | |||
|
142 | return min([(getdate(n), n) for n in nodes])[1] | |||
|
143 | else: | |||
|
144 | prev = [None] | |||
|
145 | def picknext(nodes): | |||
|
146 | # Return the first eligible child of the previously converted | |||
|
147 | # revision, or any of them. | |||
|
148 | next = nodes[0] | |||
|
149 | for n in nodes: | |||
|
150 | if prev[0] in parents[n]: | |||
|
151 | next = n | |||
|
152 | break | |||
|
153 | prev[0] = next | |||
|
154 | return next | |||
125 |
|
155 | |||
126 | s = [] |
|
156 | s = [] | |
127 |
|
|
157 | pendings = {} | |
128 | visit = children.keys() |
|
158 | while actives: | |
129 | while visit: |
|
159 | n = picknext(actives) | |
130 | n = visit.pop(0) |
|
160 | actives.remove(n) | |
131 | if n in removed: continue |
|
161 | s.append(n) | |
132 | dep = 0 |
|
|||
133 | if n in parents: |
|
|||
134 | for p in parents[n]: |
|
|||
135 | if p in self.map: continue |
|
|||
136 | if p not in removed: |
|
|||
137 | # we're still dependent |
|
|||
138 | visit.append(n) |
|
|||
139 | dep = 1 |
|
|||
140 | break |
|
|||
141 |
|
162 | |||
142 |
|
|
163 | # Update dependents list | |
143 | # all n's parents are in the list |
|
164 | for c in children.get(n, []): | |
144 | removed[n] = 1 |
|
165 | if c not in pendings: | |
145 |
if |
|
166 | pendings[c] = [p for p in parents[c] if p not in self.map] | |
146 |
|
|
167 | pendings[c].remove(n) | |
147 |
if n |
|
168 | if not pendings[c]: | |
148 | for c in children[n]: |
|
169 | # Parents are converted, node is eligible | |
149 |
|
|
170 | actives.insert(0, c) | |
|
171 | pendings[c] = None | |||
150 |
|
172 | |||
151 | if self.opts.get('datesort'): |
|
173 | if len(s) != len(parents): | |
152 | depth = {} |
|
174 | raise util.Abort(_("not all revisions were sorted")) | |
153 | for n in s: |
|
|||
154 | depth[n] = 0 |
|
|||
155 | pl = [p for p in self.commitcache[n].parents |
|
|||
156 | if p not in self.map] |
|
|||
157 | if pl: |
|
|||
158 | depth[n] = max([depth[p] for p in pl]) + 1 |
|
|||
159 |
|
||||
160 | s = [(depth[n], util.parsedate(self.commitcache[n].date), n) |
|
|||
161 | for n in s] |
|
|||
162 | s.sort() |
|
|||
163 | s = [e[2] for e in s] |
|
|||
164 |
|
175 | |||
165 | return s |
|
176 | return s | |
166 |
|
177 |
@@ -16,11 +16,11 1 files updated, 0 files merged, 0 files | |||||
16 | (branch merge, don't forget to commit) |
|
16 | (branch merge, don't forget to commit) | |
17 | marked working directory as branch branch3 |
|
17 | marked working directory as branch branch3 | |
18 | % incremental conversion |
|
18 | % incremental conversion | |
19 |
2 c |
|
19 | 2 c2 | |
20 |
pulling from branch0 into branch |
|
20 | pulling from branch0 into branch2 | |
21 | 2 changesets found |
|
21 | 2 changesets found | |
22 |
1 c |
|
22 | 1 c1 | |
23 |
pulling from branch0 into branch |
|
23 | pulling from branch0 into branch1 | |
24 | 2 changesets found |
|
24 | 2 changesets found | |
25 | 0 c3 |
|
25 | 0 c3 | |
26 | pulling from branch2 into branch3 |
|
26 | pulling from branch2 into branch3 |
General Comments 0
You need to be logged in to leave comments.
Login now