Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHG4506f801e492: branches: add -r option to show branch name(s) of a given rev (issue5948)
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
| hg-reviewers |
| Lint Skipped |
| Unit Tests Skipped |
| Path | Packages | |||
|---|---|---|---|---|
| M | mercurial/commands.py (12 lines) | |||
| M | tests/test-branches.t (12 lines) | |||
| M | tests/test-completion.t (2 lines) |
| Commit | Parents | Author | Summary | Date |
|---|---|---|---|---|
| Navaneeth Suresh | Dec 24 2018, 6:34 AM |
| if not others: | if not others: | ||||
| ui.status(_('(branches are permanent and global, ' | ui.status(_('(branches are permanent and global, ' | ||||
| 'did you want a bookmark?)\n')) | 'did you want a bookmark?)\n')) | ||||
| @command('branches', | @command('branches', | ||||
| [('a', 'active', False, | [('a', 'active', False, | ||||
| _('show only branches that have unmerged heads (DEPRECATED)')), | _('show only branches that have unmerged heads (DEPRECATED)')), | ||||
| ('c', 'closed', False, _('show normal and closed branches')), | ('c', 'closed', False, _('show normal and closed branches')), | ||||
| ('r', 'rev', [], _('show branch name(s) of the given rev')) | |||||
| ] + formatteropts, | ] + formatteropts, | ||||
| _('[-c]'), | _('[-c]'), | ||||
| helpcategory=command.CATEGORY_CHANGE_ORGANIZATION, | helpcategory=command.CATEGORY_CHANGE_ORGANIZATION, | ||||
| intents={INTENT_READONLY}) | intents={INTENT_READONLY}) | ||||
| def branches(ui, repo, active=False, closed=False, **opts): | def branches(ui, repo, active=False, closed=False, **opts): | ||||
| """list repository named branches | """list repository named branches | ||||
| List the repository's named branches, indicating which ones are | List the repository's named branches, indicating which ones are | ||||
| :active: Boolean. True if the branch is active. | :active: Boolean. True if the branch is active. | ||||
| :closed: Boolean. True if the branch is closed. | :closed: Boolean. True if the branch is closed. | ||||
| :current: Boolean. True if it is the current branch. | :current: Boolean. True if it is the current branch. | ||||
| Returns 0. | Returns 0. | ||||
| """ | """ | ||||
| opts = pycompat.byteskwargs(opts) | opts = pycompat.byteskwargs(opts) | ||||
| revs = opts.get('rev') | |||||
| selectedbranches = None | |||||
| if revs: | |||||
| revs = scmutil.revrange(repo, revs) | |||||
| getbi = repo.revbranchcache().branchinfo | |||||
| selectedbranches = {getbi(r)[0] for r in revs} | |||||
| ui.pager('branches') | ui.pager('branches') | ||||
| fm = ui.formatter('branches', opts) | fm = ui.formatter('branches', opts) | ||||
| hexfunc = fm.hexfunc | hexfunc = fm.hexfunc | ||||
| allheads = set(repo.heads()) | allheads = set(repo.heads()) | ||||
| branches = [] | branches = [] | ||||
| for tag, heads, tip, isclosed in repo.branchmap().iterbranches(): | for tag, heads, tip, isclosed in repo.branchmap().iterbranches(): | ||||
| if selectedbranches is not None and tag not in selectedbranches: | |||||
| continue | |||||
| isactive = False | isactive = False | ||||
| if not isclosed: | if not isclosed: | ||||
| openheads = set(repo.branchmap().iteropen(heads)) | openheads = set(repo.branchmap().iteropen(heads)) | ||||
| isactive = bool(openheads & allheads) | isactive = bool(openheads & allheads) | ||||
| branches.append((tag, repo[tip], isactive, not isclosed)) | branches.append((tag, repo[tip], isactive, not isclosed)) | ||||
| branches.sort(key=lambda i: (i[2], i[1].rev(), i[0], i[3]), | branches.sort(key=lambda i: (i[2], i[1].rev(), i[0], i[3]), | ||||
| reverse=True) | reverse=True) | ||||
| entry = cmdtable.pop(cmd) | entry = cmdtable.pop(cmd) | ||||
| entry[0].helpbasic = True | entry[0].helpbasic = True | ||||
| cmdtable[cmd[1:]] = entry | cmdtable[cmd[1:]] = entry | ||||
| overrides = [cmd for cmd in cmdtable if cmd in table] | overrides = [cmd for cmd in cmdtable if cmd in table] | ||||
| if overrides: | if overrides: | ||||
| ui.warn(_("extension '%s' overrides commands: %s\n") | ui.warn(_("extension '%s' overrides commands: %s\n") | ||||
| % (name, " ".join(overrides))) | % (name, " ".join(overrides))) | ||||
| table.update(cmdtable) | table.update(cmdtable) | ||||
| No newline at end of file | |||||
| changeset: 3:ac22033332d1 | changeset: 3:ac22033332d1 | ||||
| branch: b | branch: b | ||||
| parent: 0:19709c5a4e75 | parent: 0:19709c5a4e75 | ||||
| user: test | user: test | ||||
| date: Thu Jan 01 00:00:02 1970 +0000 | date: Thu Jan 01 00:00:02 1970 +0000 | ||||
| summary: Adding b branch | summary: Adding b branch | ||||
| ---- going to test branch listing by rev | |||||
| $ hg branches -r0 | |||||
| default 0:19709c5a4e75 (inactive) | |||||
| $ hg branches -qr0 | |||||
| default | |||||
| --- now more than one rev | |||||
| $ hg branches -r2:5 | |||||
| b 4:aee39cd168d0 | |||||
| a 5:d8cbc61dbaa6 (inactive) | |||||
| $ hg branches -qr2:5 | |||||
| b | |||||
| a | |||||
| ---- going to test branch closing | ---- going to test branch closing | ||||
| $ hg branches | $ hg branches | ||||
| a branch name much longer than the default justification used by branches 7:10ff5895aa57 | a branch name much longer than the default justification used by branches 7:10ff5895aa57 | ||||
| b 4:aee39cd168d0 | b 4:aee39cd168d0 | ||||
| c 6:589736a22561 (inactive) | c 6:589736a22561 (inactive) | ||||
| a 5:d8cbc61dbaa6 (inactive) | a 5:d8cbc61dbaa6 (inactive) | ||||
| default 0:19709c5a4e75 (inactive) | default 0:19709c5a4e75 (inactive) | ||||
| add: include, exclude, subrepos, dry-run | add: include, exclude, subrepos, dry-run | ||||
| addremove: similarity, subrepos, include, exclude, dry-run | addremove: similarity, subrepos, include, exclude, dry-run | ||||
| annotate: rev, follow, no-follow, text, user, file, date, number, changeset, line-number, skip, ignore-all-space, ignore-space-change, ignore-blank-lines, ignore-space-at-eol, include, exclude, template | annotate: rev, follow, no-follow, text, user, file, date, number, changeset, line-number, skip, ignore-all-space, ignore-space-change, ignore-blank-lines, ignore-space-at-eol, include, exclude, template | ||||
| archive: no-decode, prefix, rev, type, subrepos, include, exclude | archive: no-decode, prefix, rev, type, subrepos, include, exclude | ||||
| backout: merge, commit, no-commit, parent, rev, edit, tool, include, exclude, message, logfile, date, user | backout: merge, commit, no-commit, parent, rev, edit, tool, include, exclude, message, logfile, date, user | ||||
| bisect: reset, good, bad, skip, extend, command, noupdate | bisect: reset, good, bad, skip, extend, command, noupdate | ||||
| bookmarks: force, rev, delete, rename, inactive, list, template | bookmarks: force, rev, delete, rename, inactive, list, template | ||||
| branch: force, clean, rev | branch: force, clean, rev | ||||
| branches: active, closed, template | branches: active, closed, rev, template | ||||
| bundle: force, rev, branch, base, all, type, ssh, remotecmd, insecure | bundle: force, rev, branch, base, all, type, ssh, remotecmd, insecure | ||||
| cat: output, rev, decode, include, exclude, template | cat: output, rev, decode, include, exclude, template | ||||
| clone: noupdate, updaterev, rev, branch, pull, uncompressed, stream, ssh, remotecmd, insecure | clone: noupdate, updaterev, rev, branch, pull, uncompressed, stream, ssh, remotecmd, insecure | ||||
| commit: addremove, close-branch, amend, secret, edit, interactive, include, exclude, message, logfile, date, user, subrepos | commit: addremove, close-branch, amend, secret, edit, interactive, include, exclude, message, logfile, date, user, subrepos | ||||
| config: untrusted, edit, local, global, template | config: untrusted, edit, local, global, template | ||||
| copy: after, force, include, exclude, dry-run | copy: after, force, include, exclude, dry-run | ||||
| debugancestor: | debugancestor: | ||||
| debugapplystreamclonebundle: | debugapplystreamclonebundle: | ||||