##// END OF EJS Templates
convert: better support for CVS branchpoints (issue1447)...
Henrik Stuart -
r8756:6019e651 default
parent child Browse files
Show More
@@ -36,6 +36,7 b' class logentry(object):'
36 36 .synthetic - is this a synthetic "file ... added on ..." revision?
37 37 .mergepoint- the branch that has been merged from
38 38 (if present in rlog output)
39 .branchpoints- the branches that start at the current entry
39 40 '''
40 41 def __init__(self, **entries):
41 42 self.__dict__.update(entries)
@@ -400,6 +401,19 b' def createlog(ui, directory=None, root="'
400 401 else:
401 402 e.branch = None
402 403
404 # find the branches starting from this revision
405 branchpoints = set()
406 for branch, revision in branchmap.iteritems():
407 revparts = tuple([int(i) for i in revision.split('.')])
408 if revparts[-2] == 0 and revparts[-1] % 2 == 0:
409 # normal branch
410 if revparts[:-2] == e.revision:
411 branchpoints.add(branch)
412 elif revparts == (1,1,1): # vendor branch
413 if revparts in e.branches:
414 branchpoints.add(branch)
415 e.branchpoints = branchpoints
416
403 417 log.append(e)
404 418
405 419 if len(log) % 100 == 0:
@@ -453,6 +467,7 b' class changeset(object):'
453 467 .synthetic - from synthetic revision "file ... added on branch ..."
454 468 .mergepoint- the branch that has been merged from
455 469 (if present in rlog output)
470 .branchpoints- the branches that start at the current entry
456 471 '''
457 472 def __init__(self, **entries):
458 473 self.__dict__.update(entries)
@@ -477,17 +492,34 b' def createchangeset(ui, log, fuzz=60, me'
477 492 for i, e in enumerate(log):
478 493
479 494 # Check if log entry belongs to the current changeset or not.
495
496 # Since CVS is file centric, two different file revisions with
497 # different branchpoints should be treated as belonging to two
498 # different changesets (and the ordering is important and not
499 # honoured by cvsps at this point).
500 #
501 # Consider the following case:
502 # foo 1.1 branchpoints: [MYBRANCH]
503 # bar 1.1 branchpoints: [MYBRANCH, MYBRANCH2]
504 #
505 # Here foo is part only of MYBRANCH, but not MYBRANCH2, e.g. a
506 # later version of foo may be in MYBRANCH2, so foo should be the
507 # first changeset and bar the next and MYBRANCH and MYBRANCH2
508 # should both start off of the bar changeset. No provisions are
509 # made to ensure that this is, in fact, what happens.
480 510 if not (c and
481 511 e.comment == c.comment and
482 512 e.author == c.author and
483 513 e.branch == c.branch and
514 e.branchpoints == c.branchpoints and
484 515 ((c.date[0] + c.date[1]) <=
485 516 (e.date[0] + e.date[1]) <=
486 517 (c.date[0] + c.date[1]) + fuzz) and
487 518 e.file not in files):
488 519 c = changeset(comment=e.comment, author=e.author,
489 520 branch=e.branch, date=e.date, entries=[],
490 mergepoint=getattr(e, 'mergepoint', None))
521 mergepoint=getattr(e, 'mergepoint', None),
522 branchpoints=getattr(e, 'branchpoints', set()))
491 523 changesets.append(c)
492 524 files = set()
493 525 if len(changesets) % 100 == 0:
@@ -613,8 +645,17 b' def createchangeset(ui, log, fuzz=60, me'
613 645 if c.branch in branches:
614 646 p = branches[c.branch]
615 647 else:
616 for f in c.entries:
617 p = max(p, versions.get((f.rcs, f.parent), None))
648 # first changeset on a new branch
649 # the parent is a changeset with the branch in its
650 # branchpoints such that it is the latest possible
651 # commit without any intervening, unrelated commits.
652
653 for candidate in xrange(i):
654 if c.branch not in changesets[candidate].branchpoints:
655 if p is not None:
656 break
657 continue
658 p = candidate
618 659
619 660 c.parents = []
620 661 if p is not None:
@@ -753,6 +794,9 b' def debugcvsps(ui, *args, **opts):'
753 794 ui.write('Branch: %s\n' % (cs.branch or 'HEAD'))
754 795 ui.write('Tag%s: %s \n' % (['', 's'][len(cs.tags)>1],
755 796 ','.join(cs.tags) or '(none)'))
797 branchpoints = getattr(cs, 'branchpoints', None)
798 if branchpoints:
799 ui.write('Branchpoints: %s \n' % ', '.join(branchpoints))
756 800 if opts["parents"] and cs.parents:
757 801 if len(cs.parents)>1:
758 802 ui.write('Parents: %s\n' % (','.join([str(p.id) for p in cs.parents])))
@@ -1,6 +1,7 b''
1 1 #!/bin/sh
2 2
3 3 # This is http://www.selenic.com/mercurial/bts/issue1148
4 # and http://www.selenic.com/mercurial/bts/issue1447
4 5
5 6 "$TESTDIR/hghave" cvs || exit 80
6 7
@@ -62,3 +63,50 b" hg convert src | sed -e 's/connecting to"
62 63 echo % Check the result
63 64
64 65 hg -R src-hg glog --template '{rev} ({branches}) {desc} files: {files}\n'
66
67 echo ""
68
69 echo % issue 1447
70 cvscall()
71 {
72 echo cvs -f "$@"
73 cvs -f "$@"
74 sleep 1
75 }
76
77 cvsci()
78 {
79 echo cvs -f ci "$@"
80 cvs -f ci "$@" >/dev/null 2>&1
81 sleep 1
82 }
83
84 cvscall -Q -d `pwd`/cvsmaster2 init >/dev/null 2>&1
85 cd cvsmaster2
86 export CVSROOT=`pwd`
87 mkdir foo
88 cd ..
89 cvscall -Q co -d cvswork2 foo
90
91 cd cvswork2
92 echo foo > a.txt
93 echo bar > b.txt
94 cvscall -Q add a.txt b.txt
95 cvsci -m "Initial commit"
96
97 echo foo > b.txt
98 cvsci -m "Fix b on HEAD"
99
100 echo bar > a.txt
101 cvsci -m "Small fix in a on HEAD"
102
103 cvscall -Q tag -b BRANCH
104 cvscall -Q up -P -rBRANCH
105
106 echo baz > b.txt
107 cvsci -m "Change on BRANCH in b"
108
109 hg debugcvsps -x --parents foo | sed -e 's/Author:.*/Author:/' -e 's/Date:.*/Date:/'
110
111 cd ..
112
@@ -51,3 +51,71 b' o 5 () update tags files: .hgtags'
51 51 |/
52 52 o 0 () Initial revision files: a b
53 53
54
55 % issue 1447
56 cvs -f -Q co -d cvswork2 foo
57 cvs -f -Q add a.txt b.txt
58 cvs -f ci -m Initial commit
59 cvs -f ci -m Fix b on HEAD
60 cvs -f ci -m Small fix in a on HEAD
61 cvs -f -Q tag -b BRANCH
62 cvs -f -Q up -P -rBRANCH
63 cvs -f ci -m Change on BRANCH in b
64 collecting CVS rlog
65 5 log entries
66 creating changesets
67 4 changeset entries
68 ---------------------
69 PatchSet 1
70 Date:
71 Author:
72 Branch: HEAD
73 Tag: (none)
74 Log:
75 Initial commit
76
77 Members:
78 a.txt:INITIAL->1.1
79 b.txt:INITIAL->1.1
80
81 ---------------------
82 PatchSet 2
83 Date:
84 Author:
85 Branch: HEAD
86 Tag: (none)
87 Branchpoints: BRANCH
88 Parent: 1
89 Log:
90 Fix b on HEAD
91
92 Members:
93 b.txt:1.1->1.2
94
95 ---------------------
96 PatchSet 3
97 Date:
98 Author:
99 Branch: HEAD
100 Tag: (none)
101 Branchpoints: BRANCH
102 Parent: 2
103 Log:
104 Small fix in a on HEAD
105
106 Members:
107 a.txt:1.1->1.2
108
109 ---------------------
110 PatchSet 4
111 Date:
112 Author:
113 Branch: BRANCH
114 Tag: (none)
115 Parent: 3
116 Log:
117 Change on BRANCH in b
118
119 Members:
120 b.txt:1.2->1.2.2.1
121
@@ -94,7 +94,6 b' cd ..'
94 94
95 95 echo % convert again
96 96 hg convert src src-hg | sed -e 's/connecting to.*cvsrepo/connecting to cvsrepo/g'
97 hgcat a
98 97 hgcat b/c
99 98
100 99 echo % convert again with --filemap
@@ -104,7 +104,6 b' 5 changeset entries'
104 104 sorting...
105 105 converting...
106 106 0 ci2
107 a
108 107 c
109 108 d
110 109 % convert again with --filemap
@@ -142,13 +141,13 b' o 6 (branch) funny'
142 141 | ----------------------------
143 142 | log message files: a
144 143 o 5 (branch) ci2 files: b/c
144
145 o 4 () ci1 files: a b/c
145 146 |
146 | o 4 () ci1 files: a b/c
147 | |
148 | o 3 () update tags files: .hgtags
149 | |
150 | o 2 () ci0 files: b/c
151 |/
147 o 3 () update tags files: .hgtags
148 |
149 o 2 () ci0 files: b/c
150 |
152 151 | o 1 (INITIAL) import files:
153 152 |/
154 153 o 0 () Initial revision files: a b/c
@@ -157,22 +156,35 b' o 0 () Initial revision files: a b/c'
157 156 collecting CVS rlog
158 157 9 log entries
159 158 creating changesets
160 6 changeset entries
159 8 changeset entries
161 160 ---------------------
162 161 PatchSet 1
163 162 Date:
164 163 Author:
165 164 Branch: HEAD
166 165 Tag: (none)
166 Branchpoints: INITIAL
167 167 Log:
168 168 Initial revision
169 169
170 170 Members:
171 171 a:INITIAL->1.1
172
173 ---------------------
174 PatchSet 2
175 Date:
176 Author:
177 Branch: HEAD
178 Tag: (none)
179 Branchpoints: INITIAL, branch
180 Log:
181 Initial revision
182
183 Members:
172 184 b/c:INITIAL->1.1
173 185
174 186 ---------------------
175 PatchSet 2
187 PatchSet 3
176 188 Date:
177 189 Author:
178 190 Branch: INITIAL
@@ -185,7 +197,7 b' Members:'
185 197 b/c:1.1->1.1.1.1
186 198
187 199 ---------------------
188 PatchSet 3
200 PatchSet 4
189 201 Date:
190 202 Author:
191 203 Branch: HEAD
@@ -197,7 +209,20 b' Members:'
197 209 b/c:1.1->1.2
198 210
199 211 ---------------------
200 PatchSet 4
212 PatchSet 5
213 Date:
214 Author:
215 Branch: HEAD
216 Tag: (none)
217 Branchpoints: branch
218 Log:
219 ci1
220
221 Members:
222 a:1.1->1.2
223
224 ---------------------
225 PatchSet 6
201 226 Date:
202 227 Author:
203 228 Branch: HEAD
@@ -206,11 +231,10 b' Log:'
206 231 ci1
207 232
208 233 Members:
209 a:1.1->1.2
210 234 b/c:1.2->1.3
211 235
212 236 ---------------------
213 PatchSet 5
237 PatchSet 7
214 238 Date:
215 239 Author:
216 240 Branch: branch
@@ -222,7 +246,7 b' Members:'
222 246 b/c:1.1->1.1.2.1
223 247
224 248 ---------------------
225 PatchSet 6
249 PatchSet 8
226 250 Date:
227 251 Author:
228 252 Branch: branch
General Comments 0
You need to be logged in to leave comments. Login now