##// END OF EJS Templates
Add option to heads to show only heads for current branch.
Eric Hopper -
r4648:8e503fa5 default
parent child Browse files
Show More
@@ -0,0 +1,108 b''
1 #!/bin/sh
2
3 hg init a
4 cd a
5 echo 'root' >root
6 hg add root
7 hg commit -d '0 0' -u test -m "Adding root node"
8 hg heads
9 echo '-------'
10 hg heads .
11
12 echo '======='
13 echo 'a' >a
14 hg add a
15 hg branch a
16 hg commit -d '1 0' -u test -m "Adding a branch"
17 hg heads
18 echo '-------'
19 hg heads .
20
21 echo '======='
22 hg update -C 0
23 echo 'b' >b
24 hg add b
25 hg branch b
26 hg commit -d '2 0' -u test -m "Adding b branch"
27 hg heads
28 echo '-------'
29 hg heads .
30
31 echo '======='
32 echo 'bh1' >bh1
33 hg add bh1
34 hg commit -d '3 0' -u test -m "Adding b branch head 1"
35 hg heads
36 echo '-------'
37 hg heads .
38
39 echo '======='
40 hg update -C 2
41 echo 'bh2' >bh2
42 hg add bh2
43 hg commit -d '4 0' -u test -m "Adding b branch head 2"
44 hg heads
45 echo '-------'
46 hg heads .
47
48 echo '======='
49 hg update -C 2
50 echo 'bh3' >bh3
51 hg add bh3
52 hg commit -d '5 0' -u test -m "Adding b branch head 3"
53 hg heads
54 echo '-------'
55 hg heads .
56
57 echo '======='
58 hg merge 4
59 hg commit -d '6 0' -u test -m "Merging b branch head 2 and b branch head 3"
60 hg heads
61 echo '-------'
62 hg heads .
63
64 echo '======='
65 echo 'c' >c
66 hg add c
67 hg branch c
68 hg commit -d '7 0' -u test -m "Adding c branch"
69 hg heads
70 echo '-------'
71 hg heads .
72
73 echo '======='
74 hg heads -r 3 .
75 echo $?
76 echo '-------'
77 hg heads -r 2 .
78 echo $?
79 echo '-------'
80 hg update -C 4
81 echo $?
82 echo '-------'
83 hg heads -r 3 .
84 echo $?
85 echo '-------'
86 hg heads -r 2 .
87 echo $?
88 echo '-------'
89 hg heads -r 7 .
90 echo $?
91
92 echo '======='
93 for i in 0 1 2 3 4 5 6 7; do
94 hg update -C "$i"
95 hg heads
96 echo '-------'
97 hg heads .
98 echo '-------'
99 done
100
101 echo '======='
102 for i in a b c z; do
103 hg heads "$i"
104 echo '-------'
105 done
106
107 echo '======='
108 hg heads 0 1 2 3 4 5 6 7
This diff has been collapsed as it changes many lines, (608 lines changed) Show them Hide them
@@ -0,0 +1,608 b''
1 changeset: 0:19709c5a4e75
2 tag: tip
3 user: test
4 date: Thu Jan 01 00:00:00 1970 +0000
5 summary: Adding root node
6
7 -------
8 changeset: 0:19709c5a4e75
9 tag: tip
10 user: test
11 date: Thu Jan 01 00:00:00 1970 +0000
12 summary: Adding root node
13
14 =======
15 marked working directory as branch a
16 changeset: 1:dd6b440dd85a
17 branch: a
18 tag: tip
19 user: test
20 date: Thu Jan 01 00:00:01 1970 +0000
21 summary: Adding a branch
22
23 -------
24 changeset: 1:dd6b440dd85a
25 branch: a
26 tag: tip
27 user: test
28 date: Thu Jan 01 00:00:01 1970 +0000
29 summary: Adding a branch
30
31 =======
32 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
33 marked working directory as branch b
34 changeset: 2:ac22033332d1
35 branch: b
36 tag: tip
37 parent: 0:19709c5a4e75
38 user: test
39 date: Thu Jan 01 00:00:02 1970 +0000
40 summary: Adding b branch
41
42 changeset: 1:dd6b440dd85a
43 branch: a
44 user: test
45 date: Thu Jan 01 00:00:01 1970 +0000
46 summary: Adding a branch
47
48 -------
49 changeset: 2:ac22033332d1
50 branch: b
51 tag: tip
52 parent: 0:19709c5a4e75
53 user: test
54 date: Thu Jan 01 00:00:02 1970 +0000
55 summary: Adding b branch
56
57 =======
58 changeset: 3:aee39cd168d0
59 branch: b
60 tag: tip
61 user: test
62 date: Thu Jan 01 00:00:03 1970 +0000
63 summary: Adding b branch head 1
64
65 changeset: 1:dd6b440dd85a
66 branch: a
67 user: test
68 date: Thu Jan 01 00:00:01 1970 +0000
69 summary: Adding a branch
70
71 -------
72 changeset: 3:aee39cd168d0
73 branch: b
74 tag: tip
75 user: test
76 date: Thu Jan 01 00:00:03 1970 +0000
77 summary: Adding b branch head 1
78
79 =======
80 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
81 changeset: 4:22df7444f7c1
82 branch: b
83 tag: tip
84 parent: 2:ac22033332d1
85 user: test
86 date: Thu Jan 01 00:00:04 1970 +0000
87 summary: Adding b branch head 2
88
89 changeset: 3:aee39cd168d0
90 branch: b
91 user: test
92 date: Thu Jan 01 00:00:03 1970 +0000
93 summary: Adding b branch head 1
94
95 changeset: 1:dd6b440dd85a
96 branch: a
97 user: test
98 date: Thu Jan 01 00:00:01 1970 +0000
99 summary: Adding a branch
100
101 -------
102 changeset: 4:22df7444f7c1
103 branch: b
104 tag: tip
105 parent: 2:ac22033332d1
106 user: test
107 date: Thu Jan 01 00:00:04 1970 +0000
108 summary: Adding b branch head 2
109
110 changeset: 3:aee39cd168d0
111 branch: b
112 user: test
113 date: Thu Jan 01 00:00:03 1970 +0000
114 summary: Adding b branch head 1
115
116 =======
117 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
118 changeset: 5:0d57af4f9583
119 branch: b
120 tag: tip
121 parent: 2:ac22033332d1
122 user: test
123 date: Thu Jan 01 00:00:05 1970 +0000
124 summary: Adding b branch head 3
125
126 changeset: 4:22df7444f7c1
127 branch: b
128 parent: 2:ac22033332d1
129 user: test
130 date: Thu Jan 01 00:00:04 1970 +0000
131 summary: Adding b branch head 2
132
133 changeset: 3:aee39cd168d0
134 branch: b
135 user: test
136 date: Thu Jan 01 00:00:03 1970 +0000
137 summary: Adding b branch head 1
138
139 changeset: 1:dd6b440dd85a
140 branch: a
141 user: test
142 date: Thu Jan 01 00:00:01 1970 +0000
143 summary: Adding a branch
144
145 -------
146 changeset: 5:0d57af4f9583
147 branch: b
148 tag: tip
149 parent: 2:ac22033332d1
150 user: test
151 date: Thu Jan 01 00:00:05 1970 +0000
152 summary: Adding b branch head 3
153
154 changeset: 4:22df7444f7c1
155 branch: b
156 parent: 2:ac22033332d1
157 user: test
158 date: Thu Jan 01 00:00:04 1970 +0000
159 summary: Adding b branch head 2
160
161 changeset: 3:aee39cd168d0
162 branch: b
163 user: test
164 date: Thu Jan 01 00:00:03 1970 +0000
165 summary: Adding b branch head 1
166
167 =======
168 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
169 (branch merge, don't forget to commit)
170 changeset: 6:00432327d822
171 branch: b
172 tag: tip
173 parent: 5:0d57af4f9583
174 parent: 4:22df7444f7c1
175 user: test
176 date: Thu Jan 01 00:00:06 1970 +0000
177 summary: Merging b branch head 2 and b branch head 3
178
179 changeset: 3:aee39cd168d0
180 branch: b
181 user: test
182 date: Thu Jan 01 00:00:03 1970 +0000
183 summary: Adding b branch head 1
184
185 changeset: 1:dd6b440dd85a
186 branch: a
187 user: test
188 date: Thu Jan 01 00:00:01 1970 +0000
189 summary: Adding a branch
190
191 -------
192 changeset: 6:00432327d822
193 branch: b
194 tag: tip
195 parent: 5:0d57af4f9583
196 parent: 4:22df7444f7c1
197 user: test
198 date: Thu Jan 01 00:00:06 1970 +0000
199 summary: Merging b branch head 2 and b branch head 3
200
201 changeset: 3:aee39cd168d0
202 branch: b
203 user: test
204 date: Thu Jan 01 00:00:03 1970 +0000
205 summary: Adding b branch head 1
206
207 =======
208 marked working directory as branch c
209 changeset: 7:9fb091bb9835
210 branch: c
211 tag: tip
212 user: test
213 date: Thu Jan 01 00:00:07 1970 +0000
214 summary: Adding c branch
215
216 changeset: 3:aee39cd168d0
217 branch: b
218 user: test
219 date: Thu Jan 01 00:00:03 1970 +0000
220 summary: Adding b branch head 1
221
222 changeset: 1:dd6b440dd85a
223 branch: a
224 user: test
225 date: Thu Jan 01 00:00:01 1970 +0000
226 summary: Adding a branch
227
228 -------
229 changeset: 7:9fb091bb9835
230 branch: c
231 tag: tip
232 user: test
233 date: Thu Jan 01 00:00:07 1970 +0000
234 summary: Adding c branch
235
236 =======
237 No changes on branch c (the branch of revision .) are reachable from revision 3
238 1
239 -------
240 changeset: 7:9fb091bb9835
241 branch: c
242 tag: tip
243 user: test
244 date: Thu Jan 01 00:00:07 1970 +0000
245 summary: Adding c branch
246
247 0
248 -------
249 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
250 0
251 -------
252 changeset: 3:aee39cd168d0
253 branch: b
254 user: test
255 date: Thu Jan 01 00:00:03 1970 +0000
256 summary: Adding b branch head 1
257
258 0
259 -------
260 changeset: 3:aee39cd168d0
261 branch: b
262 user: test
263 date: Thu Jan 01 00:00:03 1970 +0000
264 summary: Adding b branch head 1
265
266 changeset: 6:00432327d822
267 branch: b
268 parent: 5:0d57af4f9583
269 parent: 4:22df7444f7c1
270 user: test
271 date: Thu Jan 01 00:00:06 1970 +0000
272 summary: Merging b branch head 2 and b branch head 3
273
274 0
275 -------
276 No changes on branch b (the branch of revision .) are reachable from revision 7
277 1
278 =======
279 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
280 changeset: 7:9fb091bb9835
281 branch: c
282 tag: tip
283 user: test
284 date: Thu Jan 01 00:00:07 1970 +0000
285 summary: Adding c branch
286
287 changeset: 3:aee39cd168d0
288 branch: b
289 user: test
290 date: Thu Jan 01 00:00:03 1970 +0000
291 summary: Adding b branch head 1
292
293 changeset: 1:dd6b440dd85a
294 branch: a
295 user: test
296 date: Thu Jan 01 00:00:01 1970 +0000
297 summary: Adding a branch
298
299 -------
300 changeset: 0:19709c5a4e75
301 user: test
302 date: Thu Jan 01 00:00:00 1970 +0000
303 summary: Adding root node
304
305 -------
306 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
307 changeset: 7:9fb091bb9835
308 branch: c
309 tag: tip
310 user: test
311 date: Thu Jan 01 00:00:07 1970 +0000
312 summary: Adding c branch
313
314 changeset: 3:aee39cd168d0
315 branch: b
316 user: test
317 date: Thu Jan 01 00:00:03 1970 +0000
318 summary: Adding b branch head 1
319
320 changeset: 1:dd6b440dd85a
321 branch: a
322 user: test
323 date: Thu Jan 01 00:00:01 1970 +0000
324 summary: Adding a branch
325
326 -------
327 changeset: 1:dd6b440dd85a
328 branch: a
329 user: test
330 date: Thu Jan 01 00:00:01 1970 +0000
331 summary: Adding a branch
332
333 -------
334 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
335 changeset: 7:9fb091bb9835
336 branch: c
337 tag: tip
338 user: test
339 date: Thu Jan 01 00:00:07 1970 +0000
340 summary: Adding c branch
341
342 changeset: 3:aee39cd168d0
343 branch: b
344 user: test
345 date: Thu Jan 01 00:00:03 1970 +0000
346 summary: Adding b branch head 1
347
348 changeset: 1:dd6b440dd85a
349 branch: a
350 user: test
351 date: Thu Jan 01 00:00:01 1970 +0000
352 summary: Adding a branch
353
354 -------
355 changeset: 6:00432327d822
356 branch: b
357 parent: 5:0d57af4f9583
358 parent: 4:22df7444f7c1
359 user: test
360 date: Thu Jan 01 00:00:06 1970 +0000
361 summary: Merging b branch head 2 and b branch head 3
362
363 changeset: 3:aee39cd168d0
364 branch: b
365 user: test
366 date: Thu Jan 01 00:00:03 1970 +0000
367 summary: Adding b branch head 1
368
369 -------
370 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
371 changeset: 7:9fb091bb9835
372 branch: c
373 tag: tip
374 user: test
375 date: Thu Jan 01 00:00:07 1970 +0000
376 summary: Adding c branch
377
378 changeset: 3:aee39cd168d0
379 branch: b
380 user: test
381 date: Thu Jan 01 00:00:03 1970 +0000
382 summary: Adding b branch head 1
383
384 changeset: 1:dd6b440dd85a
385 branch: a
386 user: test
387 date: Thu Jan 01 00:00:01 1970 +0000
388 summary: Adding a branch
389
390 -------
391 changeset: 6:00432327d822
392 branch: b
393 parent: 5:0d57af4f9583
394 parent: 4:22df7444f7c1
395 user: test
396 date: Thu Jan 01 00:00:06 1970 +0000
397 summary: Merging b branch head 2 and b branch head 3
398
399 changeset: 3:aee39cd168d0
400 branch: b
401 user: test
402 date: Thu Jan 01 00:00:03 1970 +0000
403 summary: Adding b branch head 1
404
405 -------
406 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
407 changeset: 7:9fb091bb9835
408 branch: c
409 tag: tip
410 user: test
411 date: Thu Jan 01 00:00:07 1970 +0000
412 summary: Adding c branch
413
414 changeset: 3:aee39cd168d0
415 branch: b
416 user: test
417 date: Thu Jan 01 00:00:03 1970 +0000
418 summary: Adding b branch head 1
419
420 changeset: 1:dd6b440dd85a
421 branch: a
422 user: test
423 date: Thu Jan 01 00:00:01 1970 +0000
424 summary: Adding a branch
425
426 -------
427 changeset: 6:00432327d822
428 branch: b
429 parent: 5:0d57af4f9583
430 parent: 4:22df7444f7c1
431 user: test
432 date: Thu Jan 01 00:00:06 1970 +0000
433 summary: Merging b branch head 2 and b branch head 3
434
435 changeset: 3:aee39cd168d0
436 branch: b
437 user: test
438 date: Thu Jan 01 00:00:03 1970 +0000
439 summary: Adding b branch head 1
440
441 -------
442 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
443 changeset: 7:9fb091bb9835
444 branch: c
445 tag: tip
446 user: test
447 date: Thu Jan 01 00:00:07 1970 +0000
448 summary: Adding c branch
449
450 changeset: 3:aee39cd168d0
451 branch: b
452 user: test
453 date: Thu Jan 01 00:00:03 1970 +0000
454 summary: Adding b branch head 1
455
456 changeset: 1:dd6b440dd85a
457 branch: a
458 user: test
459 date: Thu Jan 01 00:00:01 1970 +0000
460 summary: Adding a branch
461
462 -------
463 changeset: 6:00432327d822
464 branch: b
465 parent: 5:0d57af4f9583
466 parent: 4:22df7444f7c1
467 user: test
468 date: Thu Jan 01 00:00:06 1970 +0000
469 summary: Merging b branch head 2 and b branch head 3
470
471 changeset: 3:aee39cd168d0
472 branch: b
473 user: test
474 date: Thu Jan 01 00:00:03 1970 +0000
475 summary: Adding b branch head 1
476
477 -------
478 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
479 changeset: 7:9fb091bb9835
480 branch: c
481 tag: tip
482 user: test
483 date: Thu Jan 01 00:00:07 1970 +0000
484 summary: Adding c branch
485
486 changeset: 3:aee39cd168d0
487 branch: b
488 user: test
489 date: Thu Jan 01 00:00:03 1970 +0000
490 summary: Adding b branch head 1
491
492 changeset: 1:dd6b440dd85a
493 branch: a
494 user: test
495 date: Thu Jan 01 00:00:01 1970 +0000
496 summary: Adding a branch
497
498 -------
499 changeset: 6:00432327d822
500 branch: b
501 parent: 5:0d57af4f9583
502 parent: 4:22df7444f7c1
503 user: test
504 date: Thu Jan 01 00:00:06 1970 +0000
505 summary: Merging b branch head 2 and b branch head 3
506
507 changeset: 3:aee39cd168d0
508 branch: b
509 user: test
510 date: Thu Jan 01 00:00:03 1970 +0000
511 summary: Adding b branch head 1
512
513 -------
514 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
515 changeset: 7:9fb091bb9835
516 branch: c
517 tag: tip
518 user: test
519 date: Thu Jan 01 00:00:07 1970 +0000
520 summary: Adding c branch
521
522 changeset: 3:aee39cd168d0
523 branch: b
524 user: test
525 date: Thu Jan 01 00:00:03 1970 +0000
526 summary: Adding b branch head 1
527
528 changeset: 1:dd6b440dd85a
529 branch: a
530 user: test
531 date: Thu Jan 01 00:00:01 1970 +0000
532 summary: Adding a branch
533
534 -------
535 changeset: 7:9fb091bb9835
536 branch: c
537 tag: tip
538 user: test
539 date: Thu Jan 01 00:00:07 1970 +0000
540 summary: Adding c branch
541
542 -------
543 =======
544 changeset: 1:dd6b440dd85a
545 branch: a
546 user: test
547 date: Thu Jan 01 00:00:01 1970 +0000
548 summary: Adding a branch
549
550 -------
551 changeset: 6:00432327d822
552 branch: b
553 parent: 5:0d57af4f9583
554 parent: 4:22df7444f7c1
555 user: test
556 date: Thu Jan 01 00:00:06 1970 +0000
557 summary: Merging b branch head 2 and b branch head 3
558
559 changeset: 3:aee39cd168d0
560 branch: b
561 user: test
562 date: Thu Jan 01 00:00:03 1970 +0000
563 summary: Adding b branch head 1
564
565 -------
566 changeset: 7:9fb091bb9835
567 branch: c
568 tag: tip
569 user: test
570 date: Thu Jan 01 00:00:07 1970 +0000
571 summary: Adding c branch
572
573 -------
574 abort: unknown revision 'z'!
575 -------
576 =======
577 changeset: 0:19709c5a4e75
578 user: test
579 date: Thu Jan 01 00:00:00 1970 +0000
580 summary: Adding root node
581
582 changeset: 1:dd6b440dd85a
583 branch: a
584 user: test
585 date: Thu Jan 01 00:00:01 1970 +0000
586 summary: Adding a branch
587
588 changeset: 6:00432327d822
589 branch: b
590 parent: 5:0d57af4f9583
591 parent: 4:22df7444f7c1
592 user: test
593 date: Thu Jan 01 00:00:06 1970 +0000
594 summary: Merging b branch head 2 and b branch head 3
595
596 changeset: 3:aee39cd168d0
597 branch: b
598 user: test
599 date: Thu Jan 01 00:00:03 1970 +0000
600 summary: Adding b branch head 1
601
602 changeset: 7:9fb091bb9835
603 branch: c
604 tag: tip
605 user: test
606 date: Thu Jan 01 00:00:07 1970 +0000
607 summary: Adding c branch
608
@@ -1206,19 +1206,51 b' def grep(ui, repo, pattern, *pats, **opt'
1206 1206 found = display(fn, rev, {}, state) or found
1207 1207 return (not found and 1) or 0
1208 1208
1209 def heads(ui, repo, **opts):
1210 """show current repository heads
1211
1212 Show all repository head changesets.
1213
1214 Repository "heads" are changesets that don't have children
1209 def heads(ui, repo, *branchrevs, **opts):
1210 """show current repository heads or show branch heads
1211
1212 With no arguments, show all repository head changesets.
1213
1214 If branch or revisions names are given this will show the heads of
1215 the specified branches or the branches those revisions are tagged
1216 with.
1217
1218 Repository "heads" are changesets that don't have child
1215 1219 changesets. They are where development generally takes place and
1216 1220 are the usual targets for update and merge operations.
1221
1222 Branch heads are changesets that have a given branch tag, but have
1223 no child changesets with that tag. They are usually where
1224 development on the given branch takes place.
1217 1225 """
1218 1226 if opts['rev']:
1219 heads = repo.heads(repo.lookup(opts['rev']))
1227 start = repo.lookup(opts['rev'])
1228 else:
1229 start = None
1230 if not branchrevs:
1231 # Assume we're looking repo-wide heads if no revs were specified.
1232 heads = repo.heads(start)
1220 1233 else:
1221 heads = repo.heads()
1234 heads = []
1235 visitedset = set()
1236 displayer = cmdutil.show_changeset(ui, repo, opts)
1237 for branchrev in branchrevs:
1238 branch = repo.changectx(branchrev).branch()
1239 if branch in visitedset:
1240 continue
1241 visitedset.add(branch)
1242 bheads = repo.branchheads(branch, start)
1243 if not bheads:
1244 if branch != branchrev:
1245 ui.warn(_("no changes on branch %s containing %s are "
1246 "reachable from %s\n")
1247 % (branch, branchrev, opts['rev']))
1248 else:
1249 ui.warn(_("no changes on branch %s are reachable from %s\n")
1250 % (branch, opts['rev']))
1251 heads.extend(bheads)
1252 if not heads:
1253 return 1
1222 1254 displayer = cmdutil.show_changeset(ui, repo, opts)
1223 1255 for n in heads:
1224 1256 displayer.show(changenode=n)
@@ -2790,7 +2822,7 b' table = {'
2790 2822 [('', 'style', '', _('display using template map file')),
2791 2823 ('r', 'rev', '', _('show only heads which are descendants of rev')),
2792 2824 ('', 'template', '', _('display with template'))],
2793 _('hg heads [-r REV]')),
2825 _('hg heads [-r REV] [REV]...')),
2794 2826 "help": (help_, [], _('hg help [COMMAND]')),
2795 2827 "identify|id": (identify, [], _('hg identify')),
2796 2828 "import|patch":
@@ -1019,6 +1019,52 b' class localrepository(repo.repository):'
1019 1019 heads.sort()
1020 1020 return [n for (r, n) in heads]
1021 1021
1022 def branchheads(self, branch, start=None):
1023 branches = self.branchtags()
1024 if branch not in branches:
1025 return []
1026 # The basic algorithm is this:
1027 #
1028 # Start from the branch tip since there are no later revisions that can
1029 # possibly be in this branch, and the tip is a guaranteed head.
1030 #
1031 # Remember the tip's parents as the first ancestors, since these by
1032 # definition are not heads.
1033 #
1034 # Step backwards from the brach tip through all the revisions. We are
1035 # guaranteed by the rules of Mercurial that we will now be visiting the
1036 # nodes in reverse topological order (children before parents).
1037 #
1038 # If a revision is one of the ancestors of a head then we can toss it
1039 # out of the ancestors set (we've already found it and won't be
1040 # visiting it again) and put its parents in the ancestors set.
1041 #
1042 # Otherwise, if a revision is in the branch it's another head, since it
1043 # wasn't in the ancestor list of an existing head. So add it to the
1044 # head list, and add its parents to the ancestor list.
1045 #
1046 # If it is not in the branch ignore it.
1047 #
1048 # Once we have a list of heads, use nodesbetween to filter out all the
1049 # heads that cannot be reached from startrev. There may be a more
1050 # efficient way to do this as part of the previous algorithm.
1051
1052 set = util.set
1053 heads = [self.changelog.rev(branches[branch])]
1054 # Don't care if ancestors contains nullrev or not.
1055 ancestors = set(self.changelog.parentrevs(heads[0]))
1056 for rev in xrange(heads[0] - 1, nullrev, -1):
1057 if rev in ancestors:
1058 ancestors.update(self.changelog.parentrevs(rev))
1059 ancestors.remove(rev)
1060 elif self.changectx(rev).branch() == branch:
1061 heads.append(rev)
1062 ancestors.update(self.changelog.parentrevs(rev))
1063 heads = [self.changelog.node(rev) for rev in heads]
1064 if start is not None:
1065 heads = self.changelog.nodesbetween([start], heads)[2]
1066 return heads
1067
1022 1068 def branches(self, nodes):
1023 1069 if not nodes:
1024 1070 nodes = [self.changelog.tip()]
General Comments 0
You need to be logged in to leave comments. Login now