我git subtree
用来组织我的git存储库.假设我有一个名为的主存储库repo
和一个名为的库lib
.
我lib
通过压缩它的历史成功地"导入"了存储库.我现在想lib
通过压缩历史来回馈.这似乎不起作用:我指定--squash
选项,git subtree push
但在查看历史记录时,我仍然发送所有提交.
这是一个脚本,显示了重现问题所需的最小命令:
#!/bin/bash
rm -rf lib lib-work repo
# repo is the main repository
git init repo
# lib is the 'subtreed' repository (bare to accept pushes)
git init --bare lib
git clone lib lib-work
cd lib-work
# adding a bunch of commits to lib
echo "v1" > README
git add README
git commit -m 'lib commit 1'
echo "v2" > …
Run Code Online (Sandbox Code Playgroud) 我想在程序中嵌入 pylint。用户输入 python 程序(在 Qt 中,在 QTextEdit 中,虽然不相关)并在后台我调用 pylint 来检查他输入的文本。最后,我在消息框中打印错误。
因此有两个问题:首先,如何在不将输入的文本写入临时文件并将其提供给 pylint 的情况下执行此操作?我想在某个时候 pylint(或 astroid)处理流而不是文件了。
而且,更重要的是,这是个好主意吗?它会导致进口或其他东西出现问题吗?直觉上我会说不,因为它似乎产生了一个新进程(使用 epylint),但我不是 Python 专家,所以我真的不确定。如果我用它来启动 pylint,也可以吗?
编辑:我尝试修补 pylint 的内部结构,与它进行了斗争,但最终在某个时候被卡住了。
这是到目前为止的代码:
from astroid.builder import AstroidBuilder
from astroid.exceptions import AstroidBuildingException
from logilab.common.interface import implements
from pylint.interfaces import IRawChecker, ITokenChecker, IAstroidChecker
from pylint.lint import PyLinter
from pylint.reporters.text import TextReporter
from pylint.utils import PyLintASTWalker
class Validator():
def __init__(self):
self._messagesBuffer = InMemoryMessagesBuffer()
self._validator = None
self.initValidator()
def initValidator(self):
self._validator = StringPyLinter(reporter=TextReporter(output=self._messagesBuffer))
self._validator.load_default_plugins()
self._validator.disable('W0704')
self._validator.disable('I0020')
self._validator.disable('I0021')
self._validator.prepare_import_path([])
def destroyValidator(self):
self._validator.cleanup_import_path() …
Run Code Online (Sandbox Code Playgroud) 我正试图调用这样的模板化函数:
typedef std::tuple<int, double, bool> InstrumentTuple;
Cache cache;
InstrumentTuple tuple = cache.get<InstrumentTuple>();
Run Code Online (Sandbox Code Playgroud)
我知道我可以"简单地"传递元组的类型.这就是我所知道的但是它非常麻烦,因为我对这个函数进行了很多调用,因为元组很长:
InstrumentTuple tuple = c.get<int, double, bool>(); // syntax I'd like to avoid
Run Code Online (Sandbox Code Playgroud)
所以我尝试了get方法的多个实现,但没有成功:
#include <tuple>
class Cache
{
private:
template<int I, typename T, typename = typename std::enable_if<I == std::tuple_size<T>::value>::type>
std::tuple<> get() // line 6
{
return std::tuple<>();
}
template<int I, typename T, typename = typename std::enable_if<I != std::tuple_size<T>::value>::type>
std::tuple<typename std::tuple_element<I,T>::type, decltype(get<I+1, T>())> get() // line 12
{
std::tuple<typename std::tuple_element<I,T>::type> value;
return std::tuple_cat(value, get<I+1, T>());
}
public: …
Run Code Online (Sandbox Code Playgroud) 我正在使用QLinkedList存储我写的一些类.
事实是我必须在这个列表上进行很多迭代.
很多我的意思是我编写的程序进行无限演算(好吧,你仍然可以手动停止它),我需要通过每次迭代的QLinkedList.
问题不在于我是否在这个列表上进行了多次迭代.
这是我正在分析我的代码,我发现1/4的时间花在QLinkedList :: end()和QLinkedList :: begin()函数上.
我的代码如下:
typedef QLinkedList<Particle*> ParticlesList; // Particle is a custom class
ParticlesList* parts = // assign a QLinkedList
for (ParticlesList::const_iterator itp = parts->begin(); itp != parts->end(); ++itp)
{
//make some calculus
}
Run Code Online (Sandbox Code Playgroud)
就像我说的那样,这段代码经常被调用,它花了很多时间在parts-> begin()和parts-> end()上.
那么,问题是如何减少这个列表迭代所花费的时间?
这里有一些我想过的解决方案,请帮我选择最好的或者再提一个:)
Particle** parts = // assing it something
for (int n = 0; n < LENGTH; …
Run Code Online (Sandbox Code Playgroud) 命令"mix phoenix.server"后总是收到错误:
=INFO REPORT==== 14-Dec-2015::20:55:48 ===
application: logger
exited: stopped
type: temporary
** (Mix) Could not start application odt: Odt.start(:normal, []) returned an error: shutdown: failed to start child: Odt.Endpoint
** (Exit) shutdown: failed to start child: Phoenix.Endpoint.Server
** (Exit) shutdown: failed to start child: {:ranch_listener_sup, Odt.Endpoint.HTTP}
** (Exit) shutdown: failed to start child: :ranch_acceptors_sup
** (Exit) {:listener_error, Odt.Endpoint.HTTP, :eaddrinuse}
Run Code Online (Sandbox Code Playgroud)
我该如何解决?我究竟做错了什么?