def children(ui, repo, file_=None, **opts): """show the children of the given or working directory revision Print the children of the working directory's revisions. If a revision is given via -r/--rev, the children of that revision will be printed. If a file argument is given, revision in which the file was last changed (after the working directory revision or the argument to --rev if given) is printed. Please use :hg:`log` instead:: hg children => hg log -r "children(.)" hg children -r REV => hg log -r "children(REV)" See :hg:`help log` and :hg:`help revsets.children`. """ opts = pycompat.byteskwargs(opts) rev = opts.get(b'rev') ctx = scmutil.revsingle(repo, rev) if file_: fctx = repo.filectx(file_, changeid=ctx.rev()) childctxs = [fcctx.changectx() for fcctx in fctx.children()] else: childctxs = ctx.children() displayer = logcmdutil.changesetdisplayer(ui, repo, opts) for cctx in childctxs: displayer.show(cctx) displayer.close()
def parents(orig, ui, repo, *args, **opts): """show Mercurial & Subversion parents of the working dir or revision """ if not opts.get('svn', False): return orig(ui, repo, *args, **opts) meta = repo.svnmeta() hashes = meta.revmap.hashes() ha = util.parentrev(ui, repo, meta, hashes) if ha.node() == node.nullid: raise hgerror.Abort('No parent svn revision!') if logcmdutil is not None: displayer = logcmdutil.changesetdisplayer( ui, repo, opts, buffered=False) else: displayer = cmdutil.show_changeset(ui, repo, opts, buffered=False) displayer.show(ha) return 0
def render_changesets(ui, repo, changesets, config): url = config.commit_url if url: node_template = "<{url}{{node|short}}|{{node|short}}>".format(url=url) else: node_template = "{node|short}" template = "{0}: ```{1}```\\n".format( node_template, " | ".join([ "{branch}", "{date(date, '%Y-%m-%d [%H:%M:%S]')}", "{desc|strip|firstline}", # "{desc}", ])) displayer = changesetdisplayer(ui, repo, {'template': template}) ui.pushbuffer() for rev in changesets: displayer.show(repo[rev]) return ui.popbuffer()
def browserevs(ui, repo, nodes, opts): '''interactively transplant changesets''' displayer = logcmdutil.changesetdisplayer(ui, repo, opts) transplants = [] merges = [] prompt = _(b'apply changeset? [ynmpcq?]:' b'$$ &yes, transplant this changeset' b'$$ &no, skip this changeset' b'$$ &merge at this changeset' b'$$ show &patch' b'$$ &commit selected changesets' b'$$ &quit and cancel transplant' b'$$ &? (show this help)') for node in nodes: displayer.show(repo[node]) action = None while not action: choice = ui.promptchoice(prompt) action = b'ynmpcq?'[choice:choice + 1] if action == b'?': for c, t in ui.extractchoices(prompt)[1]: ui.write(b'%s: %s\n' % (c, t)) action = None elif action == b'p': parent = repo.changelog.parents(node)[0] for chunk in patch.diff(repo, parent, node): ui.write(chunk) action = None if action == b'y': transplants.append(node) elif action == b'm': merges.append(node) elif action == b'c': break elif action == b'q': transplants = () merges = () break displayer.close() return (transplants, merges)
def fxheads(ui, repo, **opts): """Show last known head commits for pulled Firefox trees. The displayed list may be out of date. Pull before running to ensure data is current. """ if not isfirefoxrepo(repo): raise error.Abort(_(b'fxheads is only available on Firefox repos')) opts = pycompat.byteskwargs(opts) displayer = logcmdutil.changesetdisplayer(ui, repo, opts) seen = set() for tag, node, tree, uri in get_firefoxtrees(repo): if node in seen: continue seen.add(node) ctx = repo[node] displayer.show(ctx) displayer.close()
def journal(ui, repo, *args, **opts): """show the previous position of bookmarks and the working copy The journal is used to see the previous commits that bookmarks and the working copy pointed to. By default the previous locations for the working copy. Passing a bookmark name will show all the previous positions of that bookmark. Use the --all switch to show previous locations for all bookmarks and the working copy; each line will then include the bookmark name, or '.' for the working copy, as well. If `name` starts with `re:`, the remainder of the name is treated as a regular expression. To match a name that actually starts with `re:`, use the prefix `literal:`. By default hg journal only shows the commit hash and the command that was running at that time. -v/--verbose will show the prior hash, the user, and the time at which it happened. Use -c/--commits to output log information on each commit hash; at this point you can use the usual `--patch`, `--git`, `--stat` and `--template` switches to alter the log output for these. `hg journal -T json` can be used to produce machine readable output. """ opts = pycompat.byteskwargs(opts) name = b'.' if opts.get(b'all'): if args: raise error.Abort( _(b"You can't combine --all and filtering on a name")) name = None if args: name = args[0] fm = ui.formatter(b'journal', opts) def formatnodes(nodes): return fm.formatlist(map(fm.hexfunc, nodes), name=b'node', sep=b',') if opts.get(b"template") != b"json": if name is None: displayname = _(b'the working copy and bookmarks') else: displayname = b"'%s'" % name ui.status(_(b"previous locations of %s:\n") % displayname) limit = logcmdutil.getlimit(opts) entry = None ui.pager(b'journal') for count, entry in enumerate(repo.journal.filtered(name=name)): if count == limit: break fm.startitem() fm.condwrite(ui.verbose, b'oldnodes', b'%s -> ', formatnodes(entry.oldhashes)) fm.write(b'newnodes', b'%s', formatnodes(entry.newhashes)) fm.condwrite(ui.verbose, b'user', b' %-8s', entry.user) fm.condwrite( opts.get(b'all') or name.startswith(b're:'), b'name', b' %-8s', entry.name, ) fm.condwrite( ui.verbose, b'date', b' %s', fm.formatdate(entry.timestamp, b'%Y-%m-%d %H:%M %1%2'), ) fm.write(b'command', b' %s\n', entry.command) if opts.get(b"commits"): if fm.isplain(): displayer = logcmdutil.changesetdisplayer(ui, repo, opts) else: displayer = logcmdutil.changesetformatter( ui, repo, fm.nested(b'changesets'), diffopts=opts) for hash in entry.newhashes: try: ctx = repo[hash] displayer.show(ctx) except error.RepoLookupError as e: fm.plain(b"%s\n\n" % pycompat.bytestr(e)) displayer.close() fm.end() if entry is None: ui.status(_(b"no recorded locations\n"))