##// END OF EJS Templates
localrepo: remove 'closed' argument to heads(...) function...
John Mulligan -
r8796:2bcef677 default
parent child Browse files
Show More
@@ -446,8 +446,12 b' def branches(ui, repo, active=False):'
446 446 """
447 447 hexfunc = ui.debugflag and hex or short
448 448 activebranches = [encoding.tolocal(repo[n].branch())
449 for n in repo.heads(closed=False)]
450 branches = sorted([(tag in activebranches, repo.changelog.rev(node), tag)
449 for n in repo.heads()]
450 def testactive(tag, node):
451 realhead = tag in activebranches
452 open = node in repo.branchheads(tag, closed=False)
453 return realhead and open
454 branches = sorted([(testactive(tag, node), repo.changelog.rev(node), tag)
451 455 for tag, node in repo.branchtags().items()],
452 456 reverse=True)
453 457
@@ -1302,17 +1306,22 b' def heads(ui, repo, *branchrevs, **opts)'
1302 1306
1303 1307 With no arguments, show all repository head changesets.
1304 1308
1305 If branch names or revisions are given this will show the heads of
1306 the specified branches or the branches those revisions are tagged
1307 with.
1308
1309 1309 Repository "heads" are changesets that don't have child
1310 1310 changesets. They are where development generally takes place and
1311 1311 are the usual targets for update and merge operations.
1312 1312
1313 Branch heads are changesets that have a given branch tag, but have
1314 no child changesets with that tag. They are usually where
1315 development on a given branch takes place.
1313 If one or more REV is given, the "branch heads" will be shown for
1314 the named branch associated with that revision. The name of the
1315 branch is called the revision's branch tag.
1316
1317 Branch heads are revisions on a given named branch that do not have
1318 any children on the same branch. A branch head could be a true head
1319 or it could be the last changeset on a branch before a new branch
1320 was created. If none of the branch heads are true heads, the branch
1321 is considered inactive.
1322
1323 If STARTREV is specified only those heads (or branch heads) that
1324 are descendants of STARTREV will be displayed.
1316 1325 """
1317 1326 if opts.get('rev'):
1318 1327 start = repo.lookup(opts['rev'])
@@ -1322,10 +1331,10 b' def heads(ui, repo, *branchrevs, **opts)'
1322 1331 hideinactive, _heads = opts.get('active'), None
1323 1332 if not branchrevs:
1324 1333 # Assume we're looking repo-wide heads if no revs were specified.
1325 heads = repo.heads(start, closed=closed)
1334 heads = repo.heads(start)
1326 1335 else:
1327 1336 if hideinactive:
1328 _heads = repo.heads(start, closed=closed)
1337 _heads = repo.heads(start)
1329 1338 heads = []
1330 1339 visitedset = set()
1331 1340 for branchrev in branchrevs:
@@ -1335,7 +1344,9 b' def heads(ui, repo, *branchrevs, **opts)'
1335 1344 visitedset.add(branch)
1336 1345 bheads = repo.branchheads(branch, start, closed=closed)
1337 1346 if not bheads:
1338 if branch != branchrev:
1347 if not opts.get('rev'):
1348 ui.warn(_("no open branch heads on branch %s\n") % branch)
1349 elif branch != branchrev:
1339 1350 ui.warn(_("no changes on branch %s containing %s are "
1340 1351 "reachable from %s\n")
1341 1352 % (branch, branchrev, opts.get('rev')))
@@ -3251,7 +3262,7 b' table = {'
3251 3262 ('c', 'closed', False,
3252 3263 _('show normal and closed heads')),
3253 3264 ] + templateopts,
3254 _('[-r REV] [REV]...')),
3265 _('[-r STARTREV] [REV]...')),
3255 3266 "help": (help_, [], _('[TOPIC]')),
3256 3267 "identify|id":
3257 3268 (identify,
@@ -361,7 +361,7 b' def tags(web, req, tmpl):'
361 361 def branches(web, req, tmpl):
362 362 b = web.repo.branchtags()
363 363 tips = (web.repo[n] for t, n in web.repo.branchtags().iteritems())
364 open = set(web.repo[n].branch() for n in web.repo.heads(closed=False))
364 heads = web.repo.heads()
365 365 parity = paritygen(web.stripecount)
366 366 sortkey = lambda ctx: ('close' not in ctx.extra(), ctx.rev())
367 367
@@ -371,7 +371,12 b' def branches(web, req, tmpl):'
371 371 if limit > 0 and count >= limit:
372 372 return
373 373 count += 1
374 status = ctx.branch() in open and 'open' or 'closed'
374 if ctx.node() not in heads:
375 status = 'inactive'
376 elif not web.repo.branchheads(ctx.branch()):
377 status = 'closed'
378 else:
379 status = 'open'
375 380 yield {'parity': parity.next(),
376 381 'branch': ctx.branch(),
377 382 'status': status,
@@ -1134,15 +1134,10 b' class localrepository(repo.repository):'
1134 1134 finally:
1135 1135 wlock.release()
1136 1136
1137 def heads(self, start=None, closed=False):
1137 def heads(self, start=None):
1138 1138 heads = self.changelog.heads(start)
1139 def display(head):
1140 if closed:
1141 return True
1142 extras = self.changelog.read(head)[5]
1143 return ('close' not in extras)
1144 1139 # sort the output in rev descending order
1145 heads = [(-self.changelog.rev(h), h) for h in heads if display(h)]
1140 heads = [(-self.changelog.rev(h), h) for h in heads]
1146 1141 return [n for (r, n) in sorted(heads)]
1147 1142
1148 1143 def branchheads(self, branch=None, start=None, closed=False):
@@ -71,9 +71,19 b" hg commit -d '9 0' --close-branch -m 'cl"
71 71 echo '--- b branch should be inactive'
72 72 hg branches
73 73 hg branches -a
74 hg heads b
75 hg heads --closed b
74 76 echo 'xxx4' >> b
75 77 hg commit -d '9 0' -m 'reopen branch with a change'
76 78 echo '--- branch b is back in action'
77 79 hg branches -a
78 hg heads -c
80 echo '---- test heads listings'
79 81 hg heads
82 echo '% branch default'
83 hg heads default
84 echo '% branch a'
85 hg heads a
86 hg heads --active a
87 echo '% branch b'
88 hg heads b
89 hg heads --closed b
@@ -113,9 +113,25 b' c 6:589736a'
113 113 a 5:d8cbc61dbaa6 (inactive)
114 114 default 0:19709c5a4e75 (inactive)
115 115 a branch name much longer than the default justification used by branches 7:10ff5895aa57
116 no open branch heads on branch b
117 changeset: 12:2da6583810df
118 branch: b
119 tag: tip
120 parent: 8:eebb944467c9
121 user: test
122 date: Thu Jan 01 00:00:09 1970 +0000
123 summary: close this part branch too
124
125 changeset: 11:c84627f3c15d
126 branch: b
127 user: test
128 date: Thu Jan 01 00:00:09 1970 +0000
129 summary: prune bad branch
130
116 131 --- branch b is back in action
117 132 b 13:6ac12926b8c3
118 133 a branch name much longer than the default justification used by branches 7:10ff5895aa57
134 ---- test heads listings
119 135 changeset: 13:6ac12926b8c3
120 136 branch: b
121 137 tag: tip
@@ -135,6 +151,21 b' user: test'
135 151 date: Thu Jan 01 00:00:06 1970 +0000
136 152 summary: Adding d branch
137 153
154 % branch default
155 changeset: 0:19709c5a4e75
156 user: test
157 date: Thu Jan 01 00:00:00 1970 +0000
158 summary: Adding root node
159
160 % branch a
161 changeset: 5:d8cbc61dbaa6
162 branch: a
163 parent: 2:881fe2b92ad0
164 user: test
165 date: Thu Jan 01 00:00:04 1970 +0000
166 summary: Adding b branch head 2
167
168 % branch b
138 169 changeset: 13:6ac12926b8c3
139 170 branch: b
140 171 tag: tip
@@ -142,9 +173,16 b' user: test'
142 173 date: Thu Jan 01 00:00:09 1970 +0000
143 174 summary: reopen branch with a change
144 175
145 changeset: 7:10ff5895aa57
146 branch: a branch name much longer than the default justification used by branches
176 changeset: 13:6ac12926b8c3
177 branch: b
178 tag: tip
147 179 user: test
148 date: Thu Jan 01 00:00:06 1970 +0000
149 summary: Adding d branch
180 date: Thu Jan 01 00:00:09 1970 +0000
181 summary: reopen branch with a change
150 182
183 changeset: 11:c84627f3c15d
184 branch: b
185 user: test
186 date: Thu Jan 01 00:00:09 1970 +0000
187 summary: prune bad branch
188
@@ -532,7 +532,7 b' branches |'
532 532 <tr class="parity1">
533 533 <td class="age"><i>many years ago</i></td>
534 534 <td><a class="list" href="/shortlog/a4f92ed23982?style=gitweb"><b>a4f92ed23982</b></a></td>
535 <td class="closed">default</td>
535 <td class="inactive">default</td>
536 536 <td class="link">
537 537 <a href="/changeset/a4f92ed23982?style=gitweb">changeset</a> |
538 538 <a href="/log/a4f92ed23982?style=gitweb">changelog</a> |
General Comments 0
You need to be logged in to leave comments. Login now