##// END OF EJS Templates
branches: avoid unnecessary changectx.branch() calls...
Brodie Rao -
r20182:04036798 default
parent child Browse files
Show More
@@ -1013,7 +1013,7 b' def branches(ui, repo, active=False, clo'
1013
1013
1014 hexfunc = ui.debugflag and hex or short
1014 hexfunc = ui.debugflag and hex or short
1015
1015
1016 activebranches = set([repo[n].branch() for n in repo.heads()])
1016 allheads = set(repo.heads())
1017 branches = []
1017 branches = []
1018 for tag, heads in repo.branchmap().iteritems():
1018 for tag, heads in repo.branchmap().iteritems():
1019 for h in reversed(heads):
1019 for h in reversed(heads):
@@ -1024,12 +1024,12 b' def branches(ui, repo, active=False, clo'
1024 break
1024 break
1025 else:
1025 else:
1026 tip = repo[heads[-1]]
1026 tip = repo[heads[-1]]
1027 isactive = tag in activebranches and isopen
1027 isactive = isopen and bool(set(heads) & allheads)
1028 branches.append((tip, isactive, isopen))
1028 branches.append((tag, tip, isactive, isopen))
1029 branches.sort(key=lambda i: (i[1], i[0].rev(), i[0].branch(), i[2]),
1029 branches.sort(key=lambda i: (i[2], i[1].rev(), i[0], i[3]),
1030 reverse=True)
1030 reverse=True)
1031
1031
1032 for ctx, isactive, isopen in branches:
1032 for tag, ctx, isactive, isopen in branches:
1033 if (not active) or isactive:
1033 if (not active) or isactive:
1034 if isactive:
1034 if isactive:
1035 label = 'branches.active'
1035 label = 'branches.active'
@@ -1042,16 +1042,16 b' def branches(ui, repo, active=False, clo'
1042 else:
1042 else:
1043 label = 'branches.inactive'
1043 label = 'branches.inactive'
1044 notice = _(' (inactive)')
1044 notice = _(' (inactive)')
1045 if ctx.branch() == repo.dirstate.branch():
1045 if tag == repo.dirstate.branch():
1046 label = 'branches.current'
1046 label = 'branches.current'
1047 rev = str(ctx.rev()).rjust(31 - encoding.colwidth(ctx.branch()))
1047 rev = str(ctx.rev()).rjust(31 - encoding.colwidth(tag))
1048 rev = ui.label('%s:%s' % (rev, hexfunc(ctx.node())),
1048 rev = ui.label('%s:%s' % (rev, hexfunc(ctx.node())),
1049 'log.changeset changeset.%s' % ctx.phasestr())
1049 'log.changeset changeset.%s' % ctx.phasestr())
1050 tag = ui.label(ctx.branch(), label)
1050 labeledtag = ui.label(tag, label)
1051 if ui.quiet:
1051 if ui.quiet:
1052 ui.write("%s\n" % tag)
1052 ui.write("%s\n" % labeledtag)
1053 else:
1053 else:
1054 ui.write("%s %s%s\n" % (tag, rev, notice))
1054 ui.write("%s %s%s\n" % (labeledtag, rev, notice))
1055
1055
1056 @command('bundle',
1056 @command('bundle',
1057 [('f', 'force', None, _('run even when the destination is unrelated')),
1057 [('f', 'force', None, _('run even when the destination is unrelated')),
General Comments 0
You need to be logged in to leave comments. Login now