##// END OF EJS Templates
merge with crew
Thomas Arendsen Hein -
r6135:be91a77b merge default
parent child Browse files
Show More
@@ -0,0 +1,40 b''
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 b''
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
@@ -18,6 +18,14 b' import os, shutil'
18 from mercurial import hg, util
18 from mercurial import hg, util
19 from mercurial.i18n import _
19 from mercurial.i18n import _
20
20
21 orig_encoding = 'ascii'
22
23 def recode(s):
24 if isinstance(s, unicode):
25 return s.encode(orig_encoding, 'replace')
26 else:
27 return s.decode('utf-8').encode(orig_encoding, 'replace')
28
21 source_converters = [
29 source_converters = [
22 ('cvs', convert_cvs),
30 ('cvs', convert_cvs),
23 ('git', convert_git),
31 ('git', convert_git),
@@ -102,6 +110,7 b' class converter(object):'
102 visit = parents.keys()
110 visit = parents.keys()
103 seen = {}
111 seen = {}
104 children = {}
112 children = {}
113 actives = []
105
114
106 while visit:
115 while visit:
107 n = visit.pop(0)
116 n = visit.pop(0)
@@ -110,49 +119,63 b' class converter(object):'
110 # Ensure that nodes without parents are present in the 'children'
119 # Ensure that nodes without parents are present in the 'children'
111 # mapping.
120 # mapping.
112 children.setdefault(n, [])
121 children.setdefault(n, [])
122 hasparent = False
113 for p in parents[n]:
123 for p in parents[n]:
114 if not p in self.map:
124 if not p in self.map:
115 visit.append(p)
125 visit.append(p)
126 hasparent = True
116 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
117
155
118 s = []
156 s = []
119 removed = {}
157 pendings = {}
120 visit = children.keys()
158 while actives:
121 while visit:
159 n = picknext(actives)
122 n = visit.pop(0)
160 actives.remove(n)
123 if n in removed: continue
161 s.append(n)
124 dep = 0
125 if n in parents:
126 for p in parents[n]:
127 if p in self.map: continue
128 if p not in removed:
129 # we're still dependent
130 visit.append(n)
131 dep = 1
132 break
133
162
134 if not dep:
163 # Update dependents list
135 # all n's parents are in the list
164 for c in children.get(n, []):
136 removed[n] = 1
165 if c not in pendings:
137 if n not in self.map:
166 pendings[c] = [p for p in parents[c] if p not in self.map]
138 s.append(n)
167 try:
139 if n in children:
168 pendings[c].remove(n)
140 for c in children[n]:
169 except ValueError:
141 visit.insert(0, c)
170 raise util.Abort(_('cycle detected between %s and %s')
171 % (recode(c), recode(n)))
172 if not pendings[c]:
173 # Parents are converted, node is eligible
174 actives.insert(0, c)
175 pendings[c] = None
142
176
143 if self.opts.get('datesort'):
177 if len(s) != len(parents):
144 depth = {}
178 raise util.Abort(_("not all revisions were sorted"))
145 for n in s:
146 depth[n] = 0
147 pl = [p for p in self.commitcache[n].parents
148 if p not in self.map]
149 if pl:
150 depth[n] = max([depth[p] for p in pl]) + 1
151
152 s = [(depth[n], util.parsedate(self.commitcache[n].date), n)
153 for n in s]
154 s.sort()
155 s = [e[2] for e in s]
156
179
157 return s
180 return s
158
181
@@ -240,12 +263,6 b' class converter(object):'
240
263
241 def convert(self):
264 def convert(self):
242
265
243 def recode(s):
244 if isinstance(s, unicode):
245 return s.encode(orig_encoding, 'replace')
246 else:
247 return s.decode('utf-8').encode(orig_encoding, 'replace')
248
249 try:
266 try:
250 self.source.before()
267 self.source.before()
251 self.dest.before()
268 self.dest.before()
@@ -296,8 +313,6 b' class converter(object):'
296 self.source.after()
313 self.source.after()
297 self.map.close()
314 self.map.close()
298
315
299 orig_encoding = 'ascii'
300
301 def convert(ui, src, dest=None, revmapfile=None, **opts):
316 def convert(ui, src, dest=None, revmapfile=None, **opts):
302 global orig_encoding
317 global orig_encoding
303 orig_encoding = util._encoding
318 orig_encoding = util._encoding
@@ -1522,7 +1522,7 b' class localrepository(repo.repository):'
1522 self.ui.warn(_("abort: push creates new remote branches!\n"))
1522 self.ui.warn(_("abort: push creates new remote branches!\n"))
1523 self.ui.status(_("(did you forget to merge?"
1523 self.ui.status(_("(did you forget to merge?"
1524 " use push -f to force)\n"))
1524 " use push -f to force)\n"))
1525 return None, 1
1525 return None, 0
1526 elif inc:
1526 elif inc:
1527 self.ui.warn(_("note: unsynced remote changes!\n"))
1527 self.ui.warn(_("note: unsynced remote changes!\n"))
1528
1528
@@ -901,6 +901,9 b' def gui():'
901 '''Are we running in a GUI?'''
901 '''Are we running in a GUI?'''
902 return os.name == "nt" or os.name == "mac" or os.environ.get("DISPLAY")
902 return os.name == "nt" or os.name == "mac" or os.environ.get("DISPLAY")
903
903
904 def lookup_reg(key, name=None, scope=None):
905 return None
906
904 # Platform specific variants
907 # Platform specific variants
905 if os.name == 'nt':
908 if os.name == 'nt':
906 import msvcrt
909 import msvcrt
@@ -1092,9 +1095,6 b" if os.name == 'nt':"
1092 else:
1095 else:
1093 nulldev = '/dev/null'
1096 nulldev = '/dev/null'
1094
1097
1095 def lookup_reg(key, name=None, scope=None):
1096 return None
1097
1098 def rcfiles(path):
1098 def rcfiles(path):
1099 rcs = [os.path.join(path, 'hgrc')]
1099 rcs = [os.path.join(path, 'hgrc')]
1100 rcdir = os.path.join(path, 'hgrc.d')
1100 rcdir = os.path.join(path, 'hgrc.d')
@@ -16,11 +16,11 b' 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 c1
19 2 c2
20 pulling from branch0 into branch1
20 pulling from branch0 into branch2
21 2 changesets found
21 2 changesets found
22 1 c2
22 1 c1
23 pulling from branch0 into branch2
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
@@ -33,7 +33,7 b' pushing to ../c'
33 searching for changes
33 searching for changes
34 abort: push creates new remote branches!
34 abort: push creates new remote branches!
35 (did you forget to merge? use push -f to force)
35 (did you forget to merge? use push -f to force)
36 0
36 1
37 pushing to ../c
37 pushing to ../c
38 searching for changes
38 searching for changes
39 no changes found
39 no changes found
@@ -42,12 +42,12 b' pushing to ../c'
42 searching for changes
42 searching for changes
43 abort: push creates new remote branches!
43 abort: push creates new remote branches!
44 (did you forget to merge? use push -f to force)
44 (did you forget to merge? use push -f to force)
45 0
45 1
46 pushing to ../c
46 pushing to ../c
47 searching for changes
47 searching for changes
48 abort: push creates new remote branches!
48 abort: push creates new remote branches!
49 (did you forget to merge? use push -f to force)
49 (did you forget to merge? use push -f to force)
50 0
50 1
51 pushing to ../c
51 pushing to ../c
52 searching for changes
52 searching for changes
53 adding changesets
53 adding changesets
General Comments 0
You need to be logged in to leave comments. Login now