##// END OF EJS Templates
branch closing: referencing open and closed branches/heads...
John Mulligan -
r7656:6a24fb99 default
parent child Browse files
Show More
@@ -431,7 +431,7 b' def branches(ui, repo, active=False):'
431 431 """
432 432 hexfunc = ui.debugflag and hex or short
433 433 activebranches = [util.tolocal(repo[n].branch())
434 for n in repo.heads()]
434 for n in repo.heads(closed=False)]
435 435 branches = util.sort([(tag in activebranches, repo.changelog.rev(node), tag)
436 436 for tag, node in repo.branchtags().items()])
437 437 branches.reverse()
@@ -441,9 +441,15 b' def branches(ui, repo, active=False):'
441 441 if ui.quiet:
442 442 ui.write("%s\n" % tag)
443 443 else:
444 hn = repo.lookup(node)
445 if isactive:
446 notice = ''
447 elif hn not in repo.branchheads(tag, closed=False):
448 notice = ' (closed)'
449 else:
450 notice = ' (inactive)'
444 451 rev = str(node).rjust(31 - util.locallen(tag))
445 isinactive = ((not isactive) and " (inactive)") or ''
446 data = tag, rev, hexfunc(repo.lookup(node)), isinactive
452 data = tag, rev, hexfunc(hn), notice
447 453 ui.write("%s %s:%s%s\n" % data)
448 454
449 455 def bundle(ui, repo, fname, dest=None, **opts):
@@ -1266,9 +1272,10 b' def heads(ui, repo, *branchrevs, **opts)'
1266 1272 start = repo.lookup(opts['rev'])
1267 1273 else:
1268 1274 start = None
1275 closed = not opts.get('active')
1269 1276 if not branchrevs:
1270 1277 # Assume we're looking repo-wide heads if no revs were specified.
1271 heads = repo.heads(start)
1278 heads = repo.heads(start, closed=closed)
1272 1279 else:
1273 1280 heads = []
1274 1281 visitedset = util.set()
@@ -1277,7 +1284,7 b' def heads(ui, repo, *branchrevs, **opts)'
1277 1284 if branch in visitedset:
1278 1285 continue
1279 1286 visitedset.add(branch)
1280 bheads = repo.branchheads(branch, start)
1287 bheads = repo.branchheads(branch, start, closed=closed)
1281 1288 if not bheads:
1282 1289 if branch != branchrev:
1283 1290 ui.warn(_("no changes on branch %s containing %s are "
@@ -3215,6 +3222,8 b' table = {'
3215 3222 "heads":
3216 3223 (heads,
3217 3224 [('r', 'rev', '', _('show only heads which are descendants of rev')),
3225 ('a', 'active', False,
3226 _('show only the active heads from open branches')),
3218 3227 ] + templateopts,
3219 3228 _('[-r REV] [REV]...')),
3220 3229 "help": (help_, [], _('[TOPIC]')),
@@ -398,8 +398,21 b' class localrepository(repo.repository):'
398 398
399 399 def branchtags(self):
400 400 '''return a dict where branch names map to the tipmost head of
401 the branch'''
402 return dict([(k, v[-1]) for (k, v) in self._branchheads().iteritems()])
401 the branch, open heads come before closed'''
402 bt = {}
403 for bn, heads in self._branchheads().iteritems():
404 head = None
405 for i in range(len(heads)-1, -1, -1):
406 h = heads[i]
407 if 'close' not in self.changelog.read(h)[5]:
408 head = h
409 break
410 # no open heads were found
411 if head is None:
412 head = heads[-1]
413 bt[bn] = head
414 return bt
415
403 416
404 417 def _readbranchcache(self):
405 418 partial = {}
@@ -1180,13 +1193,18 b' class localrepository(repo.repository):'
1180 1193 finally:
1181 1194 del wlock
1182 1195
1183 def heads(self, start=None):
1196 def heads(self, start=None, closed=True):
1184 1197 heads = self.changelog.heads(start)
1198 def display(head):
1199 if closed:
1200 return True
1201 extras = self.changelog.read(head)[5]
1202 return ('close' not in extras)
1185 1203 # sort the output in rev descending order
1186 heads = [(-self.changelog.rev(h), h) for h in heads]
1204 heads = [(-self.changelog.rev(h), h) for h in heads if display(h)]
1187 1205 return [n for (r, n) in util.sort(heads)]
1188 1206
1189 def branchheads(self, branch=None, start=None):
1207 def branchheads(self, branch=None, start=None, closed=True):
1190 1208 if branch is None:
1191 1209 branch = self[None].branch()
1192 1210 branches = self._branchheads()
@@ -1198,6 +1216,9 b' class localrepository(repo.repository):'
1198 1216 if start is not None:
1199 1217 # filter out the heads that cannot be reached from startrev
1200 1218 bheads = self.changelog.nodesbetween([start], bheads)[2]
1219 if not closed:
1220 bheads = [h for h in bheads if
1221 ('close' not in self.changelog.read(h)[5])]
1201 1222 return bheads
1202 1223
1203 1224 def branches(self, nodes):
General Comments 0
You need to be logged in to leave comments. Login now