def rage(ui, repo, *pats, **opts): """collect troubleshooting diagnostics The rage command collects useful diagnostic information. By default, the information will be uploaded to Phabricator and instructions about how to ask for help will be printed. After submitting to Phabricator, it prints configerable advice:: [rage] advice = Please see our FAQ guide: https://... """ with progress.spinner(ui, "collecting information"): msg = _makerage(ui, repo, **opts) if opts.get("preview"): ui.pager("rage") ui.write("%s\n" % encoding.unitolocal(msg.decode("utf-8"))) return with progress.spinner(ui, "saving paste"): try: p = subprocess.Popen( ["pastry", "--lang", "hgrage", "--title", "hgrage"], stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE, shell=pycompat.iswindows, ) out, err = p.communicate(input=msg + "\n") ret = p.returncode except OSError: ui.write(_("Failed calling pastry. (is it in your PATH?)\n")) ret = 1 if ret: fd, tmpname = tempfile.mkstemp(prefix="hg-rage-") with util.fdopen(fd, r"w") as tmpfp: tmpfp.write(msg) ui.write( _("Failed to post the diagnostic paste to Phabricator, " "but its contents have been written to:\n\n")) ui.write(_(" %s\n") % tmpname, label="rage.link") ui.write( _("\nPlease include this file in the %s.\n") % ui.config("ui", "supportcontact")) else: ui.write( _("Please post in %s with the following link:\n\n") % (ui.config("ui", "supportcontact"))) ui.write(" " + out + "\n", label="rage.link") ui.write(ui.config("rage", "advice", "") + "\n")
def manifest(self): # As of svn 1.7, the "add" command fails when receiving # already tracked entries, so we have to track and filter them # ourselves. m = set() output = self.run0("ls", recursive=True, xml=True) doc = xml.dom.minidom.parseString(output) for e in doc.getElementsByTagName("entry"): for n in e.childNodes: if n.nodeType != n.ELEMENT_NODE or n.tagName != "name": continue name = "".join(c.data for c in n.childNodes if c.nodeType == c.TEXT_NODE) # Entries are compared with names coming from # mercurial, so bytes with undefined encoding. Our # best bet is to assume they are in local # encoding. They will be passed to command line calls # later anyway, so they better be. m.add(encoding.unitolocal(name)) break return m