content_type stringclasses 8 values | main_lang stringclasses 7 values | message stringlengths 1 50 | sha stringlengths 40 40 | patch stringlengths 52 962k | file_count int64 1 300 |
|---|---|---|---|---|---|
Go | Go | fix wrong foo to zzz in docker_cli_build_test.go | 2276de8704d9b235306b50be748afa98a574a5cb | <ide><path>integration-cli/docker_cli_build_test.go
<ide> func (s *DockerSuite) TestBuildEnvironmentReplacementEnv(c *check.C) {
<ide> } else if strings.HasPrefix(parts[0], "env") {
<ide> envCount++
<ide> if parts[1] != "zzz" {
<del> c.Fatalf("%s should be 'foo' but instead its %q", parts[0], parts[1])
<add> c.Fatalf("%s should be 'zzz' but instead its %q", parts[0], parts[1])
<ide> }
<ide> } else if strings.HasPrefix(parts[0], "env") {
<ide> envCount++ | 1 |
Python | Python | use pagesizepaginationmixin for cursorpagination | 30b36a594f3f262ca5fcab49ac03d29cab9f2f09 | <ide><path>rest_framework/pagination.py
<ide> def to_html(self):
<ide> return template.render(context)
<ide>
<ide>
<del>class CursorPagination(BasePagination):
<add>class CursorPagination(BasePageSizePagination):
<ide> """
<ide> The cursor pagination implementation is neccessarily complex.
<ide> For an overview of the position/offset style we use, see this post:
<ide> http://cramer.io/2011/03/08/building-cursors-for-the-disqus-api/
<ide> """
<ide> cursor_query_param = 'cursor'
<del> page_size = api_settings.PAGE_SIZE
<ide> invalid_cursor_message = _('Invalid cursor')
<ide> ordering = '-created'
<ide> template = 'rest_framework/pagination/previous_and_next.html'
<ide>
<ide> def paginate_queryset(self, queryset, request, view=None):
<del> if self.page_size is None:
<add> self.page_size = self.get_page_size(request)
<add> if not self.page_size:
<ide> return None
<ide>
<ide> self.base_url = request.build_absolute_uri()
<ide><path>tests/test_pagination.py
<ide> def __getitem__(self, sliced):
<ide>
<ide> class ExamplePagination(pagination.CursorPagination):
<ide> page_size = 5
<add> page_size_query_param = 'page_size'
<add> max_page_size = 20
<ide> ordering = 'created'
<ide>
<ide> self.pagination = ExamplePagination()
<ide> def test_cursor_pagination(self):
<ide>
<ide> assert isinstance(self.pagination.to_html(), type(''))
<ide>
<add> def test_page_size(self):
<add> (previous, current, next, previous_url, next_url) = \
<add> self.get_pages('/?page_size=10')
<add>
<add> assert previous is None
<add> assert current == [1, 1, 1, 1, 1, 1, 2, 3, 4, 4]
<add> assert next == [4, 4, 5, 6, 7, 7, 7, 7, 7, 7]
<add> assert 'page_size=10' in next_url
<add>
<add> (previous, current, next, previous_url, next_url) = \
<add> self.get_pages(next_url.replace('page_size=10', 'page_size=4'))
<add>
<add> assert previous == [2, 3, 4, 4]
<add> assert current == [4, 4, 5, 6]
<add> assert next == [7, 7, 7, 7]
<add> assert 'page_size=4' in previous_url
<add> assert 'page_size=4' in next_url
<add>
<ide>
<ide> def test_get_displayed_page_numbers():
<ide> """ | 2 |
Javascript | Javascript | hide caret during test runs | 397bfa6ad7dff71f4b6d27ac17acc76fe8a6bbb5 | <ide><path>Libraries/Components/TextInput/TextInput.js
<ide> function InternalTextInput(props: Props): React.Node {
<ide> ],
<ide> );
<ide>
<add> // Hide caret during test runs due to a flashing caret
<add> // makes screenshot tests flakey
<add> let caretHidden = props.caretHidden;
<add> if (Platform.isTesting) {
<add> caretHidden = true;
<add> }
<add>
<ide> // TextInput handles onBlur and onFocus events
<ide> // so omitting onBlur and onFocus pressability handlers here.
<ide> const {onBlur, onFocus, ...eventHandlers} = usePressability(config) || {};
<ide> function InternalTextInput(props: Props): React.Node {
<ide> {...eventHandlers}
<ide> accessible={accessible}
<ide> blurOnSubmit={blurOnSubmit}
<add> caretHidden={caretHidden}
<ide> dataDetectorTypes={props.dataDetectorTypes}
<ide> focusable={focusable}
<ide> mostRecentEventCount={mostRecentEventCount}
<ide> function InternalTextInput(props: Props): React.Node {
<ide> accessible={accessible}
<ide> autoCapitalize={autoCapitalize}
<ide> blurOnSubmit={blurOnSubmit}
<add> caretHidden={caretHidden}
<ide> children={children}
<ide> disableFullscreenUI={props.disableFullscreenUI}
<ide> focusable={focusable} | 1 |
Java | Java | support selective filtering of error dispatches | 5d04ef4c4acbd3ce35161ce3c500163ee8729abe | <ide><path>spring-orm/src/main/java/org/springframework/orm/hibernate3/support/OpenSessionInViewFilter.java
<ide> protected boolean shouldNotFilterAsyncDispatch() {
<ide> return false;
<ide> }
<ide>
<add> /**
<add> * Returns "false" so that the filter may provide a Hibernate
<add> * {@code Session} to each error dispatches.
<add> */
<add> @Override
<add> protected boolean shouldNotFilterErrorDispatch() {
<add> return false;
<add> }
<add>
<ide> @Override
<ide> protected void doFilterInternal(
<ide> HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
<ide> protected void doFilterInternal(
<ide> boolean participate = false;
<ide>
<ide> WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(request);
<del> boolean isFirstRequest = !asyncManager.hasConcurrentResult();
<ide> String key = getAlreadyFilteredAttributeName();
<ide>
<ide> if (isSingleSession()) {
<ide> protected void doFilterInternal(
<ide> participate = true;
<ide> }
<ide> else {
<add> boolean isFirstRequest = !isAsyncDispatch(request);
<ide> if (isFirstRequest || !applySessionBindingInterceptor(asyncManager, key)) {
<ide> logger.debug("Opening single Hibernate Session in OpenSessionInViewFilter");
<ide> Session session = getSession(sessionFactory);
<ide> protected void doFilterInternal(
<ide> }
<ide> else {
<ide> // deferred close mode
<del> Assert.state(!asyncManager.isConcurrentHandlingStarted(),
<del> "Deferred close mode is not supported on async dispatches");
<add> Assert.state(!isAsyncStarted(request), "Deferred close mode is not supported on async dispatches");
<ide> if (SessionFactoryUtils.isDeferredCloseActive(sessionFactory)) {
<ide> // Do not modify deferred close: just set the participate flag.
<ide> participate = true;
<ide> protected void doFilterInternal(
<ide> // single session mode
<ide> SessionHolder sessionHolder =
<ide> (SessionHolder) TransactionSynchronizationManager.unbindResource(sessionFactory);
<del> if (!asyncManager.isConcurrentHandlingStarted()) {
<add> if (!isAsyncStarted(request)) {
<ide> logger.debug("Closing single Hibernate Session in OpenSessionInViewFilter");
<ide> closeSession(sessionHolder.getSession(), sessionFactory);
<ide> }
<ide><path>spring-orm/src/main/java/org/springframework/orm/hibernate4/support/OpenSessionInViewFilter.java
<ide> protected String getSessionFactoryBeanName() {
<ide> }
<ide>
<ide> /**
<del> * The default value is "false" so that the filter may re-bind the opened
<add> * Returns "false" so that the filter may re-bind the opened Hibernate
<ide> * {@code Session} to each asynchronously dispatched thread and postpone
<ide> * closing it until the very last asynchronous dispatch.
<ide> */
<ide> protected boolean shouldNotFilterAsyncDispatch() {
<ide> return false;
<ide> }
<ide>
<add> /**
<add> * Returns "false" so that the filter may provide a Hibernate
<add> * {@code Session} to each error dispatches.
<add> */
<add> @Override
<add> protected boolean shouldNotFilterErrorDispatch() {
<add> return false;
<add> }
<add>
<ide> @Override
<ide> protected void doFilterInternal(
<ide> HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
<ide> protected void doFilterInternal(
<ide> boolean participate = false;
<ide>
<ide> WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(request);
<del> boolean isFirstRequest = !asyncManager.hasConcurrentResult();
<ide> String key = getAlreadyFilteredAttributeName();
<ide>
<ide> if (TransactionSynchronizationManager.hasResource(sessionFactory)) {
<ide> // Do not modify the Session: just set the participate flag.
<ide> participate = true;
<ide> }
<ide> else {
<add> boolean isFirstRequest = !isAsyncDispatch(request);
<ide> if (isFirstRequest || !applySessionBindingInterceptor(asyncManager, key)) {
<ide> logger.debug("Opening Hibernate Session in OpenSessionInViewFilter");
<ide> Session session = openSession(sessionFactory);
<ide> protected void doFilterInternal(
<ide> if (!participate) {
<ide> SessionHolder sessionHolder =
<ide> (SessionHolder) TransactionSynchronizationManager.unbindResource(sessionFactory);
<del> if (!asyncManager.isConcurrentHandlingStarted()) {
<add> if (!isAsyncStarted(request)) {
<ide> logger.debug("Closing Hibernate Session in OpenSessionInViewFilter");
<ide> SessionFactoryUtils.closeSession(sessionHolder.getSession());
<ide> }
<ide><path>spring-orm/src/main/java/org/springframework/orm/jpa/support/OpenEntityManagerInViewFilter.java
<ide> protected String getPersistenceUnitName() {
<ide> }
<ide>
<ide> /**
<del> * The default value is "false" so that the filter may re-bind the opened
<add> * Returns "false" so that the filter may re-bind the opened
<ide> * {@code EntityManager} to each asynchronously dispatched thread and postpone
<ide> * closing it until the very last asynchronous dispatch.
<ide> */
<ide> protected boolean shouldNotFilterAsyncDispatch() {
<ide> return false;
<ide> }
<ide>
<add> /**
<add> * Returns "false" so that the filter may provide an {@code EntityManager}
<add> * to each error dispatches.
<add> */
<add> @Override
<add> protected boolean shouldNotFilterErrorDispatch() {
<add> return false;
<add> }
<add>
<ide> @Override
<ide> protected void doFilterInternal(
<ide> HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
<ide> protected void doFilterInternal(
<ide> boolean participate = false;
<ide>
<ide> WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(request);
<del> boolean isFirstRequest = !asyncManager.hasConcurrentResult();
<ide> String key = getAlreadyFilteredAttributeName();
<ide>
<ide> if (TransactionSynchronizationManager.hasResource(emf)) {
<ide> // Do not modify the EntityManager: just set the participate flag.
<ide> participate = true;
<ide> }
<ide> else {
<add> boolean isFirstRequest = !isAsyncDispatch(request);
<ide> if (isFirstRequest || !applyEntityManagerBindingInterceptor(asyncManager, key)) {
<ide> logger.debug("Opening JPA EntityManager in OpenEntityManagerInViewFilter");
<ide> try {
<ide> protected void doFilterInternal(
<ide> if (!participate) {
<ide> EntityManagerHolder emHolder = (EntityManagerHolder)
<ide> TransactionSynchronizationManager.unbindResource(emf);
<del> if (!asyncManager.isConcurrentHandlingStarted()) {
<add> if (!isAsyncStarted(request)) {
<ide> logger.debug("Closing JPA EntityManager in OpenEntityManagerInViewFilter");
<ide> EntityManagerFactoryUtils.closeEntityManager(emHolder.getEntityManager());
<ide> }
<ide><path>spring-web/src/main/java/org/springframework/web/filter/AbstractRequestLoggingFilter.java
<ide>
<ide> import org.springframework.util.Assert;
<ide> import org.springframework.util.StringUtils;
<del>import org.springframework.web.context.request.async.WebAsyncManager;
<del>import org.springframework.web.context.request.async.WebAsyncUtils;
<ide> import org.springframework.web.util.WebUtils;
<ide>
<ide> /**
<ide> protected boolean shouldNotFilterAsyncDispatch() {
<ide> protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
<ide> throws ServletException, IOException {
<ide>
<del> WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(request);
<del> boolean isFirstRequest = !asyncManager.hasConcurrentResult();
<add> boolean isFirstRequest = !isAsyncDispatch(request);
<ide>
<ide> if (isIncludePayload()) {
<ide> if (isFirstRequest) {
<ide> protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
<ide> filterChain.doFilter(request, response);
<ide> }
<ide> finally {
<del> if (!asyncManager.isConcurrentHandlingStarted()) {
<add> if (!isAsyncStarted(request)) {
<ide> afterRequest(request, getAfterMessage(request));
<ide> }
<ide> }
<ide><path>spring-web/src/main/java/org/springframework/web/filter/OncePerRequestFilter.java
<ide>
<ide> import org.springframework.web.context.request.async.WebAsyncManager;
<ide> import org.springframework.web.context.request.async.WebAsyncUtils;
<add>import org.springframework.web.util.WebUtils;
<ide>
<ide> /**
<del> * Filter base class that guarantees to be just executed once per request,
<del> * on any servlet container. It provides a {@link #doFilterInternal}
<add> * Filter base class that aims to guarantee a single execution per request
<add> * dispatch, on any servlet container. It provides a {@link #doFilterInternal}
<ide> * method with HttpServletRequest and HttpServletResponse arguments.
<ide> *
<del> * <p>In an async scenario a filter may be invoked again in additional threads
<del> * as part of an {@linkplain javax.servlet.DispatcherType.ASYNC ASYNC} dispatch.
<del> * Sub-classes may decide whether to be invoked once per request or once per
<del> * request thread for as long as the same request is being processed.
<del> * See {@link #shouldNotFilterAsyncDispatch()}.
<add> * <p>As of Servlet 3.0, a filter may be invoked as part of a
<add> * {@link javax.servlet.DispatcherType.REQUEST REQUEST} or
<add> * {@link javax.servlet.DispatcherType.ASYNC ASYNC} dispatches that occur in
<add> * separate threads. A filter can be configured in {@code web.xml} whether it
<add> * should be involved in async dispatches. However, in some cases servlet
<add> * containers assume different default configuration. Therefore sub-classes can
<add> * override the method {@link #shouldNotFilterAsyncDispatch()} to declare
<add> * statically if they shouuld indeed be invoked, <em>once</em>, during both types
<add> * of dispatches in order to provide thread initialization, logging, security,
<add> * and so on. This mechanism complements and does not replace the need to
<add> * configure a filter in {@code web.xml} with dispatcher types.
<ide> *
<del> * <p>The {@link #getAlreadyFilteredAttributeName} method determines how
<del> * to identify that a request is already filtered. The default implementation
<del> * is based on the configured name of the concrete filter instance.
<add> * <p>Sub-classes may use {@link #isAsyncDispatch(HttpServletRequest)} to
<add> * determine when a filter is invoked as part of an async dispatch, and
<add> * use {@link #isAsyncStarted(HttpServletRequest)} to determine when the
<add> * request has been placed in async mode and therefore the current dispatch
<add> * won't be the last one.
<add> *
<add> * <p>Yet another dispatch type that also occurs in its own thread is
<add> * {@link javax.servlet.DispatcherType.ERROR ERROR}. Sub-classes can override
<add> * {@link #shouldNotFilterErrorDispatch()} if they wish to declare statically
<add> * if they should be invoked <em>once</em> during error dispatches.
<add> *
<add> * <p>The {@link #getAlreadyFilteredAttributeName} method determines how to
<add> * identify that a request is already filtered. The default implementation is
<add> * based on the configured name of the concrete filter instance.
<ide> *
<ide> * @author Juergen Hoeller
<ide> * @author Rossen Stoyanchev
<ide> public final void doFilter(ServletRequest request, ServletResponse response, Fil
<ide> HttpServletRequest httpRequest = (HttpServletRequest) request;
<ide> HttpServletResponse httpResponse = (HttpServletResponse) response;
<ide>
<del> WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(request);
<del> boolean processAsyncDispatch = asyncManager.hasConcurrentResult() && !shouldNotFilterAsyncDispatch();
<del>
<ide> String alreadyFilteredAttributeName = getAlreadyFilteredAttributeName();
<ide> boolean hasAlreadyFilteredAttribute = request.getAttribute(alreadyFilteredAttributeName) != null;
<ide>
<del> if ((hasAlreadyFilteredAttribute && (!processAsyncDispatch)) || shouldNotFilter(httpRequest)) {
<add> if (hasAlreadyFilteredAttribute || skipDispatch(httpRequest) || shouldNotFilter(httpRequest)) {
<ide>
<ide> // Proceed without invoking this filter...
<ide> filterChain.doFilter(request, response);
<ide> public final void doFilter(ServletRequest request, ServletResponse response, Fil
<ide> doFilterInternal(httpRequest, httpResponse, filterChain);
<ide> }
<ide> finally {
<del> if (!asyncManager.isConcurrentHandlingStarted()) {
<del> // Remove the "already filtered" request attribute for this request.
<del> request.removeAttribute(alreadyFilteredAttributeName);
<del> }
<add> // Remove the "already filtered" request attribute for this request.
<add> request.removeAttribute(alreadyFilteredAttributeName);
<ide> }
<ide> }
<ide> }
<ide>
<add> private boolean skipDispatch(HttpServletRequest request) {
<add> if (isAsyncDispatch(request) && shouldNotFilterAsyncDispatch()) {
<add> return true;
<add> }
<add> if ((request.getAttribute(WebUtils.ERROR_REQUEST_URI_ATTRIBUTE) != null) && shouldNotFilterErrorDispatch()) {
<add> return true;
<add> }
<add> return false;
<add> }
<add>
<add> /**
<add> * The dispatcher type {@code javax.servlet.DispatcherType.ASYNC} introduced
<add> * in Servlet 3.0 means a filter can be invoked in more than one thread over
<add> * the course of a single request. This method returns {@code true} if the
<add> * filter is currently executing within an asynchronous dispatch.
<add> *
<add> * @param request the current request
<add> * @see WebAsyncManager#hasConcurrentResult()
<add> */
<add> protected boolean isAsyncDispatch(HttpServletRequest request) {
<add> return WebAsyncUtils.getAsyncManager(request).hasConcurrentResult();
<add> }
<add>
<add> /**
<add> * Whether request processing is in asynchronous mode meaning that the
<add> * response will not be committed after the current thread is exited.
<add> *
<add> * @param request the current request
<add> * @see WebAsyncManager#isConcurrentHandlingStarted()
<add> */
<add> protected boolean isAsyncStarted(HttpServletRequest request) {
<add> return WebAsyncUtils.getAsyncManager(request).isConcurrentHandlingStarted();
<add> }
<add>
<ide> /**
<ide> * Return the name of the request attribute that identifies that a request
<ide> * is already filtered.
<ide> protected boolean shouldNotFilter(HttpServletRequest request) throws ServletExce
<ide> }
<ide>
<ide> /**
<del> * Whether to filter async dispatches, which occur in a different thread.
<ide> * The dispatcher type {@code javax.servlet.DispatcherType.ASYNC} introduced
<del> * in Servlet 3.0 means a filter can be invoked in more than one thread (and
<del> * exited) over the course of a single request. Some filters only need to
<del> * filter the initial thread (e.g. request wrapping) while others may need
<add> * in Servlet 3.0 means a filter can be invoked in more than one thread
<add> * over the course of a single request. Some filters only need to filter
<add> * the initial thread (e.g. request wrapping) while others may need
<ide> * to be invoked at least once in each additional thread for example for
<ide> * setting up thread locals or to perform final processing at the very end.
<ide> * <p>Note that although a filter can be mapped to handle specific dispatcher
<ide> * types via {@code web.xml} or in Java through the {@code ServletContext},
<ide> * servlet containers may enforce different defaults with regards to
<ide> * dispatcher types. This flag enforces the design intent of the filter.
<del> * <p>The default setting is "true", which means the filter will not be
<add> *
<add> * <p>The default return value is "true", which means the filter will not be
<ide> * invoked during subsequent async dispatches. If "false", the filter will
<ide> * be invoked during async dispatches with the same guarantees of being
<ide> * invoked only once during a request within a single thread.
<ide> protected boolean shouldNotFilterAsyncDispatch() {
<ide> return true;
<ide> }
<ide>
<add> /**
<add> * Whether to filter error dispatches such as when the servlet container
<add> * processes and error mapped in {@code web.xml}. The default return value
<add> * is "true", which means the filter will not be invoked in case of an error
<add> * dispatch.
<add> */
<add> protected boolean shouldNotFilterErrorDispatch() {
<add> return true;
<add> }
<add>
<ide> /**
<ide> * Same contract as for <code>doFilter</code>, but guaranteed to be
<ide> * just invoked once per request within a single request thread.
<ide><path>spring-web/src/main/java/org/springframework/web/filter/RequestContextFilter.java
<ide> public void setThreadContextInheritable(boolean threadContextInheritable) {
<ide> this.threadContextInheritable = threadContextInheritable;
<ide> }
<ide>
<del>
<ide> /**
<del> * The default value is "false" in which case the filter will set up the request
<del> * context in each asynchronously dispatched thread.
<add> * Returns "false" so that the filter may set up the request context in each
<add> * asynchronously dispatched thread.
<ide> */
<ide> @Override
<ide> protected boolean shouldNotFilterAsyncDispatch() {
<ide> return false;
<ide> }
<ide>
<add> /**
<add> * Returns "false" so that the filter may set up the request context in an
<add> * error dispatch.
<add> */
<add> @Override
<add> protected boolean shouldNotFilterErrorDispatch() {
<add> return false;
<add> }
<add>
<ide> @Override
<ide> protected void doFilterInternal(
<ide> HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
<ide><path>spring-web/src/main/java/org/springframework/web/filter/ShallowEtagHeaderFilter.java
<ide> protected boolean shouldNotFilterAsyncDispatch() {
<ide> protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
<ide> throws ServletException, IOException {
<ide>
<del> WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(request);
<del> boolean isFirstRequest = !asyncManager.hasConcurrentResult();
<del>
<del> if (isFirstRequest) {
<add> if (!isAsyncDispatch(request)) {
<ide> response = new ShallowEtagResponseWrapper(response);
<ide> }
<ide>
<ide> filterChain.doFilter(request, response);
<ide>
<del> if (!asyncManager.isConcurrentHandlingStarted()) {
<add> if (!isAsyncStarted(request)) {
<ide> updateResponse(request, response);
<ide> }
<ide> }
<ide><path>spring-web/src/test/java/org/springframework/web/filter/CharacterEncodingFilterTests.java
<ide> import org.springframework.mock.web.MockHttpServletResponse;
<ide> import org.springframework.mock.web.MockServletContext;
<ide> import org.springframework.web.context.request.async.WebAsyncUtils;
<add>import org.springframework.web.util.WebUtils;
<ide>
<ide> /**
<ide> * @author Rick Evans
<ide> public void testForceAlwaysSetsEncoding() throws Exception {
<ide> HttpServletRequest request = createMock(HttpServletRequest.class);
<ide> addAsyncManagerExpectations(request);
<ide> request.setCharacterEncoding(ENCODING);
<add> expect(request.getAttribute(WebUtils.ERROR_REQUEST_URI_ATTRIBUTE)).andReturn(null);
<ide> expect(request.getAttribute(FILTER_NAME + OncePerRequestFilter.ALREADY_FILTERED_SUFFIX)).andReturn(null);
<ide> request.setAttribute(FILTER_NAME + OncePerRequestFilter.ALREADY_FILTERED_SUFFIX, Boolean.TRUE);
<ide> request.removeAttribute(FILTER_NAME + OncePerRequestFilter.ALREADY_FILTERED_SUFFIX);
<ide> public void testEncodingIfEmptyAndNotForced() throws Exception {
<ide> addAsyncManagerExpectations(request);
<ide> expect(request.getCharacterEncoding()).andReturn(null);
<ide> request.setCharacterEncoding(ENCODING);
<add> expect(request.getAttribute(WebUtils.ERROR_REQUEST_URI_ATTRIBUTE)).andReturn(null);
<ide> expect(request.getAttribute(FILTER_NAME + OncePerRequestFilter.ALREADY_FILTERED_SUFFIX)).andReturn(null);
<ide> request.setAttribute(FILTER_NAME + OncePerRequestFilter.ALREADY_FILTERED_SUFFIX, Boolean.TRUE);
<ide> request.removeAttribute(FILTER_NAME + OncePerRequestFilter.ALREADY_FILTERED_SUFFIX);
<ide> public void testDoesNowtIfEncodingIsNotEmptyAndNotForced() throws Exception {
<ide> HttpServletRequest request = createMock(HttpServletRequest.class);
<ide> addAsyncManagerExpectations(request);
<ide> expect(request.getCharacterEncoding()).andReturn(ENCODING);
<add> expect(request.getAttribute(WebUtils.ERROR_REQUEST_URI_ATTRIBUTE)).andReturn(null);
<ide> expect(request.getAttribute(FILTER_NAME + OncePerRequestFilter.ALREADY_FILTERED_SUFFIX)).andReturn(null);
<ide> request.setAttribute(FILTER_NAME + OncePerRequestFilter.ALREADY_FILTERED_SUFFIX, Boolean.TRUE);
<ide> request.removeAttribute(FILTER_NAME + OncePerRequestFilter.ALREADY_FILTERED_SUFFIX);
<ide> public void testWithBeanInitialization() throws Exception {
<ide> addAsyncManagerExpectations(request);
<ide> expect(request.getCharacterEncoding()).andReturn(null);
<ide> request.setCharacterEncoding(ENCODING);
<add> expect(request.getAttribute(WebUtils.ERROR_REQUEST_URI_ATTRIBUTE)).andReturn(null);
<ide> expect(request.getAttribute(FILTER_NAME + OncePerRequestFilter.ALREADY_FILTERED_SUFFIX)).andReturn(null);
<ide> request.setAttribute(FILTER_NAME + OncePerRequestFilter.ALREADY_FILTERED_SUFFIX, Boolean.TRUE);
<ide> request.removeAttribute(FILTER_NAME + OncePerRequestFilter.ALREADY_FILTERED_SUFFIX);
<ide> public void testWithIncompleteInitialization() throws Exception {
<ide> addAsyncManagerExpectations(request);
<ide> expect(request.getCharacterEncoding()).andReturn(null);
<ide> request.setCharacterEncoding(ENCODING);
<add> expect(request.getAttribute(WebUtils.ERROR_REQUEST_URI_ATTRIBUTE)).andReturn(null);
<ide> expect(request.getAttribute(CharacterEncodingFilter.class.getName() + OncePerRequestFilter.ALREADY_FILTERED_SUFFIX)).andReturn(null);
<ide> request.setAttribute(CharacterEncodingFilter.class.getName() + OncePerRequestFilter.ALREADY_FILTERED_SUFFIX, Boolean.TRUE);
<ide> request.removeAttribute(CharacterEncodingFilter.class.getName() + OncePerRequestFilter.ALREADY_FILTERED_SUFFIX); | 8 |
Ruby | Ruby | fix select tag helper used with enumerable choices | efe62b71d52c40849ead8855fb4f42fae91d4c54 | <ide><path>actionview/lib/action_view/helpers/tags/select.rb
<ide> def render
<ide> # [nil, []]
<ide> # { nil => [] }
<ide> def grouped_choices?
<del> !@choices.empty? && @choices.first.respond_to?(:last) && Array === @choices.first.last
<add> !@choices.blank? && @choices.first.respond_to?(:last) && Array === @choices.first.last
<ide> end
<ide> end
<ide> end
<ide><path>actionview/test/template/form_options_helper_test.rb
<ide> def category
<ide> end
<ide> end
<ide>
<add>class CustomEnumerable
<add> include Enumerable
<add>
<add> def each
<add> yield "one"
<add> yield "two"
<add> end
<add>end
<add>
<ide> class FormOptionsHelperTest < ActionView::TestCase
<ide> tests ActionView::Helpers::FormOptionsHelper
<ide>
<ide> def test_select_with_range
<ide> )
<ide> end
<ide>
<add> def test_select_with_enumerable
<add> @post = Post.new
<add> assert_dom_equal(
<add> "<select id=\"post_category\" name=\"post[category]\"><option value=\"one\">one</option>\n<option value=\"two\">two</option></select>",
<add> select("post", "category", CustomEnumerable.new)
<add> )
<add> end
<add>
<ide> def test_collection_select
<ide> @post = Post.new
<ide> @post.author_name = "Babe" | 2 |
Ruby | Ruby | change the string to use in test case | 37802dd51ec1e1b29743be2a3d02106f930e04ba | <ide><path>activerecord/test/cases/adapters/mysql/mysql_adapter_test.rb
<ide> def test_tables_quoting
<ide> flunk
<ide> rescue => e
<ide> # assertion for *quoted* database properly
<del> assert_match(/Unknown database 'foo-bar': SHOW TABLES IN `foo-bar`/, e.inspect)
<add> assert_match(/database 'foo-bar'/, e.inspect)
<ide> end
<ide> end
<ide>
<ide><path>activerecord/test/cases/adapters/mysql2/schema_test.rb
<ide> def test_tables_quoting
<ide> flunk
<ide> rescue => e
<ide> # assertion for *quoted* database properly
<del> assert_match(/Unknown database 'foo-bar': SHOW TABLES IN `foo-bar`/, e.inspect)
<add> assert_match(/database 'foo-bar'/, e.inspect)
<ide> end
<ide> end
<ide> | 2 |
Python | Python | fix bug in mark ti success api | d87ab6d3a54cb6937cfa1771c901f34dda6a2f65 | <ide><path>airflow/www/views.py
<ide> def success(self):
<ide> origin = get_safe_url(args.get('origin'))
<ide> execution_date = args.get('execution_date')
<ide>
<del> upstream = to_boolean(args.get('failed_upstream'))
<del> downstream = to_boolean(args.get('failed_downstream'))
<del> future = to_boolean(args.get('failed_future'))
<del> past = to_boolean(args.get('failed_past'))
<add> upstream = to_boolean(args.get('success_upstream'))
<add> downstream = to_boolean(args.get('success_downstream'))
<add> future = to_boolean(args.get('success_future'))
<add> past = to_boolean(args.get('success_past'))
<ide>
<ide> return self._mark_task_instance_state(
<ide> dag_id, | 1 |
Text | Text | add metadata about ecdh curve options | 870186d69a9d2442b095e6d8783ba974f6893c60 | <ide><path>doc/api/tls.md
<ide> changes:
<ide> - version: v9.3.0
<ide> pr-url: https://github.com/nodejs/node/pull/14903
<ide> description: The `options` parameter can now include `clientCertEngine`.
<add> - version: v9.0.0
<add> pr-url: https://github.com/nodejs/node/pull/15206
<add> description: The `ecdhCurve` option can now be multiple `':'` separated
<add> curve names or `'auto'`.
<ide> - version: v7.3.0
<ide> pr-url: https://github.com/nodejs/node/pull/10294
<ide> description: If the `key` option is an array, individual entries do not
<ide> console.log(tls.getCiphers()); // ['AES128-SHA', 'AES256-SHA', ...]
<ide> ## tls.DEFAULT_ECDH_CURVE
<ide> <!-- YAML
<ide> added: v0.11.13
<add>changes:
<add> - version: v10.0.0
<add> pr-url: https://github.com/nodejs/node/pull/16853
<add> description: Default value changed to `'auto'`.
<ide> -->
<ide>
<ide> The default curve name to use for ECDH key agreement in a tls server. The | 1 |
PHP | PHP | fix closing non resource | 5ac60288fd6844179feb0e0bcd137bab41b6b09b | <ide><path>lib/Cake/Console/ConsoleOutput.php
<ide> public function outputAs($type = null) {
<ide> * Clean up and close handles
<ide> */
<ide> public function __destruct() {
<del> fclose($this->_output);
<add> if (is_resource($this->_output)) {
<add> fclose($this->_output);
<add> }
<ide> }
<ide>
<ide> } | 1 |
Python | Python | add masked array tests for '==' and '!=' | 173f65c02c8d654fc55f381665ec43c64d43d636 | <ide><path>numpy/ma/tests/test_core.py
<ide> "setting an item on a masked array which has a shared mask will not copy")
<ide>
<ide>
<add># For parametrized numeric testing
<add>num_dts = [np.dtype(dt_) for dt_ in '?bhilqBHILQefdgFD']
<add>num_ids = [dt_.char for dt_ in num_dts]
<add>
<add>
<ide> class TestMaskedArray(object):
<ide> # Base test class for MaskedArrays.
<ide>
<ide> def test_eq_on_structured(self):
<ide> # Test the equality of structured arrays
<ide> ndtype = [('A', int), ('B', int)]
<ide> a = array([(1, 1), (2, 2)], mask=[(0, 1), (0, 0)], dtype=ndtype)
<add>
<ide> test = (a == a)
<ide> assert_equal(test.data, [True, True])
<ide> assert_equal(test.mask, [False, False])
<add> assert_(test.fill_value == True)
<add>
<ide> test = (a == a[0])
<ide> assert_equal(test.data, [True, False])
<ide> assert_equal(test.mask, [False, False])
<add> assert_(test.fill_value == True)
<add>
<ide> b = array([(1, 1), (2, 2)], mask=[(1, 0), (0, 0)], dtype=ndtype)
<ide> test = (a == b)
<ide> assert_equal(test.data, [False, True])
<ide> assert_equal(test.mask, [True, False])
<add> assert_(test.fill_value == True)
<add>
<ide> test = (a[0] == b)
<ide> assert_equal(test.data, [False, False])
<ide> assert_equal(test.mask, [True, False])
<add> assert_(test.fill_value == True)
<add>
<ide> b = array([(1, 1), (2, 2)], mask=[(0, 1), (1, 0)], dtype=ndtype)
<ide> test = (a == b)
<ide> assert_equal(test.data, [True, True])
<ide> assert_equal(test.mask, [False, False])
<add> assert_(test.fill_value == True)
<add>
<ide> # complicated dtype, 2-dimensional array.
<ide> ndtype = [('A', int), ('B', [('BA', int), ('BB', int)])]
<ide> a = array([[(1, (1, 1)), (2, (2, 2))],
<ide> def test_eq_on_structured(self):
<ide> test = (a[0, 0] == a)
<ide> assert_equal(test.data, [[True, False], [False, False]])
<ide> assert_equal(test.mask, [[False, False], [False, True]])
<add> assert_(test.fill_value == True)
<ide>
<ide> def test_ne_on_structured(self):
<ide> # Test the equality of structured arrays
<ide> ndtype = [('A', int), ('B', int)]
<ide> a = array([(1, 1), (2, 2)], mask=[(0, 1), (0, 0)], dtype=ndtype)
<add>
<ide> test = (a != a)
<ide> assert_equal(test.data, [False, False])
<ide> assert_equal(test.mask, [False, False])
<add> assert_(test.fill_value == True)
<add>
<ide> test = (a != a[0])
<ide> assert_equal(test.data, [False, True])
<ide> assert_equal(test.mask, [False, False])
<add> assert_(test.fill_value == True)
<add>
<ide> b = array([(1, 1), (2, 2)], mask=[(1, 0), (0, 0)], dtype=ndtype)
<ide> test = (a != b)
<ide> assert_equal(test.data, [True, False])
<ide> assert_equal(test.mask, [True, False])
<add> assert_(test.fill_value == True)
<add>
<ide> test = (a[0] != b)
<ide> assert_equal(test.data, [True, True])
<ide> assert_equal(test.mask, [True, False])
<add> assert_(test.fill_value == True)
<add>
<ide> b = array([(1, 1), (2, 2)], mask=[(0, 1), (1, 0)], dtype=ndtype)
<ide> test = (a != b)
<ide> assert_equal(test.data, [False, False])
<ide> assert_equal(test.mask, [False, False])
<add> assert_(test.fill_value == True)
<add>
<ide> # complicated dtype, 2-dimensional array.
<ide> ndtype = [('A', int), ('B', [('BA', int), ('BB', int)])]
<ide> a = array([[(1, (1, 1)), (2, (2, 2))],
<ide> def test_ne_on_structured(self):
<ide> test = (a[0, 0] != a)
<ide> assert_equal(test.data, [[False, True], [True, True]])
<ide> assert_equal(test.mask, [[False, False], [False, True]])
<add> assert_(test.fill_value == True)
<ide>
<ide> def test_eq_ne_structured_extra(self):
<ide> # ensure simple examples are symmetric and make sense.
<ide> def test_eq_ne_structured_extra(self):
<ide> el_by_el = [m1[name] != m2[name] for name in dt.names]
<ide> assert_equal(array(el_by_el, dtype=bool).any(), ne_expected)
<ide>
<add> @pytest.mark.parametrize('dt', ['S', 'U'])
<add> @pytest.mark.parametrize('fill', [None, 'A'])
<add> def test_eq_for_strings(self, dt, fill):
<add> # Test the equality of structured arrays
<add> a = array(['a', 'b'], dtype=dt, mask=[0, 1], fill_value=fill)
<add>
<add> test = (a == a)
<add> assert_equal(test.data, [True, True])
<add> assert_equal(test.mask, [False, True])
<add> assert_(test.fill_value == True)
<add>
<add> test = (a == a[0])
<add> assert_equal(test.data, [True, False])
<add> assert_equal(test.mask, [False, True])
<add> assert_(test.fill_value == True)
<add>
<add> b = array(['a', 'b'], dtype=dt, mask=[1, 0], fill_value=fill)
<add> test = (a == b)
<add> assert_equal(test.data, [False, False])
<add> assert_equal(test.mask, [True, True])
<add> assert_(test.fill_value == True)
<add>
<add> # test = (a[0] == b) # doesn't work in Python2
<add> test = (b == a[0])
<add> assert_equal(test.data, [False, False])
<add> assert_equal(test.mask, [True, False])
<add> assert_(test.fill_value == True)
<add>
<add> @pytest.mark.parametrize('dt', ['S', 'U'])
<add> @pytest.mark.parametrize('fill', [None, 'A'])
<add> def test_ne_for_strings(self, dt, fill):
<add> # Test the equality of structured arrays
<add> a = array(['a', 'b'], dtype=dt, mask=[0, 1], fill_value=fill)
<add>
<add> test = (a != a)
<add> assert_equal(test.data, [False, False])
<add> assert_equal(test.mask, [False, True])
<add> assert_(test.fill_value == True)
<add>
<add> test = (a != a[0])
<add> assert_equal(test.data, [False, True])
<add> assert_equal(test.mask, [False, True])
<add> assert_(test.fill_value == True)
<add>
<add> b = array(['a', 'b'], dtype=dt, mask=[1, 0], fill_value=fill)
<add> test = (a != b)
<add> assert_equal(test.data, [True, True])
<add> assert_equal(test.mask, [True, True])
<add> assert_(test.fill_value == True)
<add>
<add> # test = (a[0] != b) # doesn't work in Python2
<add> test = (b != a[0])
<add> assert_equal(test.data, [True, True])
<add> assert_equal(test.mask, [True, False])
<add> assert_(test.fill_value == True)
<add>
<add> @pytest.mark.parametrize('dt1', num_dts, ids=num_ids)
<add> @pytest.mark.parametrize('dt2', num_dts, ids=num_ids)
<add> @pytest.mark.parametrize('fill', [None, 1])
<add> def test_eq_for_numeric(self, dt1, dt2, fill):
<add> # Test the equality of structured arrays
<add> a = array([0, 1], dtype=dt1, mask=[0, 1], fill_value=fill)
<add>
<add> test = (a == a)
<add> assert_equal(test.data, [True, True])
<add> assert_equal(test.mask, [False, True])
<add> assert_(test.fill_value == True)
<add>
<add> test = (a == a[0])
<add> assert_equal(test.data, [True, False])
<add> assert_equal(test.mask, [False, True])
<add> assert_(test.fill_value == True)
<add>
<add> b = array([0, 1], dtype=dt2, mask=[1, 0], fill_value=fill)
<add> test = (a == b)
<add> assert_equal(test.data, [False, False])
<add> assert_equal(test.mask, [True, True])
<add> assert_(test.fill_value == True)
<add>
<add> # test = (a[0] == b) # doesn't work in Python2
<add> test = (b == a[0])
<add> assert_equal(test.data, [False, False])
<add> assert_equal(test.mask, [True, False])
<add> assert_(test.fill_value == True)
<add>
<add> @pytest.mark.parametrize('dt1', num_dts, ids=num_ids)
<add> @pytest.mark.parametrize('dt2', num_dts, ids=num_ids)
<add> @pytest.mark.parametrize('fill', [None, 1])
<add> def test_ne_for_numeric(self, dt1, dt2, fill):
<add> # Test the equality of structured arrays
<add> a = array([0, 1], dtype=dt1, mask=[0, 1], fill_value=fill)
<add>
<add> test = (a != a)
<add> assert_equal(test.data, [False, False])
<add> assert_equal(test.mask, [False, True])
<add> assert_(test.fill_value == True)
<add>
<add> test = (a != a[0])
<add> assert_equal(test.data, [False, True])
<add> assert_equal(test.mask, [False, True])
<add> assert_(test.fill_value == True)
<add>
<add> b = array([0, 1], dtype=dt2, mask=[1, 0], fill_value=fill)
<add> test = (a != b)
<add> assert_equal(test.data, [True, True])
<add> assert_equal(test.mask, [True, True])
<add> assert_(test.fill_value == True)
<add>
<add> # test = (a[0] != b) # doesn't work in Python2
<add> test = (b != a[0])
<add> assert_equal(test.data, [True, True])
<add> assert_equal(test.mask, [True, False])
<add> assert_(test.fill_value == True)
<add>
<ide> def test_eq_with_None(self):
<ide> # Really, comparisons with None should not be done, but check them
<ide> # anyway. Note that pep8 will flag these tests.
<ide> def test_astype_mask_ordering():
<ide> assert_(x_f2.mask.flags.f_contiguous)
<ide>
<ide>
<del>dts = [np.dtype(dt_) for dt_ in '?bhilqBHILQefdgFD']
<del>ids = [dt_.char for dt_ in dts]
<del>
<del>@pytest.mark.parametrize('dt1', dts, ids=ids)
<del>@pytest.mark.parametrize('dt2', dts, ids=ids)
<add>@pytest.mark.parametrize('dt1', num_dts, ids=num_ids)
<add>@pytest.mark.parametrize('dt2', num_dts, ids=num_ids)
<ide> @pytest.mark.filterwarnings('ignore::numpy.ComplexWarning')
<ide> def test_astype_basic(dt1, dt2):
<ide> # See gh-12070 | 1 |
Javascript | Javascript | update example to use a module | ba2f606143d2041d0cbbc9b641b95719319c4b0d | <ide><path>src/ng/directive/ngTransclude.js
<ide> * @element ANY
<ide> *
<ide> * @example
<del> <example module="transclude">
<add> <example module="transcludeExample">
<ide> <file name="index.html">
<ide> <script>
<del> function Ctrl($scope) {
<del> $scope.title = 'Lorem Ipsum';
<del> $scope.text = 'Neque porro quisquam est qui dolorem ipsum quia dolor...';
<del> }
<del>
<del> angular.module('transclude', [])
<add> angular.module('transcludeExample', [])
<ide> .directive('pane', function(){
<ide> return {
<ide> restrict: 'E',
<ide> '<div ng-transclude></div>' +
<ide> '</div>'
<ide> };
<del> });
<add> })
<add> .controller('ExampleController', ['$scope', function($scope) {
<add> $scope.title = 'Lorem Ipsum';
<add> $scope.text = 'Neque porro quisquam est qui dolorem ipsum quia dolor...';
<add> }]);
<ide> </script>
<del> <div ng-controller="Ctrl">
<add> <div ng-controller="ExampleController">
<ide> <input ng-model="title"><br>
<ide> <textarea ng-model="text"></textarea> <br/>
<ide> <pane title="{{title}}">{{text}}</pane> | 1 |
Text | Text | fix malformed changelog entries | f42d7a4552cdf3604833c61cf1d7923b9602833d | <ide><path>doc/changelogs/CHANGELOG_V012.md
<ide> will be maintained until December 31st, 2016.
<ide>
<ide> ### Commits:
<ide>
<del>* [[`a47fd4549d`](https://github.com/nodejs/node/commit/a47fd4549d) - build: add working lint-ci make target (Rod Vagg) https://github.com/nodejs/node/pull/9151
<del>* [[`830584ca59`](https://github.com/nodejs/node/commit/830584ca59) - deps: define missing operator delete functions (John Barboza) https://github.com/nodejs/node/pull/10356
<del>* [[`c130b31cba`](https://github.com/nodejs/node/commit/c130b31cba) - deps: upgrade npm to 2.15.11 (Jeremiah Senkpiel) https://github.com/nodejs/node/pull/9619
<del>* [[`bc6766d847`](https://github.com/nodejs/node/commit/bc6766d847) - doc: update npm license in main LICENSE file (Rod Vagg) https://github.com/nodejs/node/pull/10352
<del>* [[`0cdf344c80`](https://github.com/nodejs/node/commit/0cdf344c80) - (SEMVER-MINOR) process: reintroduce ares to versions (Johan Bergström) https://github.com/nodejs/node/pull/9191
<del>* [[`d8e27ec30a`](https://github.com/nodejs/node/commit/d8e27ec30a) - test: mark dgram-multicast-multi-process as flaky (Rod Vagg) https://github.com/nodejs/node/pull/9150
<del>* [[`c722335ead`](https://github.com/nodejs/node/commit/c722335ead) - tls: fix minor jslint failure (Rod Vagg) https://github.com/nodejs/node/pull/9107
<add>* [[`a47fd4549d`](https://github.com/nodejs/node/commit/a47fd4549d)] - build: add working lint-ci make target (Rod Vagg) https://github.com/nodejs/node/pull/9151
<add>* [[`830584ca59`](https://github.com/nodejs/node/commit/830584ca59)] - deps: define missing operator delete functions (John Barboza) https://github.com/nodejs/node/pull/10356
<add>* [[`c130b31cba`](https://github.com/nodejs/node/commit/c130b31cba)] - deps: upgrade npm to 2.15.11 (Jeremiah Senkpiel) https://github.com/nodejs/node/pull/9619
<add>* [[`bc6766d847`](https://github.com/nodejs/node/commit/bc6766d847)] - doc: update npm license in main LICENSE file (Rod Vagg) https://github.com/nodejs/node/pull/10352
<add>* [[`0cdf344c80`](https://github.com/nodejs/node/commit/0cdf344c80)] - (SEMVER-MINOR) process: reintroduce ares to versions (Johan Bergström) https://github.com/nodejs/node/pull/9191
<add>* [[`d8e27ec30a`](https://github.com/nodejs/node/commit/d8e27ec30a)] - test: mark dgram-multicast-multi-process as flaky (Rod Vagg) https://github.com/nodejs/node/pull/9150
<add>* [[`c722335ead`](https://github.com/nodejs/node/commit/c722335ead)] - tls: fix minor jslint failure (Rod Vagg) https://github.com/nodejs/node/pull/9107
<ide>
<ide> <a id="0.12.17"></a>
<ide> ## 2016-10-18, Version 0.12.17 (Maintenance), @rvagg
<ide> This is a security release. All Node.js users should consult the security releas
<ide>
<ide> ### Commits:
<ide>
<del>* [[`c5b095ecf8`](https://github.com/nodejs/node/commit/c5b095ecf8) - deps: avoid single-byte buffer overwrite (Daniel Stenberg) https://github.com/nodejs/node/pull/8849
<add>* [[`c5b095ecf8`](https://github.com/nodejs/node/commit/c5b095ecf8)] - deps: avoid single-byte buffer overwrite (Daniel Stenberg) https://github.com/nodejs/node/pull/8849
<ide>
<ide> <a id="0.12.16"></a>
<ide> ## 2016-09-27, Version 0.12.16 (Maintenance), @rvagg
<ide> This is a security release. All Node.js users should consult the security releas
<ide>
<ide> ### Commits:
<ide>
<del>* [[`38d7258d89`](https://github.com/nodejs/node/commit/38d7258d89) - buffer: zero-fill uninitialized bytes in .concat() (Сковорода Никита Андреевич) https://github.com/nodejs/node-private/pull/66
<del>* [[`1ba6d16786`](https://github.com/nodejs/node/commit/1ba6d16786) - build: turn on -fno-delete-null-pointer-checks (Ben Noordhuis) https://github.com/nodejs/node/pull/6737
<del>* [[`71e4285e27`](https://github.com/nodejs/node/commit/71e4285e27) - crypto: don't build hardware engines (Rod Vagg) https://github.com/nodejs/node-private/pull/69
<del>* [[`b6e0105a66`](https://github.com/nodejs/node/commit/b6e0105a66) - deps: add -no_rand_screen to openssl s_client (Shigeki Ohtsu) https://github.com/nodejs/node-v0.x-archive/pull/25368
<del>* [[`1caec97eab`](https://github.com/nodejs/node/commit/1caec97eab) - deps: fix openssl assembly error on ia32 win32 (Fedor Indutny) https://github.com/nodejs/node-v0.x-archive/pull/25654
<del>* [[`734bc6938b`](https://github.com/nodejs/node/commit/734bc6938b) - deps: separate sha256/sha512-x86_64.pl for openssl (Shigeki Ohtsu) https://github.com/nodejs/node-v0.x-archive/pull/25654
<del>* [[`7cc6d4eb5c`](https://github.com/nodejs/node/commit/7cc6d4eb5c) - deps: copy all openssl header files to include dir (Shigeki Ohtsu) https://github.com/nodejs/node/pull/8718
<del>* [[`4a9da21217`](https://github.com/nodejs/node/commit/4a9da21217) - deps: upgrade openssl sources to 1.0.1u (Shigeki Ohtsu) https://github.com/nodejs/node/pull/8718
<del>* [[`6d977902bd`](https://github.com/nodejs/node/commit/6d977902bd) - http: check reason chars in writeHead (Evan Lucas) https://github.com/nodejs/node-private/pull/47
<del>* [[`ad470e496b`](https://github.com/nodejs/node/commit/ad470e496b) - http: disallow sending obviously invalid status codes (Evan Lucas) https://github.com/nodejs/node-private/pull/47
<del>* [[`9dbde2fc88`](https://github.com/nodejs/node/commit/9dbde2fc88) - lib: make tls.checkServerIdentity() more strict (Ben Noordhuis) https://github.com/nodejs/node-private/pull/61
<del>* [[`db80592071`](https://github.com/nodejs/node/commit/db80592071) - openssl: fix keypress requirement in apps on win32 (Shigeki Ohtsu) https://github.com/nodejs/node-v0.x-archive/pull/25654
<add>* [[`38d7258d89`](https://github.com/nodejs/node/commit/38d7258d89)] - buffer: zero-fill uninitialized bytes in .concat() (Сковорода Никита Андреевич) https://github.com/nodejs/node-private/pull/66
<add>* [[`1ba6d16786`](https://github.com/nodejs/node/commit/1ba6d16786)] - build: turn on -fno-delete-null-pointer-checks (Ben Noordhuis) https://github.com/nodejs/node/pull/6737
<add>* [[`71e4285e27`](https://github.com/nodejs/node/commit/71e4285e27)] - crypto: don't build hardware engines (Rod Vagg) https://github.com/nodejs/node-private/pull/69
<add>* [[`b6e0105a66`](https://github.com/nodejs/node/commit/b6e0105a66)] - deps: add -no_rand_screen to openssl s_client (Shigeki Ohtsu) https://github.com/nodejs/node-v0.x-archive/pull/25368
<add>* [[`1caec97eab`](https://github.com/nodejs/node/commit/1caec97eab)] - deps: fix openssl assembly error on ia32 win32 (Fedor Indutny) https://github.com/nodejs/node-v0.x-archive/pull/25654
<add>* [[`734bc6938b`](https://github.com/nodejs/node/commit/734bc6938b)] - deps: separate sha256/sha512-x86_64.pl for openssl (Shigeki Ohtsu) https://github.com/nodejs/node-v0.x-archive/pull/25654
<add>* [[`7cc6d4eb5c`](https://github.com/nodejs/node/commit/7cc6d4eb5c)] - deps: copy all openssl header files to include dir (Shigeki Ohtsu) https://github.com/nodejs/node/pull/8718
<add>* [[`4a9da21217`](https://github.com/nodejs/node/commit/4a9da21217)] - deps: upgrade openssl sources to 1.0.1u (Shigeki Ohtsu) https://github.com/nodejs/node/pull/8718
<add>* [[`6d977902bd`](https://github.com/nodejs/node/commit/6d977902bd)] - http: check reason chars in writeHead (Evan Lucas) https://github.com/nodejs/node-private/pull/47
<add>* [[`ad470e496b`](https://github.com/nodejs/node/commit/ad470e496b)] - http: disallow sending obviously invalid status codes (Evan Lucas) https://github.com/nodejs/node-private/pull/47
<add>* [[`9dbde2fc88`](https://github.com/nodejs/node/commit/9dbde2fc88)] - lib: make tls.checkServerIdentity() more strict (Ben Noordhuis) https://github.com/nodejs/node-private/pull/61
<add>* [[`db80592071`](https://github.com/nodejs/node/commit/db80592071)] - openssl: fix keypress requirement in apps on win32 (Shigeki Ohtsu) https://github.com/nodejs/node-v0.x-archive/pull/25654
<ide>
<ide> <a id="0.12.15"></a>
<ide> ## 2016-06-23, Version 0.12.15 (Maintenance), @rvagg
<ide> This is a security release. All Node.js users should consult the security releas
<ide>
<ide> ### Commits:
<ide>
<del>* [[`da8501edf6`](https://github.com/nodejs/node/commit/da8501edf6) - deps: backport bd1777fd from libuv upstream (Rod Vagg)
<del>* [[`9207a00f8e`](https://github.com/nodejs/node/commit/9207a00f8e) - deps: backport 85adf43e from libuv upstream (Rod Vagg)
<del>* [[`9627f34230`](https://github.com/nodejs/node/commit/9627f34230) - deps: backport 98239224 from libuv upstream (Rod Vagg)
<del>* [[`5df21b2e36`](https://github.com/nodejs/node/commit/5df21b2e36) - deps: backport 9a4fd268 from libuv upstream (Rod Vagg)
<del>* [[`e75de35057`](https://github.com/nodejs/node/commit/e75de35057) - deps: backport 3eb6764a from libuv upstream (Rod Vagg)
<del>* [[`a113e02f16`](https://github.com/nodejs/node/commit/a113e02f16) - deps: backport 3a9bfec from v8 upstream (Ben Noordhuis)
<del>* [[`8138055c88`](https://github.com/nodejs/node/commit/8138055c88) - test: fix test failure due to expired certificates (Ben Noordhuis) https://github.com/nodejs/node/pull/7195
<add>* [[`da8501edf6`](https://github.com/nodejs/node/commit/da8501edf6)] - deps: backport bd1777fd from libuv upstream (Rod Vagg)
<add>* [[`9207a00f8e`](https://github.com/nodejs/node/commit/9207a00f8e)] - deps: backport 85adf43e from libuv upstream (Rod Vagg)
<add>* [[`9627f34230`](https://github.com/nodejs/node/commit/9627f34230)] - deps: backport 98239224 from libuv upstream (Rod Vagg)
<add>* [[`5df21b2e36`](https://github.com/nodejs/node/commit/5df21b2e36)] - deps: backport 9a4fd268 from libuv upstream (Rod Vagg)
<add>* [[`e75de35057`](https://github.com/nodejs/node/commit/e75de35057)] - deps: backport 3eb6764a from libuv upstream (Rod Vagg)
<add>* [[`a113e02f16`](https://github.com/nodejs/node/commit/a113e02f16)] - deps: backport 3a9bfec from v8 upstream (Ben Noordhuis)
<add>* [[`8138055c88`](https://github.com/nodejs/node/commit/8138055c88)] - test: fix test failure due to expired certificates (Ben Noordhuis) https://github.com/nodejs/node/pull/7195
<ide>
<ide> <a id="0.12.14"></a>
<ide> ## 2016-05-06, Version 0.12.14 (Maintenance), @rvagg
<ide> This is a security release. All Node.js users should consult the security releas
<ide>
<ide> ### Commits:
<ide>
<del>* [[`3e99ee1b47`](https://github.com/nodejs/node/commit/3e99ee1b47) - deps: completely upgrade npm in LTS to 2.15.1 (Forrest L Norvell) https://github.com/nodejs/node/pull/5988
<del>* [[`2b63396e1f`](https://github.com/nodejs/node/commit/2b63396e1f) - deps: add -no_rand_screen to openssl s_client (Shigeki Ohtsu) https://github.com/joyent/node/pull/25368
<del>* [[`f21705df58`](https://github.com/nodejs/node/commit/f21705df58) - deps: update openssl asm files (Shigeki Ohtsu) https://github.com/nodejs/node/pull/6553
<del>* [[`02b6a6bc27`](https://github.com/nodejs/node/commit/02b6a6bc27) - deps: fix openssl assembly error on ia32 win32 (Fedor Indutny) https://github.com/joyent/node/pull/25654
<del>* [[`1aecc668b0`](https://github.com/nodejs/node/commit/1aecc668b0) - deps: separate sha256/sha512-x86_64.pl for openssl (Shigeki Ohtsu) https://github.com/joyent/node/pull/25654
<del>* [[`39380836a0`](https://github.com/nodejs/node/commit/39380836a0) - deps: copy all openssl header files to include dir (Shigeki Ohtsu) https://github.com/nodejs/node/pull/6553
<del>* [[`08c8ae44a8`](https://github.com/nodejs/node/commit/08c8ae44a8) - deps: upgrade openssl sources to 1.0.1t (Shigeki Ohtsu) https://github.com/nodejs/node/pull/6553
<del>* [[`f5a961ab13`](https://github.com/nodejs/node/commit/f5a961ab13) - openssl: fix keypress requirement in apps on win32 (Shigeki Ohtsu) https://github.com/joyent/node/pull/25654
<del>* [[`810fb211a7`](https://github.com/nodejs/node/commit/810fb211a7) - tools: remove obsolete npm test-legacy command (Kat Marchán) https://github.com/nodejs/node/pull/5988
<add>* [[`3e99ee1b47`](https://github.com/nodejs/node/commit/3e99ee1b47)] - deps: completely upgrade npm in LTS to 2.15.1 (Forrest L Norvell) https://github.com/nodejs/node/pull/5988
<add>* [[`2b63396e1f`](https://github.com/nodejs/node/commit/2b63396e1f)] - deps: add -no_rand_screen to openssl s_client (Shigeki Ohtsu) https://github.com/joyent/node/pull/25368
<add>* [[`f21705df58`](https://github.com/nodejs/node/commit/f21705df58)] - deps: update openssl asm files (Shigeki Ohtsu) https://github.com/nodejs/node/pull/6553
<add>* [[`02b6a6bc27`](https://github.com/nodejs/node/commit/02b6a6bc27)] - deps: fix openssl assembly error on ia32 win32 (Fedor Indutny) https://github.com/joyent/node/pull/25654
<add>* [[`1aecc668b0`](https://github.com/nodejs/node/commit/1aecc668b0)] - deps: separate sha256/sha512-x86_64.pl for openssl (Shigeki Ohtsu) https://github.com/joyent/node/pull/25654
<add>* [[`39380836a0`](https://github.com/nodejs/node/commit/39380836a0)] - deps: copy all openssl header files to include dir (Shigeki Ohtsu) https://github.com/nodejs/node/pull/6553
<add>* [[`08c8ae44a8`](https://github.com/nodejs/node/commit/08c8ae44a8)] - deps: upgrade openssl sources to 1.0.1t (Shigeki Ohtsu) https://github.com/nodejs/node/pull/6553
<add>* [[`f5a961ab13`](https://github.com/nodejs/node/commit/f5a961ab13)] - openssl: fix keypress requirement in apps on win32 (Shigeki Ohtsu) https://github.com/joyent/node/pull/25654
<add>* [[`810fb211a7`](https://github.com/nodejs/node/commit/810fb211a7)] - tools: remove obsolete npm test-legacy command (Kat Marchán) https://github.com/nodejs/node/pull/5988
<ide>
<ide> <a id="0.12.13"></a>
<ide> ## 2016-03-31, Version 0.12.13 (LTS), @rvagg
<ide> This is a security release. All Node.js users should consult the security releas
<ide>
<ide> ### Commits
<ide>
<del>* [[`4041ea6bc5`](https://github.com/nodejs/node/commit/4041ea6bc5) - deps: upgrade npm in LTS to 2.15.1 (Forrest L Norvell)
<del>* [[`a115779026`](https://github.com/nodejs/node/commit/a115779026) - deps: Disable EXPORT and LOW ciphers in openssl (Shigeki Ohtsu) https://github.com/nodejs/node/pull/5712
<del>* [[`ab907eb5a8`](https://github.com/nodejs/node/commit/ab907eb5a8) - test: skip cluster-disconnect-race on Windows (Gibson Fahnestock) https://github.com/nodejs/node/pull/5621
<del>* [[`9c06db7444`](https://github.com/nodejs/node/commit/9c06db7444) - test: change tls tests not to use LOW cipher (Shigeki Ohtsu) https://github.com/nodejs/node/pull/5712
<del>* [[`154098a3dc`](https://github.com/nodejs/node/commit/154098a3dc) - test: bp fix for test-http-get-pipeline-problem.js (Michael Dawson) https://github.com/nodejs/node/pull/3013
<del>* [[`ff2bed6e86`](https://github.com/nodejs/node/commit/ff2bed6e86) - win,build: support Visual C++ Build Tools 2015 (João Reis) https://github.com/nodejs/node/pull/5627
<add>* [[`4041ea6bc5`](https://github.com/nodejs/node/commit/4041ea6bc5)] - deps: upgrade npm in LTS to 2.15.1 (Forrest L Norvell)
<add>* [[`a115779026`](https://github.com/nodejs/node/commit/a115779026)] - deps: Disable EXPORT and LOW ciphers in openssl (Shigeki Ohtsu) https://github.com/nodejs/node/pull/5712
<add>* [[`ab907eb5a8`](https://github.com/nodejs/node/commit/ab907eb5a8)] - test: skip cluster-disconnect-race on Windows (Gibson Fahnestock) https://github.com/nodejs/node/pull/5621
<add>* [[`9c06db7444`](https://github.com/nodejs/node/commit/9c06db7444)] - test: change tls tests not to use LOW cipher (Shigeki Ohtsu) https://github.com/nodejs/node/pull/5712
<add>* [[`154098a3dc`](https://github.com/nodejs/node/commit/154098a3dc)] - test: bp fix for test-http-get-pipeline-problem.js (Michael Dawson) https://github.com/nodejs/node/pull/3013
<add>* [[`ff2bed6e86`](https://github.com/nodejs/node/commit/ff2bed6e86)] - win,build: support Visual C++ Build Tools 2015 (João Reis) https://github.com/nodejs/node/pull/5627
<ide>
<ide> <a id="0.12.12"></a>
<ide> ## 2016-03-08, Version 0.12.12 (LTS), @rvagg
<ide> Note that the upgrade to OpenSSL 1.0.1s in Node.js v0.12.11 removed internal SSL
<ide>
<ide> ### Commits:
<ide>
<del>* [[`dbfc9d9241`](https://github.com/nodejs/node/commit/dbfc9d9241) - crypto,tls: remove SSLv2 support (Ben Noordhuis) https://github.com/nodejs/node/pull/5536
<add>* [[`dbfc9d9241`](https://github.com/nodejs/node/commit/dbfc9d9241)] - crypto,tls: remove SSLv2 support (Ben Noordhuis) https://github.com/nodejs/node/pull/5536
<ide>
<ide> <a id="0.12.11"></a>
<ide> ## 2016-03-03, Version 0.12.11 (LTS), @rvagg
<ide> Note that the upgrade to OpenSSL 1.0.1s in Node.js v0.12.11 removed internal SSL
<ide>
<ide> ### Commits:
<ide>
<del>* [[`1ab6653db9`](https://github.com/nodejs/node/commit/1ab6653db9) - build: update Node.js logo on OSX installer (Rod Vagg) https://github.com/nodejs/node/pull/5401
<del>* [[`fcc64792ae`](https://github.com/nodejs/node/commit/fcc64792ae) - child_process: guard against race condition (Rich Trott) https://github.com/nodejs/node/pull/5153
<del>* [[`6c468df9af`](https://github.com/nodejs/node/commit/6c468df9af) - child_process: fix data loss with readable event (Brian White) https://github.com/nodejs/node/pull/5037
<del>* [[`61a22019c2`](https://github.com/nodejs/node/commit/61a22019c2) - deps: upgrade openssl to 1.0.1s (Ben Noordhuis) https://github.com/nodejs/node/pull/5509
<del>* [[`fa26b13df7`](https://github.com/nodejs/node/commit/fa26b13df7) - deps: update to http-parser 2.3.2 (James M Snell) https://github.com/nodejs/node/pull/5241
<del>* [[`46c8e2165f`](https://github.com/nodejs/node/commit/46c8e2165f) - deps: backport 1f8555 from v8's upstream (Trevor Norris) https://github.com/nodejs/node/pull/3945
<del>* [[`ce58c2c31a`](https://github.com/nodejs/node/commit/ce58c2c31a) - doc: remove SSLv2 descriptions (Shigeki Ohtsu) https://github.com/nodejs/node/pull/5541
<del>* [[`018e4e0b1a`](https://github.com/nodejs/node/commit/018e4e0b1a) - domains: fix handling of uncaught exceptions (Julien Gilli) https://github.com/nodejs/node/pull/3885
<del>* [[`d421e85dc9`](https://github.com/nodejs/node/commit/d421e85dc9) - lib: fix cluster handle leak (Rich Trott) https://github.com/nodejs/node/pull/5152
<del>* [[`3a48f0022f`](https://github.com/nodejs/node/commit/3a48f0022f) - node: fix leaking Context handle (Trevor Norris) https://github.com/nodejs/node/pull/3945
<del>* [[`28dddabf6a`](https://github.com/nodejs/node/commit/28dddabf6a) - src: fix build error without OpenSSL support (Jörg Krause) https://github.com/nodejs/node/pull/4201
<del>* [[`a79baf03cd`](https://github.com/nodejs/node/commit/a79baf03cd) - src: use global SealHandleScope (Trevor Norris) https://github.com/nodejs/node/pull/3945
<del>* [[`be39f30447`](https://github.com/nodejs/node/commit/be39f30447) - test: add test-domain-exit-dispose-again back (Julien Gilli) https://github.com/nodejs/node/pull/4278
<del>* [[`da66166b9a`](https://github.com/nodejs/node/commit/da66166b9a) - test: fix test-domain-exit-dispose-again (Julien Gilli) https://github.com/nodejs/node/pull/3991
<add>* [[`1ab6653db9`](https://github.com/nodejs/node/commit/1ab6653db9)] - build: update Node.js logo on OSX installer (Rod Vagg) https://github.com/nodejs/node/pull/5401
<add>* [[`fcc64792ae`](https://github.com/nodejs/node/commit/fcc64792ae)] - child_process: guard against race condition (Rich Trott) https://github.com/nodejs/node/pull/5153
<add>* [[`6c468df9af`](https://github.com/nodejs/node/commit/6c468df9af)] - child_process: fix data loss with readable event (Brian White) https://github.com/nodejs/node/pull/5037
<add>* [[`61a22019c2`](https://github.com/nodejs/node/commit/61a22019c2)] - deps: upgrade openssl to 1.0.1s (Ben Noordhuis) https://github.com/nodejs/node/pull/5509
<add>* [[`fa26b13df7`](https://github.com/nodejs/node/commit/fa26b13df7)] - deps: update to http-parser 2.3.2 (James M Snell) https://github.com/nodejs/node/pull/5241
<add>* [[`46c8e2165f`](https://github.com/nodejs/node/commit/46c8e2165f)] - deps: backport 1f8555 from v8's upstream (Trevor Norris) https://github.com/nodejs/node/pull/3945
<add>* [[`ce58c2c31a`](https://github.com/nodejs/node/commit/ce58c2c31a)] - doc: remove SSLv2 descriptions (Shigeki Ohtsu) https://github.com/nodejs/node/pull/5541
<add>* [[`018e4e0b1a`](https://github.com/nodejs/node/commit/018e4e0b1a)] - domains: fix handling of uncaught exceptions (Julien Gilli) https://github.com/nodejs/node/pull/3885
<add>* [[`d421e85dc9`](https://github.com/nodejs/node/commit/d421e85dc9)] - lib: fix cluster handle leak (Rich Trott) https://github.com/nodejs/node/pull/5152
<add>* [[`3a48f0022f`](https://github.com/nodejs/node/commit/3a48f0022f)] - node: fix leaking Context handle (Trevor Norris) https://github.com/nodejs/node/pull/3945
<add>* [[`28dddabf6a`](https://github.com/nodejs/node/commit/28dddabf6a)] - src: fix build error without OpenSSL support (Jörg Krause) https://github.com/nodejs/node/pull/4201
<add>* [[`a79baf03cd`](https://github.com/nodejs/node/commit/a79baf03cd)] - src: use global SealHandleScope (Trevor Norris) https://github.com/nodejs/node/pull/3945
<add>* [[`be39f30447`](https://github.com/nodejs/node/commit/be39f30447)] - test: add test-domain-exit-dispose-again back (Julien Gilli) https://github.com/nodejs/node/pull/4278
<add>* [[`da66166b9a`](https://github.com/nodejs/node/commit/da66166b9a)] - test: fix test-domain-exit-dispose-again (Julien Gilli) https://github.com/nodejs/node/pull/3991
<ide>
<ide> <a id="0.12.10"></a>
<ide> ## 2016-02-09, Version 0.12.10 (LTS), @jasnell
<ide> This is an important security release. All Node.js users should consult the secu
<ide>
<ide> ### Commits
<ide>
<del>* [[`4312848bff`](https://github.com/nodejs/node/commit/4312848bff) - build: enable xz compressed tarballs where possible (Rod Vagg) https://github.com/nodejs/node/pull/4894
<del>* [[`247626245c`](https://github.com/nodejs/node/commit/247626245c) - deps: upgrade openssl sources to 1.0.1r (Shigeki Ohtsu) https://github.com/joyent/node/pull/25368
<del>* [[`744c9749fc`](https://github.com/nodejs/node/commit/744c9749fc) - deps: update http-parser to version 2.3.1 (James M Snell)
<del>* [[`d1c56ec7d1`](https://github.com/nodejs/node/commit/d1c56ec7d1) - doc: clarify v0.12.9 notable items (Rod Vagg) https://github.com/nodejs/node/pull/4154
<del>* [[`e128d9a5b4`](https://github.com/nodejs/node/commit/e128d9a5b4) - http: strictly forbid invalid characters from headers (James M Snell)
<del>* [[`bdb9f2cf89`](https://github.com/nodejs/node/commit/bdb9f2cf89) - src: avoiding compiler warnings in node_revert.cc (James M Snell)
<del>* [[`23bced1fb3`](https://github.com/nodejs/node/commit/23bced1fb3) - src: add --security-revert command line flag (James M Snell)
<del>* [[`f41a3c73e7`](https://github.com/nodejs/node/commit/f41a3c73e7) - tools: backport tools/install.py for headers (Richard Lau) https://github.com/nodejs/node/pull/4149
<add>* [[`4312848bff`](https://github.com/nodejs/node/commit/4312848bff)] - build: enable xz compressed tarballs where possible (Rod Vagg) https://github.com/nodejs/node/pull/4894
<add>* [[`247626245c`](https://github.com/nodejs/node/commit/247626245c)] - deps: upgrade openssl sources to 1.0.1r (Shigeki Ohtsu) https://github.com/joyent/node/pull/25368
<add>* [[`744c9749fc`](https://github.com/nodejs/node/commit/744c9749fc)] - deps: update http-parser to version 2.3.1 (James M Snell)
<add>* [[`d1c56ec7d1`](https://github.com/nodejs/node/commit/d1c56ec7d1)] - doc: clarify v0.12.9 notable items (Rod Vagg) https://github.com/nodejs/node/pull/4154
<add>* [[`e128d9a5b4`](https://github.com/nodejs/node/commit/e128d9a5b4)] - http: strictly forbid invalid characters from headers (James M Snell)
<add>* [[`bdb9f2cf89`](https://github.com/nodejs/node/commit/bdb9f2cf89)] - src: avoiding compiler warnings in node_revert.cc (James M Snell)
<add>* [[`23bced1fb3`](https://github.com/nodejs/node/commit/23bced1fb3)] - src: add --security-revert command line flag (James M Snell)
<add>* [[`f41a3c73e7`](https://github.com/nodejs/node/commit/f41a3c73e7)] - tools: backport tools/install.py for headers (Richard Lau) https://github.com/nodejs/node/pull/4149
<ide>
<ide> <a id="0.12.9"></a>
<ide> ## 2015-12-04, Version 0.12.9 (LTS), @rvagg
<ide> Security Update
<ide>
<ide> ### Commits
<ide>
<del>* [[`8d24a14f2c`](https://github.com/nodejs/node/commit/8d24a14f2c) - deps: upgrade to openssl 1.0.1q (Ben Noordhuis) https://github.com/nodejs/node/pull/4133
<del>* [[`dfc6f4a9af`](https://github.com/nodejs/node/commit/dfc6f4a9af) - http: fix pipeline regression (Fedor Indutny)
<add>* [[`8d24a14f2c`](https://github.com/nodejs/node/commit/8d24a14f2c)] - deps: upgrade to openssl 1.0.1q (Ben Noordhuis) https://github.com/nodejs/node/pull/4133
<add>* [[`dfc6f4a9af`](https://github.com/nodejs/node/commit/dfc6f4a9af)] - http: fix pipeline regression (Fedor Indutny)
<ide>
<ide> <a id="0.12.8"></a>
<ide> ## 2015.11.25, Version 0.12.8 (LTS), @rvagg
<ide>
<del>* [[`d9399569bd`](https://github.com/nodejs/node/commit/d9399569bd) - build: backport tools/release.sh (Rod Vagg) https://github.com/nodejs/node/pull/3642
<del>* [[`78c5b4c8bd`](https://github.com/nodejs/node/commit/78c5b4c8bd) - build: backport config for new CI infrastructure (Rod Vagg) https://github.com/nodejs/node/pull/3642
<del>* [[`83441616a5`](https://github.com/nodejs/node/commit/83441616a5) - build: fix --without-ssl compile time error (Ben Noordhuis) https://github.com/nodejs/node/pull/3825
<del>* [[`8887666b0b`](https://github.com/nodejs/node/commit/8887666b0b) - build: update manifest to include Windows 10 (Lucien Greathouse) https://github.com/nodejs/node/pull/2843
<del>* [[`08afe4ec8e`](https://github.com/nodejs/node/commit/08afe4ec8e) - build: add MSVS 2015 support (Rod Vagg) https://github.com/nodejs/node/pull/2843
<del>* [[`4f2456369c`](https://github.com/nodejs/node/commit/4f2456369c) - build: work around VS2015 issue in ICU <56 (Steven R. Loomis) https://github.com/nodejs/node-v0.x-archive/pull/25804
<del>* [[`15030f26fd`](https://github.com/nodejs/node/commit/15030f26fd) - build: Intl: bump ICU4C from 54 to 55 (backport) (Steven R. Loomis) https://github.com/nodejs/node-v0.x-archive/pull/25856
<del>* [[`1083fa70f0`](https://github.com/nodejs/node/commit/1083fa70f0) - build: run-ci makefile rule (Alexis Campailla) https://github.com/nodejs/node-v0.x-archive/pull/25653
<del>* [[`2d2494cf14`](https://github.com/nodejs/node/commit/2d2494cf14) - build: support flaky tests in test-ci (Alexis Campailla) https://github.com/nodejs/node-v0.x-archive/pull/25653
<del>* [[`b25d26f2ef`](https://github.com/nodejs/node/commit/b25d26f2ef) - build: support Jenkins via test-ci (Alexis Campailla) https://github.com/nodejs/node-v0.x-archive/pull/25653
<del>* [[`7e4b47f38a`](https://github.com/nodejs/node/commit/7e4b47f38a) - build,win: fix node.exe resource version (João Reis) https://github.com/nodejs/node/pull/3053
<del>* [[`e07c86e240`](https://github.com/nodejs/node/commit/e07c86e240) - build,win: try next MSVS version on failure (João Reis) https://github.com/nodejs/node/pull/2843
<del>* [[`b5a0abcfdf`](https://github.com/nodejs/node/commit/b5a0abcfdf) - child_process: clone spawn options argument (cjihrig) https://github.com/nodejs/node-v0.x-archive/pull/9159
<del>* [[`8b81f98c41`](https://github.com/nodejs/node/commit/8b81f98c41) - configure: add --without-mdb flag (cgalibern) https://github.com/nodejs/node-v0.x-archive/pull/25707
<del>* [[`071c860c2b`](https://github.com/nodejs/node/commit/071c860c2b) - crypto: replace rwlocks with simple mutexes (Ben Noordhuis) https://github.com/nodejs/node/pull/2723
<del>* [[`ca97fb6be3`](https://github.com/nodejs/node/commit/ca97fb6be3) - deps: upgrade npm to 2.14.9 (Forrest L Norvell) https://github.com/nodejs/node/pull/3684
<del>* [[`583734342e`](https://github.com/nodejs/node/commit/583734342e) - deps: fix openssl for MSVS 2015 (Andy Polyakov) https://github.com/nodejs/node/pull/2843
<del>* [[`02c262a4c6`](https://github.com/nodejs/node/commit/02c262a4c6) - deps: fix gyp to work on MacOSX without XCode (Shigeki Ohtsu) https://github.com/nodejs/node/pull/2843
<del>* [[`f0fba0bce8`](https://github.com/nodejs/node/commit/f0fba0bce8) - deps: update gyp to 25ed9ac (João Reis) https://github.com/nodejs/node/pull/2843
<del>* [[`f693565813`](https://github.com/nodejs/node/commit/f693565813) - deps: upgrade to npm 2.13.4 (Kat Marchán) https://github.com/nodejs/node-v0.x-archive/pull/25825
<del>* [[`618b142679`](https://github.com/nodejs/node/commit/618b142679) - deps,v8: fix compilation in VS2015 (João Reis) https://github.com/nodejs/node/pull/2843
<del>* [[`49b4f0d54e`](https://github.com/nodejs/node/commit/49b4f0d54e) - doc: backport README.md (Rod Vagg) https://github.com/nodejs/node/pull/3642
<del>* [[`2860c53562`](https://github.com/nodejs/node/commit/2860c53562) - doc: fixed child_process.exec doc (Tyler Anton) https://github.com/nodejs/node-v0.x-archive/pull/14088
<del>* [[`4a91fa11a3`](https://github.com/nodejs/node/commit/4a91fa11a3) - doc: Update docs for os.platform() (George Kotchlamazashvili) https://github.com/nodejs/node-v0.x-archive/pull/25777
<del>* [[`b03ab02fe8`](https://github.com/nodejs/node/commit/b03ab02fe8) - doc: Change the link for v8 docs to v8dox.com (Chad Walker) https://github.com/nodejs/node-v0.x-archive/pull/25811
<del>* [[`1fd8f37efd`](https://github.com/nodejs/node/commit/1fd8f37efd) - doc: buffer, adding missing backtick (Dyana Rose) https://github.com/nodejs/node-v0.x-archive/pull/25811
<del>* [[`162d0db3bb`](https://github.com/nodejs/node/commit/162d0db3bb) - doc: tls.markdown, adjust version from v0.10.39 to v0.10.x (James M Snell) https://github.com/nodejs/node-v0.x-archive/pull/25591
<del>* [[`eda2560cdc`](https://github.com/nodejs/node/commit/eda2560cdc) - doc: additional refinement to readable event (James M Snell) https://github.com/nodejs/node-v0.x-archive/pull/25591
<del>* [[`881d9bea01`](https://github.com/nodejs/node/commit/881d9bea01) - doc: readable event clarification (James M Snell) https://github.com/nodejs/node-v0.x-archive/pull/25591
<del>* [[`b6378f0c75`](https://github.com/nodejs/node/commit/b6378f0c75) - doc: stream.unshift does not reset reading state (James M Snell) https://github.com/nodejs/node-v0.x-archive/pull/25591
<del>* [[`4952e2b4d2`](https://github.com/nodejs/node/commit/4952e2b4d2) - doc: clarify Readable._read and Readable.push (fresheneesz) https://github.com/nodejs/node-v0.x-archive/pull/25591
<del>* [[`14000b97d4`](https://github.com/nodejs/node/commit/14000b97d4) - doc: two minor stream doc improvements (James M Snell) https://github.com/nodejs/node-v0.x-archive/pull/25591
<del>* [[`6b6bd21497`](https://github.com/nodejs/node/commit/6b6bd21497) - doc: Clarified read method with specified size argument. (Philippe Laferriere) https://github.com/nodejs/node-v0.x-archive/pull/25591
<del>* [[`16f547600a`](https://github.com/nodejs/node/commit/16f547600a) - doc: Document http.request protocol option (Ville Skyttä) https://github.com/nodejs/node-v0.x-archive/pull/25591
<del>* [[`618e4ecda9`](https://github.com/nodejs/node/commit/618e4ecda9) - doc: add a note about readable in flowing mode (James M Snell) https://github.com/nodejs/node-v0.x-archive/pull/25591
<del>* [[`0b165be37b`](https://github.com/nodejs/node/commit/0b165be37b) - doc: fix line wrapping in buffer.markdown (James M Snell) https://github.com/nodejs/node-v0.x-archive/pull/25591
<del>* [[`70dd13f88d`](https://github.com/nodejs/node/commit/70dd13f88d) - doc: add CleartextStream deprecation notice (James M Snell) https://github.com/nodejs/node-v0.x-archive/pull/25591
<del>* [[`418cde0765`](https://github.com/nodejs/node/commit/418cde0765) - doc: mention that mode is ignored if file exists (James M Snell) https://github.com/nodejs/node-v0.x-archive/pull/25591
<del>* [[`85bcb281e4`](https://github.com/nodejs/node/commit/85bcb281e4) - doc: improve http.abort description (James M Snell) https://github.com/nodejs/node-v0.x-archive/pull/25591
<del>* [[`5ccb429ee8`](https://github.com/nodejs/node/commit/5ccb429ee8) - doc, comments: Grammar and spelling fixes (Ville Skyttä) https://github.com/nodejs/node-v0.x-archive/pull/25591
<del>* [[`a24db43101`](https://github.com/nodejs/node/commit/a24db43101) - docs: event emitter behavior notice (Samuel Mills (Henchman)) https://github.com/nodejs/node-v0.x-archive/pull/25467
<del>* [[`8cbf7cb021`](https://github.com/nodejs/node/commit/8cbf7cb021) - docs: events clarify emitter.listener() behavior (Benjamin Steephenson) https://github.com/nodejs/node-v0.x-archive/pull/25591
<del>* [[`b7229debbe`](https://github.com/nodejs/node/commit/b7229debbe) - docs: Fix default options for fs.createWriteStream() (Chris Neave) https://github.com/nodejs/node-v0.x-archive/pull/25591
<del>* [[`f0453caea2`](https://github.com/nodejs/node/commit/f0453caea2) - domains: port caeb677 from v0.10 to v0.12 (Jeremy Whitlock) https://github.com/nodejs/node-v0.x-archive/pull/25835
<del>* [[`261fa3620f`](https://github.com/nodejs/node/commit/261fa3620f) - src: fix intermittent SIGSEGV in resolveTxt (Evan Lucas) https://github.com/nodejs/node-v0.x-archive/pull/9300
<del>* [[`1f7257b02d`](https://github.com/nodejs/node/commit/1f7257b02d) - test: mark test-https-aws-ssl flaky on linux (João Reis) https://github.com/nodejs/node-v0.x-archive/pull/25893
<del>* [[`cf435d55db`](https://github.com/nodejs/node/commit/cf435d55db) - test: mark test-signal-unregister as flaky (Alexis Campailla) https://github.com/nodejs/node-v0.x-archive/pull/25750
<del>* [[`ceb6a8c131`](https://github.com/nodejs/node/commit/ceb6a8c131) - test: fix test-debug-port-from-cmdline (João Reis) https://github.com/nodejs/node-v0.x-archive/pull/25748
<del>* [[`22997731e6`](https://github.com/nodejs/node/commit/22997731e6) - test: add regression test for #25735 (Fedor Indutny) https://github.com/nodejs/node-v0.x-archive/pull/25739
<del>* [[`39e05639f4`](https://github.com/nodejs/node/commit/39e05639f4) - test: mark http-pipeline-flood flaky on win32 (Julien Gilli) https://github.com/nodejs/node-v0.x-archive/pull/25707
<del>* [[`78d256e7f5`](https://github.com/nodejs/node/commit/78d256e7f5) - test: unmark tests that are no longer flaky (João Reis) https://github.com/nodejs/node-v0.x-archive/pull/25676
<del>* [[`a9b642cf5b`](https://github.com/nodejs/node/commit/a9b642cf5b) - test: runner should return 0 on flaky tests (Alexis Campailla) https://github.com/nodejs/node-v0.x-archive/pull/25653
<del>* [[`b48639befd`](https://github.com/nodejs/node/commit/b48639befd) - test: support writing test output to file (Alexis Campailla) https://github.com/nodejs/node-v0.x-archive/pull/25653
<del>* [[`caa16b41d6`](https://github.com/nodejs/node/commit/caa16b41d6) - (SEMVER-MINOR) tls: prevent server from using dhe keys < 768 (Michael Dawson) https://github.com/nodejs/node/pull/3890
<del>* [[`0363cf4a80`](https://github.com/nodejs/node/commit/0363cf4a80) - tls: Closing parent socket also closes the tls sock (Devin Nakamura) https://github.com/nodejs/node-v0.x-archive/pull/25642
<del>* [[`75697112e8`](https://github.com/nodejs/node/commit/75697112e8) - tls: do not hang without `newSession` handler (Fedor Indutny) https://github.com/nodejs/node-v0.x-archive/pull/25739
<del>* [[`d998a65058`](https://github.com/nodejs/node/commit/d998a65058) - tools: pass constant to logger instead of string (Johan Bergström) https://github.com/nodejs/node-v0.x-archive/pull/25653
<del>* [[`1982ed6e63`](https://github.com/nodejs/node/commit/1982ed6e63) - v8: port fbff705 from v0.10 to v0.12 (Jeremy Whitlock) https://github.com/nodejs/node-v0.x-archive/pull/25835
<del>* [[`44d7054252`](https://github.com/nodejs/node/commit/44d7054252) - win: fix custom actions for WiX older than 3.9 (João Reis) https://github.com/nodejs/node/pull/2843
<del>* [[`586c4d8b8e`](https://github.com/nodejs/node/commit/586c4d8b8e) - win: fix custom actions on Visual Studio != 2013 (Julien Gilli) https://github.com/nodejs/node/pull/2843
<del>* [[`14db629497`](https://github.com/nodejs/node/commit/14db629497) - win,msi: correct installation path registry keys (João Reis) https://github.com/nodejs/node-v0.x-archive/pull/25640
<del>* [[`8e80528453`](https://github.com/nodejs/node/commit/8e80528453) - win,msi: change InstallScope to perMachine (João Reis) https://github.com/nodejs/node-v0.x-archive/pull/25640
<del>* [[`35bbe98401`](https://github.com/nodejs/node/commit/35bbe98401) - Update addons.markdown (Max Deepfield) https://github.com/nodejs/node-v0.x-archive/pull/25885
<del>* [[`9a6f1ce416`](https://github.com/nodejs/node/commit/9a6f1ce416) - comma (Julien Valéry) https://github.com/nodejs/node-v0.x-archive/pull/25811
<del>* [[`d384bf8f84`](https://github.com/nodejs/node/commit/d384bf8f84) - Update assert.markdown (daveboivin) https://github.com/nodejs/node-v0.x-archive/pull/25811
<del>* [[`89b22ccbe1`](https://github.com/nodejs/node/commit/89b22ccbe1) - Fixed typo (Andrew Murray) https://github.com/nodejs/node-v0.x-archive/pull/25811
<del>* [[`5ad05af380`](https://github.com/nodejs/node/commit/5ad05af380) - Update util.markdown (Daniel Rentz) https://github.com/nodejs/node-v0.x-archive/pull/25591
<del>* [[`cb660ab3d3`](https://github.com/nodejs/node/commit/cb660ab3d3) - Update child_process.markdown, spelling (Jared Fox) https://github.com/nodejs/node-v0.x-archive/pull/25591
<del>* [[`59c67fe3cd`](https://github.com/nodejs/node/commit/59c67fe3cd) - updated documentation for fs.createReadStream (Michele Caini) https://github.com/nodejs/node-v0.x-archive/pull/25591
<del>* [[`53b6a615a5`](https://github.com/nodejs/node/commit/53b6a615a5) - Documentation update about Buffer initialization (Sarath) https://github.com/nodejs/node-v0.x-archive/pull/25591
<del>* [[`b8d47a7b6f`](https://github.com/nodejs/node/commit/b8d47a7b6f) - fix (Fedor Indutny) https://github.com/nodejs/node-v0.x-archive/pull/25739
<del>
<del><a id="0.12.7"></a>
<del>## 2015-07-09, Version 0.12.7 (Stable)
<add>* [[`d9399569bd`](https://github.com/nodejs/node/commit/d9399569bd)] - build: backport tools/release.sh (Rod Vagg) https://github.com/nodejs/node/pull/3642
<add>* [[`78c5b4c8bd`](https://github.com/nodejs/node/commit/78c5b4c8bd)] - build: backport config for new CI infrastructure (Rod Vagg) https://github.com/nodejs/node/pull/3642
<add>* [[`83441616a5`](https://github.com/nodejs/node/commit/83441616a5)] - build: fix --without-ssl compile time error (Ben Noordhuis) https://github.com/nodejs/node/pull/3825
<add>* [[`8887666b0b`](https://github.com/nodejs/node/commit/8887666b0b)] - build: update manifest to include Windows 10 (Lucien Greathouse) https://github.com/nodejs/node/pull/2843
<add>* [[`08afe4ec8e`](https://github.com/nodejs/node/commit/08afe4ec8e)] - build: add MSVS 2015 support (Rod Vagg) https://github.com/nodejs/node/pull/2843
<add>* [[`4f2456369c`](https://github.com/nodejs/node/commit/4f2456369c)] - build: work around VS2015 issue in ICU <56 (Steven R. Loomis) https://github.com/nodejs/node-v0.x-archive/pull/25804
<add>* [[`15030f26fd`](https://github.com/nodejs/node/commit/15030f26fd)] - build: Intl: bump ICU4C from 54 to 55 (backport) (Steven R. Loomis) https://github.com/nodejs/node-v0.x-archive/pull/25856
<add>* [[`1083fa70f0`](https://github.com/nodejs/node/commit/1083fa70f0)] - build: run-ci makefile rule (Alexis Campailla) https://github.com/nodejs/node-v0.x-archive/pull/25653
<add>* [[`2d2494cf14`](https://github.com/nodejs/node/commit/2d2494cf14)] - build: support flaky tests in test-ci (Alexis Campailla) https://github.com/nodejs/node-v0.x-archive/pull/25653
<add>* [[`b25d26f2ef`](https://github.com/nodejs/node/commit/b25d26f2ef)] - build: support Jenkins via test-ci (Alexis Campailla) https://github.com/nodejs/node-v0.x-archive/pull/25653
<add>* [[`7e4b47f38a`](https://github.com/nodejs/node/commit/7e4b47f38a)] - build,win: fix node.exe resource version (João Reis) https://github.com/nodejs/node/pull/3053
<add>* [[`e07c86e240`](https://github.com/nodejs/node/commit/e07c86e240)] - build,win: try next MSVS version on failure (João Reis) https://github.com/nodejs/node/pull/2843
<add>* [[`b5a0abcfdf`](https://github.com/nodejs/node/commit/b5a0abcfdf)] - child_process: clone spawn options argument (cjihrig) https://github.com/nodejs/node-v0.x-archive/pull/9159
<add>* [[`8b81f98c41`](https://github.com/nodejs/node/commit/8b81f98c41)] - configure: add --without-mdb flag (cgalibern) https://github.com/nodejs/node-v0.x-archive/pull/25707
<add>* [[`071c860c2b`](https://github.com/nodejs/node/commit/071c860c2b)] - crypto: replace rwlocks with simple mutexes (Ben Noordhuis) https://github.com/nodejs/node/pull/2723
<add>* [[`ca97fb6be3`](https://github.com/nodejs/node/commit/ca97fb6be3)] - deps: upgrade npm to 2.14.9 (Forrest L Norvell) https://github.com/nodejs/node/pull/3684
<add>* [[`583734342e`](https://github.com/nodejs/node/commit/583734342e)] - deps: fix openssl for MSVS 2015 (Andy Polyakov) https://github.com/nodejs/node/pull/2843
<add>* [[`02c262a4c6`](https://github.com/nodejs/node/commit/02c262a4c6)] - deps: fix gyp to work on MacOSX without XCode (Shigeki Ohtsu) https://github.com/nodejs/node/pull/2843
<add>* [[`f0fba0bce8`](https://github.com/nodejs/node/commit/f0fba0bce8)] - deps: update gyp to 25ed9ac (João Reis) https://github.com/nodejs/node/pull/2843
<add>* [[`f693565813`](https://github.com/nodejs/node/commit/f693565813)] - deps: upgrade to npm 2.13.4 (Kat Marchán) https://github.com/nodejs/node-v0.x-archive/pull/25825
<add>* [[`618b142679`](https://github.com/nodejs/node/commit/618b142679)] - deps,v8: fix compilation in VS2015 (João Reis) https://github.com/nodejs/node/pull/2843
<add>* [[`49b4f0d54e`](https://github.com/nodejs/node/commit/49b4f0d54e)] - doc: backport README.md (Rod Vagg) https://github.com/nodejs/node/pull/3642
<add>* [[`2860c53562`](https://github.com/nodejs/node/commit/2860c53562)] - doc: fixed child_process.exec doc (Tyler Anton) https://github.com/nodejs/node-v0.x-archive/pull/14088
<add>* [[`4a91fa11a3`](https://github.com/nodejs/node/commit/4a91fa11a3)] - doc: Update docs for os.platform() (George Kotchlamazashvili) https://github.com/nodejs/node-v0.x-archive/pull/25777
<add>* [[`b03ab02fe8`](https://github.com/nodejs/node/commit/b03ab02fe8)] - doc: Change the link for v8 docs to v8dox.com (Chad Walker) https://github.com/nodejs/node-v0.x-archive/pull/25811
<add>* [[`1fd8f37efd`](https://github.com/nodejs/node/commit/1fd8f37efd)] - doc: buffer, adding missing backtick (Dyana Rose) https://github.com/nodejs/node-v0.x-archive/pull/25811
<add>* [[`162d0db3bb`](https://github.com/nodejs/node/commit/162d0db3bb)] - doc: tls.markdown, adjust version from v0.10.39 to v0.10.x (James M Snell) https://github.com/nodejs/node-v0.x-archive/pull/25591
<add>* [[`eda2560cdc`](https://github.com/nodejs/node/commit/eda2560cdc)] - doc: additional refinement to readable event (James M Snell) https://github.com/nodejs/node-v0.x-archive/pull/25591
<add>* [[`881d9bea01`](https://github.com/nodejs/node/commit/881d9bea01)] - doc: readable event clarification (James M Snell) https://github.com/nodejs/node-v0.x-archive/pull/25591
<add>* [[`b6378f0c75`](https://github.com/nodejs/node/commit/b6378f0c75)] - doc: stream.unshift does not reset reading state (James M Snell) https://github.com/nodejs/node-v0.x-archive/pull/25591
<ide>
<ide> ### Commits
<ide> | 1 |
PHP | PHP | fix remaining cs errors | aaf2d2ef71886a95cc5d31f74e09ca0f767b9857 | <ide><path>app/Config/Schema/i18n.php
<ide> * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
<ide> */
<ide>
<add>// @codingStandardsIgnoreStart
<add>
<ide> /*
<ide> *
<ide> * Using the Schema command line utility
<ide> * cake schema run create i18n
<del> *
<ide> */
<ide> class i18nSchema extends CakeSchema {
<ide>
<add>// @codingStandardsIgnoreEnd
<add>
<ide> public $name = 'i18n';
<ide>
<ide> public function before($event = array()) {
<ide><path>lib/Cake/Console/Templates/skel/Config/Schema/i18n.php
<ide> * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
<ide> */
<ide>
<add>// @codingStandardsIgnoreStart
<add>
<ide> /*
<ide> *
<ide> * Using the Schema command line utility
<ide> * cake schema run create i18n
<del> *
<ide> */
<ide> class i18nSchema extends CakeSchema {
<ide>
<add>// @codingStandardsIgnoreEnd
<add>
<ide> public $name = 'i18n';
<ide>
<ide> public function before($event = array()) {
<ide><path>lib/Cake/I18n/Multibyte.php
<ide> public static function mimeEncode($string, $charset = null, $newline = "\r\n") {
<ide> if ($charset == 'UTF-8') {
<ide> $parts = array();
<ide> $maxchars = floor(($length * 3) / 4);
<del> while (strlen($string) > $maxchars) {
<add> $stringLength = strlen($string);
<add> while ($stringLength > $maxchars) {
<ide> $i = (int)$maxchars;
<ide> $test = ord($string[$i]);
<ide> while ($test >= 128 && $test <= 191) {
<ide> public static function mimeEncode($string, $charset = null, $newline = "\r\n") {
<ide> }
<ide> $parts[] = base64_encode(substr($string, 0, $i));
<ide> $string = substr($string, $i);
<add> $stringLength = strlen($string);
<ide> }
<ide> $parts[] = base64_encode($string);
<ide> $string = implode($spacer, $parts);
<ide><path>lib/Cake/Model/Model.php
<ide> class Model extends Object implements CakeEventListener {
<ide> */
<ide> protected $_associations = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany');
<ide>
<add>// @codingStandardsIgnoreStart
<add>
<ide> /**
<ide> * Holds model associations temporarily to allow for dynamic (un)binding.
<ide> *
<ide> class Model extends Object implements CakeEventListener {
<ide> */
<ide> public $__backContainableAssociation = array();
<ide>
<add>// @codingStandardsIgnoreEnd
<add>
<ide> /**
<ide> * The ID of the model record that was last inserted.
<ide> *
<ide><path>lib/Cake/Test/Case/Controller/Component/Acl/DbAclTest.php
<ide> public function testRevoke() {
<ide> /**
<ide> * debug function - to help editing/creating test cases for the ACL component
<ide> *
<del> * To check the overall ACL status at any time call $this->__debug();
<add> * To check the overall ACL status at any time call $this->_debug();
<ide> * Generates a list of the current aro and aco structures and a grid dump of the permissions that are defined
<ide> * Only designed to work with the db based ACL
<ide> *
<ide> * @param bool $treesToo
<ide> * @return void
<ide> */
<del> protected function __debug($printTreesToo = false) {
<add> protected function _debug($printTreesToo = false) {
<ide> $this->Acl->Aro->displayField = 'alias';
<ide> $this->Acl->Aco->displayField = 'alias';
<ide> $aros = $this->Acl->Aro->find('list', array('order' => 'lft'));
<ide> protected function __debug($printTreesToo = false) {
<ide> }
<ide> foreach ($permissions as $key => $values) {
<ide> array_unshift($values, $key);
<del> $values = array_map(array(&$this, '__pad'), $values);
<add> $values = array_map(array(&$this, '_pad'), $values);
<ide> $permissions[$key] = implode (' ', $values);
<ide> }
<del> $permisssions = array_map(array(&$this, '__pad'), $permissions);
<add> $permisssions = array_map(array(&$this, '_pad'), $permissions);
<ide> array_unshift($permissions, 'Current Permissions :');
<ide> if ($printTreesToo) {
<ide> debug(array('aros' => $this->Acl->Aro->generateTreeList(), 'acos' => $this->Acl->Aco->generateTreeList()));
<ide> protected function __debug($printTreesToo = false) {
<ide> * @param integer $len
<ide> * @return void
<ide> */
<del> protected function __pad($string = '', $len = 14) {
<add> protected function _pad($string = '', $len = 14) {
<ide> return str_pad($string, $len);
<ide> }
<ide> }
<ide><path>lib/Cake/Test/Case/Controller/Component/CookieComponentTest.php
<ide> public function testReadingCookieDataOnStartup() {
<ide> $this->assertNull($data);
<ide>
<ide> $_COOKIE['CakeTestCookie'] = array(
<del> 'Encrytped_array' => $this->__encrypt(array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!')),
<add> 'Encrytped_array' => $this->_encrypt(array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!')),
<ide> 'Encrytped_multi_cookies' => array(
<del> 'name' => $this->__encrypt('CakePHP'),
<del> 'version' => $this->__encrypt('1.2.0.x'),
<del> 'tag' => $this->__encrypt('CakePHP Rocks!')),
<add> 'name' => $this->_encrypt('CakePHP'),
<add> 'version' => $this->_encrypt('1.2.0.x'),
<add> 'tag' => $this->_encrypt('CakePHP Rocks!')),
<ide> 'Plain_array' => '{"name":"CakePHP","version":"1.2.0.x","tag":"CakePHP Rocks!"}',
<ide> 'Plain_multi_cookies' => array(
<ide> 'name' => 'CakePHP',
<ide> public function testReadingCookieDataWithoutStartup() {
<ide> $this->assertEquals($expected, $data);
<ide>
<ide> $_COOKIE['CakeTestCookie'] = array(
<del> 'Encrytped_array' => $this->__encrypt(array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!')),
<add> 'Encrytped_array' => $this->_encrypt(array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!')),
<ide> 'Encrytped_multi_cookies' => array(
<del> 'name' => $this->__encrypt('CakePHP'),
<del> 'version' => $this->__encrypt('1.2.0.x'),
<del> 'tag' => $this->__encrypt('CakePHP Rocks!')),
<add> 'name' => $this->_encrypt('CakePHP'),
<add> 'version' => $this->_encrypt('1.2.0.x'),
<add> 'tag' => $this->_encrypt('CakePHP Rocks!')),
<ide> 'Plain_array' => '{"name":"CakePHP","version":"1.2.0.x","tag":"CakePHP Rocks!"}',
<ide> 'Plain_multi_cookies' => array(
<ide> 'name' => 'CakePHP',
<ide> protected function _implode(array $array) {
<ide> * @param array|string $value
<ide> * @return string
<ide> */
<del> protected function __encrypt($value) {
<add> protected function _encrypt($value) {
<ide> if (is_array($value)) {
<ide> $value = $this->_implode($value);
<ide> }
<ide><path>lib/Cake/Test/Case/Network/CakeRequestTest.php
<ide> public static function environmentGenerator() {
<ide> */
<ide> public function testEnvironmentDetection($name, $env, $expected) {
<ide> $_GET = array();
<del> $this->__loadEnvironment($env);
<add> $this->_loadEnvironment($env);
<ide>
<ide> $request = new CakeRequest();
<ide> $this->assertEquals($expected['url'], $request->url, "url error");
<ide> public function testIsRequested() {
<ide> * @param array $env
<ide> * @return void
<ide> */
<del> protected function __loadEnvironment($env) {
<add> protected function _loadEnvironment($env) {
<ide> if (isset($env['App'])) {
<ide> Configure::write('App', $env['App']);
<ide> }
<ide><path>lib/Cake/Test/Case/Routing/DispatcherTest.php
<ide> public function testFullPageCachingDispatch($url) {
<ide>
<ide> $this->assertTextEquals($out, $cached);
<ide>
<del> $filename = $this->__cachePath($request->here());
<add> $filename = $this->_cachePath($request->here());
<ide> unlink($filename);
<ide> }
<ide>
<ide> public function testHttpMethodOverrides() {
<ide> unset($_POST['_method']);
<ide> }
<ide>
<del>/**
<del> * backupEnvironment method
<del> *
<del> * @return void
<del> */
<del> protected function __backupEnvironment() {
<del> return array(
<del> 'App' => Configure::read('App'),
<del> 'GET' => $_GET,
<del> 'POST' => $_POST,
<del> 'SERVER' => $_SERVER
<del> );
<del> }
<del>
<del>/**
<del> * reloadEnvironment method
<del> *
<del> * @return void
<del> */
<del> protected function __reloadEnvironment() {
<del> foreach ($_GET as $key => $val) {
<del> unset($_GET[$key]);
<del> }
<del> foreach ($_POST as $key => $val) {
<del> unset($_POST[$key]);
<del> }
<del> foreach ($_SERVER as $key => $val) {
<del> unset($_SERVER[$key]);
<del> }
<del> Configure::write('App', array());
<del> }
<del>
<del>/**
<del> * loadEnvironment method
<del> *
<del> * @param array $env
<del> * @return void
<del> */
<del> protected function __loadEnvironment($env) {
<del> if ($env['reload']) {
<del> $this->__reloadEnvironment();
<del> }
<del>
<del> if (isset($env['App'])) {
<del> Configure::write('App', $env['App']);
<del> }
<del>
<del> if (isset($env['GET'])) {
<del> foreach ($env['GET'] as $key => $val) {
<del> $_GET[$key] = $val;
<del> }
<del> }
<del>
<del> if (isset($env['POST'])) {
<del> foreach ($env['POST'] as $key => $val) {
<del> $_POST[$key] = $val;
<del> }
<del> }
<del>
<del> if (isset($env['SERVER'])) {
<del> foreach ($env['SERVER'] as $key => $val) {
<del> $_SERVER[$key] = $val;
<del> }
<del> }
<del> }
<del>
<ide> /**
<ide> * cachePath method
<ide> *
<ide> * @param string $here
<ide> * @return string
<ide> */
<del> protected function __cachePath($here) {
<add> protected function _cachePath($here) {
<ide> $path = $here;
<ide> if ($here == '/') {
<ide> $path = 'home';
<ide><path>lib/Cake/TestSuite/templates/menu.php
<ide> <?php
<add>// @codingStandardsIgnoreFile
<ide> /**
<ide> * Short description for file.
<ide> *
<ide> <?php if (!empty($plugins)): ?>
<ide> <li style="padding-top: 10px">
<ide> <span style="font-size: 18px">Plugins</span>
<del> <?php foreach ($plugins as $plugin): ?>
<add> <?php foreach ($plugins as $plugin) : ?>
<ide> <ul>
<ide> <li style="padding-top: 10px">
<ide> <span style="font-size: 18px"><?php echo $plugin; ?></span> | 9 |
Mixed | Javascript | add isdisposed method to components | 064fcafd44a0bb775c084c646d9947146693900e | <ide><path>docs/guides/player-workflows.md
<ide> Additionally, these actions are recursively applied to _all_ the player's child
<ide>
<ide> > **Note**: Do _not_ remove players via standard DOM removal methods: this will leave listeners and other objects in memory that you might not be able to clean up!
<ide>
<add>### Checking if a Player is Disposed
<add>
<add>At times, it is useful to know whether or not a player reference in your code is stale. The `isDisposed()` method is available on all components (including players) for this purpose.
<add>
<ide> ### Signs of an Undisposed Player
<ide>
<ide> Seeing an error such as:
<ide><path>src/js/component.js
<ide> class Component {
<ide> this.player_ = player;
<ide> }
<ide>
<add> this.isDisposed_ = false;
<add>
<ide> // Hold the reference to the parent component via `addChild` method
<ide> this.parentComponent_ = null;
<ide>
<ide> class Component {
<ide> */
<ide> dispose() {
<ide>
<add> // Bail out if the component has already been disposed.
<add> if (this.isDisposed_) {
<add> return;
<add> }
<add>
<ide> /**
<ide> * Triggered when a `Component` is disposed.
<ide> *
<ide> * @event Component#dispose
<ide> * @type {EventTarget~Event}
<ide> *
<ide> * @property {boolean} [bubbles=false]
<del> * set to false so that the close event does not
<add> * set to false so that the dispose event does not
<ide> * bubble up
<ide> */
<ide> this.trigger({type: 'dispose', bubbles: false});
<ide>
<add> this.isDisposed_ = true;
<add>
<ide> // Dispose all children.
<ide> if (this.children_) {
<ide> for (let i = this.children_.length - 1; i >= 0; i--) {
<ide> class Component {
<ide> this.player_ = null;
<ide> }
<ide>
<add> /**
<add> * Determine whether or not this component has been disposed.
<add> *
<add> * @return {boolean}
<add> * If the component has been disposed, will be `true`. Otherwise, `false`.
<add> */
<add> isDisposed() {
<add> return Boolean(this.isDisposed_);
<add> }
<add>
<ide> /**
<ide> * Return the {@link Player} that the `Component` has attached to.
<ide> *
<ide><path>test/unit/component.test.js
<ide> QUnit.test('should dispose of component and children', function(assert) {
<ide> const child = comp.addChild('Component');
<ide>
<ide> assert.ok(comp.children().length === 1);
<add> assert.notOk(comp.isDisposed(), 'the component reports that it is not disposed');
<ide>
<ide> // Add a listener
<ide> comp.on('click', function() {
<ide> QUnit.test('should dispose of component and children', function(assert) {
<ide> !Object.getOwnPropertyNames(data).length,
<ide> 'original listener data object was emptied'
<ide> );
<add> assert.ok(comp.isDisposed(), 'the component reports that it is disposed');
<ide> });
<ide>
<ide> QUnit.test('should add and remove event listeners to element', function(assert) { | 3 |
Python | Python | add comments to clarify cache handling in _raw_fft | 15f02e2515cf879900d5cb27adba23ab0e0ce235 | <ide><path>numpy/fft/fftpack.py
<ide> def _raw_fft(a, n=None, axis=-1, init_function=fftpack.cffti,
<ide> raise ValueError("Invalid number of FFT data points (%d) specified." % n)
<ide>
<ide> try:
<add> # Thread-safety note: We rely on list.pop() here to atomically
<add> # retrieve-and-remove a wsave from the cache. This ensures that no
<add> # other thread can get the same wsave while we're using it.
<ide> wsave = fft_cache.setdefault(n, []).pop()
<ide> except (IndexError):
<ide> wsave = init_function(n)
<ide> def _raw_fft(a, n=None, axis=-1, init_function=fftpack.cffti,
<ide> r = work_function(a, wsave)
<ide> if axis != -1:
<ide> r = swapaxes(r, axis, -1)
<add>
<add> # As soon as we put wsave back into the cache, another thread could pick it
<add> # up and start using it, so we must not do this until after we're
<add> # completely done using it ourselves.
<ide> fft_cache[n].append(wsave)
<add>
<ide> return r
<ide>
<ide> | 1 |
Python | Python | remove 405 method not allowed immediateresponse | 474780f9d6cdb593f82130d39b6a6ff7ef8b78e0 | <ide><path>djangorestframework/exceptions.py
<ide> def __init__(self, detail=None):
<ide> self.detail = detail or self.default_detail
<ide>
<ide>
<add>class MethodNotAllowed(Exception):
<add> status_code = status.HTTP_405_METHOD_NOT_ALLOWED
<add> default_detail = "Method '%s' not allowed"
<add>
<add> def __init__(self, method, detail):
<add> self.detail = (detail or self.default_detail) % method
<add>
<add>
<ide> class UnsupportedMediaType(Exception):
<del> status_code = 415
<del> default_detail = 'Unsupported media type in request'
<add> status_code = status.HTTP_415_UNSUPPORTED_MEDIA_TYPE
<add> default_detail = "Unsupported media type '%s' in request"
<ide>
<del> def __init__(self, detail=None):
<del> self.detail = detail or self.default_detail
<add> def __init__(self, media_type, detail=None):
<add> self.detail = (detail or self.default_detail) % media_type
<ide>
<ide> # class Throttled(Exception):
<ide> # def __init__(self, detail):
<ide><path>djangorestframework/request.py
<ide> def _parse(self):
<ide> """
<ide> Parse the request content.
<ide>
<del> May raise a 415 ImmediateResponse (Unsupported Media Type), or a
<del> 400 ImmediateResponse (Bad Request).
<add> May raise an `UnsupportedMediaType`, or `ParseError` exception.
<ide> """
<ide> if self.stream is None or self.content_type is None:
<ide> return (None, None)
<ide> def _parse(self):
<ide> if parser.can_handle_request(self.content_type):
<ide> return parser.parse(self.stream, self.META, self.upload_handlers)
<ide>
<del> raise UnsupportedMediaType("Unsupported media type in request '%s'" %
<del> self._content_type)
<add> raise UnsupportedMediaType(self._content_type)
<ide>
<ide> def _authenticate(self):
<ide> """
<ide><path>djangorestframework/views.py
<ide> def http_method_not_allowed(self, request, *args, **kwargs):
<ide> Return an HTTP 405 error if an operation is called which does not have
<ide> a handler method.
<ide> """
<del> content = {
<del> 'detail': "Method '%s' not allowed." % request.method
<del> }
<del> raise ImmediateResponse(content, status.HTTP_405_METHOD_NOT_ALLOWED)
<add> raise exceptions.MethodNotAllowed(request.method)
<ide>
<ide> @property
<ide> def _parsed_media_types(self): | 3 |
Java | Java | fix uimanager detection in touch event emitter | 9bc6c0f8a5cb779b9df394893cc097605dea37f6 | <ide><path>ReactAndroid/src/main/java/com/facebook/react/uimanager/events/ReactEventEmitter.java
<ide> public void receiveTouches(
<ide> @Override
<ide> public void receiveTouches(TouchEvent event) {
<ide> int reactTag = event.getViewTag();
<del> @UIManagerType int uiManagerType = ViewUtil.getUIManagerType(reactTag);
<add> @UIManagerType int uiManagerType = event.getUIManagerType();
<ide> if (uiManagerType == UIManagerType.FABRIC && mFabricEventEmitter != null) {
<ide> mFabricEventEmitter.receiveTouches(event);
<ide> } else if (uiManagerType == UIManagerType.DEFAULT && getEventEmitter(reactTag) != null) { | 1 |
Ruby | Ruby | avoid query from exists? on contradictory relation | 3b622bc0d63c2089ffff7b96e35f90e458ac2de4 | <ide><path>activerecord/lib/active_record/relation/finder_methods.rb
<ide> def exists?(conditions = :none)
<ide> end
<ide>
<ide> relation = construct_relation_for_exists(conditions)
<add> return false if relation.where_clause.contradiction?
<ide>
<ide> skip_query_cache_if_necessary { connection.select_rows(relation.arel, "#{name} Exists?").size == 1 }
<ide> end
<ide><path>activerecord/test/cases/relation_test.rb
<ide> def test_marshal_load_legacy_relation
<ide> end
<ide> end
<ide>
<add> test "no queries on empty relation exists?" do
<add> assert_queries(0) do
<add> Post.where(id: []).exists?(123)
<add> end
<add> end
<add>
<add> test "no queries on empty condition exists?" do
<add> assert_queries(0) do
<add> Post.all.exists?(id: [])
<add> end
<add> end
<add>
<ide> private
<ide> def skip_if_sqlite3_version_includes_quoting_bug
<ide> if sqlite3_version_includes_quoting_bug? | 2 |
Javascript | Javascript | remove magictouch require | 576b3b3a5cdeb70bb1796b252c9b421827c17e09 | <ide><path>packages/sproutcore-touch/lib/system.js
<ide> require('sproutcore-touch/system/gesture');
<ide> require('sproutcore-touch/system/view');
<del>require('sproutcore-touch/system/magictouch');
<ide> require('sproutcore-touch/system/gesture_manager');
<ide> require('sproutcore-touch/system/gestures'); | 1 |
Text | Text | add list of extracted plugins to rails4 guide | ce7a493a3033abf270ff480b2e1d32e11a5127e3 | <ide><path>guides/source/4_0_release_notes.md
<ide> $ ruby /path/to/rails/railties/bin/rails new myapp --dev
<ide> Major Features
<ide> --------------
<ide>
<add>Moved to a Plugin
<add>-----------------
<add>
<add>With Rails 4 several pieces have been extracted. While Rails won't ship with these features anymore,
<add>you can simply add the extracted plugin to your `Gemfile` to bring the functionality back.
<add>
<add>* Hash-based & Dynamic finder methods ([Github](https://github.com/rails/activerecord-deprecated_finders))
<add>* Mass assignment protection in Active Record models ([Github](https://github.com/rails/protected_attributes), [Pull Request](https://github.com/rails/rails/pull/7251))
<add>* ActiveRecord::SessionStore ([Github](https://github.com/rails/activerecord-session_store), [Pull Request](https://github.com/rails/rails/pull/7436))
<add>* Active Record Observers ([Github](https://github.com/rails/rails-observers), [Commit](https://github.com/rails/rails/commit/39e85b3b90c58449164673909a6f1893cba290b2))
<add>* Active Resource ([Github](https://github.com/rails/activeresource), [Pull Request](https://github.com/rails/rails/pull/572), [Blog](http://yetimedia.tumblr.com/post/35233051627/activeresource-is-dead-long-live-activeresource))
<add>* Action Caching ([Github](https://github.com/rails/actionpack-action_caching), [Pull Request](https://github.com/rails/rails/pull/7833))
<add>* Page Caching ([Github](https://github.com/rails/actionpack-page_caching), [Pull Request](https://github.com/rails/rails/pull/7833))
<add>
<ide> Documentation
<ide> -------------
<ide> | 1 |
Text | Text | move volume filters to api 1.24 docs | 8ef76f779d6ea59cb1a8c6fde52e4d719a8c073a | <ide><path>docs/reference/api/docker_remote_api_v1.23.md
<ide> Status Codes:
<ide>
<ide> Query Parameters:
<ide>
<del>- **filters** - JSON encoded value of the filters (a `map[string][]string`) to process on the volumes list. Available filters:
<del> - `name=<volume-name>` Matches all or part of a volume name.
<del> - `dangling=<boolean>` When set to `true` (or `1`), returns all volumes that are "dangling" (not in use by a container). When set to `false` (or `0`), only volumes that are in use by one or more containers are returned.
<del> - `driver=<volume-driver-name>` Matches all or part of a volume driver name.
<add>- **filters** - JSON encoded value of the filters (a `map[string][]string`) to process on the volumes list. There is one available filter: `dangling=true`
<ide>
<ide> Status Codes:
<ide>
<ide><path>docs/reference/api/docker_remote_api_v1.24.md
<ide> Status Codes:
<ide>
<ide> Query Parameters:
<ide>
<del>- **filters** - JSON encoded value of the filters (a `map[string][]string`) to process on the volumes list. There is one available filter: `dangling=true`
<add>- **filters** - JSON encoded value of the filters (a `map[string][]string`) to process on the volumes list. Available filters:
<add> - `name=<volume-name>` Matches all or part of a volume name.
<add> - `dangling=<boolean>` When set to `true` (or `1`), returns all volumes that are "dangling" (not in use by a container). When set to `false` (or `0`), only volumes that are in use by one or more containers are returned.
<add> - `driver=<volume-driver-name>` Matches all or part of a volume driver name.
<ide>
<ide> Status Codes:
<ide> | 2 |
Text | Text | prepare entry to the changelog.md | eca847f4ba5733c4cb3cc1ecabbd117a4443cd74 | <ide><path>activerecord/CHANGELOG.md
<add>* Add `rake db:prepare` runs setup if database does not exist, or runs migrations if it does.
<add>
<add> *Roberto Miranda*
<add>
<ide> * Add `after_save_commit` callback as shortcut for `after_commit :hook, on: [ :create, :update ]`.
<ide>
<ide> *DHH* | 1 |
Mixed | Javascript | add `maxstrlength` option to `inspect` function | 944d8626b37d3096f4c4a0e881c52f3ac2da0213 | <ide><path>doc/api/util.md
<ide> stream.write('With ES6');
<ide> <!-- YAML
<ide> added: v0.3.0
<ide> changes:
<add> - version: REPLACEME
<add> pr-url: https://github.com/nodejs/node/pull/32392
<add> description: The `maxStringLength` option is supported now.
<ide> - version: v13.5.0
<ide> pr-url: https://github.com/nodejs/node/pull/30768
<ide> description: User defined prototype properties are inspected in case
<ide> changes:
<ide> [`TypedArray`][], [`WeakMap`][] and [`WeakSet`][] elements to include when
<ide> formatting. Set to `null` or `Infinity` to show all elements. Set to `0` or
<ide> negative to show no elements. **Default:** `100`.
<add> * `maxStringLength` {integer} Specifies the maximum number of characters to
<add> include when formatting. Set to `null` or `Infinity` to show all elements.
<add> Set to `0` or negative to show no characters. **Default:** `Infinity`.
<ide> * `breakLength` {integer} The length at which input values are split across
<ide> multiple lines. Set to `Infinity` to format the input as a single line
<ide> (in combination with `compact` set to `true` or any number >= `1`).
<ide><path>lib/internal/util/inspect.js
<ide> const inspectDefaultOptions = ObjectSeal({
<ide> customInspect: true,
<ide> showProxy: false,
<ide> maxArrayLength: 100,
<add> maxStringLength: Infinity,
<ide> breakLength: 80,
<ide> compact: 3,
<ide> sorted: false,
<ide> function getUserOptions(ctx) {
<ide> customInspect: ctx.customInspect,
<ide> showProxy: ctx.showProxy,
<ide> maxArrayLength: ctx.maxArrayLength,
<add> maxStringLength: ctx.maxStringLength,
<ide> breakLength: ctx.breakLength,
<ide> compact: ctx.compact,
<ide> sorted: ctx.sorted,
<ide> function inspect(value, opts) {
<ide> customInspect: inspectDefaultOptions.customInspect,
<ide> showProxy: inspectDefaultOptions.showProxy,
<ide> maxArrayLength: inspectDefaultOptions.maxArrayLength,
<add> maxStringLength: inspectDefaultOptions.maxStringLength,
<ide> breakLength: inspectDefaultOptions.breakLength,
<ide> compact: inspectDefaultOptions.compact,
<ide> sorted: inspectDefaultOptions.sorted,
<ide> function inspect(value, opts) {
<ide> }
<ide> if (ctx.colors) ctx.stylize = stylizeWithColor;
<ide> if (ctx.maxArrayLength === null) ctx.maxArrayLength = Infinity;
<add> if (ctx.maxStringLength === null) ctx.maxStringLength = Infinity;
<ide> return formatValue(ctx, value, 0);
<ide> }
<ide> inspect.custom = customInspectSymbol;
<ide> function formatBigInt(fn, value) {
<ide>
<ide> function formatPrimitive(fn, value, ctx) {
<ide> if (typeof value === 'string') {
<add> let trailer = '';
<add> if (value.length > ctx.maxStringLength) {
<add> const remaining = value.length - ctx.maxStringLength;
<add> value = value.slice(0, ctx.maxStringLength);
<add> trailer = `... ${remaining} more character${remaining > 1 ? 's' : ''}`;
<add> }
<ide> if (ctx.compact !== true &&
<ide> // TODO(BridgeAR): Add unicode support. Use the readline getStringWidth
<ide> // function.
<ide> function formatPrimitive(fn, value, ctx) {
<ide> return value
<ide> .split(/(?<=\n)/)
<ide> .map((line) => fn(strEscape(line), 'string'))
<del> .join(` +\n${' '.repeat(ctx.indentationLvl + 2)}`);
<add> .join(` +\n${' '.repeat(ctx.indentationLvl + 2)}`) + trailer;
<ide> }
<del> return fn(strEscape(value), 'string');
<add> return fn(strEscape(value), 'string') + trailer;
<ide> }
<ide> if (typeof value === 'number')
<ide> return formatNumber(fn, value);
<ide><path>test/parallel/test-util-inspect.js
<ide> assert.strictEqual(
<ide> v8.setFlagsFromString('--no-allow-natives-syntax');
<ide> assert.strictEqual(inspect(undetectable), '{}');
<ide> }
<add>
<add>{
<add> const x = 'a'.repeat(1e6);
<add> assert.strictEqual(
<add> util.inspect(x, { maxStringLength: 4 }),
<add> "'aaaa'... 999996 more characters"
<add> );
<add>} | 3 |
Python | Python | fix scoring normalization | e0b29f8ef7e4693355e481795af04413ccdf0d55 | <ide><path>spacy/tests/pipeline/test_pipe_factories.py
<ide> def test_language_factories_invalid():
<ide>
<ide>
<ide> @pytest.mark.parametrize(
<del> "weights,expected",
<add> "weights,override,expected",
<ide> [
<del> ([{"a": 1.0}, {"b": 1.0}, {"c": 1.0}], {"a": 0.33, "b": 0.33, "c": 0.33}),
<del> ([{"a": 1.0}, {"b": 50}, {"c": 123}], {"a": 0.33, "b": 0.33, "c": 0.33}),
<add> ([{"a": 1.0}, {"b": 1.0}, {"c": 1.0}], {}, {"a": 0.33, "b": 0.33, "c": 0.33}),
<add> ([{"a": 1.0}, {"b": 50}, {"c": 100}], {}, {"a": 0.01, "b": 0.33, "c": 0.66}),
<ide> (
<ide> [{"a": 0.7, "b": 0.3}, {"c": 1.0}, {"d": 0.5, "e": 0.5}],
<add> {},
<ide> {"a": 0.23, "b": 0.1, "c": 0.33, "d": 0.17, "e": 0.17},
<ide> ),
<ide> (
<del> [{"a": 100, "b": 400}, {"c": 0.5, "d": 0.5}],
<del> {"a": 0.1, "b": 0.4, "c": 0.25, "d": 0.25},
<add> [{"a": 100, "b": 300}, {"c": 50, "d": 50}],
<add> {},
<add> {"a": 0.2, "b": 0.6, "c": 0.1, "d": 0.1},
<ide> ),
<del> ([{"a": 0.5, "b": 0.5}, {"b": 1.0}], {"a": 0.25, "b": 0.75}),
<del> ([{"a": 0.0, "b": 0.0}, {"c": 0.0}], {"a": 0.0, "b": 0.0, "c": 0.0}),
<add> ([{"a": 0.5, "b": 0.5}, {"b": 1.0}], {}, {"a": 0.33, "b": 0.67}),
<add> ([{"a": 0.5, "b": 0.0}], {}, {"a": 1.0, "b": 0.0}),
<add> ([{"a": 0.5, "b": 0.5}, {"b": 1.0}], {"a": 0.0}, {"a": 0.0, "b": 1.0}),
<add> ([{"a": 0.0, "b": 0.0}, {"c": 0.0}], {}, {"a": 0.0, "b": 0.0, "c": 0.0}),
<add> ([{"a": 0.0, "b": 0.0}, {"c": 1.0}], {}, {"a": 0.0, "b": 0.0, "c": 1.0}),
<add> ([{"a": 0.0, "b": 0.0}, {"c": 0.0}], {"c": 0.2}, {"a": 0.0, "b": 0.0, "c": 1.0}),
<add> ([{"a": 0.5, "b": 0.5, "c": 1.0, "d": 1.0}], {"a": 0.0, "b": 0.0}, {"a": 0.0, "b": 0.0, "c": 0.5, "d": 0.5}),
<ide> ],
<ide> )
<del>def test_language_factories_combine_score_weights(weights, expected):
<del> result = combine_score_weights(weights)
<add>def test_language_factories_combine_score_weights(weights, override, expected):
<add> result = combine_score_weights(weights, override)
<ide> assert sum(result.values()) in (0.99, 1.0, 0.0)
<ide> assert result == expected
<ide>
<ide> def test_language_factories_scores():
<ide> # Test with custom defaults
<ide> config = nlp.config.copy()
<ide> config["training"]["score_weights"]["a1"] = 0.0
<del> config["training"]["score_weights"]["b3"] = 1.0
<add> config["training"]["score_weights"]["b3"] = 1.3
<ide> nlp = English.from_config(config)
<ide> score_weights = nlp.config["training"]["score_weights"]
<del> expected = {"a1": 0.0, "a2": 0.5, "b1": 0.03, "b2": 0.12, "b3": 0.34}
<add> expected = {"a1": 0.0, "a2": 0.12, "b1": 0.05, "b2": 0.17, "b3": 0.65}
<ide> assert score_weights == expected
<ide> # Test with null values
<ide> config = nlp.config.copy()
<ide> config["training"]["score_weights"]["a1"] = None
<ide> nlp = English.from_config(config)
<ide> score_weights = nlp.config["training"]["score_weights"]
<del> expected = {"a1": None, "a2": 0.5, "b1": 0.03, "b2": 0.12, "b3": 0.35}
<add> expected = {"a1": None, "a2": 0.12, "b1": 0.05, "b2": 0.17, "b3": 0.66}
<ide> assert score_weights == expected
<ide>
<ide>
<ide><path>spacy/util.py
<ide> def combine_score_weights(
<ide> should be preserved.
<ide> RETURNS (Dict[str, float]): The combined and normalized weights.
<ide> """
<add> # We divide each weight by the total weight sum.
<ide> # We first need to extract all None/null values for score weights that
<ide> # shouldn't be shown in the table *or* be weighted
<del> result = {}
<del> all_weights = []
<del> for w_dict in weights:
<del> filtered_weights = {}
<del> for key, value in w_dict.items():
<del> value = overrides.get(key, value)
<del> if value is None:
<del> result[key] = None
<del> else:
<del> filtered_weights[key] = value
<del> all_weights.append(filtered_weights)
<del> for w_dict in all_weights:
<del> # We need to account for weights that don't sum to 1.0 and normalize
<del> # the score weights accordingly, then divide score by the number of
<del> # components.
<del> total = sum(w_dict.values())
<del> for key, value in w_dict.items():
<del> if total == 0:
<del> weight = 0.0
<del> else:
<del> weight = round(value / total / len(all_weights), 2)
<del> prev_weight = result.get(key, 0.0)
<del> prev_weight = 0.0 if prev_weight is None else prev_weight
<del> result[key] = prev_weight + weight
<add> result = {key: overrides.get(key, value) for w_dict in weights for (key, value) in w_dict.items()}
<add> weight_sum = sum([v if v else 0.0 for v in result.values()])
<add> for key, value in result.items():
<add> if value and weight_sum > 0:
<add> result[key] = round(value / weight_sum, 2)
<ide> return result
<ide>
<ide> | 2 |
Ruby | Ruby | improve deprecation message for leaking scope | c90bca75724037c097b1bb954ef932b46f8abc4c | <ide><path>activerecord/lib/active_record/scoping/named.rb
<ide> def all
<ide> ActiveSupport::Deprecation.warn(<<~MSG.squish)
<ide> Class level methods will no longer inherit scoping from `#{scope._deprecated_scope_source}`
<ide> in Rails 6.1. To continue using the scoped relation, pass it into the block directly.
<del> To instead access the full set of models, as Rails 6.1 will, use `#{name}.unscoped`.
<add> To instead access the full set of models, as Rails 6.1 will, use `#{name}.unscoped`,
<add> or `#{name}.default_scoped` if a model has default scopes.
<ide> MSG
<ide> end
<ide> | 1 |
Javascript | Javascript | put react.fragment under a feature flag | 0e15ff5669271f5f5956e30a4fe1ae5963778e89 | <ide><path>packages/react-cs-renderer/src/ReactNativeCSFeatureFlags.js
<ide> import type {FeatureFlags} from 'shared/ReactFeatureFlags';
<ide> var ReactNativeCSFeatureFlags: FeatureFlags = {
<ide> enableAsyncSubtreeAPI: true,
<ide> enableAsyncSchedulingByDefaultInReactDOM: false,
<add> enableReactFragment: false,
<ide> // React Native CS uses persistent reconciler.
<ide> enableMutatingReconciler: false,
<ide> enableNoopReconciler: false,
<ide><path>packages/react-dom/src/__tests__/ReactDOMServerIntegration-test.js
<ide> let ReactDOMServer;
<ide> let ReactTestUtils;
<ide>
<ide> const stream = require('stream');
<add>const ReactFeatureFlags = require('shared/ReactFeatureFlags');
<ide>
<ide> const TEXT_NODE_TYPE = 3;
<ide>
<ide> describe('ReactDOMServerIntegration', () => {
<ide> expect(parent.childNodes[2].tagName).toBe('P');
<ide> });
<ide>
<del> itRenders('a fragment with one child', async render => {
<del> let e = await render(<React.Fragment><div>text1</div></React.Fragment>);
<del> let parent = e.parentNode;
<del> expect(parent.childNodes[0].tagName).toBe('DIV');
<del> });
<del>
<del> itRenders('a fragment with several children', async render => {
<del> let Header = props => {
<del> return <p>header</p>;
<del> };
<del> let Footer = props => {
<del> return <React.Fragment><h2>footer</h2><h3>about</h3></React.Fragment>;
<del> };
<del> let e = await render(
<del> <React.Fragment>
<del> <div>text1</div>
<del> <span>text2</span>
<del> <Header />
<del> <Footer />
<del> </React.Fragment>,
<del> );
<del> let parent = e.parentNode;
<del> expect(parent.childNodes[0].tagName).toBe('DIV');
<del> expect(parent.childNodes[1].tagName).toBe('SPAN');
<del> expect(parent.childNodes[2].tagName).toBe('P');
<del> expect(parent.childNodes[3].tagName).toBe('H2');
<del> expect(parent.childNodes[4].tagName).toBe('H3');
<del> });
<add> if (ReactFeatureFlags.enableReactFragment) {
<add> itRenders('a fragment with one child', async render => {
<add> let e = await render(<React.Fragment><div>text1</div></React.Fragment>);
<add> let parent = e.parentNode;
<add> expect(parent.childNodes[0].tagName).toBe('DIV');
<add> });
<ide>
<del> itRenders('a nested fragment', async render => {
<del> let e = await render(
<del> <React.Fragment>
<add> itRenders('a fragment with several children', async render => {
<add> let Header = props => {
<add> return <p>header</p>;
<add> };
<add> let Footer = props => {
<add> return <React.Fragment><h2>footer</h2><h3>about</h3></React.Fragment>;
<add> };
<add> let e = await render(
<ide> <React.Fragment>
<ide> <div>text1</div>
<del> </React.Fragment>
<del> <span>text2</span>
<add> <span>text2</span>
<add> <Header />
<add> <Footer />
<add> </React.Fragment>,
<add> );
<add> let parent = e.parentNode;
<add> expect(parent.childNodes[0].tagName).toBe('DIV');
<add> expect(parent.childNodes[1].tagName).toBe('SPAN');
<add> expect(parent.childNodes[2].tagName).toBe('P');
<add> expect(parent.childNodes[3].tagName).toBe('H2');
<add> expect(parent.childNodes[4].tagName).toBe('H3');
<add> });
<add>
<add> itRenders('a nested fragment', async render => {
<add> let e = await render(
<ide> <React.Fragment>
<ide> <React.Fragment>
<del> <React.Fragment>{null}<p /></React.Fragment>{false}
<add> <div>text1</div>
<ide> </React.Fragment>
<del> </React.Fragment>
<del> </React.Fragment>,
<del> );
<del> let parent = e.parentNode;
<del> expect(parent.childNodes[0].tagName).toBe('DIV');
<del> expect(parent.childNodes[1].tagName).toBe('SPAN');
<del> expect(parent.childNodes[2].tagName).toBe('P');
<del> });
<add> <span>text2</span>
<add> <React.Fragment>
<add> <React.Fragment>
<add> <React.Fragment>{null}<p /></React.Fragment>{false}
<add> </React.Fragment>
<add> </React.Fragment>
<add> </React.Fragment>,
<add> );
<add> let parent = e.parentNode;
<add> expect(parent.childNodes[0].tagName).toBe('DIV');
<add> expect(parent.childNodes[1].tagName).toBe('SPAN');
<add> expect(parent.childNodes[2].tagName).toBe('P');
<add> });
<add> }
<ide>
<ide> itRenders('an iterable', async render => {
<ide> const threeDivIterable = {
<ide> describe('ReactDOMServerIntegration', () => {
<ide> // but server returns empty HTML. So we compare parent text.
<ide> expect((await render(<div>{''}</div>)).textContent).toBe('');
<ide>
<del> expect(await render(<React.Fragment />)).toBe(null);
<add> if (ReactFeatureFlags.enableReactFragment) {
<add> expect(await render(<React.Fragment />)).toBe(null);
<add> }
<ide> expect(await render([])).toBe(null);
<ide> expect(await render(false)).toBe(null);
<ide> expect(await render(true)).toBe(null);
<ide><path>packages/react-reconciler/src/ReactChildFiber.js
<ide> import type {
<ide>
<ide> var ReactTypeOfSideEffect = require('shared/ReactTypeOfSideEffect');
<ide> var ReactTypeOfWork = require('shared/ReactTypeOfWork');
<add>var ReactFeatureFlags = require('shared/ReactFeatureFlags');
<ide> var emptyObject = require('fbjs/lib/emptyObject');
<ide> var invariant = require('fbjs/lib/invariant');
<ide> var {REACT_PORTAL_TYPE} = require('./ReactPortal');
<ide> function ChildReconciler(shouldClone, shouldTrackSideEffects) {
<ide> // This leads to an ambiguity between <>{[...]}</> and <>...</>.
<ide> // We treat the ambiguous cases above the same.
<ide> if (
<add> ReactFeatureFlags.enableReactFragment &&
<ide> typeof newChild === 'object' &&
<ide> newChild !== null &&
<ide> newChild.type === REACT_FRAGMENT_TYPE &&
<ide><path>packages/react-reconciler/src/__tests__/ReactFragment-test.js
<ide> */
<ide> 'use strict';
<ide>
<add>var ReactFeatureFlags = require('shared/ReactFeatureFlags');
<add>
<ide> let React;
<ide> let ReactNoop;
<ide>
<ide> describe('ReactFragment', () => {
<ide> return {type: 'div', children, prop: undefined};
<ide> }
<ide>
<del> it('should render a single child via noop renderer', () => {
<del> const element = (
<del> <React.Fragment>
<del> <span>foo</span>
<del> </React.Fragment>
<del> );
<add> if (ReactFeatureFlags.enableReactFragment) {
<add> it('should render a single child via noop renderer', () => {
<add> const element = (
<add> <React.Fragment>
<add> <span>foo</span>
<add> </React.Fragment>
<add> );
<ide>
<del> ReactNoop.render(element);
<del> ReactNoop.flush();
<add> ReactNoop.render(element);
<add> ReactNoop.flush();
<ide>
<del> expect(ReactNoop.getChildren()).toEqual([span()]);
<del> });
<add> expect(ReactNoop.getChildren()).toEqual([span()]);
<add> });
<ide>
<del> it('should render zero children via noop renderer', () => {
<del> const element = <React.Fragment />;
<add> it('should render zero children via noop renderer', () => {
<add> const element = <React.Fragment />;
<ide>
<del> ReactNoop.render(element);
<del> ReactNoop.flush();
<add> ReactNoop.render(element);
<add> ReactNoop.flush();
<ide>
<del> expect(ReactNoop.getChildren()).toEqual([]);
<del> });
<add> expect(ReactNoop.getChildren()).toEqual([]);
<add> });
<ide>
<del> it('should render multiple children via noop renderer', () => {
<del> const element = (
<del> <React.Fragment>
<del> hello <span>world</span>
<del> </React.Fragment>
<del> );
<add> it('should render multiple children via noop renderer', () => {
<add> const element = (
<add> <React.Fragment>
<add> hello <span>world</span>
<add> </React.Fragment>
<add> );
<ide>
<del> ReactNoop.render(element);
<del> ReactNoop.flush();
<add> ReactNoop.render(element);
<add> ReactNoop.flush();
<ide>
<del> expect(ReactNoop.getChildren()).toEqual([text('hello '), span()]);
<del> });
<add> expect(ReactNoop.getChildren()).toEqual([text('hello '), span()]);
<add> });
<ide>
<del> it('should render an iterable via noop renderer', () => {
<del> const element = (
<del> <React.Fragment>
<del> {new Set([<span key="a">hi</span>, <span key="b">bye</span>])}
<del> </React.Fragment>
<del> );
<add> it('should render an iterable via noop renderer', () => {
<add> const element = (
<add> <React.Fragment>
<add> {new Set([<span key="a">hi</span>, <span key="b">bye</span>])}
<add> </React.Fragment>
<add> );
<ide>
<del> ReactNoop.render(element);
<del> ReactNoop.flush();
<add> ReactNoop.render(element);
<add> ReactNoop.flush();
<ide>
<del> expect(ReactNoop.getChildren()).toEqual([span(), span()]);
<del> });
<add> expect(ReactNoop.getChildren()).toEqual([span(), span()]);
<add> });
<ide>
<del> it('should preserve state of children with 1 level nesting', function() {
<del> var ops = [];
<add> it('should preserve state of children with 1 level nesting', function() {
<add> var ops = [];
<ide>
<del> class Stateful extends React.Component {
<del> componentDidUpdate() {
<del> ops.push('Update Stateful');
<add> class Stateful extends React.Component {
<add> componentDidUpdate() {
<add> ops.push('Update Stateful');
<add> }
<add>
<add> render() {
<add> return <div>Hello</div>;
<add> }
<ide> }
<ide>
<del> render() {
<del> return <div>Hello</div>;
<add> function Foo({condition}) {
<add> return condition
<add> ? <Stateful key="a" />
<add> : <React.Fragment>
<add> <Stateful key="a" />
<add> <div key="b">World</div>
<add> </React.Fragment>;
<ide> }
<del> }
<ide>
<del> function Foo({condition}) {
<del> return condition
<del> ? <Stateful key="a" />
<del> : <React.Fragment>
<del> <Stateful key="a" />
<del> <div key="b">World</div>
<del> </React.Fragment>;
<del> }
<add> ReactNoop.render(<Foo condition={true} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={true} />);
<del> ReactNoop.flush();
<add> ReactNoop.render(<Foo condition={false} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={false} />);
<del> ReactNoop.flush();
<add> expect(ops).toEqual(['Update Stateful']);
<add> expect(ReactNoop.getChildren()).toEqual([div(), div()]);
<ide>
<del> expect(ops).toEqual(['Update Stateful']);
<del> expect(ReactNoop.getChildren()).toEqual([div(), div()]);
<add> ReactNoop.render(<Foo condition={true} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={true} />);
<del> ReactNoop.flush();
<add> expect(ops).toEqual(['Update Stateful', 'Update Stateful']);
<add> expect(ReactNoop.getChildren()).toEqual([div()]);
<add> });
<ide>
<del> expect(ops).toEqual(['Update Stateful', 'Update Stateful']);
<del> expect(ReactNoop.getChildren()).toEqual([div()]);
<del> });
<add> it('should preserve state between top-level fragments', function() {
<add> var ops = [];
<ide>
<del> it('should preserve state between top-level fragments', function() {
<del> var ops = [];
<add> class Stateful extends React.Component {
<add> componentDidUpdate() {
<add> ops.push('Update Stateful');
<add> }
<ide>
<del> class Stateful extends React.Component {
<del> componentDidUpdate() {
<del> ops.push('Update Stateful');
<add> render() {
<add> return <div>Hello</div>;
<add> }
<ide> }
<ide>
<del> render() {
<del> return <div>Hello</div>;
<add> function Foo({condition}) {
<add> return condition
<add> ? <React.Fragment>
<add> <Stateful />
<add> </React.Fragment>
<add> : <React.Fragment>
<add> <Stateful />
<add> </React.Fragment>;
<ide> }
<del> }
<ide>
<del> function Foo({condition}) {
<del> return condition
<del> ? <React.Fragment>
<del> <Stateful />
<del> </React.Fragment>
<del> : <React.Fragment>
<del> <Stateful />
<del> </React.Fragment>;
<del> }
<add> ReactNoop.render(<Foo condition={true} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={true} />);
<del> ReactNoop.flush();
<add> ReactNoop.render(<Foo condition={false} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={false} />);
<del> ReactNoop.flush();
<add> expect(ops).toEqual(['Update Stateful']);
<add> expect(ReactNoop.getChildren()).toEqual([div()]);
<ide>
<del> expect(ops).toEqual(['Update Stateful']);
<del> expect(ReactNoop.getChildren()).toEqual([div()]);
<add> ReactNoop.render(<Foo condition={true} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={true} />);
<del> ReactNoop.flush();
<add> expect(ops).toEqual(['Update Stateful', 'Update Stateful']);
<add> expect(ReactNoop.getChildren()).toEqual([div()]);
<add> });
<ide>
<del> expect(ops).toEqual(['Update Stateful', 'Update Stateful']);
<del> expect(ReactNoop.getChildren()).toEqual([div()]);
<del> });
<del>
<del> it('should preserve state of children nested at same level', function() {
<del> var ops = [];
<add> it('should preserve state of children nested at same level', function() {
<add> var ops = [];
<ide>
<del> class Stateful extends React.Component {
<del> componentDidUpdate() {
<del> ops.push('Update Stateful');
<del> }
<add> class Stateful extends React.Component {
<add> componentDidUpdate() {
<add> ops.push('Update Stateful');
<add> }
<ide>
<del> render() {
<del> return <div>Hello</div>;
<add> render() {
<add> return <div>Hello</div>;
<add> }
<ide> }
<del> }
<ide>
<del> function Foo({condition}) {
<del> return condition
<del> ? <React.Fragment>
<del> <React.Fragment>
<add> function Foo({condition}) {
<add> return condition
<add> ? <React.Fragment>
<ide> <React.Fragment>
<del> <Stateful key="a" />
<add> <React.Fragment>
<add> <Stateful key="a" />
<add> </React.Fragment>
<ide> </React.Fragment>
<ide> </React.Fragment>
<del> </React.Fragment>
<del> : <React.Fragment>
<del> <React.Fragment>
<add> : <React.Fragment>
<ide> <React.Fragment>
<del> <div />
<del> <Stateful key="a" />
<add> <React.Fragment>
<add> <div />
<add> <Stateful key="a" />
<add> </React.Fragment>
<ide> </React.Fragment>
<del> </React.Fragment>
<del> </React.Fragment>;
<del> }
<add> </React.Fragment>;
<add> }
<ide>
<del> ReactNoop.render(<Foo condition={true} />);
<del> ReactNoop.flush();
<add> ReactNoop.render(<Foo condition={true} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={false} />);
<del> ReactNoop.flush();
<add> ReactNoop.render(<Foo condition={false} />);
<add> ReactNoop.flush();
<ide>
<del> expect(ops).toEqual(['Update Stateful']);
<del> expect(ReactNoop.getChildren()).toEqual([div(), div()]);
<add> expect(ops).toEqual(['Update Stateful']);
<add> expect(ReactNoop.getChildren()).toEqual([div(), div()]);
<ide>
<del> ReactNoop.render(<Foo condition={true} />);
<del> ReactNoop.flush();
<add> ReactNoop.render(<Foo condition={true} />);
<add> ReactNoop.flush();
<ide>
<del> expect(ops).toEqual(['Update Stateful', 'Update Stateful']);
<del> expect(ReactNoop.getChildren()).toEqual([div()]);
<del> });
<add> expect(ops).toEqual(['Update Stateful', 'Update Stateful']);
<add> expect(ReactNoop.getChildren()).toEqual([div()]);
<add> });
<ide>
<del> it('should not preserve state in non-top-level fragment nesting', function() {
<del> var ops = [];
<add> it('should not preserve state in non-top-level fragment nesting', function() {
<add> var ops = [];
<ide>
<del> class Stateful extends React.Component {
<del> componentDidUpdate() {
<del> ops.push('Update Stateful');
<add> class Stateful extends React.Component {
<add> componentDidUpdate() {
<add> ops.push('Update Stateful');
<add> }
<add>
<add> render() {
<add> return <div>Hello</div>;
<add> }
<ide> }
<ide>
<del> render() {
<del> return <div>Hello</div>;
<add> function Foo({condition}) {
<add> return condition
<add> ? <React.Fragment>
<add> <React.Fragment><Stateful key="a" /></React.Fragment>
<add> </React.Fragment>
<add> : <React.Fragment><Stateful key="a" /></React.Fragment>;
<ide> }
<del> }
<ide>
<del> function Foo({condition}) {
<del> return condition
<del> ? <React.Fragment>
<del> <React.Fragment><Stateful key="a" /></React.Fragment>
<del> </React.Fragment>
<del> : <React.Fragment><Stateful key="a" /></React.Fragment>;
<del> }
<add> ReactNoop.render(<Foo condition={true} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={true} />);
<del> ReactNoop.flush();
<add> ReactNoop.render(<Foo condition={false} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={false} />);
<del> ReactNoop.flush();
<add> expect(ops).toEqual([]);
<add> expect(ReactNoop.getChildren()).toEqual([div()]);
<ide>
<del> expect(ops).toEqual([]);
<del> expect(ReactNoop.getChildren()).toEqual([div()]);
<add> ReactNoop.render(<Foo condition={true} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={true} />);
<del> ReactNoop.flush();
<add> expect(ops).toEqual([]);
<add> expect(ReactNoop.getChildren()).toEqual([div()]);
<add> });
<ide>
<del> expect(ops).toEqual([]);
<del> expect(ReactNoop.getChildren()).toEqual([div()]);
<del> });
<add> it('should not preserve state of children if nested 2 levels without siblings', function() {
<add> var ops = [];
<ide>
<del> it('should not preserve state of children if nested 2 levels without siblings', function() {
<del> var ops = [];
<add> class Stateful extends React.Component {
<add> componentDidUpdate() {
<add> ops.push('Update Stateful');
<add> }
<ide>
<del> class Stateful extends React.Component {
<del> componentDidUpdate() {
<del> ops.push('Update Stateful');
<add> render() {
<add> return <div>Hello</div>;
<add> }
<ide> }
<ide>
<del> render() {
<del> return <div>Hello</div>;
<add> function Foo({condition}) {
<add> return condition
<add> ? <Stateful key="a" />
<add> : <React.Fragment>
<add> <React.Fragment>
<add> <Stateful key="a" />
<add> </React.Fragment>
<add> </React.Fragment>;
<ide> }
<del> }
<ide>
<del> function Foo({condition}) {
<del> return condition
<del> ? <Stateful key="a" />
<del> : <React.Fragment>
<del> <React.Fragment>
<del> <Stateful key="a" />
<del> </React.Fragment>
<del> </React.Fragment>;
<del> }
<add> ReactNoop.render(<Foo condition={true} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={true} />);
<del> ReactNoop.flush();
<add> ReactNoop.render(<Foo condition={false} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={false} />);
<del> ReactNoop.flush();
<add> expect(ops).toEqual([]);
<add> expect(ReactNoop.getChildren()).toEqual([div()]);
<ide>
<del> expect(ops).toEqual([]);
<del> expect(ReactNoop.getChildren()).toEqual([div()]);
<add> ReactNoop.render(<Foo condition={true} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={true} />);
<del> ReactNoop.flush();
<add> expect(ops).toEqual([]);
<add> expect(ReactNoop.getChildren()).toEqual([div()]);
<add> });
<ide>
<del> expect(ops).toEqual([]);
<del> expect(ReactNoop.getChildren()).toEqual([div()]);
<del> });
<add> it('should not preserve state of children if nested 2 levels with siblings', function() {
<add> var ops = [];
<ide>
<del> it('should not preserve state of children if nested 2 levels with siblings', function() {
<del> var ops = [];
<add> class Stateful extends React.Component {
<add> componentDidUpdate() {
<add> ops.push('Update Stateful');
<add> }
<ide>
<del> class Stateful extends React.Component {
<del> componentDidUpdate() {
<del> ops.push('Update Stateful');
<add> render() {
<add> return <div>Hello</div>;
<add> }
<ide> }
<ide>
<del> render() {
<del> return <div>Hello</div>;
<add> function Foo({condition}) {
<add> return condition
<add> ? <Stateful key="a" />
<add> : <React.Fragment>
<add> <React.Fragment>
<add> <Stateful key="a" />
<add> </React.Fragment>
<add> <div />
<add> </React.Fragment>;
<ide> }
<del> }
<ide>
<del> function Foo({condition}) {
<del> return condition
<del> ? <Stateful key="a" />
<del> : <React.Fragment>
<del> <React.Fragment>
<del> <Stateful key="a" />
<del> </React.Fragment>
<del> <div />
<del> </React.Fragment>;
<del> }
<add> ReactNoop.render(<Foo condition={true} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={true} />);
<del> ReactNoop.flush();
<add> ReactNoop.render(<Foo condition={false} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={false} />);
<del> ReactNoop.flush();
<add> expect(ops).toEqual([]);
<add> expect(ReactNoop.getChildren()).toEqual([div(), div()]);
<ide>
<del> expect(ops).toEqual([]);
<del> expect(ReactNoop.getChildren()).toEqual([div(), div()]);
<add> ReactNoop.render(<Foo condition={true} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={true} />);
<del> ReactNoop.flush();
<add> expect(ops).toEqual([]);
<add> expect(ReactNoop.getChildren()).toEqual([div()]);
<add> });
<ide>
<del> expect(ops).toEqual([]);
<del> expect(ReactNoop.getChildren()).toEqual([div()]);
<del> });
<add> it('should preserve state between array nested in fragment and fragment', function() {
<add> var ops = [];
<ide>
<del> it('should preserve state between array nested in fragment and fragment', function() {
<del> var ops = [];
<add> class Stateful extends React.Component {
<add> componentDidUpdate() {
<add> ops.push('Update Stateful');
<add> }
<ide>
<del> class Stateful extends React.Component {
<del> componentDidUpdate() {
<del> ops.push('Update Stateful');
<add> render() {
<add> return <div>Hello</div>;
<add> }
<ide> }
<ide>
<del> render() {
<del> return <div>Hello</div>;
<add> function Foo({condition}) {
<add> return condition
<add> ? <React.Fragment>
<add> <Stateful key="a" />
<add> </React.Fragment>
<add> : <React.Fragment>
<add> {[<Stateful key="a" />]}
<add> </React.Fragment>;
<ide> }
<del> }
<ide>
<del> function Foo({condition}) {
<del> return condition
<del> ? <React.Fragment>
<del> <Stateful key="a" />
<del> </React.Fragment>
<del> : <React.Fragment>
<del> {[<Stateful key="a" />]}
<del> </React.Fragment>;
<del> }
<add> ReactNoop.render(<Foo condition={true} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={true} />);
<del> ReactNoop.flush();
<add> ReactNoop.render(<Foo condition={false} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={false} />);
<del> ReactNoop.flush();
<add> expect(ops).toEqual(['Update Stateful']);
<add> expect(ReactNoop.getChildren()).toEqual([div()]);
<ide>
<del> expect(ops).toEqual(['Update Stateful']);
<del> expect(ReactNoop.getChildren()).toEqual([div()]);
<add> ReactNoop.render(<Foo condition={true} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={true} />);
<del> ReactNoop.flush();
<add> expect(ops).toEqual(['Update Stateful', 'Update Stateful']);
<add> expect(ReactNoop.getChildren()).toEqual([div()]);
<add> });
<ide>
<del> expect(ops).toEqual(['Update Stateful', 'Update Stateful']);
<del> expect(ReactNoop.getChildren()).toEqual([div()]);
<del> });
<add> it('should preserve state between top level fragment and array', function() {
<add> var ops = [];
<ide>
<del> it('should preserve state between top level fragment and array', function() {
<del> var ops = [];
<add> class Stateful extends React.Component {
<add> componentDidUpdate() {
<add> ops.push('Update Stateful');
<add> }
<ide>
<del> class Stateful extends React.Component {
<del> componentDidUpdate() {
<del> ops.push('Update Stateful');
<add> render() {
<add> return <div>Hello</div>;
<add> }
<ide> }
<ide>
<del> render() {
<del> return <div>Hello</div>;
<add> function Foo({condition}) {
<add> return condition
<add> ? [<Stateful key="a" />]
<add> : <React.Fragment>
<add> <Stateful key="a" />
<add> </React.Fragment>;
<ide> }
<del> }
<ide>
<del> function Foo({condition}) {
<del> return condition
<del> ? [<Stateful key="a" />]
<del> : <React.Fragment>
<del> <Stateful key="a" />
<del> </React.Fragment>;
<del> }
<add> ReactNoop.render(<Foo condition={true} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={true} />);
<del> ReactNoop.flush();
<add> ReactNoop.render(<Foo condition={false} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={false} />);
<del> ReactNoop.flush();
<add> expect(ops).toEqual(['Update Stateful']);
<add> expect(ReactNoop.getChildren()).toEqual([div()]);
<ide>
<del> expect(ops).toEqual(['Update Stateful']);
<del> expect(ReactNoop.getChildren()).toEqual([div()]);
<add> ReactNoop.render(<Foo condition={true} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={true} />);
<del> ReactNoop.flush();
<add> expect(ops).toEqual(['Update Stateful', 'Update Stateful']);
<add> expect(ReactNoop.getChildren()).toEqual([div()]);
<add> });
<ide>
<del> expect(ops).toEqual(['Update Stateful', 'Update Stateful']);
<del> expect(ReactNoop.getChildren()).toEqual([div()]);
<del> });
<add> it('should not preserve state between array nested in fragment and double nested fragment', function() {
<add> var ops = [];
<ide>
<del> it('should not preserve state between array nested in fragment and double nested fragment', function() {
<del> var ops = [];
<add> class Stateful extends React.Component {
<add> componentDidUpdate() {
<add> ops.push('Update Stateful');
<add> }
<ide>
<del> class Stateful extends React.Component {
<del> componentDidUpdate() {
<del> ops.push('Update Stateful');
<add> render() {
<add> return <div>Hello</div>;
<add> }
<ide> }
<ide>
<del> render() {
<del> return <div>Hello</div>;
<add> function Foo({condition}) {
<add> return condition
<add> ? <React.Fragment>{[<Stateful key="a" />]}</React.Fragment>
<add> : <React.Fragment>
<add> <React.Fragment><Stateful key="a" /></React.Fragment>
<add> </React.Fragment>;
<ide> }
<del> }
<ide>
<del> function Foo({condition}) {
<del> return condition
<del> ? <React.Fragment>{[<Stateful key="a" />]}</React.Fragment>
<del> : <React.Fragment>
<del> <React.Fragment><Stateful key="a" /></React.Fragment>
<del> </React.Fragment>;
<del> }
<add> ReactNoop.render(<Foo condition={true} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={true} />);
<del> ReactNoop.flush();
<add> ReactNoop.render(<Foo condition={false} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={false} />);
<del> ReactNoop.flush();
<add> expect(ops).toEqual([]);
<add> expect(ReactNoop.getChildren()).toEqual([div()]);
<ide>
<del> expect(ops).toEqual([]);
<del> expect(ReactNoop.getChildren()).toEqual([div()]);
<add> ReactNoop.render(<Foo condition={true} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={true} />);
<del> ReactNoop.flush();
<add> expect(ops).toEqual([]);
<add> expect(ReactNoop.getChildren()).toEqual([div()]);
<add> });
<ide>
<del> expect(ops).toEqual([]);
<del> expect(ReactNoop.getChildren()).toEqual([div()]);
<del> });
<add> it('should not preserve state between array nested in fragment and double nested array', function() {
<add> var ops = [];
<ide>
<del> it('should not preserve state between array nested in fragment and double nested array', function() {
<del> var ops = [];
<add> class Stateful extends React.Component {
<add> componentDidUpdate() {
<add> ops.push('Update Stateful');
<add> }
<ide>
<del> class Stateful extends React.Component {
<del> componentDidUpdate() {
<del> ops.push('Update Stateful');
<add> render() {
<add> return <div>Hello</div>;
<add> }
<ide> }
<ide>
<del> render() {
<del> return <div>Hello</div>;
<add> function Foo({condition}) {
<add> return condition
<add> ? <React.Fragment>{[<Stateful key="a" />]}</React.Fragment>
<add> : [[<Stateful key="a" />]];
<ide> }
<del> }
<ide>
<del> function Foo({condition}) {
<del> return condition
<del> ? <React.Fragment>{[<Stateful key="a" />]}</React.Fragment>
<del> : [[<Stateful key="a" />]];
<del> }
<add> ReactNoop.render(<Foo condition={true} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={true} />);
<del> ReactNoop.flush();
<add> ReactNoop.render(<Foo condition={false} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={false} />);
<del> ReactNoop.flush();
<add> expect(ops).toEqual([]);
<add> expect(ReactNoop.getChildren()).toEqual([div()]);
<ide>
<del> expect(ops).toEqual([]);
<del> expect(ReactNoop.getChildren()).toEqual([div()]);
<add> ReactNoop.render(<Foo condition={true} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={true} />);
<del> ReactNoop.flush();
<add> expect(ops).toEqual([]);
<add> expect(ReactNoop.getChildren()).toEqual([div()]);
<add> });
<ide>
<del> expect(ops).toEqual([]);
<del> expect(ReactNoop.getChildren()).toEqual([div()]);
<del> });
<add> it('should preserve state between double nested fragment and double nested array', function() {
<add> var ops = [];
<ide>
<del> it('should preserve state between double nested fragment and double nested array', function() {
<del> var ops = [];
<add> class Stateful extends React.Component {
<add> componentDidUpdate() {
<add> ops.push('Update Stateful');
<add> }
<ide>
<del> class Stateful extends React.Component {
<del> componentDidUpdate() {
<del> ops.push('Update Stateful');
<add> render() {
<add> return <div>Hello</div>;
<add> }
<ide> }
<ide>
<del> render() {
<del> return <div>Hello</div>;
<add> function Foo({condition}) {
<add> return condition
<add> ? <React.Fragment>
<add> <React.Fragment><Stateful key="a" /></React.Fragment>
<add> </React.Fragment>
<add> : [[<Stateful key="a" />]];
<ide> }
<del> }
<ide>
<del> function Foo({condition}) {
<del> return condition
<del> ? <React.Fragment>
<del> <React.Fragment><Stateful key="a" /></React.Fragment>
<del> </React.Fragment>
<del> : [[<Stateful key="a" />]];
<del> }
<add> ReactNoop.render(<Foo condition={true} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={true} />);
<del> ReactNoop.flush();
<add> ReactNoop.render(<Foo condition={false} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={false} />);
<del> ReactNoop.flush();
<add> expect(ops).toEqual(['Update Stateful']);
<add> expect(ReactNoop.getChildren()).toEqual([div()]);
<ide>
<del> expect(ops).toEqual(['Update Stateful']);
<del> expect(ReactNoop.getChildren()).toEqual([div()]);
<add> ReactNoop.render(<Foo condition={true} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={true} />);
<del> ReactNoop.flush();
<add> expect(ops).toEqual(['Update Stateful', 'Update Stateful']);
<add> expect(ReactNoop.getChildren()).toEqual([div()]);
<add> });
<ide>
<del> expect(ops).toEqual(['Update Stateful', 'Update Stateful']);
<del> expect(ReactNoop.getChildren()).toEqual([div()]);
<del> });
<add> it('should not preserve state of children when the keys are different', function() {
<add> var ops = [];
<ide>
<del> it('should not preserve state of children when the keys are different', function() {
<del> var ops = [];
<add> class Stateful extends React.Component {
<add> componentDidUpdate() {
<add> ops.push('Update Stateful');
<add> }
<ide>
<del> class Stateful extends React.Component {
<del> componentDidUpdate() {
<del> ops.push('Update Stateful');
<add> render() {
<add> return <div>Hello</div>;
<add> }
<ide> }
<ide>
<del> render() {
<del> return <div>Hello</div>;
<add> function Foo({condition}) {
<add> return condition
<add> ? <React.Fragment key="a">
<add> <Stateful />
<add> </React.Fragment>
<add> : <React.Fragment key="b">
<add> <Stateful />
<add> <span>World</span>
<add> </React.Fragment>;
<ide> }
<del> }
<ide>
<del> function Foo({condition}) {
<del> return condition
<del> ? <React.Fragment key="a">
<del> <Stateful />
<del> </React.Fragment>
<del> : <React.Fragment key="b">
<del> <Stateful />
<del> <span>World</span>
<del> </React.Fragment>;
<del> }
<add> ReactNoop.render(<Foo condition={true} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={true} />);
<del> ReactNoop.flush();
<add> ReactNoop.render(<Foo condition={false} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={false} />);
<del> ReactNoop.flush();
<add> expect(ops).toEqual([]);
<add> expect(ReactNoop.getChildren()).toEqual([div(), span()]);
<ide>
<del> expect(ops).toEqual([]);
<del> expect(ReactNoop.getChildren()).toEqual([div(), span()]);
<add> ReactNoop.render(<Foo condition={true} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={true} />);
<del> ReactNoop.flush();
<add> expect(ops).toEqual([]);
<add> expect(ReactNoop.getChildren()).toEqual([div()]);
<add> });
<ide>
<del> expect(ops).toEqual([]);
<del> expect(ReactNoop.getChildren()).toEqual([div()]);
<del> });
<add> it('should not preserve state between unkeyed and keyed fragment', function() {
<add> var ops = [];
<ide>
<del> it('should not preserve state between unkeyed and keyed fragment', function() {
<del> var ops = [];
<add> class Stateful extends React.Component {
<add> componentDidUpdate() {
<add> ops.push('Update Stateful');
<add> }
<ide>
<del> class Stateful extends React.Component {
<del> componentDidUpdate() {
<del> ops.push('Update Stateful');
<add> render() {
<add> return <div>Hello</div>;
<add> }
<ide> }
<ide>
<del> render() {
<del> return <div>Hello</div>;
<add> function Foo({condition}) {
<add> return condition
<add> ? <React.Fragment key="a">
<add> <Stateful />
<add> </React.Fragment>
<add> : <React.Fragment>
<add> <Stateful />
<add> </React.Fragment>;
<ide> }
<del> }
<ide>
<del> function Foo({condition}) {
<del> return condition
<del> ? <React.Fragment key="a">
<del> <Stateful />
<del> </React.Fragment>
<del> : <React.Fragment>
<del> <Stateful />
<del> </React.Fragment>;
<del> }
<add> ReactNoop.render(<Foo condition={true} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={true} />);
<del> ReactNoop.flush();
<add> ReactNoop.render(<Foo condition={false} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={false} />);
<del> ReactNoop.flush();
<add> expect(ops).toEqual([]);
<add> expect(ReactNoop.getChildren()).toEqual([div()]);
<ide>
<del> expect(ops).toEqual([]);
<del> expect(ReactNoop.getChildren()).toEqual([div()]);
<add> ReactNoop.render(<Foo condition={true} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={true} />);
<del> ReactNoop.flush();
<add> expect(ops).toEqual([]);
<add> expect(ReactNoop.getChildren()).toEqual([div()]);
<add> });
<ide>
<del> expect(ops).toEqual([]);
<del> expect(ReactNoop.getChildren()).toEqual([div()]);
<del> });
<add> it('should preserve state with reordering in multiple levels', function() {
<add> var ops = [];
<ide>
<del> it('should preserve state with reordering in multiple levels', function() {
<del> var ops = [];
<add> class Stateful extends React.Component {
<add> componentDidUpdate() {
<add> ops.push('Update Stateful');
<add> }
<ide>
<del> class Stateful extends React.Component {
<del> componentDidUpdate() {
<del> ops.push('Update Stateful');
<add> render() {
<add> return <div>Hello</div>;
<add> }
<ide> }
<ide>
<del> render() {
<del> return <div>Hello</div>;
<add> function Foo({condition}) {
<add> return condition
<add> ? <div>
<add> <React.Fragment key="c">
<add> <span>foo</span>
<add> <div key="b">
<add> <Stateful key="a" />
<add> </div>
<add> </React.Fragment>
<add> <span>boop</span>
<add> </div>
<add> : <div>
<add> <span>beep</span>
<add> <React.Fragment key="c">
<add> <div key="b">
<add> <Stateful key="a" />
<add> </div>
<add> <span>bar</span>
<add> </React.Fragment>
<add> </div>;
<ide> }
<del> }
<ide>
<del> function Foo({condition}) {
<del> return condition
<del> ? <div>
<del> <React.Fragment key="c">
<del> <span>foo</span>
<del> <div key="b">
<del> <Stateful key="a" />
<del> </div>
<del> </React.Fragment>
<del> <span>boop</span>
<del> </div>
<del> : <div>
<del> <span>beep</span>
<del> <React.Fragment key="c">
<del> <div key="b">
<del> <Stateful key="a" />
<del> </div>
<del> <span>bar</span>
<del> </React.Fragment>
<del> </div>;
<del> }
<add> ReactNoop.render(<Foo condition={true} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={true} />);
<del> ReactNoop.flush();
<add> ReactNoop.render(<Foo condition={false} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={false} />);
<del> ReactNoop.flush();
<add> expect(ops).toEqual(['Update Stateful']);
<add> expect(ReactNoop.getChildren()).toEqual([
<add> div(span(), div(div()), span()),
<add> ]);
<ide>
<del> expect(ops).toEqual(['Update Stateful']);
<del> expect(ReactNoop.getChildren()).toEqual([div(span(), div(div()), span())]);
<add> ReactNoop.render(<Foo condition={true} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={true} />);
<del> ReactNoop.flush();
<add> expect(ops).toEqual(['Update Stateful', 'Update Stateful']);
<add> expect(ReactNoop.getChildren()).toEqual([
<add> div(span(), div(div()), span()),
<add> ]);
<add> });
<ide>
<del> expect(ops).toEqual(['Update Stateful', 'Update Stateful']);
<del> expect(ReactNoop.getChildren()).toEqual([div(span(), div(div()), span())]);
<del> });
<add> it('should not preserve state when switching to a keyed fragment to an array', function() {
<add> spyOn(console, 'error');
<add> var ops = [];
<ide>
<del> it('should not preserve state when switching to a keyed fragment to an array', function() {
<del> spyOn(console, 'error');
<del> var ops = [];
<add> class Stateful extends React.Component {
<add> componentDidUpdate() {
<add> ops.push('Update Stateful');
<add> }
<ide>
<del> class Stateful extends React.Component {
<del> componentDidUpdate() {
<del> ops.push('Update Stateful');
<add> render() {
<add> return <div>Hello</div>;
<add> }
<ide> }
<ide>
<del> render() {
<del> return <div>Hello</div>;
<add> function Foo({condition}) {
<add> return condition
<add> ? <div>
<add> {<React.Fragment key="foo"><Stateful /></React.Fragment>}<span />
<add> </div>
<add> : <div>{[<Stateful />]}<span /></div>;
<ide> }
<del> }
<ide>
<del> function Foo({condition}) {
<del> return condition
<del> ? <div>
<del> {<React.Fragment key="foo"><Stateful /></React.Fragment>}<span />
<del> </div>
<del> : <div>{[<Stateful />]}<span /></div>;
<del> }
<add> ReactNoop.render(<Foo condition={true} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={true} />);
<del> ReactNoop.flush();
<add> ReactNoop.render(<Foo condition={false} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={false} />);
<del> ReactNoop.flush();
<add> expect(ops).toEqual([]);
<add> expect(ReactNoop.getChildren()).toEqual([div(div(), span())]);
<ide>
<del> expect(ops).toEqual([]);
<del> expect(ReactNoop.getChildren()).toEqual([div(div(), span())]);
<add> ReactNoop.render(<Foo condition={true} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={true} />);
<del> ReactNoop.flush();
<add> expect(ops).toEqual([]);
<add> expect(ReactNoop.getChildren()).toEqual([div(div(), span())]);
<add> expectDev(console.error.calls.count()).toBe(1);
<add> expectDev(console.error.calls.argsFor(0)[0]).toContain(
<add> 'Each child in an array or iterator should have a unique "key" prop.',
<add> );
<add> });
<ide>
<del> expect(ops).toEqual([]);
<del> expect(ReactNoop.getChildren()).toEqual([div(div(), span())]);
<del> expectDev(console.error.calls.count()).toBe(1);
<del> expectDev(console.error.calls.argsFor(0)[0]).toContain(
<del> 'Each child in an array or iterator should have a unique "key" prop.',
<del> );
<del> });
<add> it('should preserve state when it does not change positions', function() {
<add> spyOn(console, 'error');
<add> var ops = [];
<ide>
<del> it('should preserve state when it does not change positions', function() {
<del> spyOn(console, 'error');
<del> var ops = [];
<add> class Stateful extends React.Component {
<add> componentDidUpdate() {
<add> ops.push('Update Stateful');
<add> }
<ide>
<del> class Stateful extends React.Component {
<del> componentDidUpdate() {
<del> ops.push('Update Stateful');
<add> render() {
<add> return <div>Hello</div>;
<add> }
<ide> }
<ide>
<del> render() {
<del> return <div>Hello</div>;
<add> function Foo({condition}) {
<add> return condition
<add> ? [<span />, <React.Fragment><Stateful /></React.Fragment>]
<add> : [<span />, <React.Fragment><Stateful /></React.Fragment>];
<ide> }
<del> }
<ide>
<del> function Foo({condition}) {
<del> return condition
<del> ? [<span />, <React.Fragment><Stateful /></React.Fragment>]
<del> : [<span />, <React.Fragment><Stateful /></React.Fragment>];
<del> }
<add> ReactNoop.render(<Foo condition={true} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={true} />);
<del> ReactNoop.flush();
<add> ReactNoop.render(<Foo condition={false} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={false} />);
<del> ReactNoop.flush();
<add> expect(ops).toEqual(['Update Stateful']);
<add> expect(ReactNoop.getChildren()).toEqual([span(), div()]);
<ide>
<del> expect(ops).toEqual(['Update Stateful']);
<del> expect(ReactNoop.getChildren()).toEqual([span(), div()]);
<add> ReactNoop.render(<Foo condition={true} />);
<add> ReactNoop.flush();
<ide>
<del> ReactNoop.render(<Foo condition={true} />);
<del> ReactNoop.flush();
<del>
<del> expect(ops).toEqual(['Update Stateful', 'Update Stateful']);
<del> expect(ReactNoop.getChildren()).toEqual([span(), div()]);
<del> expectDev(console.error.calls.count()).toBe(3);
<del> for (let errorIndex = 0; errorIndex < 3; ++errorIndex) {
<del> expectDev(console.error.calls.argsFor(errorIndex)[0]).toContain(
<del> 'Each child in an array or iterator should have a unique "key" prop.',
<del> );
<del> }
<del> });
<add> expect(ops).toEqual(['Update Stateful', 'Update Stateful']);
<add> expect(ReactNoop.getChildren()).toEqual([span(), div()]);
<add> expectDev(console.error.calls.count()).toBe(3);
<add> for (let errorIndex = 0; errorIndex < 3; ++errorIndex) {
<add> expectDev(console.error.calls.argsFor(errorIndex)[0]).toContain(
<add> 'Each child in an array or iterator should have a unique "key" prop.',
<add> );
<add> }
<add> });
<add> } else {
<add> it('should not run any tests', function() {});
<add> }
<ide> });
<ide><path>packages/react/src/React.js
<ide> 'use strict';
<ide>
<ide> var ReactVersion = require('shared/ReactVersion');
<add>var ReactFeatureFlags = require('shared/ReactFeatureFlags');
<ide>
<ide> var ReactBaseClasses = require('./ReactBaseClasses');
<ide> var ReactChildren = require('./ReactChildren');
<ide> var React = {
<ide> Component: ReactBaseClasses.Component,
<ide> PureComponent: ReactBaseClasses.PureComponent,
<ide> unstable_AsyncComponent: ReactBaseClasses.AsyncComponent,
<del> Fragment: REACT_FRAGMENT_TYPE,
<ide>
<ide> createElement: createElement,
<ide> cloneElement: cloneElement,
<ide> var React = {
<ide> },
<ide> };
<ide>
<add>if (ReactFeatureFlags.enableReactFragment) {
<add> React.Fragment = REACT_FRAGMENT_TYPE;
<add>}
<add>
<ide> if (__DEV__) {
<ide> Object.assign(React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, {
<ide> // These should not be included in production.
<ide><path>packages/react/src/__tests__/ReactJSXElementValidator-test.js
<ide>
<ide> 'use strict';
<ide>
<add>var ReactFeatureFlags = require('shared/ReactFeatureFlags');
<add>
<ide> // TODO: All these warnings should become static errors using Flow instead
<ide> // of dynamic errors when using JSX with Flow.
<ide> var React;
<ide> describe('ReactJSXElementValidator', () => {
<ide> );
<ide> });
<ide>
<del> it('warns for fragments with illegal attributes', () => {
<del> spyOn(console, 'error');
<add> if (ReactFeatureFlags.enableReactFragment) {
<add> it('warns for fragments with illegal attributes', () => {
<add> spyOn(console, 'error');
<ide>
<del> class Foo extends React.Component {
<del> render() {
<del> return <React.Fragment a={1} b={2}>hello</React.Fragment>;
<add> class Foo extends React.Component {
<add> render() {
<add> return <React.Fragment a={1} b={2}>hello</React.Fragment>;
<add> }
<ide> }
<del> }
<del>
<del> ReactTestUtils.renderIntoDocument(<Foo />);
<ide>
<del> expectDev(console.error.calls.count()).toBe(1);
<del> expectDev(console.error.calls.argsFor(0)[0]).toContain('Invalid prop `');
<del> expectDev(console.error.calls.argsFor(0)[0]).toContain(
<del> '` supplied to `React.Fragment`. React.Fragment ' +
<del> 'can only have `key` and `children` props.',
<del> );
<del> });
<add> ReactTestUtils.renderIntoDocument(<Foo />);
<ide>
<del> it('warns for fragments with refs', () => {
<del> spyOn(console, 'error');
<add> expectDev(console.error.calls.count()).toBe(1);
<add> expectDev(console.error.calls.argsFor(0)[0]).toContain('Invalid prop `');
<add> expectDev(console.error.calls.argsFor(0)[0]).toContain(
<add> '` supplied to `React.Fragment`. React.Fragment ' +
<add> 'can only have `key` and `children` props.',
<add> );
<add> });
<ide>
<del> class Foo extends React.Component {
<del> render() {
<del> return (
<del> <React.Fragment
<del> ref={bar => {
<del> this.foo = bar;
<del> }}>
<del> hello
<del> </React.Fragment>
<del> );
<add> it('warns for fragments with refs', () => {
<add> spyOn(console, 'error');
<add>
<add> class Foo extends React.Component {
<add> render() {
<add> return (
<add> <React.Fragment
<add> ref={bar => {
<add> this.foo = bar;
<add> }}>
<add> hello
<add> </React.Fragment>
<add> );
<add> }
<ide> }
<del> }
<ide>
<del> ReactTestUtils.renderIntoDocument(<Foo />);
<add> ReactTestUtils.renderIntoDocument(<Foo />);
<ide>
<del> expectDev(console.error.calls.count()).toBe(1);
<del> expectDev(console.error.calls.argsFor(0)[0]).toContain(
<del> 'Invalid attribute `ref` supplied to `React.Fragment`.',
<del> );
<del> });
<add> expectDev(console.error.calls.count()).toBe(1);
<add> expectDev(console.error.calls.argsFor(0)[0]).toContain(
<add> 'Invalid attribute `ref` supplied to `React.Fragment`.',
<add> );
<add> });
<add> }
<ide>
<ide> it('warns for keys for iterables of elements in rest args', () => {
<ide> spyOn(console, 'error');
<ide> describe('ReactJSXElementValidator', () => {
<ide> );
<ide> });
<ide>
<del> it('does not warn for fragments of multiple elements without keys', () => {
<del> ReactTestUtils.renderIntoDocument(
<del> <React.Fragment>
<del> <span>1</span>
<del> <span>2</span>
<del> </React.Fragment>,
<del> );
<del> });
<del>
<del> it('warns for fragments of multiple elements with same key', () => {
<del> spyOn(console, 'error');
<del>
<del> ReactTestUtils.renderIntoDocument(
<del> <React.Fragment>
<del> <span key="a">1</span>
<del> <span key="a">2</span>
<del> <span key="b">3</span>
<del> </React.Fragment>,
<del> );
<add> if (ReactFeatureFlags.enableReactFragment) {
<add> it('does not warn for fragments of multiple elements without keys', () => {
<add> ReactTestUtils.renderIntoDocument(
<add> <React.Fragment>
<add> <span>1</span>
<add> <span>2</span>
<add> </React.Fragment>,
<add> );
<add> });
<ide>
<del> expectDev(console.error.calls.count()).toBe(1);
<del> expectDev(console.error.calls.argsFor(0)[0]).toContain(
<del> 'Encountered two children with the same key, `a`.',
<del> );
<del> });
<add> it('warns for fragments of multiple elements with same key', () => {
<add> spyOn(console, 'error');
<add>
<add> ReactTestUtils.renderIntoDocument(
<add> <React.Fragment>
<add> <span key="a">1</span>
<add> <span key="a">2</span>
<add> <span key="b">3</span>
<add> </React.Fragment>,
<add> );
<add>
<add> expectDev(console.error.calls.count()).toBe(1);
<add> expectDev(console.error.calls.argsFor(0)[0]).toContain(
<add> 'Encountered two children with the same key, `a`.',
<add> );
<add> });
<add> }
<ide>
<ide> it('does not warn for arrays of elements with keys', () => {
<ide> spyOn(console, 'error');
<ide><path>packages/shared/ReactFeatureFlags.js
<ide> export type FeatureFlags = {|
<ide> enableMutatingReconciler: boolean,
<ide> enableNoopReconciler: boolean,
<ide> enablePersistentReconciler: boolean,
<add> enableReactFragment: boolean,
<ide> |};
<ide>
<ide> var ReactFeatureFlags: FeatureFlags = {
<ide> var ReactFeatureFlags: FeatureFlags = {
<ide> enableNoopReconciler: false,
<ide> // Experimental persistent mode (CS):
<ide> enablePersistentReconciler: false,
<add> // Exports React.Fragment
<add> enableReactFragment: false,
<ide> };
<ide>
<ide> if (__DEV__) { | 7 |
Ruby | Ruby | fix has_one through reflection casting check | d739c835bc0dfe9d2ee4d6a7588df7989f756480 | <ide><path>activerecord/lib/active_record/reflection.rb
<ide> def through_reflection?
<ide> def klass
<ide> @klass ||= delegate_reflection.compute_class(class_name).tap do |klass|
<ide> if !parent_reflection.is_a?(HasAndBelongsToManyReflection) &&
<del> !klass.reflections.include?(options[:through].to_s) &&
<add> !(klass.reflections.key?(options[:through].to_s) ||
<add> klass.reflections.key?(options[:through].to_s.pluralize)) &&
<ide> active_record.type_for_attribute(active_record.primary_key).type != :integer
<ide> raise NotImplementedError, <<~MSG.squish
<ide> In order to correctly type cast #{active_record}.#{active_record.primary_key},
<ide><path>activerecord/test/cases/reflection_test.rb
<ide> def test_has_many_through_reflection
<ide> assert_kind_of ThroughReflection, Subscriber.reflect_on_association(:books)
<ide> end
<ide>
<del> def test_uncastable_has_many_through_reflection
<del> error = assert_raises(NotImplementedError) { Subscriber.new.published_books }
<del> assert_equal <<~MSG.squish, error.message
<del> In order to correctly type cast Subscriber.nick,
<del> PublishedBook needs to define a :subscriptions association.
<del> MSG
<del> end
<del>
<ide> def test_chain
<ide> expected = [
<ide> Organization.reflect_on_association(:author_essay_categories),
<ide> def assert_reflection(klass, association, options)
<ide> end
<ide> end
<ide> end
<add>
<add>class UncastableReflectionTest < ActiveRecord::TestCase
<add> class Book < ActiveRecord::Base
<add> end
<add>
<add> class Subscription < ActiveRecord::Base
<add> belongs_to :subscriber
<add> belongs_to :book
<add> end
<add>
<add> class Subscriber < ActiveRecord::Base
<add> self.primary_key = "nick"
<add> has_many :subscriptions
<add> has_one :subscription
<add> has_many :books, through: :subscriptions
<add> has_one :book, through: :subscription
<add> end
<add>
<add> setup do
<add> @subscriber = Subscriber.create!(nick: "unique")
<add> end
<add>
<add> teardown do
<add> Book._reflections.clear
<add> Book.clear_reflections_cache
<add> Subscriber.has_many :books, through: :subscriptions
<add> Subscriber.has_one :book, through: :subscription
<add> end
<add>
<add> test "uncastable has_many through: reflection" do
<add> error = assert_raises(NotImplementedError) { @subscriber.books }
<add> assert_equal <<~MSG.squish, error.message
<add> In order to correctly type cast UncastableReflectionTest::Subscriber.nick,
<add> UncastableReflectionTest::Book needs to define a :subscriptions association.
<add> MSG
<add> end
<add>
<add> test "fixing uncastable has_many through: reflection with has_many" do
<add> Book.has_many :subscriptions
<add> @subscriber.books
<add> end
<add>
<add> test "uncastable has_one through: reflection" do
<add> error = assert_raises(NotImplementedError) { @subscriber.book }
<add>
<add> assert_equal <<~MSG.squish, error.message
<add> In order to correctly type cast UncastableReflectionTest::Subscriber.nick,
<add> UncastableReflectionTest::Book needs to define a :subscription association.
<add> MSG
<add> end
<add>
<add> test "fixing uncastable has_one through: reflection with has_many" do
<add> Book.has_many :subscriptions
<add> @subscriber.book
<add> end
<add>
<add> test "fixing uncastable has_one through: reflection with has_one" do
<add> Book.has_one :subscription
<add> @subscriber.book
<add> end
<add>end | 2 |
Ruby | Ruby | add actioncontroller#head example | 419d4c09dfcc5cbd898ce52d779603c6a29ac3bc | <ide><path>actionpack/lib/action_controller/metal/head.rb
<ide> module Head
<ide> #
<ide> # head :created, :location => person_path(@person)
<ide> #
<add> # head :created, :location => @person
<add> #
<ide> # It can also be used to return exceptional conditions:
<ide> #
<ide> # return head(:method_not_allowed) unless request.post? | 1 |
PHP | PHP | propagate root names to sub commands | 2489da888a2aa03879a8ed860fd7482956682c1b | <ide><path>src/Console/ConsoleOptionParser.php
<ide> public function help($subcommand = null, $format = 'text', $width = 72)
<ide> $subparser->setDescription($command->getRawHelp());
<ide> }
<ide> $subparser->setCommand($this->getCommand() . ' ' . $subcommand);
<add> $subparser->setRootName($this->rootName);
<ide>
<ide> return $subparser->help(null, $format, $width);
<ide> }
<ide><path>tests/TestCase/Console/ConsoleOptionParserTest.php
<ide> public function testHelpSubcommandHelpArray()
<ide>
<ide> $parser = new ConsoleOptionParser('mycommand', false);
<ide> $parser->addSubcommand('method', [
<del> 'help' => 'This is a subcommand',
<del> 'parser' => $subParser
<del> ])
<add> 'help' => 'This is a subcommand',
<add> 'parser' => $subParser
<add> ])
<add> ->setRootName('tool')
<ide> ->addOption('test', ['help' => 'A test option.']);
<ide>
<ide> $result = $parser->help('method');
<ide> $expected = <<<TEXT
<ide> This is a subcommand
<ide>
<ide> <info>Usage:</info>
<del>cake mycommand method [-f] [-h] [-q] [-v]
<add>tool mycommand method [-f] [-h] [-q] [-v]
<ide>
<ide> <info>Options:</info>
<ide> | 2 |
Java | Java | remove redundant check | ab96bb54280544fb060ecad6d80bf39617b28dc7 | <ide><path>spring-webflux/src/main/java/org/springframework/web/reactive/result/view/AbstractView.java
<ide> public AbstractView(ReactiveAdapterRegistry registry) {
<ide> public void setSupportedMediaTypes(@Nullable List<MediaType> supportedMediaTypes) {
<ide> Assert.notEmpty(supportedMediaTypes, "MediaType List must not be empty");
<ide> this.mediaTypes.clear();
<del> if (supportedMediaTypes != null) {
<del> this.mediaTypes.addAll(supportedMediaTypes);
<del> }
<add> this.mediaTypes.addAll(supportedMediaTypes);
<ide> }
<ide>
<ide> /**
<ide><path>spring-webflux/src/main/java/org/springframework/web/reactive/result/view/ViewResolverSupport.java
<ide> public ViewResolverSupport() {
<ide> public void setSupportedMediaTypes(@Nullable List<MediaType> supportedMediaTypes) {
<ide> Assert.notEmpty(supportedMediaTypes, "MediaType List must not be empty");
<ide> this.mediaTypes.clear();
<del> if (supportedMediaTypes != null) {
<del> this.mediaTypes.addAll(supportedMediaTypes);
<del> }
<add> this.mediaTypes.addAll(supportedMediaTypes);
<ide> }
<ide>
<ide> /** | 2 |
Java | Java | fix jira issue number in @ignore comments | c0e4387cbcb9ef0b62372ae8a7a0fbca567b955a | <ide><path>spring-orm/src/test/java/org/springframework/orm/jpa/openjpa/OpenJpaEntityManagerFactoryWithAspectJWeavingIntegrationTests.java
<ide> * @author Ramnivas Laddad
<ide> * @author Chris Beams
<ide> */
<del>@Ignore("This test causes gradle to hang. See SPR-103333.")
<add>@Ignore("This test causes gradle to hang. See SPR-10333.")
<ide> public class OpenJpaEntityManagerFactoryWithAspectJWeavingIntegrationTests extends OpenJpaEntityManagerFactoryIntegrationTests {
<ide>
<ide> @Override
<ide><path>spring-orm/src/test/java/org/springframework/orm/jpa/toplink/TopLinkMultiEntityManagerFactoryIntegrationTests.java
<ide> * @author Costin Leau
<ide> * @author Chris Beams
<ide> */
<del>@Ignore("This test causes gradle to hang. See SPR-103333.")
<add>@Ignore("This test causes gradle to hang. See SPR-10333.")
<ide> public class TopLinkMultiEntityManagerFactoryIntegrationTests extends
<ide> AbstractContainerEntityManagerFactoryIntegrationTests {
<ide> | 2 |
Python | Python | add error message in oom situations | 18e2c1de776c8c3bc42c984ea0d31515788b6572 | <ide><path>airflow/task/task_runner/standard_task_runner.py
<ide> def terminate(self):
<ide> if self._rc is None:
<ide> # Something else reaped it before we had a chance, so let's just "guess" at an error code.
<ide> self._rc = -9
<add>
<add> if self._rc == -9:
<add> # If either we or psutil gives out a -9 return code, it likely means
<add> # an OOM happened
<add> self.log.error(
<add> 'Job %s was killed before it finished (likely due to running out of memory)',
<add> self._task_instance.job_id,
<add> )
<ide><path>tests/task/task_runner/test_standard_task_runner.py
<ide> import logging
<ide> import os
<ide> import time
<del>import unittest
<ide> from logging.config import dictConfig
<ide> from unittest import mock
<ide>
<ide> import psutil
<add>import pytest
<ide>
<ide> from airflow import models, settings
<ide> from airflow.jobs.local_task_job import LocalTaskJob
<ide> 'class': 'logging.StreamHandler',
<ide> 'formatter': 'airflow.task',
<ide> 'stream': 'ext://sys.stdout',
<del> }
<add> },
<ide> },
<del> 'loggers': {'airflow': {'handlers': ['console'], 'level': 'INFO', 'propagate': False}},
<add> 'loggers': {'airflow': {'handlers': ['console'], 'level': 'INFO', 'propagate': True}},
<ide> }
<ide>
<ide>
<del>class TestStandardTaskRunner(unittest.TestCase):
<del> @classmethod
<del> def setUpClass(cls):
<add>class TestStandardTaskRunner:
<add> @pytest.fixture(autouse=True, scope="class")
<add> def logging_and_db(self):
<add> """
<add> This fixture sets up logging to have a different setup on the way in
<add> (as the test environment does not have enough context for the normal
<add> way to run) and ensures they reset back to normal on the way out.
<add> """
<ide> dictConfig(LOGGING_CONFIG)
<del>
<del> @classmethod
<del> def tearDownClass(cls):
<add> yield
<ide> airflow_logger = logging.getLogger('airflow')
<ide> airflow_logger.handlers = []
<del> airflow_logger.propagate = True
<ide> try:
<ide> clear_db_runs()
<ide> except Exception: # noqa pylint: disable=broad-except
<ide> def test_start_and_terminate_run_as_user(self):
<ide>
<ide> assert runner.return_code() is not None
<ide>
<add> def test_early_reap_exit(self, caplog):
<add> """
<add> Tests that when a child process running a task is killed externally
<add> (e.g. by an OOM error, which we fake here), then we get return code
<add> -9 and a log message.
<add> """
<add> # Set up mock task
<add> local_task_job = mock.Mock()
<add> local_task_job.task_instance = mock.MagicMock()
<add> local_task_job.task_instance.run_as_user = getpass.getuser()
<add> local_task_job.task_instance.command_as_list.return_value = [
<add> 'airflow',
<add> 'tasks',
<add> 'test',
<add> 'test_on_kill',
<add> 'task1',
<add> '2016-01-01',
<add> ]
<add>
<add> # Kick off the runner
<add> runner = StandardTaskRunner(local_task_job)
<add> runner.start()
<add> time.sleep(0.2)
<add>
<add> # Kill the child process externally from the runner
<add> # Note that we have to do this from ANOTHER process, as if we just
<add> # call os.kill here we're doing it from the parent process and it
<add> # won't be the same as an external kill in terms of OS tracking.
<add> pgid = os.getpgid(runner.process.pid)
<add> os.system(f"kill -s KILL {pgid}")
<add> time.sleep(0.2)
<add>
<add> runner.terminate()
<add>
<add> assert runner.return_code() == -9
<add> assert "running out of memory" in caplog.text
<add>
<ide> def test_on_kill(self):
<ide> """
<ide> Test that ensures that clearing in the UI SIGTERMS | 2 |
PHP | PHP | apply fixes from styleci | 01a1474aa2fad999902b606efaa214dd7d607178 | <ide><path>src/Illuminate/Foundation/Vite.php
<ide> public function reactRefresh()
<ide> }
<ide>
<ide> $attributes = $this->parseAttributes([
<del> 'nonce' => $this->cspNonce()
<add> 'nonce' => $this->cspNonce(),
<ide> ]);
<ide>
<ide> return new HtmlString( | 1 |
PHP | PHP | remove unused "closure" class import | 9fade488f9f427fe140cef4e59f5d6d257fd00bd | <ide><path>src/Illuminate/Validation/Validator.php
<ide>
<ide> namespace Illuminate\Validation;
<ide>
<del>use Closure;
<ide> use RuntimeException;
<ide> use BadMethodCallException;
<ide> use Illuminate\Support\Arr; | 1 |
Javascript | Javascript | fix mocks in navigationexperimental | 21ee7fde6e6f3054fe15e77e3d61cacca2948608 | <ide><path>Libraries/NavigationExperimental/Reducer/__tests__/NavigationFindReducer-test.js
<ide> 'use strict';
<ide>
<ide> jest
<del> .autoMockOff()
<del> .mock('ErrorUtils');
<add> .dontMock('NavigationFindReducer');
<ide>
<ide> const NavigationFindReducer = require('NavigationFindReducer');
<ide>
<ide><path>Libraries/NavigationExperimental/Reducer/__tests__/NavigationStackReducer-test.js
<ide> 'use strict';
<ide>
<ide> jest
<del> .autoMockOff()
<del> .mock('ErrorUtils');
<add> .dontMock('NavigationRootContainer')
<add> .dontMock('NavigationStackReducer')
<add> .dontMock('NavigationStateUtils');
<add>
<add>jest.setMock('React', {Component() {}, PropTypes: {}});
<ide>
<ide> const NavigationStackReducer = require('NavigationStackReducer');
<ide> const NavigationRootContainer = require('NavigationRootContainer');
<ide><path>Libraries/NavigationExperimental/Reducer/__tests__/NavigationTabsReducer-test.js
<ide> 'use strict';
<ide>
<ide> jest
<del> .autoMockOff()
<del> .mock('ErrorUtils');
<add> .dontMock('NavigationTabsReducer')
<add> .dontMock('NavigationFindReducer')
<add> .dontMock('NavigationStateUtils');
<ide>
<ide> const NavigationTabsReducer = require('NavigationTabsReducer');
<ide>
<ide><path>Libraries/NavigationExperimental/__tests__/NavigationStateUtils-test.js
<ide> 'use strict';
<ide>
<ide> jest
<del> .autoMockOff()
<del> .mock('ErrorUtils');
<add> .dontMock('NavigationStateUtils');
<ide>
<ide> var NavigationStateUtils = require('NavigationStateUtils');
<ide> | 4 |
Text | Text | fix typo in description | 2f27b6e6875cccf461239ae28662d8a9cd153164 | <ide><path>curriculum/challenges/english/01-responsive-web-design/basic-css/use-attribute-selectors-to-style-elements.english.md
<ide> videoUrl: 'https://scrimba.com/c/cnpymfJ'
<ide>
<ide> ## Description
<ide> <section id='description'>
<del>You have been giving <code>id</code> or <code>class</code> attributes to elements that you wish to specifically style. These are known as ID and class selectors. There are other CSS Selectors you can use to select custom groups of elements to style.
<add>You have been given <code>id</code> or <code>class</code> attributes to elements that you wish to specifically style. These are known as ID and class selectors. There are other CSS Selectors you can use to select custom groups of elements to style.
<ide> Let's bring out CatPhotoApp again to practice using CSS Selectors.
<ide> For this challenge, you will use the <code>[attr=value]</code> attribute selector to style the checkboxes in CatPhotoApp. This selector matches and styles elements with a specific attribute value. For example, the below code changes the margins of all elements with the attribute <code>type</code> and a corresponding value of <code>radio</code>:
<ide> <blockquote>[type='radio'] {<br> margin: 20px 0px 20px 0px;<br>}</blockquote> | 1 |
Javascript | Javascript | add support comment | 9db9316609c2881dbb6abc49efc3aa91a57a02ad | <ide><path>src/event.js
<ide> function returnFalse() {
<ide> return false;
<ide> }
<ide>
<add>// Support: IE9
<add>// See #13393 for more info
<ide> function safeActiveElement() {
<ide> try {
<ide> return document.activeElement;
<ide> jQuery.event = {
<ide> delegateCount = handlers.delegateCount,
<ide> cur = event.target;
<ide>
<add> // Support (at least): Chrome, IE9
<ide> // Find delegate handlers
<ide> // Black-hole SVG <use> instance trees (#13180)
<add> //
<add> // Support: Firefox
<ide> // Avoid non-left-click bubbling in Firefox (#3861)
<ide> if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) {
<ide>
<ide> jQuery.event = {
<ide> };
<ide>
<ide> jQuery.removeEvent = function( elem, type, handle ) {
<add> // This "if" is needed for plain objects
<ide> if ( elem.removeEventListener ) {
<ide> elem.removeEventListener( type, handle, false );
<ide> } | 1 |
Javascript | Javascript | add test for | cb8afda183e9c931978279d3a1706d1d9c905484 | <ide><path>packages/react-native-renderer/src/__tests__/ReactFabric-test.internal.js
<ide> describe('ReactFabric', () => {
<ide> expect(TextInputState.focusTextInput).toHaveBeenCalledTimes(1);
<ide> expect(TextInputState.focusTextInput).toHaveBeenCalledWith(viewRef.current);
<ide> });
<add>
<add> it('should no-op if calling sendAccessibilityEvent on unmounted refs', () => {
<add> const View = createReactNativeComponentClass('RCTView', () => ({
<add> validAttributes: {foo: true},
<add> uiViewClassName: 'RCTView',
<add> }));
<add>
<add> nativeFabricUIManager.sendAccessibilityEvent.mockReset();
<add>
<add> let viewRef;
<add> act(() => {
<add> ReactFabric.render(
<add> <View
<add> ref={ref => {
<add> viewRef = ref;
<add> }}
<add> />,
<add> 11,
<add> );
<add> });
<add> const dangerouslyRetainedViewRef = viewRef;
<add> act(() => {
<add> ReactFabric.stopSurface(11);
<add> });
<add>
<add> ReactFabric.sendAccessibilityEvent(
<add> dangerouslyRetainedViewRef,
<add> 'eventTypeName',
<add> );
<add>
<add> expect(nativeFabricUIManager.sendAccessibilityEvent).not.toBeCalled();
<add> });
<ide> }); | 1 |
PHP | PHP | simplify opening routes | 2d9b6958ecef4c9195dc6036ae66b5f7ff575206 | <ide><path>app/Http/Controllers/WelcomeController.php
<del><?php namespace App\Http\Controllers;
<del>
<del>class WelcomeController extends Controller
<del>{
<del> /*
<del> |--------------------------------------------------------------------------
<del> | Welcome Controller
<del> |--------------------------------------------------------------------------
<del> |
<del> | This controller renders the "marketing page" for the application and
<del> | is configured to only allow guests. Like most of the other sample
<del> | controllers, you are free to modify or remove it as you desire.
<del> |
<del> */
<del>
<del> /**
<del> * Create a new controller instance.
<del> *
<del> * @return void
<del> */
<del> public function __construct()
<del> {
<del> $this->middleware('guest');
<del> }
<del>
<del> /**
<del> * Show the application welcome screen to the user.
<del> *
<del> * @return Response
<del> */
<del> public function index()
<del> {
<del> return view('welcome');
<del> }
<del>}
<ide><path>app/Http/routes.php
<ide> |
<ide> */
<ide>
<del>Route::get('/', 'WelcomeController@index');
<add>Route::get('/', function () {
<add> return view('welcome');
<add>}); | 2 |
PHP | PHP | remove double space and fix return type hint | 9cf2b41bfcfbb8eb4a6f242e1f634dbf28efe14d | <ide><path>tests/TestCase/Controller/Component/SecurityComponentTest.php
<ide> public function fail(): void
<ide> * @param int $status
<ide> * @return \Cake\Http\Response|null
<ide> */
<del> public function redirect($url, int $status = null): ?\Cake\Http\Response
<add> public function redirect($url, int $status = null): ?Response
<ide> {
<ide> return $status;
<ide> } | 1 |
Text | Text | fix toc links in faq and recipes | 1a1c7ac2a8768127d89bc866acce73340148bdc4 | <ide><path>docs/FAQ.md
<ide> - [Can Redux only be used with React?](/docs/faq/General.md#can-redux-only-be-used-with-react)
<ide> - [Do I need to have a particular build tool to use Redux?](/docs/faq/General.md#do-i-need-to-have-a-particular-build-tool-to-use-redux)
<ide> - **Reducers**
<del> - [How do I share state between two reducers? Do I have to use combineReducers?](/docs/faq/Reducers.md#reducers-share-state)
<del> - [Do I have to use the switch statement to handle actions?](/docs/faq/Reducers.md#reducers-use-switch)
<add> - [How do I share state between two reducers? Do I have to use combineReducers?](/docs/faq/Reducers.md#how-do-i-share-state-between-two-reducers-do-i-have-to-use-combinereducers)
<add> - [Do I have to use the switch statement to handle actions?](/docs/faq/Reducers.md#do-i-have-to-use-the-switch-statement-to-handle-actions)
<ide> - **Organizing State**
<del> - [Do I have to put all my state into Redux? Should I ever use React's setState()?](/docs/faq/OrganizingState.md#organizing-state-only-redux-state)
<del> - [Can I put functions, promises, or other non-serializable items in my store state?](/docs/faq/OrganizingState.md#organizing-state-non-serializable)
<del> - [How do I organize nested or duplicate data in my state?](/docs/faq/OrganizingState.md#organizing-state-nested-data)
<add> - [Do I have to put all my state into Redux? Should I ever use React's setState()?](/docs/faq/OrganizingState.md#do-i-have-to-put-all-my-state-into-redux-should-i-ever-use-reacts-setstate)
<add> - [Can I put functions, promises, or other non-serializable items in my store state?](/docs/faq/OrganizingState.md#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)
<add> - [How do I organize nested or duplicate data in my state?](/docs/faq/OrganizingState.md#how-do-i-organize-nested-or-duplicate-data-in-my-state)
<ide> - **Store Setup**
<del> - [Can or should I create multiple stores? Can I import my store directly, and use it in components myself?](/docs/faq/StoreSetup.md#store-setup-multiple-stores)
<del> - [Is it OK to have more than one middleware chain in my store enhancer? What is the difference between next and dispatch in a middleware function?](/docs/faq/StoreSetup.md#store-setup-middleware-chains)
<del> - [How do I subscribe to only a portion of the state? Can I get the dispatched action as part of the subscription?](/docs/faq/StoreSetup.md#store-setup-subscriptions)
<add> - [Can or should I create multiple stores? Can I import my store directly, and use it in components myself?](/docs/faq/StoreSetup.md#can-or-should-i-create-multiple-stores-can-i-import-my-store-directly-and-use-it-in-components-myself)
<add> - [Is it OK to have more than one middleware chain in my store enhancer? What is the difference between next and dispatch in a middleware function?](/docs/faq/StoreSetup.md#is-it-ok-to-have-more-than-one-middleware-chain-in-my-store-enhancer-what-is-the-difference-between-next-and-dispatch-in-a-middleware-function)
<add> - [How do I subscribe to only a portion of the state? Can I get the dispatched action as part of the subscription?](/docs/faq/StoreSetup.md#how-do-i-subscribe-to-only-a-portion-of-the-state-can-i-get-the-dispatched-action-as-part-of-the-subscription)
<ide> - **Actions**
<del> - [Why should type be a string, or at least serializable? Why should my action types be constants?](/docs/faq/Actions.md#actions-string-constants)
<del> - [Is there always a one-to-one mapping between reducers and actions?](/docs/faq/Actions.md#actions-reducer-mappings)
<del> - [How can I represent “side effects” such as AJAX calls? Why do we need things like “action creators”, “thunks”, and “middleware” to do async behavior?](/docs/faq/Actions.md#actions-side-effects)
<del> - [Should I dispatch multiple actions in a row from one action creator?](/docs/faq/Actions.md#actions-multiple-actions)
<add> - [Why should type be a string, or at least serializable? Why should my action types be constants?](/docs/Actions.md#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)
<add> - [Is there always a one-to-one mapping between reducers and actions?](/docs/Actions.md#is-there-always-a-one-to-one-mapping-between-reducers-and-actions)
<add> - [How can I represent “side effects” such as AJAX calls? Why do we need things like “action creators”, “thunks”, and “middleware” to do async behavior?](/docs/Actions.md#how-can-i-represent-side-effects-such-as-ajax-calls-why-do-we-need-things-like-action-creators-thunks-and-middleware-to-do-async-behavior)
<add> - [What async middleware should I use? How do you decide between thunks, sagas, observables, or something else?](/docs/Actions.md#what-async-middleware-should-i-use-how-do-you-decide-between-thunks-sagas-observables-or-something-else)
<add> - [Should I dispatch multiple actions in a row from one action creator?](/docs/Actions.md#should-i-dispatch-multiple-actions-in-a-row-from-one-action-creator)
<ide> - **Immutable Data**
<del> - [What are the benefits of Immutability?](/docs/faq/ImmutableData.md#benefits-of-immutability)
<del> - [Why is immutability required in Redux?](/docs/faq/ImmutableData.md#why-is-immutability-required)
<del> - [Do I have to use Immutable.JS?](/docs/faq/ImmutableData.md#do-i-have-to-use-immutable-js)
<del> - [What are the issues with using ES6 for immutable operations?](/docs/faq/ImmutableData.md#issues-with-es6-for-immutable-ops)
<add> - [What are the benefits of immutability?](/docs/ImmutableData.md#what-are-the-benefits-of-immutability)
<add> - [Why is immutability required by Redux?](/docs/ImmutableData.md#why-is-immutability-required-by-redux)
<add> - [What approaches are there for handling data immutability? Do I have to use Immutable.JS?](/docs/ImmutableData.md#what-approaches-are-there-for-handling-data-immutability-do-i-have-to-use-immutable-js)
<add> - [What are the issues with using JavaScript for immutable operations?](/docs/ImmutableData.md#what-are-the-issues-with-using-plain-javascript-for-immutable-operations)
<ide> - **Using Immutable.JS with Redux**
<del> - [Why should I use an immutable-focused library such as Immutable.JS?](/docs/recipes/UsingImmutableJS.md#why-use-immutable-library)
<del> - [Why should I choose Immutable.JS as an immutable library?](/docs/recipes/UsingImmutableJS.md#why-choose-immutable-js)
<del> - [What are the issues with using Immutable.JS?](/docs/recipes/UsingImmutableJS.md#issues-with-immutable-js)
<del> - [Is Immutable.JS worth the effort?](/docs/recipes/UsingImmutableJS.md#is-immutable-js-worth-effort)
<del> - [What are some opinionated Best Practices for using Immutable.JS with Redux?](/docs/recipes/UsingImmutableJS.md#immutable-js-best-practices)
<add> - [Why should I use an immutable-focused library such as Immutable.JS?](/docs/recipes/UsingImmutableJS.md#why-should-i-use-an-immutable-focused-library-such-as-immutable-js)
<add> - [Why should I choose Immutable.JS as an immutable library?](/docs/recipes/UsingImmutableJS.md#why-should-i-choose-immutable-js-as-an-immutable-library)
<add> - [What are the issues with using Immutable.JS?](/docs/recipes/UsingImmutableJS.md#what-are-the-issues-with-using-immutable-js)
<add> - [Is Immutable.JS worth the effort?](/docs/recipes/UsingImmutableJS.md#is-using-immutable-js-worth-the-effort)
<add> - [What are some opinionated Best Practices for using Immutable.JS with Redux?](/docs/recipes/UsingImmutableJS.md#what-are-some-opinionated-best-practices-for-using-immutable-js-with-redux)
<ide>
<ide> - **Code Structure**
<del> - [What should my file structure look like? How should I group my action creators and reducers in my project? Where should my selectors go?](/docs/faq/CodeStructure.md#structure-file-structure)
<del> - [How should I split my logic between reducers and action creators? Where should my “business logic” go?](/docs/faq/CodeStructure.md#structure-business-logic)
<del> - [Why should I use action creators?](/docs/faq/CodeStructure.md#structure-action-creators)
<add> - [What should my file structure look like? How should I group my action creators and reducers in my project? Where should my selectors go?](/docs/faq/CodeStructure.md#what-should-my-file-structure-look-like-how-should-i-group-my-action-creators-and-reducers-in-my-project-where-should-my-selectors-go)
<add> - [How should I split my logic between reducers and action creators? Where should my “business logic” go?](/docs/faq/CodeStructure.md#how-should-i-split-my-logic-between-reducers-and-action-creators-where-should-my-business-logic-go)
<add> - [Why should I use action creators?](/docs/faq/CodeStructure.md#why-should-i-use-action-creators)
<add> - [Where should websockets and other persistent connections live?](/docs/faq/CodeStructure.md#where-should-websockets-and-other-persistent-connections-live)
<ide> - **Performance**
<del> - [How well does Redux “scale” in terms of performance and architecture?](/docs/faq/Performance.md#performance-scaling)
<del> - [Won't calling “all my reducers” for each action be slow?](/docs/faq/Performance.md#performance-all-reducers)
<del> - [Do I have to deep-clone my state in a reducer? Isn't copying my state going to be slow?](/docs/faq/Performance.md#performance-clone-state)
<del> - [How can I reduce the number of store update events?](/docs/faq/Performance.md#performance-update-events)
<del> - [Will having “one state tree” cause memory problems? Will dispatching many actions take up memory?](/docs/faq/Performance.md#performance-state-memory)
<del> - [Will caching remote data cause memory problems?](/docs/faq/Performance.md#performance-cache-memory)
<add> - [How well does Redux “scale” in terms of performance and architecture?](/docs/faq/Performance.md#how-well-does-redux-scale-in-terms-of-performance-and-architecture)
<add> - [Won't calling “all my reducers” for each action be slow?](/docs/faq/Performance.md#wont-calling-all-my-reducers-for-each-action-be-slow)
<add> - [Do I have to deep-clone my state in a reducer? Isn't copying my state going to be slow?](/docs/faq/Performance.md#do-i-have-to-deep-clone-my-state-in-a-reducer-isnt-copying-my-state-going-to-be-slow)
<add> - [How can I reduce the number of store update events?](/docs/faq/Performance.md#how-can-i-reduce-the-number-of-store-update-events)
<add> - [Will having “one state tree” cause memory problems? Will dispatching many actions take up memory?](/docs/faq/Performance.md#will-having-one-state-tree-cause-memory-problems-will-dispatching-many-actions-take-up-memory)
<add> - [Will caching remote data cause memory problems?](/docs/faq/Performance.md#will-caching-remote-data-cause-memory-problems)
<ide> - **Design Decisions**
<del> - [Why doesn't Redux pass the state and action to subscribers?](/docs/faq/DesignDecisions.md#does-not-pass-state-action-to-subscribers)
<del> - [Why doesn't Redux support using classes for actions and reducers?](/docs/faq/DesignDecisions.md#does-not-support-classes)
<del> - [Why does the middleware signature use currying?](/docs/faq/DesignDecisions.md#why-currying)
<del> - [Why does applyMiddleware use a closure for dispatch?](/docs/faq/DesignDecisions.md#closure-dispatch)
<del> - [Why doesn't `combineReducers` include a third argument with the entire state when it calls each reducer?](/docs/faq/DesignDecisions.md#combineReducers-limitations)
<del> - [Why doesn't `mapDispatchToProps` allow use of return values from `getState()` or `mapStateToProps()`?](/docs/faq/DesignDecisions.md#no-asynch-in-mapDispatchToProps)
<add> - [Why doesn't Redux pass the state and action to subscribers?](/docs/faq/DesignDecisions.md#why-doesnt-redux-pass-the-state-and-action-to-subscribers)
<add> - [Why doesn't Redux support using classes for actions and reducers?](/docs/faq/DesignDecisions.md#why-doesnt-redux-support-using-classes-for-actions-and-reducers)
<add> - [Why does the middleware signature use currying?](/docs/faq/DesignDecisions.md#why-does-the-middleware-signature-use-currying)
<add> - [Why does applyMiddleware use a closure for dispatch?](/docs/faq/DesignDecisions.md#why-does-applymiddleware-use-a-closure-for-dispatch)
<add> - [Why doesn't `combineReducers` include a third argument with the entire state when it calls each reducer?](/docs/faq/DesignDecisions.md#why-doesnt-combinereducers-include-a-third-argument-with-the-entire-state-when-it-calls-each-reducer)
<add> - [Why doesn't mapDispatchToProps allow use of return values from `getState()` or `mapStateToProps()`?](/docs/faq/DesignDecisions.md#why-doesnt-mapdispatchtoprops-allow-use-of-return-values-from-getstate-or-mapstatetoprops)
<ide> - **React Redux**
<del> - [Why isn't my component re-rendering, or my mapStateToProps running?](/docs/faq/ReactRedux.md#react-not-rerendering)
<del> - [Why is my component re-rendering too often?](/docs/faq/ReactRedux.md#react-rendering-too-often)
<del> - [How can I speed up my mapStateToProps?](/docs/faq/ReactRedux.md#react-mapstate-speed)
<del> - [Why don't I have this.props.dispatch available in my connected component?](/docs/faq/ReactRedux.md#react-props-dispatch)
<del> - [Should I only connect my top component, or can I connect multiple components in my tree?](/docs/faq/ReactRedux.md#react-multiple-components)
<add> - [Why isn't my component re-rendering, or my mapStateToProps running?](/docs/faq/ReactRedux.md#why-isnt-my-component-re-rendering-or-my-mapstatetoprops-running)
<add> - [Why is my component re-rendering too often?](/docs/faq/ReactRedux.md#why-is-my-component-re-rendering-too-often)
<add> - [How can I speed up my mapStateToProps?](/docs/faq/ReactRedux.md#how-can-i-speed-up-my-mapstatetoprops)
<add> - [Why don't I have this.props.dispatch available in my connected component?](/docs/faq/ReactRedux.md#why-dont-i-have-this-props-dispatch-available-in-my-connected-component)
<add> - [Should I only connect my top component, or can I connect multiple components in my tree?](/docs/faq/ReactRedux.md#should-i-only-connect-my-top-component-or-can-i-connect-multiple-components-in-my-tree)
<ide> - **Miscellaneous**
<del> - [Are there any larger, “real” Redux projects?](/docs/faq/Miscellaneous.md#miscellaneous-real-projects)
<del> - [How can I implement authentication in Redux?](/docs/faq/Miscellaneous.md#miscellaneous-authentication)
<add> - [Are there any larger, “real” Redux projects?](/docs/faq/Miscellaneous.md#are-there-any-larger-real-redux-projects)
<add> - [How can I implement authentication in Redux?](/docs/faq/Miscellaneous.md#how-can-i-implement-authentication-in-redux)
<ide><path>docs/faq/Actions.md
<ide>
<ide> ## Table of Contents
<ide>
<del>- [Why should type be a string, or at least serializable? Why should my action types be constants?](#actions-string-constants)
<del>- [Is there always a one-to-one mapping between reducers and actions?](#actions-reducer-mappings)
<del>- [How can I represent “side effects” such as AJAX calls? Why do we need things like “action creators”, “thunks”, and “middleware” to do async behavior?](#actions-side-effects)
<del>- [What async middleware should I use? How do you decide between thunks, sagas, observables, or something else?](#actions-async-middlewares)
<del>- [Should I dispatch multiple actions in a row from one action creator?](#actions-multiple-actions)
<add>- [Why should type be a string, or at least serializable? Why should my action types be constants?](#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)
<add>- [Is there always a one-to-one mapping between reducers and actions?](#is-there-always-a-one-to-one-mapping-between-reducers-and-actions)
<add>- [How can I represent “side effects” such as AJAX calls? Why do we need things like “action creators”, “thunks”, and “middleware” to do async behavior?](#how-can-i-represent-side-effects-such-as-ajax-calls-why-do-we-need-things-like-action-creators-thunks-and-middleware-to-do-async-behavior)
<add>- [What async middleware should I use? How do you decide between thunks, sagas, observables, or something else?](#what-async-middleware-should-i-use-how-do-you-decide-between-thunks-sagas-observables-or-something-else)
<add>- [Should I dispatch multiple actions in a row from one action creator?](#should-i-dispatch-multiple-actions-in-a-row-from-one-action-creator)
<ide>
<ide>
<ide> ## Actions
<ide>
<del><a id="actions-string-constants"></a>
<ide> ### Why should `type` be a string, or at least serializable? Why should my action types be constants?
<ide>
<ide> As with state, serializable actions enable several of Redux's defining features, such as time travel debugging, and recording and replaying actions. Using something like a `Symbol` for the `type` value or using `instanceof` checks for actions themselves would break that. Strings are serializable and easily self-descriptive, and so are a better choice. Note that it *is* okay to use Symbols, Promises, or other non-serializable values in an action if the action is intended for use by middleware. Actions only need to be serializable by the time they actually reach the store and are passed to the reducers.
<ide> Encapsulating and centralizing commonly used pieces of code is a key concept in
<ide> - [Stack Overflow: What is the point of the constants in Redux?](http://stackoverflow.com/q/34965856/62937)
<ide>
<ide>
<del><a id="actions-reducer-mappings"></a>
<ide> ### Is there always a one-to-one mapping between reducers and actions?
<ide>
<ide> No. We suggest you write independent small reducer functions that are each responsible for updates to a specific slice of state. We call this pattern “reducer composition”. A given action could be handled by all, some, or none of them. This keeps components decoupled from the actual data changes, as one action may affect different parts of the state tree, and there is no need for the component to be aware of this. Some users do choose to bind them more tightly together, such as the “ducks” file structure, but there is definitely no one-to-one mapping by default, and you should break out of such a paradigm any time you feel you want to handle an action in many reducers.
<ide> No. We suggest you write independent small reducer functions that are each respo
<ide> - [Stack Overflow: Can I dispatch multiple actions without Redux Thunk middleware?](http://stackoverflow.com/questions/35493352/can-i-dispatch-multiple-actions-without-redux-thunk-middleware/35642783)
<ide>
<ide>
<del><a id="actions-side-effects"></a>
<ide> ### How can I represent “side effects” such as AJAX calls? Why do we need things like “action creators”, “thunks”, and “middleware” to do async behavior?
<ide>
<ide> This is a long and complex topic, with a wide variety of opinions on how code should be organized and what approaches should be used.
<ide> The simplest and most common way to do this is to add the [Redux Thunk](https://
<ide> - [Reddit: Help performing Async API calls with Redux-Promise Middleware.](https://www.reddit.com/r/reactjs/comments/469iyc/help_performing_async_api_calls_with_reduxpromise/)
<ide> - [Twitter: possible comparison between sagas, loops, and other approaches](https://twitter.com/dan_abramov/status/689639582120415232)
<ide>
<del><a id="actions-async-middlewares"></a>
<ide> ### What async middleware should I use? How do you decide between thunks, sagas, observables, or something else?
<ide>
<ide> There are [many async/side effect middlewares available](https://github.com/markerikson/redux-ecosystem-links/blob/master/side-effects.md), but the most commonly used ones are [`redux-thunk`](https://github.com/reduxjs/redux-thunk), [`redux-saga`](https://github.com/redux-saga/redux-saga), and [`redux-observable`](https://github.com/redux-observable/redux-observable). These are different tools, with different strengths, weaknesses, and use cases.
<ide> Since sagas and observables have the same use case, an application would normall
<ide> - [Stack Overflow: Why use Redux-Observable over Redux-Saga?](https://stackoverflow.com/questions/40021344/why-use-redux-observable-over-redux-saga/40027778#40027778)
<ide>
<ide>
<del><a id="actions-multiple-actions"></a>
<ide> ### Should I dispatch multiple actions in a row from one action creator?
<ide>
<ide> There's no specific rule for how you should structure your actions. Using an async middleware like Redux Thunk certainly enables scenarios such as dispatching multiple distinct but related actions in a row, dispatching actions to represent progression of an AJAX request, dispatching actions conditionally based on state, or even dispatching an action and checking the updated state immediately afterwards.
<ide><path>docs/faq/CodeStructure.md
<ide>
<ide> ## Table of Contents
<ide>
<del>- [What should my file structure look like? How should I group my action creators and reducers in my project? Where should my selectors go?](#structure-file-structure)
<del>- [How should I split my logic between reducers and action creators? Where should my “business logic” go?](#structure-business-logic)
<del>- [Why should I use action creators?](#structure-action-creators)
<del>- [Where should websockets and other persistent connections live?](#structure-persistent-connections)
<add>- [What should my file structure look like? How should I group my action creators and reducers in my project? Where should my selectors go?](#what-should-my-file-structure-look-like-how-should-i-group-my-action-creators-and-reducers-in-my-project-where-should-my-selectors-go)
<add>- [How should I split my logic between reducers and action creators? Where should my “business logic” go?](#how-should-i-split-my-logic-between-reducers-and-action-creators-where-should-my-business-logic-go)
<add>- [Why should I use action creators?](#why-should-i-use-action-creators)
<add>- [Where should websockets and other persistent connections live?](#where-should-websockets-and-other-persistent-connections-live)
<ide>
<ide> ## Code Structure
<ide>
<del><a id="structure-file-structure"></a>
<ide> ### What should my file structure look like? How should I group my action creators and reducers in my project? Where should my selectors go?
<ide>
<ide> Since Redux is just a data store library, it has no direct opinion on how your project should be structured. However, there are a few common patterns that most Redux developers tend to use:
<ide> While it ultimately doesn't matter how you lay out your code on disk, it's impor
<ide> - [Twitter: There is no ultimate file structure for Redux](https://twitter.com/dan_abramov/status/783428282666614784)
<ide>
<ide>
<del><a id="structure-business-logic"></a>
<ide> ### How should I split my logic between reducers and action creators? Where should my “business logic” go?
<ide>
<ide> There's no single clear answer to exactly what pieces of logic should go in a reducer or an action creator. Some developers prefer to have “fat” action creators, with “thin” reducers that simply take the data in an action and blindly merge it into the corresponding state. Others try to emphasize keeping actions as small as possible, and minimize the usage of `getState()` in an action creator. (For purposes of this question, other async approaches such as sagas and observables fall in the "action creator" category.)
<ide> Find the balance between these two extremes, and you will master Redux.
<ide> - [Twitter: Moving away from unclear terminology...](https://twitter.com/FwardPhoenix/status/952971237004926977)
<ide>
<ide>
<del><a id="structure-action-creators"></a>
<ide> ### Why should I use action creators?
<ide>
<ide> Redux does not require action creators. You are free to create actions in any way that is best for you, including simply passing an object literal to `dispatch`. Action creators emerged from the [Flux architecture](https://facebook.github.io/react/blog/2014/07/30/flux-actions-and-the-dispatcher.html#actions-and-actioncreators) and have been adopted by the Redux community because they offer several benefits.
<ide>
<ide> Action creators are more maintainable. Updates to an action can be made in one place and applied everywhere. All instances of an action are guaranteed to have the same shape and the same default values.
<ide>
<del>Action creators are testable. The correctness of an inline action must be verified manually. Like any function, tests for an action creator can be written once and run automatically.
<add>Action creators are testable. The correctness of an inline action must be verified manually. Like any function, tests for an action creator can be written once and run automatically.
<ide>
<ide> Action creators are easier to document. The action creator's parameters enumerate the action's dependencies. And centralization of the action definition provides a convenient place for documentation comments. When actions are written inline, this information is harder to capture and communicate.
<ide>
<ide> Action creators are a more powerful abstraction. Creating an action often involv
<ide> - [Reddit: Redbox - Redux action creation made simple](https://www.reddit.com/r/reactjs/comments/54k8js/redbox_redux_action_creation_made_simple/d8493z1/?context=4)
<ide>
<ide>
<del><a id="structure-persistent-connections"></a>
<ide> ### Where should websockets and other persistent connections live?
<ide>
<ide> Middleware are the right place for persistent connections like websockets in a Redux app, for several reasons:
<ide><path>docs/faq/DesignDecisions.md
<ide>
<ide> ## Table of Contents
<ide>
<del>- [Why doesn't Redux pass the state and action to subscribers?](#does-not-pass-state-action-to-subscribers)
<del>- [Why doesn't Redux support using classes for actions and reducers?](#does-not-support-classes)
<del>- [Why does the middleware signature use currying?](#why-currying)
<del>- [Why does applyMiddleware use a closure for dispatch?](#closure-dispatch)
<del>- [Why doesn't `combineReducers` include a third argument with the entire state when it calls each reducer?](#combineReducers-limitations)
<del>- [Why doesn't mapDispatchToProps allow use of return values from `getState()` or `mapStateToProps()`?](#no-asynch-in-mapDispatchToProps)
<add>- [Why doesn't Redux pass the state and action to subscribers?](#why-doesnt-redux-pass-the-state-and-action-to-subscribers)
<add>- [Why doesn't Redux support using classes for actions and reducers?](#why-doesnt-redux-support-using-classes-for-actions-and-reducers)
<add>- [Why does the middleware signature use currying?](#why-does-the-middleware-signature-use-currying)
<add>- [Why does applyMiddleware use a closure for dispatch?](#why-does-applymiddleware-use-a-closure-for-dispatch)
<add>- [Why doesn't `combineReducers` include a third argument with the entire state when it calls each reducer?](#why-doesnt-combinereducers-include-a-third-argument-with-the-entire-state-when-it-calls-each-reducer)
<add>- [Why doesn't mapDispatchToProps allow use of return values from `getState()` or `mapStateToProps()`?](#why-doesnt-mapdispatchtoprops-allow-use-of-return-values-from-getstate-or-mapstatetoprops)
<ide>
<ide>
<ide> ## Design Decisions
<ide>
<del><a id="does-not-pass-state-action-to-subscribers"></a>
<ide> ### Why doesn't Redux pass the state and action to subscribers?
<ide> Subscribers are intended to respond to the state value itself, not the action. Updates to the state are processed synchronously, but notifications to subscribers can be batched or debounced, meaning that subscribers are not always notified with every action. This is a common [performance optimization](http://redux.js.org/docs/faq/Performance.html#performance-update-events) to avoid repeated re-rendering.
<ide>
<ide> A potential use-case for using the action inside a subscriber -- which is an uns
<ide> * [#580: Why doesn't Redux pass the state to subscribers?](https://github.com/reactjs/redux/issues/580)
<ide> * [#2214: Alternate Proof of Concept: Enhancer Overhaul -- more on debouncing](https://github.com/reactjs/redux/pull/2214)
<ide>
<del><a id="does-not-support-classes"></a>
<ide> ### Why doesn't Redux support using classes for actions and reducers?
<del>The pattern of using functions, called action creators, to return action objects may seem counterintuitive to programmers with a lot of Object Oriented Programming experience, who would see this is a strong use-case for Classes and instances. Class instances for action objects and reducers are not supported because class instances make serialization and deserialization tricky. Deserialization methods like `JSON.parse(string)` will return a plain old Javascript object rather than class instances.
<add>The pattern of using functions, called action creators, to return action objects may seem counterintuitive to programmers with a lot of Object Oriented Programming experience, who would see this is a strong use-case for Classes and instances. Class instances for action objects and reducers are not supported because class instances make serialization and deserialization tricky. Deserialization methods like `JSON.parse(string)` will return a plain old Javascript object rather than class instances.
<ide>
<ide> As described in the [Store FAQ](./OrganizingState.md#organizing-state-non-serializable), if you are okay with things like persistence and time-travel debugging not working as intended, you are welcome to put non-serializable items into your Redux store.
<ide>
<ide> Serialization enables the browser to store all actions that have been dispatched
<ide> **Discussions**
<ide> * [#1171: Why doesn't Redux use classes for actions and reducers?](https://github.com/reactjs/redux/issues/1171#issuecomment-196819727)
<ide>
<del><a id="why-currying"></a>
<ide> ### Why does the middleware signature use currying?
<ide>
<ide> Redux middleware are written using a triply-nested function structure that looks like `const middleware = storeAPI => next => action => {}`, rather than a single function that looks like `const middleware = (storeAPI, next, action) => {}`. There's a few reasons for this.
<ide> The [curried function signature](https://github.com/reactjs/redux/issues/1744) o
<ide> * Prior discussions: [#55](https://github.com/reactjs/redux/pull/55), [#534](https://github.com/reactjs/redux/issues/534), [#784](https://github.com/reactjs/redux/pull/784), [#922](https://github.com/reactjs/redux/issues/922), [#1744](https://github.com/reactjs/redux/issues/1744)
<ide> * [React Boston 2017: You Might Need Redux (And Its Ecosystem)](http://blog.isquaredsoftware.com/2017/09/presentation-might-need-redux-ecosystem/)
<ide>
<del><a id="closure-dispatch"></a>
<ide> ### Why does `applyMiddleware` use a closure for `dispatch`?
<del>`applyMiddleware` takes the existing dispatch from the store and closes over it to create the initial chain of middlewares that have been invoked with an object that exposes the getState and dispatch functions, which enables middlewares that [rely on dispatch during initialization](https://github.com/reactjs/redux/pull/1592) to run.
<add>`applyMiddleware` takes the existing dispatch from the store and closes over it to create the initial chain of middlewares that have been invoked with an object that exposes the getState and dispatch functions, which enables middlewares that [rely on dispatch during initialization](https://github.com/reactjs/redux/pull/1592) to run.
<ide>
<ide> #### Further Information
<ide> **Discussions**
<ide> * Why does applyMiddleware use a closure for dispatch?
<ide> * See - [#1592](https://github.com/reactjs/redux/pull/1592) and [#2097](https://github.com/reactjs/redux/issues/2097)
<ide>
<del><a id="combineReducers-limitations"></a>
<ide> ### Why doesn't `combineReducers` include a third argument with the entire state when it calls each reducer?
<ide>
<del>`combineReducers` is opinionated to encourage splitting reducer logic by domain. As stated in [Beyond `combineReducers`](../recipes/reducers/BeyondCombineReducers.md),`combineReducers` is deliberately limited to handle a single common use case: updating a state tree that is a plain Javascript object by delegating the work of updating each slice of state to a specific slice reducer.
<add>`combineReducers` is opinionated to encourage splitting reducer logic by domain. As stated in [Beyond `combineReducers`](../recipes/reducers/BeyondCombineReducers.md),`combineReducers` is deliberately limited to handle a single common use case: updating a state tree that is a plain Javascript object by delegating the work of updating each slice of state to a specific slice reducer.
<ide>
<del>It's not immediately obvious what a potential third argument to each reducer should be: the entire state tree, some callback function, some other part of the state tree, etc. If `combineReducers` doesn't fit your use case, consider using libraries like [combineSectionReducers](https://github.com/ryo33/combine-section-reducers) or [reduceReducers](https://github.com/acdlite/reduce-reducers) for other options with deeply nested reducers and reducers that require access to the global state.
<add>It's not immediately obvious what a potential third argument to each reducer should be: the entire state tree, some callback function, some other part of the state tree, etc. If `combineReducers` doesn't fit your use case, consider using libraries like [combineSectionReducers](https://github.com/ryo33/combine-section-reducers) or [reduceReducers](https://github.com/acdlite/reduce-reducers) for other options with deeply nested reducers and reducers that require access to the global state.
<ide>
<ide> If none of the published utilities solve your use case, you can always write a function yourself that does just exactly what you need.
<ide>
<ide> If none of the published utilities solve your use case, you can always write a f
<ide> **Discussions**
<ide> * [#1768 Allow reducers to consult global state](https://github.com/reactjs/redux/pull/1768)
<ide>
<del><a id="no-asynch-in-mapDispatchToProps"></a>
<ide> ### Why doesn't `mapDispatchToProps` allow use of return values from `getState()` or `mapStateToProps()`?
<ide>
<del>There have been requests to use either the entire `state` or the return value of `mapState` inside of `mapDispatch`, so that when functions are declared inside of `mapDispatch`, they can close over the latest returned values from the store.
<add>There have been requests to use either the entire `state` or the return value of `mapState` inside of `mapDispatch`, so that when functions are declared inside of `mapDispatch`, they can close over the latest returned values from the store.
<ide>
<ide> This approach is not supported in `mapDispatch` because it would mean also calling `mapDispatch` every time the store is updated. This would cause the re-creation of functions with every state update, thus adding a lot of performance overhead.
<ide>
<ide><path>docs/faq/ImmutableData.md
<ide> # Redux FAQ: Immutable Data
<ide>
<ide> ## Table of Contents
<del>- [What are the benefits of immutability?](#benefits-of-immutability)
<del>- [Why is immutability required by Redux?](#why-is-immutability-required)
<del>- [Why does Redux’s use of shallow equality checking require immutability?](#redux-shallow-checking-requires-immutability)
<del> - [How do Shallow and Deep Equality Checking differ?](#shallow-and-deep-equality-checking)
<del> - [How does Redux use shallow equality checking?](#how-redux-uses-shallow-checking)
<del> - [How does `combineReducers` use shallow equality checking?](#how-combine-reducers-uses-shallow-checking)
<del> - [How does React-Redux use shallow equality checking?](#how-react-redux-uses-shallow-checking)
<del> - [How does React-Redux use shallow equality checking to determine whether a component needs re-rendering?](#how-react-redux-determines-need-for-re-rendering)
<del> - [Why will shallow equality checking not work with mutable objects?](#no-shallow-equality-checking-with-mutable-objects)
<del> - [Does shallow equality checking with a mutable object cause problems with Redux?](#shallow-checking-problems-with-redux)
<del> - [Why does a reducer mutating the state prevent React-Redux from re-rendering a wrapped component?](#shallow-checking-problems-with-react-redux)
<del> - [Why does a selector mutating and returning a persistent object to `mapStateToProps` prevent React-Redux from re-rendering a wrapped component?](#shallow-checking-stops-component-re-rendering)
<del> - [How does immutability enable a shallow check to detect object mutations?](#immutability-enables-shallow-checking)
<del>- [How can immutability in your reducers cause components to render unnecessarily?](#immutability-issues-with-redux)
<del>- [How can immutability in mapStateToProps cause components to render unnecessarily?](#immutability-issues-with-react-redux)
<del>- [What approaches are there for handling data immutability? Do I have to use Immutable.JS?](#do-i-have-to-use-immutable-js)
<del>- [What are the issues with using JavaScript for immutable operations?](#issues-with-es6-for-immutable-ops)
<del>
<del>
<del><a id="benefits-of-immutability"></a>
<add>- [What are the benefits of immutability?](#what-are-the-benefits-of-immutability)
<add>- [Why is immutability required by Redux?](#why-is-immutability-required-by-redux)
<add>- [Why does Redux’s use of shallow equality checking require immutability?](#why-does-reduxs-use-of-shallow-equality-checking-require-immutability)
<add> - [How do Shallow and Deep Equality Checking differ?](#how-do-shallow-and-deep-equality-checking-differ)
<add> - [How does Redux use shallow equality checking?](#how-does-redux-use-shallow-equality-checking)
<add> - [How does `combineReducers` use shallow equality checking?](#how-does-combinereducers-use-shallow-equality-checking)
<add> - [How does React-Redux use shallow equality checking?](#how-does-react-redux-use-shallow-equality-checking)
<add> - [How does React-Redux use shallow equality checking to determine whether a component needs re-rendering?](#how-does-react-redux-use-shallow-equality-checking-to-determine-whether-a-component-needs-re-rendering)
<add> - [Why will shallow equality checking not work with mutable objects?](#why-will-shallow-equality-checking-not-work-with-mutable-objects)
<add> - [Does shallow equality checking with a mutable object cause problems with Redux?](#does-shallow-equality-checking-with-a-mutable-object-cause-problems-with-redux)
<add> - [Why does a reducer mutating the state prevent React-Redux from re-rendering a wrapped component?](#why-does-a-reducer-mutating-the-state-prevent-react-redux-from-re-rendering-a-wrapped-component)
<add> - [Why does a selector mutating and returning a persistent object to `mapStateToProps` prevent React-Redux from re-rendering a wrapped component?](#why-does-a-selector-mutating-and-returning-a-persistent-object-to-mapstatetoprops-prevent-react-redux-from-re-rendering-a-wrapped-component)
<add> - [How does immutability enable a shallow check to detect object mutations?](#how-does-immutability-enable-a-shallow-check-to-detect-object-mutations)
<add>- [How can immutability in your reducers cause components to render unnecessarily?](#how-can-immutability-in-your-reducers-cause-components-to-render-unnecessarily)
<add>- [How can immutability in mapStateToProps cause components to render unnecessarily?](#how-can-immutability-in-mapstatetoprops-cause-components-to-render-unnecessarily)
<add>- [What approaches are there for handling data immutability? Do I have to use Immutable.JS?](#what-approaches-are-there-for-handling-data-immutability-do-i-have-to-use-immutable-js)
<add>- [What are the issues with using JavaScript for immutable operations?](#what-are-the-issues-with-using-plain-javascript-for-immutable-operations)
<add>
<add>
<ide> ## What are the benefits of immutability?
<ide> Immutability can bring increased performance to your app, and leads to simpler programming and debugging, as data that never changes is easier to reason about than data that is free to be changed arbitrarily throughout your app.
<ide>
<ide> In particular, immutability in the context of a Web app enables sophisticated ch
<ide> - [JavaScript Application Architecture On The Road To 2015](https://medium.com/google-developers/javascript-application-architecture-on-the-road-to-2015-d8125811101b#.djje0rfys)
<ide>
<ide>
<del><a id="why-is-immutability-required"></a>
<ide> ## Why is immutability required by Redux?
<ide> - Both Redux and React-Redux employ [shallow equality checking](#shallow-and-deep-equality-checking). In particular:
<ide> - Redux's `combineReducers` utility [shallowly checks for reference changes](#how-redux-uses-shallow-checking) caused by the reducers that it calls.
<ide> Such [shallow checking requires immutability](#redux-shallow-checking-requires-i
<ide> - [Reddit: Why Redux Needs Reducers To Be Pure Functions](https://www.reddit.com/r/reactjs/comments/5ecqqv/why_redux_need_reducers_to_be_pure_functions/dacmmjh/?context=3)
<ide>
<ide>
<del><a id="redux-shallow-checking-requires-immutability"></a>
<ide> ## Why does Redux’s use of shallow equality checking require immutability?
<ide> Redux's use of shallow equality checking requires immutability if any connected components are to be updated correctly. To see why, we need to understand the difference between shallow and deep equality checking in JavaScript.
<ide>
<ide>
<del><a id="shallow-and-deep-equality-checking"></a>
<ide> ### How do shallow and deep equality checking differ?
<ide> Shallow equality checking (or _reference equality_) simply checks that two different _variables_ reference the same object; in contrast, deep equality checking (or _value equality_) must check every _value_ of two objects' properties.
<ide>
<ide> It's for this improvement in performance that Redux uses shallow equality checki
<ide> - [Pros and Cons of using immutability with React.js](http://reactkungfu.com/2015/08/pros-and-cons-of-using-immutability-with-react-js/)
<ide>
<ide>
<del><a id="how-redux-uses-shallow-checking"></a>
<ide> ### How does Redux use shallow equality checking?
<del>Redux uses shallow equality checking in its `combineReducers` function to return either a new mutated copy of the root state object, or, if no mutations have been made, the current root state object.
<add>Redux uses shallow equality checking in its `combineReducers` function to return either a new mutated copy of the root state object, or, if no mutations have been made, the current root state object.
<ide>
<ide> #### Further Information
<ide>
<ide> **Documentation**
<ide> - [API: combineReducers](http://redux.js.org/docs/api/combineReducers.html)
<ide>
<ide>
<del><a id="how-combine-reducers-uses-shallow-checking"></a>
<ide> #### How does `combineReducers` use shallow equality checking?
<ide> The [suggested structure](http://redux.js.org/docs/faq/Reducers.html#reducers-share-state) for a Redux store is to split the state object into multiple "slices" or "domains" by key, and provide a separate reducer function to manage each individual data slice.
<ide>
<ide> This is worth emphasizing: *If the reducers all return the same `state` object p
<ide> - [Egghead.io: Redux: Implementing combineReducers() from Scratch](https://egghead.io/lessons/javascript-redux-implementing-combinereducers-from-scratch)
<ide>
<ide>
<del><a id="how-react-redux-uses-shallow-checking"></a>
<ide> ### How does React-Redux use shallow equality checking?
<ide> React-Redux uses shallow equality checking to determine whether the component it’s wrapping needs to be re-rendered.
<ide>
<ide> React-Redux therefore maintains separate references to each _value_ in the retur
<ide> - [React.js pure render performance anti-pattern](https://medium.com/@esamatti/react-js-pure-render-performance-anti-pattern-fb88c101332f#.gh07cm24f)
<ide>
<ide>
<del><a id="how-react-redux-determines-need-for-re-rendering"></a>
<ide> ### How does React-Redux use shallow equality checking to determine whether a component needs re-rendering?
<ide> Each time React-Redux’s `connect` function is called, it will perform a shallow equality check on its stored reference to the root state object, and the current root state object passed to it from the store. If the check passes, the root state object has not been updated, and so there is no need to re-render the component, or even call `mapStateToProps`.
<ide>
<ide> If the shallow equality check fails between the new values returned from `mapSt
<ide> - [#300: Potential connect() optimization](https://github.com/reduxjs/react-redux/issues/300)
<ide>
<ide>
<del><a id="no-shallow-equality-checking-with-mutable-objects"></a>
<ide> ### Why will shallow equality checking not work with mutable objects?
<ide> Shallow equality checking cannot be used to detect if a function mutates an object passed into it if that object is mutable.
<ide>
<ide> The shallow check of `param` and `returnValue` simply checks whether both variab
<ide> - [Pros and Cons of using immutability with React.js](http://reactkungfu.com/2015/08/pros-and-cons-of-using-immutability-with-react-js/)
<ide>
<ide>
<del><a id="shallow-checking-problems-with-redux"></a>
<ide> ### Does shallow equality checking with a mutable object cause problems with Redux?
<ide> Shallow equality checking with a mutable object will not cause problems with Redux, but [it will cause problems with libraries that depend on the store, such as React-Redux](#shallow-checking-problems-with-react-redux).
<ide>
<ide> The store will still be updated with the new values for the root state, but beca
<ide> - [Troubleshooting: Never mutate reducer arguments](http://redux.js.org/docs/Troubleshooting.html#never-mutate-reducer-arguments)
<ide>
<ide>
<del><a id="shallow-checking-problems-with-react-redux"></a>
<ide> ### Why does a reducer mutating the state prevent React-Redux from re-rendering a wrapped component?
<ide> If a Redux reducer directly mutates, and returns, the state object passed into it, the values of the root state object will change, but the object itself will not.
<ide>
<ide> Because React-Redux performs a shallow check on the root state object to determi
<ide> - [Troubleshooting: My views aren’t updating when something changes outside of Redux](https://github.com/reduxjs/react-redux/blob/f4d55840a14601c3a5bdc0c3d741fc5753e87f66/docs/troubleshooting.md#my-views-arent-updating-when-something-changes-outside-of-redux)
<ide>
<ide>
<del><a id="shallow-checking-stops-component-re-rendering"></a>
<ide> ### Why does a selector mutating and returning a persistent object to `mapStateToProps` prevent React-Redux from re-rendering a wrapped component?
<ide> If one of the values of the props object returned from `mapStateToProps` is an object that persists across calls to `connect` (such as, potentially, the root state object), yet is directly mutated and returned by a selector function, React-Redux will not be able to detect the mutation, and so will not trigger a re-render of the wrapped component.
<ide>
<ide> Note that, conversely, if an _immutable_ object is used, the [component may re-r
<ide> - [#1948: Is getMappedItems an anti-pattern in mapStateToProps?](https://github.com/reduxjs/redux/issues/1948)
<ide>
<ide>
<del><a id="immutability-enables-shallow-checking"></a>
<ide> ### How does immutability enable a shallow check to detect object mutations?
<ide> If an object is immutable, any changes that need to be made to it within a function must be made to a _copy_ of the object.
<ide>
<ide> This mutated copy is a _separate_ object from that passed into the function, and
<ide> - [Pros and Cons of using immutability with React.js](http://reactkungfu.com/2015/08/pros-and-cons-of-using-immutability-with-react-js/)
<ide>
<ide>
<del><a id="immutability-issues-with-redux"></a>
<ide> ### How can immutability in your reducers cause components to render unnecessarily?
<ide> You cannot mutate an immutable object; instead, you must mutate a copy of it, leaving the original intact.
<ide>
<ide> To prevent this from happening, you must *always return the state slice object t
<ide> - [Building Efficient UI with React and Redux](https://www.toptal.com/react/react-redux-and-immutablejs)
<ide>
<ide>
<del><a id="immutability-issues-with-react-redux"></a>
<ide> ### How can immutability in `mapStateToProps` cause components to render unnecessarily?
<ide> Certain immutable operations, such as an Array filter, will always return a new object, even if the values themselves have not changed.
<ide>
<ide> Note that, conversely, if the values in your props object refer to mutable objec
<ide> - [ImmutableJS: worth the price?](https://medium.com/@AlexFaunt/immutablejs-worth-the-price-66391b8742d4#.a3alci2g8)
<ide>
<ide>
<del><a id="do-i-have-to-use-immutable-js"></a>
<ide> ## What approaches are there for handling data immutability? Do I have to use Immutable.JS?
<ide> You do not need to use Immutable.JS with Redux. Plain JavaScript, if written correctly, is perfectly capable of providing immutability without having to use an immutable-focused library.
<ide>
<ide> However, guaranteeing immutability with JavaScript is difficult, and it can be e
<ide> - [Introduction to Immutable.js and Functional Programming Concepts](https://auth0.com/blog/intro-to-immutable-js/)
<ide>
<ide>
<del><a id="issues-with-es6-for-immutable-ops"></a>
<ide> ## What are the issues with using plain JavaScript for immutable operations?
<ide> JavaScript was never designed to provide guaranteed immutable operations. Accordingly, there are several issues you need to be aware of if you choose to use it for your immutable operations in your Redux app.
<ide>
<ide><path>docs/faq/Miscellaneous.md
<ide>
<ide> ## Table of Contents
<ide>
<del>- [Are there any larger, “real” Redux projects?](#miscellaneous-real-projects)
<del>- [How can I implement authentication in Redux?](#miscellaneous-authentication)
<add>- [Are there any larger, “real” Redux projects?](#are-there-any-larger-real-redux-projects)
<add>- [How can I implement authentication in Redux?](#how-can-i-implement-authentication-in-redux)
<ide>
<ide>
<ide>
<ide> ## Miscellaneous
<ide>
<del><a id="miscellaneous-real-projects"></a>
<ide> ### Are there any larger, “real” Redux projects?
<ide>
<ide> Yes, lots of them! To name just a few:
<ide> And many, many more! The Redux Addons Catalog has **[a list of Redux-based appl
<ide> - [HN: Is there any huge web application built using Redux?](https://news.ycombinator.com/item?id=10710240)
<ide>
<ide>
<del><a id="miscellaneous-authentication"></a>
<ide> ### How can I implement authentication in Redux?
<ide>
<ide> Authentication is essential to any real application. When going about authentication you must keep in mind that nothing changes with how you should organize your application and you should implement authentication in the same way you would any other feature. It is relatively straightforward:
<ide><path>docs/faq/OrganizingState.md
<ide>
<ide> ## Table of Contents
<ide>
<del>- [Do I have to put all my state into Redux? Should I ever use React's setState()?](#organizing-state-only-redux-state)
<del>- [Can I put functions, promises, or other non-serializable items in my store state?](#organizing-state-non-serializable)
<del>- [How do I organize nested or duplicate data in my state?](#organizing-state-nested-data)
<add>- [Do I have to put all my state into Redux? Should I ever use React's setState()?](#do-i-have-to-put-all-my-state-into-redux-should-i-ever-use-reacts-setstate)
<add>- [Can I put functions, promises, or other non-serializable items in my store state?](#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)
<add>- [How do I organize nested or duplicate data in my state?](#how-do-i-organize-nested-or-duplicate-data-in-my-state)
<ide>
<ide>
<ide> ## Organizing State
<ide>
<del><a id="organizing-state-only-redux-state"></a>
<ide> ### Do I have to put all my state into Redux? Should I ever use React's `setState()`?
<ide>
<del>There is no “right” answer for this. Some users prefer to keep every single piece of data in Redux, to maintain a fully serializable and controlled version of their application at all times. Others prefer to keep non-critical or UI state, such as “is this dropdown currently open”, inside a component's internal state.
<add>There is no “right” answer for this. Some users prefer to keep every single piece of data in Redux, to maintain a fully serializable and controlled version of their application at all times. Others prefer to keep non-critical or UI state, such as “is this dropdown currently open”, inside a component's internal state.
<ide>
<ide> ***Using local component state is fine***. As a developer, it is _your_ job to determine what kinds of state make up your application, and where each piece of state should live. Find a balance that works for you, and go with it.
<ide>
<ide> There are a number of community packages that implement various approaches for s
<ide> - [Redux Addons Catalog: Component State](https://github.com/markerikson/redux-ecosystem-links/blob/master/component-state.md)
<ide>
<ide>
<del><a id="organizing-state-non-serializable"></a>
<ide> ### Can I put functions, promises, or other non-serializable items in my store state?
<ide>
<ide> It is highly recommended that you only put plain serializable objects, arrays, and primitives into your store. It's *technically* possible to insert non-serializable items into the store, but doing so can break the ability to persist and rehydrate the contents of a store, as well as interfere with time-travel debugging.
<ide> If you are okay with things like persistence and time-travel debugging potential
<ide> - [#1793: React Elements in Redux State](https://github.com/reduxjs/redux/issues/1793)
<ide>
<ide>
<del><a id="organizing-state-nested-data"></a>
<ide> ### How do I organize nested or duplicate data in my state?
<ide>
<ide> Data with IDs, nesting, or relationships should generally be stored in a “normalized” fashion: each object should be stored once, keyed by ID, and other objects that reference it should only store the ID rather than a copy of the entire object. It may help to think of parts of your store as a database, with individual “tables” per item type. Libraries such as [normalizr](https://github.com/paularmstrong/normalizr) and [redux-orm](https://github.com/tommikaikkonen/redux-orm) can provide help and abstractions in managing normalized data.
<ide><path>docs/faq/Performance.md
<ide>
<ide> ## Table of Contents
<ide>
<del>- [How well does Redux “scale” in terms of performance and architecture?](#performance-scaling)
<del>- [Won't calling “all my reducers” for each action be slow?](#performance-all-reducers)
<del>- [Do I have to deep-clone my state in a reducer? Isn't copying my state going to be slow?](#performance-clone-state)
<del>- [How can I reduce the number of store update events?](#performance-update-events)
<del>- [Will having “one state tree” cause memory problems? Will dispatching many actions take up memory?](#performance-state-memory)
<del>- [Will caching remote data cause memory problems?](#performance-cache-memory)
<add>- [How well does Redux “scale” in terms of performance and architecture?](#how-well-does-redux-scale-in-terms-of-performance-and-architecture)
<add>- [Won't calling “all my reducers” for each action be slow?](#wont-calling-all-my-reducers-for-each-action-be-slow)
<add>- [Do I have to deep-clone my state in a reducer? Isn't copying my state going to be slow?](#do-i-have-to-deep-clone-my-state-in-a-reducer-isnt-copying-my-state-going-to-be-slow)
<add>- [How can I reduce the number of store update events?](#how-can-i-reduce-the-number-of-store-update-events)
<add>- [Will having “one state tree” cause memory problems? Will dispatching many actions take up memory?](#will-having-one-state-tree-cause-memory-problems-will-dispatching-many-actions-take-up-memory)
<add>- [Will caching remote data cause memory problems?](#will-caching-remote-data-cause-memory-problems)
<ide>
<ide>
<ide>
<ide> ## Performance
<ide>
<del><a id="performance-scaling"></a>
<ide> ### How well does Redux “scale” in terms of performance and architecture?
<ide>
<ide> While there's no single definitive answer to this, most of the time this should not be a concern in either case.
<ide> As for architecture, anecdotal evidence is that Redux works well for varying pro
<ide> - [Chat log: React/Redux perf - single connection vs many connections](https://gist.github.com/markerikson/6056565dd65d1232784bf42b65f8b2ad)
<ide>
<ide>
<del><a id="performance-all-reducers"></a>
<ide> ### Won't calling “all my reducers” for each action be slow?
<ide>
<ide> It's important to note that a Redux store really only has a single reducer function. The store passes the current state and dispatched action to that one reducer function, and lets the reducer handle things appropriately.
<ide> If you actually are concerned about reducer performance, you can use a utility s
<ide> - [Stack Overflow: How does Redux deal with deeply nested models?](http://stackoverflow.com/questions/34494866/how-does-redux-deals-with-deeply-nested-models/34495397)
<ide>
<ide>
<del><a id="performance-clone-state"></a>
<ide> ### Do I have to deep-clone my state in a reducer? Isn't copying my state going to be slow?
<ide>
<ide> Immutably updating state generally means making shallow copies, not deep copies. Shallow copies are much faster than deep copies, because fewer objects and fields have to be copied, and it effectively comes down to moving some pointers around.
<ide> However, you *do* need to create a copied and updated object for each level of n
<ide> - [Cloning Objects in JavaScript](http://www.zsoltnagy.eu/cloning-objects-in-javascript/)
<ide>
<ide>
<del><a id="performance-update-events"></a>
<ide> ### How can I reduce the number of store update events?
<ide>
<ide> Redux notifies subscribers after each successfully dispatched action (i.e. an action reached the store and was handled by reducers). In some cases, it may be useful to cut down on the number of times subscribers are called, particularly if an action creator dispatches multiple distinct actions in a row.
<ide> If you use React, note that you can improve performance of multiple synchronous
<ide> - [Redux Addons Catalog: Store - Change Subscriptions](https://github.com/markerikson/redux-ecosystem-links/blob/master/store.md#store-change-subscriptions)
<ide>
<ide>
<del><a id="performance-state-memory"></a>
<ide> ### Will having “one state tree” cause memory problems? Will dispatching many actions take up memory?
<ide>
<ide> First, in terms of raw memory usage, Redux is no different than any other JavaScript library. The only difference is that all the various object references are nested together into one tree, instead of maybe saved in various independent model instances such as in Backbone. Second, a typical Redux app would probably have somewhat *less* memory usage than an equivalent Backbone app because Redux encourages use of plain JavaScript objects and arrays rather than creating instances of Models and Collections. Finally, Redux only holds onto a single state tree reference at a time. Objects that are no longer referenced in that tree will be garbage collected, as usual.
<ide> Redux does not store a history of actions itself. However, the Redux DevTools do
<ide> - [Reddit: What's the best place to keep initial state?](https://www.reddit.com/r/reactjs/comments/47m9h5/whats_the_best_place_to_keep_the_initial_state/)
<ide>
<ide>
<del><a id="performance-cache-memory"></a>
<ide> ### Will caching remote data cause memory problems?
<ide>
<ide> The amount of memory available to JavaScript applications running in a browser is finite. Caching data will cause performance problems when the size of the cache approaches the amount of available memory. This tends to be a problem when the cached data is exceptionally large or the session is exceptionally long-running. And while it is good to be aware of the potential for these problems, this awareness should not discourage you from efficiently caching reasonable amounts of data.
<ide><path>docs/faq/ReactRedux.md
<ide>
<ide> ## Table of Contents
<ide>
<del>- [Why isn't my component re-rendering, or my mapStateToProps running?](#react-not-rerendering)
<del>- [Why is my component re-rendering too often?](#react-rendering-too-often)
<del>- [How can I speed up my mapStateToProps?](#react-mapstate-speed)
<del>- [Why don't I have this.props.dispatch available in my connected component?](#react-props-dispatch)
<del>- [Should I only connect my top component, or can I connect multiple components in my tree?](#react-multiple-components)
<add>- [Why isn't my component re-rendering, or my mapStateToProps running?](#why-isnt-my-component-re-rendering-or-my-mapstatetoprops-running)
<add>- [Why is my component re-rendering too often?](#why-is-my-component-re-rendering-too-often)
<add>- [How can I speed up my mapStateToProps?](#how-can-i-speed-up-my-mapstatetoprops)
<add>- [Why don't I have this.props.dispatch available in my connected component?](#why-dont-i-have-this-props-dispatch-available-in-my-connected-component)
<add>- [Should I only connect my top component, or can I connect multiple components in my tree?](#should-i-only-connect-my-top-component-or-can-i-connect-multiple-components-in-my-tree)
<ide>
<ide>
<ide> ## React Redux
<ide>
<del><a id="react-not-rerendering"></a>
<ide> ### Why isn't my component re-rendering, or my mapStateToProps running?
<ide>
<ide> Accidentally mutating or modifying your state directly is by far the most common reason why components do not re-render after an action has been dispatched. Redux expects that your reducers will update their state “immutably”, which effectively means always making copies of your data, and applying your changes to the copies. If you return the same object from a reducer, Redux assumes that nothing has been changed, even if you made changes to its contents. Similarly, React Redux tries to improve performance by doing shallow equality reference checks on incoming props in `shouldComponentUpdate`, and if all references are the same, `shouldComponentUpdate` returns `false` to skip actually updating your original component.
<ide> Note that “updating data immutably” does *not* mean that you must use [Immut
<ide> - [Gist: state mutations](https://gist.github.com/amcdnl/7d93c0c67a9a44fe5761#gistcomment-1706579)
<ide>
<ide>
<del><a id="react-rendering-too-often"></a>
<ide> ### Why is my component re-rendering too often?
<ide>
<ide> React Redux implements several optimizations to ensure your actual component only re-renders when actually necessary. One of those is a shallow equality check on the combined props object generated by the `mapStateToProps` and `mapDispatchToProps` arguments passed to `connect`. Unfortunately, shallow equality does not help in cases where new array or object instances are created each time `mapStateToProps` is called. A typical example might be mapping over an array of IDs and returning the matching object references, such as:
<ide> For non-connected components, you may want to check what props are being passed
<ide>
<ide>
<ide>
<del><a id="react-mapstate-speed"></a>
<ide> ### How can I speed up my `mapStateToProps`?
<ide>
<ide> While React Redux does work to minimize the number of times that your `mapStateToProps` function is called, it's still a good idea to ensure that your `mapStateToProps` runs quickly and also minimizes the amount of work it does. The common recommended approach is to create memoized “selector” functions using [Reselect](https://github.com/reduxjs/reselect). These selectors can be combined and composed together, and selectors later in a pipeline will only run if their inputs have changed. This means you can create selectors that do things like filtering or sorting, and ensure that the real work only happens if needed.
<ide> While React Redux does work to minimize the number of times that your `mapStateT
<ide> - [Reselect #47: Memoizing Hierarchical Selectors](https://github.com/reduxjs/reselect/issues/47)
<ide>
<ide>
<del><a id="react-props-dispatch"></a>
<ide> ### Why don't I have `this.props.dispatch` available in my connected component?
<ide>
<ide> The `connect()` function takes two primary arguments, both optional. The first, `mapStateToProps`, is a function you provide to pull data from the store when it changes, and pass those values as props to your component. The second, `mapDispatchToProps`, is a function you provide to make use of the store's `dispatch` function, usually by creating pre-bound versions of action creators that will automatically dispatch their actions as soon as they are called.
<ide> If you do not provide your own `mapDispatchToProps` function when calling `conne
<ide> - [Stack Overflow: How to get simple dispatch from this.props using connect w/ Redux?](http://stackoverflow.com/questions/34458261/how-to-get-simple-dispatch-from-this-props-using-connect-w-redux/34458710])
<ide>
<ide>
<del><a id="react-multiple-components"></a>
<ide> ### Should I only connect my top component, or can I connect multiple components in my tree?
<ide>
<ide> Early Redux documentation advised that you should only have a few connected components near the top of your component tree. However, time and experience has shown that such a component architecture generally requires a few components to know too much about the data requirements of all their descendants, and forces them to pass down a confusing number of props.
<ide><path>docs/faq/Reducers.md
<ide>
<ide> ## Table of Contents
<ide>
<del>- [How do I share state between two reducers? Do I have to use combineReducers?](#reducers-share-state)
<del>- [Do I have to use the switch statement to handle actions?](#reducers-use-switch)
<add>- [How do I share state between two reducers? Do I have to use combineReducers?](#how-do-i-share-state-between-two-reducers-do-i-have-to-use-combinereducers)
<add>- [Do I have to use the switch statement to handle actions?](#do-i-have-to-use-the-switch-statement-to-handle-actions)
<ide>
<ide>
<ide>
<ide> ## Reducers
<ide>
<del><a id="reducers-share-state"></a>
<ide> ### How do I share state between two reducers? Do I have to use `combineReducers`?
<ide>
<ide> The suggested structure for a Redux store is to split the state object into multiple “slices” or “domains” by key, and provide a separate reducer function to manage each individual data slice. This is similar to how the standard Flux pattern has multiple independent stores, and Redux provides the [`combineReducers`](/docs/api/combineReducers.md) utility function to make this pattern easier. However, it's important to note that `combineReducers` is *not* required—it is simply a utility function for the common use case of having a single reducer function per state slice, with plain JavaScript objects for the data.
<ide> In general, remember that reducers are just functions—you can organize them an
<ide> - [Sharing State Between Redux Reducers](https://invalidpatent.wordpress.com/2016/02/18/sharing-state-between-redux-reducers/)
<ide>
<ide>
<del><a id="reducers-use-switch"></a>
<ide> ### Do I have to use the `switch` statement to handle actions?
<ide>
<ide> No. You are welcome to use any approach you'd like to respond to an action in a reducer. The `switch` statement is the most common approach, but it's fine to use `if` statements, a lookup table of functions, or to create a function that abstracts this away. In fact, while Redux does require that action objects contain a `type` field, your reducer logic doesn't even have to rely on that to handle the action. That said, the standard approach is definitely using a switch statement or a lookup table based on `type`.
<ide><path>docs/faq/StoreSetup.md
<ide>
<ide> ## Table of Contents
<ide>
<del>- [Can or should I create multiple stores? Can I import my store directly, and use it in components myself?](#store-setup-multiple-stores)
<del>- [Is it OK to have more than one middleware chain in my store enhancer? What is the difference between next and dispatch in a middleware function?](#store-setup-middleware-chains)
<del>- [How do I subscribe to only a portion of the state? Can I get the dispatched action as part of the subscription?](#store-setup-subscriptions)
<add>- [Can or should I create multiple stores? Can I import my store directly, and use it in components myself?](#can-or-should-i-create-multiple-stores-can-i-import-my-store-directly-and-use-it-in-components-myself)
<add>- [Is it OK to have more than one middleware chain in my store enhancer? What is the difference between next and dispatch in a middleware function?](#is-it-ok-to-have-more-than-one-middleware-chain-in-my-store-enhancer-what-is-the-difference-between-next-and-dispatch-in-a-middleware-function)
<add>- [How do I subscribe to only a portion of the state? Can I get the dispatched action as part of the subscription?](#how-do-i-subscribe-to-only-a-portion-of-the-state-can-i-get-the-dispatched-action-as-part-of-the-subscription)
<ide>
<ide> ## Store Setup
<ide>
<del><a id="store-setup-multiple-stores"></a>
<ide> ### Can or should I create multiple stores? Can I import my store directly, and use it in components myself?
<ide>
<ide> The original Flux pattern describes having multiple “stores” in an app, each one holding a different area of domain data. This can introduce issues such as needing to have one store “`waitFor`” another store to update. This is not necessary in Redux because the separation between data domains is already achieved by splitting a single reducer into smaller reducers.
<ide> With [React Redux](https://github.com/reduxjs/react-redux), the wrapper classes
<ide> - [Gist: Breaking out of Redux paradigm to isolate apps](https://gist.github.com/gaearon/eeee2f619620ab7b55673a4ee2bf8400)
<ide>
<ide>
<del><a id="store-setup-middleware-chains"></a>
<ide> ### Is it OK to have more than one middleware chain in my store enhancer? What is the difference between `next` and `dispatch` in a middleware function?
<ide>
<ide> Redux middleware act like a linked list. Each middleware function can either call `next(action)` to pass an action along to the next middleware in line, call `dispatch(action)` to restart the processing at the beginning of the list, or do nothing at all to stop the action from being processed further.
<ide> This chain of middleware is defined by the arguments passed to the `applyMiddlew
<ide> - [Exploring Redux Middleware](http://blog.krawaller.se/posts/exploring-redux-middleware/)
<ide>
<ide>
<del><a id="store-setup-subscriptions"></a>
<ide> ### How do I subscribe to only a portion of the state? Can I get the dispatched action as part of the subscription?
<ide>
<ide> Redux provides a single `store.subscribe` method for notifying listeners that the store has updated. Listener callbacks do not receive the current state as an argument—it is simply an indication that *something* has changed. The subscriber logic can then call `getState()` to get the current state value.
<ide><path>docs/recipes/UsingImmutableJS.md
<ide> # Using Immutable.JS with Redux
<ide> ## Table of Contents
<del>- [Why should I use an immutable-focused library such as Immutable.JS?](#why-use-immutable-library)
<del>- [Why should I choose Immutable.JS as an immutable library?](#why-choose-immutable-js)
<del>- [What are the issues with using Immutable.JS?](#issues-with-immutable-js)
<del>- [Is Immutable.JS worth the effort?](#is-immutable-js-worth-effort)
<del>- [What are some opinionated Best Practices for using Immutable.JS with Redux?](#immutable-js-best-practices)
<add>- [Why should I use an immutable-focused library such as Immutable.JS?](#why-should-i-use-an-immutable-focused-library-such-as-immutable-js)
<add>- [Why should I choose Immutable.JS as an immutable library?](#why-should-i-choose-immutable-js-as-an-immutable-library)
<add>- [What are the issues with using Immutable.JS?](#what-are-the-issues-with-using-immutable-js)
<add>- [Is Immutable.JS worth the effort?](#is-using-immutable-js-worth-the-effort)
<add>- [What are some opinionated Best Practices for using Immutable.JS with Redux?](#what-are-some-opinionated-best-practices-for-using-immutable-js-with-redux)
<ide>
<del><a id="why-use-immutable-library"></a>
<ide> ## Why should I use an immutable-focused library such as Immutable.JS?
<ide>
<ide> Immutable-focused libraries such as Immutable.JS have been designed to overcome the issues with immutability inherent within JavaScript, providing all the benefits of immutability with the performance your app requires.
<ide> Whichever option you choose, make sure you’re familiar with the concepts of [i
<ide> - [Pros and Cons of using immutability with React.js](http://reactkungfu.com/2015/08/pros-and-cons-of-using-immutability-with-react-js/)
<ide>
<ide>
<del><a id="why-choose-immutable-js"></a>
<ide> ## Why should I choose Immutable.JS as an immutable library?
<ide>
<ide> Immutable.JS was designed to provide immutability in a performant manner in an effort to overcome the limitations of immutability with JavaScript. Its principle advantages include:
<ide> You never see this, of course - the data you give to an Immutable.JS object is n
<ide> - [Immutable.js](https://facebook.github.io/immutable-js/)
<ide>
<ide>
<del><a id="issues-with-immutable-js"></a>
<ide> ## What are the issues with using Immutable.JS?
<ide>
<ide> Although powerful, Immutable.JS needs to be used carefully, as it comes with issues of its own. Note, however, that all of these issues can be overcome quite easily with careful coding.
<ide> This can be prevented by using `toJS()` in a Higher Order Component, as discusse
<ide> - [Immutable Object Formatter](https://chrome.google.com/webstore/detail/immutablejs-object-format/hgldghadipiblonfkkicmgcbbijnpeog)
<ide>
<ide>
<del><a id="is-immutable-js-worth-effort"></a>
<ide> ## Is Using Immutable.JS worth the effort?
<ide>
<ide> Frequently, yes. There are various tradeoffs and opinions to consider, but there are many good reasons to use Immutable.JS. Do not underestimate the difficulty of trying to track down a property of your state tree that has been inadvertently mutated.
<ide> This, together with its performance and rich API for data manipulation, is why I
<ide> - [Troubleshooting: Nothing happens when I dispatch an action](http://redux.js.org/Troubleshooting.html#nothing-happens-when-i-dispatch-an-action)
<ide>
<ide>
<del><a id="immutable-js-best-practices"></a>
<ide> ## What are some opinionated Best Practices for using Immutable.JS with Redux?
<ide>
<ide> Immutable.JS can provide significant reliability and performance improvements to your app, but it must be used correctly. If you choose to use Immutable.JS (and remember, you are not required to, and there are other immutable libraries you can use), follow these opinionated best practices, and you’ll be able to get the most out of it, without tripping up on any of the issues it can potentially cause.
<ide>
<del>### Never mix plain JavaScript objects with Immutable.JS
<add>### Never mix plain JavaScript objects with Immutable.JS
<ide>
<ide> Never let a plain JavaScript object contain Immutable.JS properties. Equally, never let an Immutable.JS object contain a plain JavaScript object.
<ide> | 12 |
Ruby | Ruby | add benchmark inject code" | 2f44990ea9e0439db24c8b6ef932c608f3f0069b | <ide><path>Library/Homebrew/cmd/audit.rb
<ide> def audit
<ide> ENV.activate_extensions!
<ide> ENV.setup_build_environment
<ide>
<del> if ARGV.switch? "D"
<del> FormulaAuditor.module_eval do
<del> instance_methods.grep(/audit_/).map do |name|
<del> method = instance_method(name)
<del> define_method(name) do |*args, &block|
<del> begin
<del> time = Time.now
<del> method.bind(self).(*args, &block)
<del> ensure
<del> $times[name] ||= 0
<del> $times[name] += Time.now - time
<del> end
<del> end
<del> end
<del> end
<del>
<del> $times = {}
<del> at_exit { puts $times.sort_by{ |k, v| v }.map{ |k, v| "#{k}: #{v}" } }
<del> end
<del>
<ide> ff = if ARGV.named.empty?
<ide> Formula
<ide> else | 1 |
Java | Java | update jctools code | 07fb3280cd777bc79c7f59fdeb07dd814c9cc9e1 | <ide><path>rxjava-core/src/main/java/rx/internal/util/unsafe/ConcurrentCircularArrayQueue.java
<ide> import java.util.AbstractQueue;
<ide> import java.util.Iterator;
<ide>
<del>abstract class ConcurrentCircularArrayQueueL0Pad<E> extends AbstractQueue<E>{
<add>abstract class ConcurrentCircularArrayQueueL0Pad<E> extends AbstractQueue<E> implements MessagePassingQueue<E> {
<ide> long p00, p01, p02, p03, p04, p05, p06, p07;
<ide> long p30, p31, p32, p33, p34, p35, p36, p37;
<ide> }
<ide>
<add>/**
<add> * A concurrent access enabling class used by circular array based queues this class exposes an offset computation
<add> * method along with differently memory fenced load/store methods into the underlying array. The class is pre-padded and
<add> * the array is padded on either side to help with False sharing prvention. It is expected theat subclasses handle post
<add> * padding.
<add> * <p>
<add> * Offset calculation is separate from access to enable the reuse of a give compute offset.
<add> * <p>
<add> * Load/Store methods using a <i>buffer</i> parameter are provided to allow the prevention of final field reload after a
<add> * LoadLoad barrier.
<add> * <p>
<add> *
<add> * @author nitsanw
<add> *
<add> * @param <E>
<add> */
<ide> public abstract class ConcurrentCircularArrayQueue<E> extends ConcurrentCircularArrayQueueL0Pad<E> {
<ide> protected static final int SPARSE_SHIFT = Integer.getInteger("sparse.shift", 0);
<ide> protected static final int BUFFER_PAD = 32;
<ide>
<ide> @SuppressWarnings("unchecked")
<ide> public ConcurrentCircularArrayQueue(int capacity) {
<del> this.capacity = Pow2.findNextPositivePowerOfTwo(capacity);
<add> this.capacity = Pow2.roundToPowerOfTwo(capacity);
<ide> mask = this.capacity - 1;
<ide> // pad data on either end with some empty slots.
<ide> buffer = (E[]) new Object[(this.capacity << SPARSE_SHIFT) + BUFFER_PAD * 2];
<ide> }
<ide>
<del> public ConcurrentCircularArrayQueue(ConcurrentCircularArrayQueue<E> c) {
<del> this.capacity = c.capacity;
<del> this.mask = c.mask;
<del> // pad data on either end with some empty slots.
<del> this.buffer = c.buffer;
<del> }
<del>
<del> protected final long calcOffset(long index) {
<add> /**
<add> * @param index desirable element index
<add> * @return the offset in bytes within the array for a given index.
<add> */
<add> protected final long calcElementOffset(long index) {
<ide> return REF_ARRAY_BASE + ((index & mask) << REF_ELEMENT_SHIFT);
<ide> }
<ide>
<add> /**
<add> * A plain store (no ordering/fences) of an element to a given offset
<add> *
<add> * @param offset computed via {@link ConcurrentCircularArrayQueue#calcElementOffset(long)}
<add> * @param e a kitty
<add> */
<ide> protected final void spElement(long offset, E e) {
<del> UNSAFE.putObject(buffer, offset, e);
<del> }
<del>
<del> protected final void soElement(long offset, E e) {
<del> UNSAFE.putOrderedObject(buffer, offset, e);
<del> }
<del>
<del> protected final void svElement(long offset, E e) {
<del> UNSAFE.putObjectVolatile(buffer, offset, e);
<del> }
<del>
<del> @SuppressWarnings("unchecked")
<del> protected final E lpElement(long offset) {
<del> return (E) UNSAFE.getObject(buffer, offset);
<del> }
<del>
<del> @SuppressWarnings("unchecked")
<del> protected final E lvElement(long offset) {
<del> return (E) UNSAFE.getObjectVolatile(buffer, offset);
<add> spElement(buffer, offset, e);
<ide> }
<ide>
<add> /**
<add> * A plain store (no ordering/fences) of an element to a given offset
<add> *
<add> * @param buffer this.buffer
<add> * @param offset computed via {@link ConcurrentCircularArrayQueue#calcElementOffset(long)}
<add> * @param e an orderly kitty
<add> */
<ide> protected final void spElement(E[] buffer, long offset, E e) {
<ide> UNSAFE.putObject(buffer, offset, e);
<ide> }
<ide>
<add> /**
<add> * An ordered store(store + StoreStore barrier) of an element to a given offset
<add> *
<add> * @param offset computed via {@link ConcurrentCircularArrayQueue#calcElementOffset(long)}
<add> * @param e an orderly kitty
<add> */
<add> protected final void soElement(long offset, E e) {
<add> soElement(buffer, offset, e);
<add> }
<add>
<add> /**
<add> * An ordered store(store + StoreStore barrier) of an element to a given offset
<add> *
<add> * @param buffer this.buffer
<add> * @param offset computed via {@link ConcurrentCircularArrayQueue#calcElementOffset(long)}
<add> * @param e an orderly kitty
<add> */
<ide> protected final void soElement(E[] buffer, long offset, E e) {
<ide> UNSAFE.putOrderedObject(buffer, offset, e);
<ide> }
<ide>
<del> protected final void svElement(E[] buffer, long offset, E e) {
<del> UNSAFE.putObjectVolatile(buffer, offset, e);
<add> /**
<add> * A plain load (no ordering/fences) of an element from a given offset.
<add> *
<add> * @param offset computed via {@link ConcurrentCircularArrayQueue#calcElementOffset(long)}
<add> * @return the element at the offset
<add> */
<add> protected final E lpElement(long offset) {
<add> return lpElement(buffer, offset);
<ide> }
<ide>
<add> /**
<add> * A plain load (no ordering/fences) of an element from a given offset.
<add> *
<add> * @param buffer this.buffer
<add> * @param offset computed via {@link ConcurrentCircularArrayQueue#calcElementOffset(long)}
<add> * @return the element at the offset
<add> */
<ide> @SuppressWarnings("unchecked")
<ide> protected final E lpElement(E[] buffer, long offset) {
<ide> return (E) UNSAFE.getObject(buffer, offset);
<ide> }
<ide>
<add> /**
<add> * A volatile load (load + LoadLoad barrier) of an element from a given offset.
<add> *
<add> * @param offset computed via {@link ConcurrentCircularArrayQueue#calcElementOffset(long)}
<add> * @return the element at the offset
<add> */
<add> protected final E lvElement(long offset) {
<add> return lvElement(buffer, offset);
<add> }
<add>
<add> /**
<add> * A volatile load (load + LoadLoad barrier) of an element from a given offset.
<add> *
<add> * @param buffer this.buffer
<add> * @param offset computed via {@link ConcurrentCircularArrayQueue#calcElementOffset(long)}
<add> * @return the element at the offset
<add> */
<ide> @SuppressWarnings("unchecked")
<ide> protected final E lvElement(E[] buffer, long offset) {
<ide> return (E) UNSAFE.getObjectVolatile(buffer, offset);
<ide> }
<ide>
<del> @Override
<del> public boolean offer(E e) {
<del> throw new UnsupportedOperationException();
<del> }
<del>
<del> @Override
<del> public E poll() {
<del> throw new UnsupportedOperationException();
<del> }
<del> @Override
<del> public E peek() {
<del> throw new UnsupportedOperationException();
<del> }
<ide> @Override
<ide> public Iterator<E> iterator() {
<ide> throw new UnsupportedOperationException();
<ide> }
<del>
<del> @Override
<del> public int size() {
<del> throw new UnsupportedOperationException();
<del> }
<ide> }
<ide>\ No newline at end of file
<ide><path>rxjava-core/src/main/java/rx/internal/util/unsafe/ConcurrentSequencedCircularArrayQueue.java
<ide> throw new IllegalStateException("Unexpected long[] element size");
<ide> }
<ide> // Including the buffer pad in the array base offset
<del> ARRAY_BASE = UnsafeAccess.UNSAFE.arrayBaseOffset(long[].class)
<del> + (BUFFER_PAD << (ELEMENT_SHIFT - SPARSE_SHIFT));
<add> ARRAY_BASE = UnsafeAccess.UNSAFE.arrayBaseOffset(long[].class) + (BUFFER_PAD << (ELEMENT_SHIFT - SPARSE_SHIFT));
<ide> }
<ide> protected final long[] sequenceBuffer;
<ide>
<ide> public ConcurrentSequencedCircularArrayQueue(int capacity) {
<ide> // pad data on either end with some empty slots.
<ide> sequenceBuffer = new long[(this.capacity << SPARSE_SHIFT) + BUFFER_PAD * 2];
<ide> for (long i = 0; i < this.capacity; i++) {
<del> soSequenceElement(calcSequenceOffset(i), i);
<add> soSequence(sequenceBuffer, calcSequenceOffset(i), i);
<ide> }
<ide> }
<ide>
<del> public ConcurrentSequencedCircularArrayQueue(ConcurrentSequencedCircularArrayQueue<E> c) {
<del> super(c);
<del> this.sequenceBuffer = c.sequenceBuffer;
<del> }
<del>
<ide> protected final long calcSequenceOffset(long index) {
<ide> return ARRAY_BASE + ((index & mask) << ELEMENT_SHIFT);
<ide> }
<ide>
<del> protected final void spSequenceElement(long offset, long e) {
<del> UNSAFE.putLong(sequenceBuffer, offset, e);
<del> }
<del>
<del> protected final void soSequenceElement(long offset, long e) {
<del> UNSAFE.putOrderedLong(sequenceBuffer, offset, e);
<del> }
<del>
<del> protected final void svSequenceElement(long offset, long e) {
<del> UNSAFE.putLongVolatile(sequenceBuffer, offset, e);
<del> }
<del>
<del> protected final long lpSequenceElement(long offset) {
<del> return UNSAFE.getLong(sequenceBuffer, offset);
<del> }
<del>
<del> protected final long lvSequenceElement(long offset) {
<del> return UNSAFE.getLongVolatile(sequenceBuffer, offset);
<del> }
<del>
<del> protected final void spSequenceElement(long[] buffer, long offset, long e) {
<del> UNSAFE.putLong(buffer, offset, e);
<del> }
<del>
<del> protected final void soSequenceElement(long[] buffer, long offset, long e) {
<add> protected final void soSequence(long[] buffer, long offset, long e) {
<ide> UNSAFE.putOrderedLong(buffer, offset, e);
<ide> }
<ide>
<del> protected final void svSequenceElement(long[] buffer, long offset, long e) {
<del> UNSAFE.putLongVolatile(buffer, offset, e);
<del> }
<del>
<del> protected final long lpSequenceElement(long[] buffer, long offset) {
<del> return UNSAFE.getLong(buffer, offset);
<del> }
<del>
<del> protected final long lvSequenceElement(long[] buffer, long offset) {
<add> protected final long lvSequence(long[] buffer, long offset) {
<ide> return UNSAFE.getLongVolatile(buffer, offset);
<ide> }
<ide>
<ide><path>rxjava-core/src/main/java/rx/internal/util/unsafe/IntConcurrentCircularArrayQueue.java
<del>/*
<del> * Licensed under the Apache License, Version 2.0 (the "License");
<del> * you may not use this file except in compliance with the License.
<del> * You may obtain a copy of the License at
<del> *
<del> * http://www.apache.org/licenses/LICENSE-2.0
<del> *
<del> * Unless required by applicable law or agreed to in writing, software
<del> * distributed under the License is distributed on an "AS IS" BASIS,
<del> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<del> * See the License for the specific language governing permissions and
<del> * limitations under the License.
<del> *
<del> * Original License: https://github.com/JCTools/JCTools/blob/master/LICENSE
<del> * Original location: https://github.com/JCTools/JCTools/blob/master/jctools-core/src/main/java/org/jctools/queues/IntConcurrentCircularArrayQueue.java
<del> */
<del>package rx.internal.util.unsafe;
<del>
<del>import static rx.internal.util.unsafe.UnsafeAccess.UNSAFE;
<del>
<del>abstract class IntConcurrentCircularArrayQueueL0Pad {
<del> long p00, p01, p02, p03, p04, p05, p06, p07;
<del> long p30, p31, p32, p33, p34, p35, p36, p37;
<del>}
<del>
<del>public abstract class IntConcurrentCircularArrayQueue extends IntConcurrentCircularArrayQueueL0Pad {
<del> protected static final int SPARSE_SHIFT = Integer.getInteger("sparse.shift", 0);
<del> protected static final int BUFFER_PAD = 32;
<del> private static final long REF_ARRAY_BASE;
<del> private static final int REF_ELEMENT_SHIFT;
<del> static {
<del> final int scale = UnsafeAccess.UNSAFE.arrayIndexScale(int[].class);
<del> if (4 == scale) {
<del> REF_ELEMENT_SHIFT = 2 + SPARSE_SHIFT;
<del> } else if (8 == scale) {
<del> REF_ELEMENT_SHIFT = 3 + SPARSE_SHIFT;
<del> } else {
<del> throw new IllegalStateException("Unknown pointer size");
<del> }
<del> // Including the buffer pad in the array base offset
<del> REF_ARRAY_BASE = UnsafeAccess.UNSAFE.arrayBaseOffset(int[].class)
<del> + (BUFFER_PAD << (REF_ELEMENT_SHIFT - SPARSE_SHIFT));
<del> }
<del> protected final int capacity;
<del> protected final long mask;
<del> // @Stable :(
<del> protected final int[] buffer;
<del>
<del> public IntConcurrentCircularArrayQueue(int capacity) {
<del> this.capacity = Pow2.findNextPositivePowerOfTwo(capacity);
<del> mask = this.capacity - 1;
<del> // pad data on either end with some empty slots.
<del> buffer = new int[(this.capacity << SPARSE_SHIFT) + BUFFER_PAD * 2];
<del> }
<del>
<del> public IntConcurrentCircularArrayQueue(IntConcurrentCircularArrayQueue c) {
<del> this.capacity = c.capacity;
<del> this.mask = c.mask;
<del> // pad data on either end with some empty slots.
<del> this.buffer = c.buffer;
<del> }
<del>
<del> protected final long calcOffset(long index) {
<del> return REF_ARRAY_BASE + ((index & mask) << REF_ELEMENT_SHIFT);
<del> }
<del>
<del> protected final void spElement(long offset, int e) {
<del> UNSAFE.putInt(buffer, offset, e);
<del> }
<del>
<del> protected final void soElement(long offset, int e) {
<del> UNSAFE.putOrderedInt(buffer, offset, e);
<del> }
<del>
<del> protected final void svElement(long offset, int e) {
<del> UNSAFE.putIntVolatile(buffer, offset, e);
<del> }
<del>
<del> protected final int lpElement(long offset) {
<del> return UNSAFE.getInt(buffer, offset);
<del> }
<del>
<del> protected final int lvElement(long offset) {
<del> return UNSAFE.getIntVolatile(buffer, offset);
<del> }
<del>
<del> protected final void spElement(int[] buffer, long offset, int e) {
<del> UNSAFE.putInt(buffer, offset, e);
<del> }
<del>
<del> protected final void soElement(int[] buffer, long offset, int e) {
<del> UNSAFE.putOrderedInt(buffer, offset, e);
<del> }
<del>
<del> protected final void svElement(int[] buffer, long offset, int e) {
<del> UNSAFE.putIntVolatile(buffer, offset, e);
<del> }
<del>
<del> protected final int lpElement(int[] buffer, long offset) {
<del> return UNSAFE.getInt(buffer, offset);
<del> }
<del>
<del> protected final int lvElement(int[] buffer, long offset) {
<del> return UNSAFE.getIntVolatile(buffer, offset);
<del> }
<del>
<del>}
<ide>\ No newline at end of file
<ide><path>rxjava-core/src/main/java/rx/internal/util/unsafe/IntConcurrentSequencedCircularArrayQueue.java
<del>/*
<del> * Licensed under the Apache License, Version 2.0 (the "License");
<del> * you may not use this file except in compliance with the License.
<del> * You may obtain a copy of the License at
<del> *
<del> * http://www.apache.org/licenses/LICENSE-2.0
<del> *
<del> * Unless required by applicable law or agreed to in writing, software
<del> * distributed under the License is distributed on an "AS IS" BASIS,
<del> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<del> * See the License for the specific language governing permissions and
<del> * limitations under the License.
<del> *
<del> * Original License: https://github.com/JCTools/JCTools/blob/master/LICENSE
<del> * Original location: https://github.com/JCTools/JCTools/blob/master/jctools-core/src/main/java/org/jctools/queues/ConcurrentSequencedCircularArrayQueue.java
<del> */
<del>package rx.internal.util.unsafe;
<del>
<del>import static rx.internal.util.unsafe.UnsafeAccess.UNSAFE;
<del>
<del>public abstract class IntConcurrentSequencedCircularArrayQueue extends IntConcurrentCircularArrayQueue {
<del> private static final long ARRAY_BASE;
<del> private static final int ELEMENT_SHIFT;
<del> static {
<del> final int scale = UnsafeAccess.UNSAFE.arrayIndexScale(long[].class);
<del> if (8 == scale) {
<del> ELEMENT_SHIFT = 3 + SPARSE_SHIFT;
<del> } else {
<del> throw new IllegalStateException("Unexpected long[] element size");
<del> }
<del> // Including the buffer pad in the array base offset
<del> ARRAY_BASE = UnsafeAccess.UNSAFE.arrayBaseOffset(long[].class)
<del> + (BUFFER_PAD << (ELEMENT_SHIFT - SPARSE_SHIFT));
<del> }
<del> protected final long[] sequenceBuffer;
<del>
<del> public IntConcurrentSequencedCircularArrayQueue(int capacity) {
<del> super(capacity);
<del> // pad data on either end with some empty slots.
<del> sequenceBuffer = new long[(this.capacity << SPARSE_SHIFT) + BUFFER_PAD * 2];
<del> for (long i = 0; i < this.capacity; i++) {
<del> soSequenceElement(calcSequenceOffset(i), i);
<del> }
<del> }
<del>
<del> public IntConcurrentSequencedCircularArrayQueue(IntConcurrentSequencedCircularArrayQueue c) {
<del> super(c);
<del> this.sequenceBuffer = c.sequenceBuffer;
<del> }
<del>
<del> protected final long calcSequenceOffset(long index) {
<del> return ARRAY_BASE + ((index & mask) << ELEMENT_SHIFT);
<del> }
<del>
<del> protected final void spSequenceElement(long offset, long e) {
<del> UNSAFE.putLong(sequenceBuffer, offset, e);
<del> }
<del>
<del> protected final void soSequenceElement(long offset, long e) {
<del> UNSAFE.putOrderedLong(sequenceBuffer, offset, e);
<del> }
<del>
<del> protected final void svSequenceElement(long offset, long e) {
<del> UNSAFE.putLongVolatile(sequenceBuffer, offset, e);
<del> }
<del>
<del> protected final long lpSequenceElement(long offset) {
<del> return UNSAFE.getLong(sequenceBuffer, offset);
<del> }
<del>
<del> protected final long lvSequenceElement(long offset) {
<del> return UNSAFE.getLongVolatile(sequenceBuffer, offset);
<del> }
<del>
<del> protected final void spSequenceElement(long[] buffer, long offset, long e) {
<del> UNSAFE.putLong(buffer, offset, e);
<del> }
<del>
<del> protected final void soSequenceElement(long[] buffer, long offset, long e) {
<del> UNSAFE.putOrderedLong(buffer, offset, e);
<del> }
<del>
<del> protected final void svSequenceElement(long[] buffer, long offset, long e) {
<del> UNSAFE.putLongVolatile(buffer, offset, e);
<del> }
<del>
<del> protected final long lpSequenceElement(long[] buffer, long offset) {
<del> return UNSAFE.getLong(buffer, offset);
<del> }
<del>
<del> protected final long lvSequenceElement(long[] buffer, long offset) {
<del> return UNSAFE.getLongVolatile(buffer, offset);
<del> }
<del>
<del>}
<ide>\ No newline at end of file
<ide><path>rxjava-core/src/main/java/rx/internal/util/unsafe/IntMpmcArrayQueue.java
<del>/*
<del> * Licensed under the Apache License, Version 2.0 (the "License");
<del> * you may not use this file except in compliance with the License.
<del> * You may obtain a copy of the License at
<del> *
<del> * http://www.apache.org/licenses/LICENSE-2.0
<del> *
<del> * Unless required by applicable law or agreed to in writing, software
<del> * distributed under the License is distributed on an "AS IS" BASIS,
<del> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<del> * See the License for the specific language governing permissions and
<del> * limitations under the License.
<del> *
<del> * Original License: https://github.com/JCTools/JCTools/blob/master/LICENSE
<del> * Original location: https://github.com/JCTools/JCTools/blob/master/jctools-core/src/main/java/org/jctools/queues/IntMpmcArrayQueue.java
<del> */
<del>package rx.internal.util.unsafe;
<del>
<del>import static rx.internal.util.unsafe.UnsafeAccess.UNSAFE;
<del>
<del>import java.util.Queue;
<del>
<del>abstract class IntMpmcArrayQueueL1Pad extends IntConcurrentSequencedCircularArrayQueue {
<del> long p10, p11, p12, p13, p14, p15, p16;
<del> long p30, p31, p32, p33, p34, p35, p36, p37;
<del>
<del> public IntMpmcArrayQueueL1Pad(int capacity) {
<del> super(capacity);
<del> }
<del>}
<del>
<del>abstract class IntMpmcArrayQueueTailField extends IntMpmcArrayQueueL1Pad {
<del> private final static long TAIL_OFFSET;
<del> static {
<del> try {
<del> TAIL_OFFSET = UNSAFE.objectFieldOffset(IntMpmcArrayQueueTailField.class.getDeclaredField("tail"));
<del> } catch (NoSuchFieldException e) {
<del> throw new RuntimeException(e);
<del> }
<del> }
<del> private volatile long tail;
<del>
<del> public IntMpmcArrayQueueTailField(int capacity) {
<del> super(capacity);
<del> }
<del>
<del> protected final long lvTail() {
<del> return tail;
<del> }
<del>
<del> protected final boolean casTail(long expect, long newValue) {
<del> return UNSAFE.compareAndSwapLong(this, TAIL_OFFSET, expect, newValue);
<del> }
<del>}
<del>
<del>abstract class IntMpmcArrayQueueL2Pad extends IntMpmcArrayQueueTailField {
<del> long p20, p21, p22, p23, p24, p25, p26;
<del> long p30, p31, p32, p33, p34, p35, p36, p37;
<del>
<del> public IntMpmcArrayQueueL2Pad(int capacity) {
<del> super(capacity);
<del> }
<del>}
<del>
<del>abstract class IntMpmcArrayQueueHeadField extends IntMpmcArrayQueueL2Pad {
<del> private final static long HEAD_OFFSET;
<del> static {
<del> try {
<del> HEAD_OFFSET = UNSAFE.objectFieldOffset(IntMpmcArrayQueueHeadField.class.getDeclaredField("head"));
<del> } catch (NoSuchFieldException e) {
<del> throw new RuntimeException(e);
<del> }
<del> }
<del> private volatile long head;
<del>
<del> public IntMpmcArrayQueueHeadField(int capacity) {
<del> super(capacity);
<del> }
<del>
<del> protected final long lvHead() {
<del> return head;
<del> }
<del>
<del> protected final boolean casHead(long expect, long newValue) {
<del> return UNSAFE.compareAndSwapLong(this, HEAD_OFFSET, expect, newValue);
<del> }
<del>}
<del>
<del>public class IntMpmcArrayQueue extends IntMpmcArrayQueueHeadField {
<del> long p40, p41, p42, p43, p44, p45, p46;
<del> long p30, p31, p32, p33, p34, p35, p36, p37;
<del>
<del> public IntMpmcArrayQueue(final int capacity) {
<del> super(Math.max(2, capacity));
<del> }
<del>
<del> public boolean offer(final int e) {
<del> if (e < 0) {
<del> throw new IllegalStateException("only supports positive numbers");
<del> }
<del> final long[] lsb = sequenceBuffer;
<del> long currentTail;
<del> long pOffset;
<del>
<del> for (;;) {
<del> currentTail = lvTail();
<del> pOffset = calcSequenceOffset(currentTail);
<del> long seq = lvSequenceElement(lsb, pOffset);
<del> long delta = seq - currentTail;
<del> if (delta == 0) {
<del> // this is expected if we see this first time around
<del> if (casTail(currentTail, currentTail + 1)) {
<del> break;
<del> }
<del> // failed cas, retry 1
<del> } else if (delta < 0) {
<del> // poll has not moved this value forward
<del> return false;
<del> } else {
<del> // another producer beat us
<del> }
<del> }
<del> final long offset = calcOffset(currentTail);
<del> spElement(offset, e);
<del> // increment position, seeing this value again should lead to retry 2
<del> soSequenceElement(lsb, pOffset, currentTail + 1);
<del> return true;
<del> }
<del>
<del> public int poll() {
<del> final long[] lsb = sequenceBuffer;
<del> long currentHead;
<del> long pOffset;
<del> for (;;) {
<del> currentHead = lvHead();
<del> pOffset = calcSequenceOffset(currentHead);
<del> long seq = lvSequenceElement(lsb, pOffset);
<del> long delta = seq - (currentHead + 1);
<del> if (delta == 0) {
<del> if (casHead(currentHead, currentHead + 1)) {
<del> break;
<del> }
<del> // failed cas, retry 1
<del> } else if (delta < 0) {
<del> // queue is empty
<del> return -1;
<del> } else {
<del> // another consumer beat us
<del> }
<del> }
<del> final long offset = calcOffset(currentHead);
<del> final int[] lb = buffer;
<del> int e = lvElement(lb, offset);
<del> spElement(lb, offset, -1);
<del> soSequenceElement(lsb, pOffset, currentHead + capacity);
<del> return e;
<del> }
<del>
<del> public int size() {
<del> return (int) (lvTail() - lvHead());
<del> }
<del>
<del> public void clear() {
<del> while (poll() != -1)
<del> ;
<del> }
<del>}
<ide>\ No newline at end of file
<ide><path>rxjava-core/src/main/java/rx/internal/util/unsafe/MessagePassingQueue.java
<add>/*
<add> * Licensed under the Apache License, Version 2.0 (the "License");
<add> * you may not use this file except in compliance with the License.
<add> * You may obtain a copy of the License at
<add> *
<add> * http://www.apache.org/licenses/LICENSE-2.0
<add> *
<add> * Unless required by applicable law or agreed to in writing, software
<add> * distributed under the License is distributed on an "AS IS" BASIS,
<add> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<add> * See the License for the specific language governing permissions and
<add> * limitations under the License.
<add> *
<add> * Original License: https://github.com/JCTools/JCTools/blob/master/LICENSE
<add> * Original location: https://github.com/JCTools/JCTools/blob/master/jctools-core/src/main/java/org/jctools/queues/MessagePassingQueue.java
<add> */
<add>package rx.internal.util.unsafe;
<add>
<add>import java.util.Queue;
<add>
<add>/**
<add> * This is a tagging interface for the queues in this library which implement a subset of the {@link Queue} interface
<add> * sufficient for concurrent message passing.<br>
<add> * Message passing queues offer happens before semantics to messages passed through, namely that writes made by the
<add> * producer before offering the message are visible to the consuming thread after the message has been polled out of the
<add> * queue.
<add> *
<add> * @author nitsanw
<add> *
<add> * @param <M> the event/message type
<add> */
<add>interface MessagePassingQueue<M> {
<add>
<add> /**
<add> * Called from a producer thread subject to the restrictions appropriate to the implementation and according to the
<add> * {@link Queue#offer(Object)} interface (but failure to offer doesn't necessitate queue is full).
<add> *
<add> * @param message
<add> * @return true if element was inserted into the queue, false if cannot enqueue
<add> */
<add> boolean offer(M message);
<add>
<add> /**
<add> * Called from the consumer thread subject to the restrictions appropriate to the implementation and according to
<add> * the {@link Queue#poll()} interface (barring the hard requirement on null returns).
<add> *
<add> * @return a message from the queue if one is available, null otherwise(not necessarily empty)
<add> */
<add> M poll();
<add>
<add> /**
<add> * Called from the consumer thread subject to the restrictions appropriate to the implementation and according to
<add> * the {@link Queue#peek()} interface (barring the hard requirement on null returns).
<add> *
<add> * @return a message from the queue if one is available, null otherwise(not necessarily empty)
<add> */
<add> M peek();
<add>
<add> /**
<add> * This method's accuracy is subject to concurrent modifications happening as the size is estimated and as such is a
<add> * best effort rather than absolute value. For some implementations this method may be O(n) rather than O(1).
<add> *
<add> * @return number of messages in the queue, between 0 and queue capacity or {@link Integer#MAX_VALUE} if not bounded
<add> */
<add> int size();
<add>
<add> /**
<add> * This method's accuracy is subject to concurrent modifications happening as the observation is carried out.
<add> *
<add> * @return true if empty, false otherwise
<add> */
<add> boolean isEmpty();
<add>
<add>}
<ide>\ No newline at end of file
<ide><path>rxjava-core/src/main/java/rx/internal/util/unsafe/MpmcArrayQueue.java
<ide> public MpmcArrayQueueL1Pad(int capacity) {
<ide> }
<ide> }
<ide>
<del>abstract class MpmcArrayQueueTailField<E> extends MpmcArrayQueueL1Pad<E> {
<del> private final static long TAIL_OFFSET;
<add>abstract class MpmcArrayQueueProducerField<E> extends MpmcArrayQueueL1Pad<E> {
<add> private final static long P_INDEX_OFFSET;
<ide> static {
<ide> try {
<del> TAIL_OFFSET = UNSAFE.objectFieldOffset(MpmcArrayQueueTailField.class.getDeclaredField("tail"));
<add> P_INDEX_OFFSET =
<add> UNSAFE.objectFieldOffset(MpmcArrayQueueProducerField.class.getDeclaredField("producerIndex"));
<ide> } catch (NoSuchFieldException e) {
<ide> throw new RuntimeException(e);
<ide> }
<ide> }
<del> private volatile long tail;
<add> private volatile long producerIndex;
<ide>
<del> public MpmcArrayQueueTailField(int capacity) {
<add> public MpmcArrayQueueProducerField(int capacity) {
<ide> super(capacity);
<ide> }
<ide>
<del> protected final long lvTail() {
<del> return tail;
<add> protected final long lvProducerIndex() {
<add> return producerIndex;
<ide> }
<ide>
<del> protected final boolean casTail(long expect, long newValue) {
<del> return UNSAFE.compareAndSwapLong(this, TAIL_OFFSET, expect, newValue);
<add> protected final boolean casProducerIndex(long expect, long newValue) {
<add> return UNSAFE.compareAndSwapLong(this, P_INDEX_OFFSET, expect, newValue);
<ide> }
<ide> }
<ide>
<del>abstract class MpmcArrayQueueL2Pad<E> extends MpmcArrayQueueTailField<E> {
<add>abstract class MpmcArrayQueueL2Pad<E> extends MpmcArrayQueueProducerField<E> {
<ide> long p20, p21, p22, p23, p24, p25, p26;
<ide> long p30, p31, p32, p33, p34, p35, p36, p37;
<ide>
<ide> public MpmcArrayQueueL2Pad(int capacity) {
<ide> }
<ide> }
<ide>
<del>abstract class MpmcArrayQueueHeadField<E> extends MpmcArrayQueueL2Pad<E> {
<del> private final static long HEAD_OFFSET;
<add>abstract class MpmcArrayQueueConsumerField<E> extends MpmcArrayQueueL2Pad<E> {
<add> private final static long C_INDEX_OFFSET;
<ide> static {
<ide> try {
<del> HEAD_OFFSET = UNSAFE.objectFieldOffset(MpmcArrayQueueHeadField.class.getDeclaredField("head"));
<add> C_INDEX_OFFSET =
<add> UNSAFE.objectFieldOffset(MpmcArrayQueueConsumerField.class.getDeclaredField("consumerIndex"));
<ide> } catch (NoSuchFieldException e) {
<ide> throw new RuntimeException(e);
<ide> }
<ide> }
<del> private volatile long head;
<add> private volatile long consumerIndex;
<ide>
<del> public MpmcArrayQueueHeadField(int capacity) {
<add> public MpmcArrayQueueConsumerField(int capacity) {
<ide> super(capacity);
<ide> }
<ide>
<del> protected final long lvHead() {
<del> return head;
<add> protected final long lvConsumerIndex() {
<add> return consumerIndex;
<ide> }
<ide>
<del> protected final boolean casHead(long expect, long newValue) {
<del> return UNSAFE.compareAndSwapLong(this, HEAD_OFFSET, expect, newValue);
<add> protected final boolean casConsumerIndex(long expect, long newValue) {
<add> return UNSAFE.compareAndSwapLong(this, C_INDEX_OFFSET, expect, newValue);
<ide> }
<ide> }
<ide>
<del>public class MpmcArrayQueue<E> extends MpmcArrayQueueHeadField<E> implements Queue<E> {
<add>/**
<add> * A Multi-Producer-Multi-Consumer queue based on a {@link ConcurrentCircularArrayQueue}. This implies that any and all
<add> * threads may call the offer/poll/peek methods and correctness is maintained. <br>
<add> * This implementation follows patterns documented on the package level for False Sharing protection.<br>
<add> * The algorithm for offer/poll is an adaptation of the one put forward by D. Vyukov (See <a
<add> * href="http://www.1024cores.net/home/lock-free-algorithms/queues/bounded-mpmc-queue">here</a>). The original algorithm
<add> * uses an array of structs which should offer nice locality properties but is sadly not possible in Java (waiting on
<add> * Value Types or similar). The alternative explored here utilizes 2 arrays, one for each field of the struct. There is
<add> * a further alternative in the experimental project which uses iteration phase markers to achieve the same algo and is
<add> * closer structurally to the original, but sadly does not perform as well as this implementation.<br>
<add> * Tradeoffs to keep in mind:
<add> * <ol>
<add> * <li>Padding for false sharing: counter fields and queue fields are all padded as well as either side of both arrays.
<add> * We are trading memory to avoid false sharing(active and passive).
<add> * <li>2 arrays instead of one: The algorithm requires an extra array of longs matching the size of the elements array.
<add> * This is doubling/tripling the memory allocated for the buffer.
<add> * <li>Power of 2 capacity: Actual elements buffer (and sequence buffer) is the closest power of 2 larger or
<add> * equal to the requested capacity.
<add> * </ol>
<add> *
<add> * @param <E> type of the element stored in the {@link java.util.Queue}
<add> */
<add>public class MpmcArrayQueue<E> extends MpmcArrayQueueConsumerField<E> {
<ide> long p40, p41, p42, p43, p44, p45, p46;
<ide> long p30, p31, p32, p33, p34, p35, p36, p37;
<ide>
<ide> public boolean offer(final E e) {
<ide> if (null == e) {
<ide> throw new NullPointerException("Null is not a valid element");
<ide> }
<del> final long[] lsb = sequenceBuffer;
<del> long currentTail;
<del> long pOffset;
<del>
<del> for (;;) {
<del> currentTail = lvTail();
<del> pOffset = calcSequenceOffset(currentTail);
<del> long seq = lvSequenceElement(lsb, pOffset);
<del> long delta = seq - currentTail;
<add>
<add> // local load of field to avoid repeated loads after volatile reads
<add> final long[] lSequenceBuffer = sequenceBuffer;
<add> long currentProducerIndex;
<add> long seqOffset;
<add>
<add> while (true) {
<add> currentProducerIndex = lvProducerIndex(); // LoadLoad
<add> seqOffset = calcSequenceOffset(currentProducerIndex);
<add> final long seq = lvSequence(lSequenceBuffer, seqOffset); // LoadLoad
<add> final long delta = seq - currentProducerIndex;
<add>
<ide> if (delta == 0) {
<ide> // this is expected if we see this first time around
<del> if (casTail(currentTail, currentTail + 1)) {
<add> if (casProducerIndex(currentProducerIndex, currentProducerIndex + 1)) {
<add> // Successful CAS: full barrier
<ide> break;
<ide> }
<ide> // failed cas, retry 1
<ide> } else if (delta < 0) {
<ide> // poll has not moved this value forward
<ide> return false;
<del> } else {
<del> // another producer beat us
<ide> }
<add>
<add> // another producer has moved the sequence by one, retry 2
<ide> }
<del> final long offset = calcOffset(currentTail);
<del> spElement(offset, e);
<del> // increment position, seeing this value again should lead to retry 2
<del> soSequenceElement(lsb, pOffset, currentTail + 1);
<add>
<add> // on 64bit(no compressed oops) JVM this is the same as seqOffset
<add> final long elementOffset = calcElementOffset(currentProducerIndex);
<add> spElement(elementOffset, e);
<add>
<add> // increment sequence by 1, the value expected by consumer
<add> // (seeing this value from a producer will lead to retry 2)
<add> soSequence(lSequenceBuffer, seqOffset, currentProducerIndex + 1); // StoreStore
<add>
<ide> return true;
<ide> }
<ide>
<add> /**
<add> * {@inheritDoc}
<add> * Because return null indicates queue is empty we cannot simply rely on next element visibility for poll and must
<add> * test producer index when next element is not visible.
<add> */
<ide> @Override
<ide> public E poll() {
<del> final long[] lsb = sequenceBuffer;
<del> long currentHead;
<del> long pOffset;
<del> for (;;) {
<del> currentHead = lvHead();
<del> pOffset = calcSequenceOffset(currentHead);
<del> long seq = lvSequenceElement(lsb, pOffset);
<del> long delta = seq - (currentHead + 1);
<add> // local load of field to avoid repeated loads after volatile reads
<add> final long[] lSequenceBuffer = sequenceBuffer;
<add> long currentConsumerIndex;
<add> long seqOffset;
<add>
<add> while (true) {
<add> currentConsumerIndex = lvConsumerIndex();// LoadLoad
<add> seqOffset = calcSequenceOffset(currentConsumerIndex);
<add> final long seq = lvSequence(lSequenceBuffer, seqOffset);// LoadLoad
<add> final long delta = seq - (currentConsumerIndex + 1);
<add>
<ide> if (delta == 0) {
<del> if (casHead(currentHead, currentHead + 1)) {
<add> if (casConsumerIndex(currentConsumerIndex, currentConsumerIndex + 1)) {
<add> // Successful CAS: full barrier
<ide> break;
<ide> }
<ide> // failed cas, retry 1
<ide> } else if (delta < 0) {
<del> // queue is empty
<add> // COMMENTED OUT: strict empty check.
<add>// if (currentConsumerIndex == lvProducerIndex()) {
<add>// return null;
<add>// }
<add> // next element is not visible, probably empty
<ide> return null;
<del> } else {
<del> // another consumer beat us
<ide> }
<add>
<add> // another consumer beat us and moved sequence ahead, retry 2
<ide> }
<del> final long offset = calcOffset(currentHead);
<del> final E[] lb = buffer;
<del> E e = lvElement(lb, offset);
<del> spElement(lb, offset, null);
<del> soSequenceElement(lsb, pOffset, currentHead + capacity);
<add>
<add> // on 64bit(no compressed oops) JVM this is the same as seqOffset
<add> final long offset = calcElementOffset(currentConsumerIndex);
<add> final E e = lpElement(offset);
<add> spElement(offset, null);
<add>
<add> // Move sequence ahead by capacity, preparing it for next offer
<add> // (seeing this value from a consumer will lead to retry 2)
<add> soSequence(lSequenceBuffer, seqOffset, currentConsumerIndex + capacity);// StoreStore
<add>
<ide> return e;
<ide> }
<ide>
<ide> @Override
<ide> public E peek() {
<del> return lpElement(calcOffset(lvHead()));
<add> return lpElement(calcElementOffset(lvConsumerIndex()));
<ide> }
<ide>
<ide> @Override
<ide> public int size() {
<del> return (int) (lvTail() - lvHead());
<add> /*
<add> * It is possible for a thread to be interrupted or reschedule between the read of the producer and consumer
<add> * indices, therefore protection is required to ensure size is within valid range. In the event of concurrent
<add> * polls/offers to this method the size is OVER estimated as we read consumer index BEFORE the producer index.
<add> */
<add> long after = lvConsumerIndex();
<add> while (true) {
<add> final long before = after;
<add> final long currentProducerIndex = lvProducerIndex();
<add> after = lvConsumerIndex();
<add> if (before == after) {
<add> return (int) (currentProducerIndex - after);
<add> }
<add> }
<add> }
<add>
<add> @Override
<add> public boolean isEmpty() {
<add> // Order matters!
<add> // Loading consumer before producer allows for producer increments after consumer index is read.
<add> // This ensures this method is conservative in it's estimate. Note that as this is an MPMC there is nothing we
<add> // can do to make this an exact method.
<add> return (lvConsumerIndex() == lvProducerIndex());
<ide> }
<ide> }
<ide>\ No newline at end of file
<ide><path>rxjava-core/src/main/java/rx/internal/util/unsafe/Pow2.java
<ide> package rx.internal.util.unsafe;
<ide>
<ide> public class Pow2 {
<del> public static int findNextPositivePowerOfTwo(final int value) {
<add>
<add> /**
<add> * Find the next larger positive power of two value up from the given value. If value is a power of two then
<add> * this value will be returned.
<add> *
<add> * @param value from which next positive power of two will be found.
<add> * @return the next positive power of 2 or this value if it is a power of 2.
<add> */
<add> public static int roundToPowerOfTwo(final int value) {
<ide> return 1 << (32 - Integer.numberOfLeadingZeros(value - 1));
<ide> }
<ide>
<del> public static boolean isPowerOf2(final int value) {
<add> /**
<add> * Is this value a power of two.
<add> *
<add> * @param value to be tested to see if it is a power of two.
<add> * @return true if the value is a power of 2 otherwise false.
<add> */
<add> public static boolean isPowerOfTwo(final int value) {
<ide> return (value & (value - 1)) == 0;
<ide> }
<ide> }
<ide>\ No newline at end of file
<ide><path>rxjava-core/src/main/java/rx/internal/util/unsafe/SpmcArrayQueue.java
<ide> */
<ide> package rx.internal.util.unsafe;
<ide>
<del>import java.util.Queue;
<del>
<ide> abstract class SpmcArrayQueueL1Pad<E> extends ConcurrentCircularArrayQueue<E> {
<ide> long p10, p11, p12, p13, p14, p15, p16;
<ide> long p30, p31, p32, p33, p34, p35, p36, p37;
<ide> public SpmcArrayQueueL1Pad(int capacity) {
<ide> }
<ide> }
<ide>
<del>abstract class SpmcArrayQueueTailField<E> extends SpmcArrayQueueL1Pad<E> {
<del> protected final static long TAIL_OFFSET;
<add>abstract class SpmcArrayQueueProducerField<E> extends SpmcArrayQueueL1Pad<E> {
<add> protected final static long P_INDEX_OFFSET;
<ide> static {
<ide> try {
<del> TAIL_OFFSET = UnsafeAccess.UNSAFE.objectFieldOffset(SpmcArrayQueueTailField.class
<del> .getDeclaredField("tail"));
<add> P_INDEX_OFFSET =
<add> UnsafeAccess.UNSAFE.objectFieldOffset(SpmcArrayQueueProducerField.class.getDeclaredField("producerIndex"));
<ide> } catch (NoSuchFieldException e) {
<ide> throw new RuntimeException(e);
<ide> }
<ide> }
<del> private volatile long tail;
<add> private volatile long producerIndex;
<ide>
<del> protected final long lvTail() {
<del> return tail;
<add> protected final long lvProducerIndex() {
<add> return producerIndex;
<ide> }
<ide>
<ide> protected final void soTail(long v) {
<del> UnsafeAccess.UNSAFE.putOrderedLong(this, TAIL_OFFSET, v);
<add> UnsafeAccess.UNSAFE.putOrderedLong(this, P_INDEX_OFFSET, v);
<ide> }
<ide>
<del> public SpmcArrayQueueTailField(int capacity) {
<add> public SpmcArrayQueueProducerField(int capacity) {
<ide> super(capacity);
<ide> }
<ide> }
<ide>
<del>abstract class SpmcArrayQueueL2Pad<E> extends SpmcArrayQueueTailField<E> {
<add>abstract class SpmcArrayQueueL2Pad<E> extends SpmcArrayQueueProducerField<E> {
<ide> long p20, p21, p22, p23, p24, p25, p26;
<ide> long p30, p31, p32, p33, p34, p35, p36, p37;
<ide>
<ide> public SpmcArrayQueueL2Pad(int capacity) {
<ide> }
<ide> }
<ide>
<del>abstract class SpmcArrayQueueHeadField<E> extends SpmcArrayQueueL2Pad<E> {
<del> protected final static long HEAD_OFFSET;
<add>abstract class SpmcArrayQueueConsumerField<E> extends SpmcArrayQueueL2Pad<E> {
<add> protected final static long C_INDEX_OFFSET;
<ide> static {
<ide> try {
<del> HEAD_OFFSET = UnsafeAccess.UNSAFE.objectFieldOffset(SpmcArrayQueueHeadField.class
<del> .getDeclaredField("head"));
<add> C_INDEX_OFFSET =
<add> UnsafeAccess.UNSAFE.objectFieldOffset(SpmcArrayQueueConsumerField.class.getDeclaredField("consumerIndex"));
<ide> } catch (NoSuchFieldException e) {
<ide> throw new RuntimeException(e);
<ide> }
<ide> }
<del> private volatile long head;
<add> private volatile long consumerIndex;
<ide>
<del> public SpmcArrayQueueHeadField(int capacity) {
<add> public SpmcArrayQueueConsumerField(int capacity) {
<ide> super(capacity);
<ide> }
<ide>
<del> protected final long lvHead() {
<del> return head;
<add> protected final long lvConsumerIndex() {
<add> return consumerIndex;
<ide> }
<ide>
<ide> protected final boolean casHead(long expect, long newValue) {
<del> return UnsafeAccess.UNSAFE.compareAndSwapLong(this, HEAD_OFFSET, expect, newValue);
<add> return UnsafeAccess.UNSAFE.compareAndSwapLong(this, C_INDEX_OFFSET, expect, newValue);
<ide> }
<ide> }
<ide>
<del>abstract class SpmcArrayQueueMidPad<E> extends SpmcArrayQueueHeadField<E> {
<add>abstract class SpmcArrayQueueMidPad<E> extends SpmcArrayQueueConsumerField<E> {
<ide> long p20, p21, p22, p23, p24, p25, p26;
<ide> long p30, p31, p32, p33, p34, p35, p36, p37;
<ide>
<ide> public SpmcArrayQueueMidPad(int capacity) {
<ide> }
<ide> }
<ide>
<del>abstract class SpmcArrayQueueTailCacheField<E> extends SpmcArrayQueueMidPad<E> {
<del> private volatile long tailCache;
<add>abstract class SpmcArrayQueueProducerIndexCacheField<E> extends SpmcArrayQueueMidPad<E> {
<add> // This is separated from the consumerIndex which will be highly contended in the hope that this value spends most
<add> // of it's time in a cache line that is Shared(and rarely invalidated)
<add> private volatile long producerIndexCache;
<ide>
<del> public SpmcArrayQueueTailCacheField(int capacity) {
<add> public SpmcArrayQueueProducerIndexCacheField(int capacity) {
<ide> super(capacity);
<ide> }
<ide>
<del> protected final long lvTailCache() {
<del> return tailCache;
<add> protected final long lvProducerIndexCache() {
<add> return producerIndexCache;
<ide> }
<ide>
<del> protected final void svTailCache(long v) {
<del> tailCache = v;
<add> protected final void svProducerIndexCache(long v) {
<add> producerIndexCache = v;
<ide> }
<ide> }
<ide>
<del>abstract class SpmcArrayQueueL3Pad<E> extends SpmcArrayQueueTailCacheField<E> {
<add>abstract class SpmcArrayQueueL3Pad<E> extends SpmcArrayQueueProducerIndexCacheField<E> {
<ide> long p40, p41, p42, p43, p44, p45, p46;
<ide> long p30, p31, p32, p33, p34, p35, p36, p37;
<ide>
<ide> public SpmcArrayQueueL3Pad(int capacity) {
<ide> }
<ide> }
<ide>
<del>public final class SpmcArrayQueue<E> extends SpmcArrayQueueL3Pad<E> implements Queue<E> {
<add>public final class SpmcArrayQueue<E> extends SpmcArrayQueueL3Pad<E> {
<ide>
<ide> public SpmcArrayQueue(final int capacity) {
<ide> super(capacity);
<ide> public boolean offer(final E e) {
<ide> throw new NullPointerException("Null is not a valid element");
<ide> }
<ide> final E[] lb = buffer;
<del> final long currTail = lvTail();
<del> final long offset = calcOffset(currTail);
<add> final long currProducerIndex = lvProducerIndex();
<add> final long offset = calcElementOffset(currProducerIndex);
<ide> if (null != lvElement(lb, offset)) {
<ide> return false;
<ide> }
<ide> spElement(lb, offset, e);
<ide> // single producer, so store ordered is valid. It is also required to correctly publish the element
<ide> // and for the consumers to pick up the tail value.
<del> soTail(currTail + 1);
<add> soTail(currProducerIndex + 1);
<ide> return true;
<ide> }
<ide>
<add> /**
<add> * {@inheritDoc}
<add> * <p>
<add> * Note that we are not doing the the whole poll/tryPoll thing here like we do in MPMC/MPSC, that is because the
<add> * problem we try to solve there is caused by having multiple producers making progress concurrently which can
<add> * create 'bubbles' of claimed but not fully visible elements in the queue. For a single producer the problem
<add> * doesn't exist.
<add> */
<ide> @Override
<ide> public E poll() {
<del> long currentHead;
<del> final long currTailCache = lvTailCache();
<add> long currentConsumerIndex;
<add> final long currProducerIndexCache = lvProducerIndexCache();
<ide> do {
<del> currentHead = lvHead();
<del> if (currentHead >= currTailCache) {
<del> long currTail = lvTail();
<del> if (currentHead >= currTail) {
<add> currentConsumerIndex = lvConsumerIndex();
<add> if (currentConsumerIndex >= currProducerIndexCache) {
<add> long currProducerIndex = lvProducerIndex();
<add> if (currentConsumerIndex >= currProducerIndex) {
<ide> return null;
<ide> } else {
<del> svTailCache(currTail);
<add> svProducerIndexCache(currProducerIndex);
<ide> }
<ide> }
<del> } while (!casHead(currentHead, currentHead + 1));
<add> } while (!casHead(currentConsumerIndex, currentConsumerIndex + 1));
<ide> // consumers are gated on latest visible tail, and so can't see a null value in the queue or overtake
<ide> // and wrap to hit same location.
<del> final long offset = calcOffset(currentHead);
<add> final long offset = calcElementOffset(currentConsumerIndex);
<ide> final E[] lb = buffer;
<ide> // load plain, element happens before it's index becomes visible
<ide> final E e = lpElement(lb, offset);
<ide> // store ordered, make sure nulling out is visible. Producer is waiting for this value.
<ide> soElement(lb, offset, null);
<ide> return e;
<ide> }
<del>
<add>
<ide> @Override
<ide> public E peek() {
<del> return lvElement(calcOffset(lvHead()));
<add> return lvElement(calcElementOffset(lvConsumerIndex()));
<ide> }
<add>
<ide> @Override
<ide> public int size() {
<del> return (int) (lvTail() - lvHead());
<add> /*
<add> * It is possible for a thread to be interrupted or reschedule between the read of the producer and consumer
<add> * indices, therefore protection is required to ensure size is within valid range. In the event of concurrent
<add> * polls/offers to this method the size is OVER estimated as we read consumer index BEFORE the producer index.
<add> */
<add> long after = lvConsumerIndex();
<add> while (true) {
<add> final long before = after;
<add> final long currentProducerIndex = lvProducerIndex();
<add> after = lvConsumerIndex();
<add> if (before == after) {
<add> return (int) (currentProducerIndex - after);
<add> }
<add> }
<add> }
<add>
<add> @Override
<add> public boolean isEmpty() {
<add> // Order matters!
<add> // Loading consumer before producer allows for producer increments after consumer index is read.
<add> // This ensures the correctness of this method at least for the consumer thread. Other threads POV is not really
<add> // something we can fix here.
<add> return (lvConsumerIndex() == lvProducerIndex());
<ide> }
<ide> }
<ide>\ No newline at end of file
<ide><path>rxjava-core/src/main/java/rx/internal/util/unsafe/SpscArrayQueue.java
<ide>
<ide> import java.util.Queue;
<ide>
<del>abstract class SpscArrayQueueL1Pad<E> extends ConcurrentCircularArrayQueue<E> {
<add>abstract class SpscArrayQueueColdField<E> extends ConcurrentCircularArrayQueue<E> {
<add> private static final Integer MAX_LOOK_AHEAD_STEP = Integer.getInteger("jctoolts.spsc.max.lookahead.step", 4096);
<add> protected final int lookAheadStep;
<add> public SpscArrayQueueColdField(int capacity) {
<add> super(capacity);
<add> lookAheadStep = Math.min(capacity/4, MAX_LOOK_AHEAD_STEP);
<add> }
<add>}
<add>abstract class SpscArrayQueueL1Pad<E> extends SpscArrayQueueColdField<E> {
<ide> long p10, p11, p12, p13, p14, p15, p16;
<ide> long p30, p31, p32, p33, p34, p35, p36, p37;
<ide>
<ide> public SpscArrayQueueL1Pad(int capacity) {
<ide> }
<ide> }
<ide>
<del>abstract class SpscArrayQueueTailField<E> extends SpscArrayQueueL1Pad<E> {
<del> protected long tail;
<del> protected long batchTail;
<add>abstract class SpscArrayQueueProducerFields<E> extends SpscArrayQueueL1Pad<E> {
<add> private final static long P_INDEX_OFFSET;
<add> static {
<add> try {
<add> P_INDEX_OFFSET =
<add> UnsafeAccess.UNSAFE.objectFieldOffset(SpscArrayQueueProducerFields.class.getDeclaredField("producerIndex"));
<add> } catch (NoSuchFieldException e) {
<add> throw new RuntimeException(e);
<add> }
<add> }
<add> protected long producerIndex;
<add> protected long producerLookAhead;
<ide>
<del> public SpscArrayQueueTailField(int capacity) {
<add> public SpscArrayQueueProducerFields(int capacity) {
<ide> super(capacity);
<ide> }
<add> protected final long lvProducerIndex() {
<add> return UnsafeAccess.UNSAFE.getLongVolatile(this, P_INDEX_OFFSET);
<add> }
<ide> }
<ide>
<del>abstract class SpscArrayQueueL2Pad<E> extends SpscArrayQueueTailField<E> {
<add>abstract class SpscArrayQueueL2Pad<E> extends SpscArrayQueueProducerFields<E> {
<ide> long p20, p21, p22, p23, p24, p25, p26;
<ide> long p30, p31, p32, p33, p34, p35, p36, p37;
<ide>
<ide> public SpscArrayQueueL2Pad(int capacity) {
<ide> }
<ide> }
<ide>
<del>abstract class SpscArrayQueueHeadField<E> extends SpscArrayQueueL2Pad<E> {
<del> protected long head;
<del>
<del> public SpscArrayQueueHeadField(int capacity) {
<add>abstract class SpscArrayQueueConsumerField<E> extends SpscArrayQueueL2Pad<E> {
<add> protected long consumerIndex;
<add> private final static long C_INDEX_OFFSET;
<add> static {
<add> try {
<add> C_INDEX_OFFSET =
<add> UnsafeAccess.UNSAFE.objectFieldOffset(SpscArrayQueueConsumerField.class.getDeclaredField("consumerIndex"));
<add> } catch (NoSuchFieldException e) {
<add> throw new RuntimeException(e);
<add> }
<add> }
<add> public SpscArrayQueueConsumerField(int capacity) {
<ide> super(capacity);
<ide> }
<add> protected final long lvConsumerIndex() {
<add> return UnsafeAccess.UNSAFE.getLongVolatile(this, C_INDEX_OFFSET);
<add> }
<ide> }
<ide>
<del>abstract class SpscArrayQueueL3Pad<E> extends SpscArrayQueueHeadField<E> {
<add>abstract class SpscArrayQueueL3Pad<E> extends SpscArrayQueueConsumerField<E> {
<ide> long p40, p41, p42, p43, p44, p45, p46;
<ide> long p30, p31, p32, p33, p34, p35, p36, p37;
<ide>
<ide> public SpscArrayQueueL3Pad(int capacity) {
<ide> }
<ide> }
<ide>
<del>public final class SpscArrayQueue<E> extends SpscArrayQueueL3Pad<E> implements Queue<E> {
<del> private final static long TAIL_OFFSET;
<del> private final static long HEAD_OFFSET;
<del> static {
<del> try {
<del> TAIL_OFFSET = UnsafeAccess.UNSAFE.objectFieldOffset(SpscArrayQueueTailField.class
<del> .getDeclaredField("tail"));
<del> HEAD_OFFSET = UnsafeAccess.UNSAFE.objectFieldOffset(SpscArrayQueueHeadField.class
<del> .getDeclaredField("head"));
<del> } catch (NoSuchFieldException e) {
<del> throw new RuntimeException(e);
<del> }
<del> }
<add>/**
<add> * A Single-Producer-Single-Consumer queue backed by a pre-allocated buffer.</br> This implementation is a mashup of the
<add> * <a href="http://sourceforge.net/projects/mc-fastflow/">Fast Flow</a> algorithm with an optimization of the offer
<add> * method taken from the <a href="http://staff.ustc.edu.cn/~bhua/publications/IJPP_draft.pdf">BQueue</a> algorithm (a
<add> * variation on Fast Flow).<br>
<add> * For convenience the relevant papers are available in the resources folder:</br>
<add> * <i>2010 - Pisa - SPSC Queues on Shared Cache Multi-Core Systems.pdf</br>
<add> * 2012 - Junchang- BQueue- Efficient and Practical Queuing.pdf </br></i>
<add> * This implementation is wait free.
<add> *
<add> * @author nitsanw
<add> *
<add> * @param <E>
<add> */
<add>public final class SpscArrayQueue<E> extends SpscArrayQueueL3Pad<E> {
<ide>
<ide> public SpscArrayQueue(final int capacity) {
<ide> super(capacity);
<ide> }
<ide>
<del> private long getHeadV() {
<del> return UnsafeAccess.UNSAFE.getLongVolatile(this, HEAD_OFFSET);
<del> }
<del>
<del> private long getTailV() {
<del> return UnsafeAccess.UNSAFE.getLongVolatile(this, TAIL_OFFSET);
<del> }
<del>
<add> /**
<add> * {@inheritDoc}
<add> * <p>
<add> * This implementation is correct for single producer thread use only.
<add> */
<ide> @Override
<ide> public boolean offer(final E e) {
<ide> if (null == e) {
<ide> throw new NullPointerException("Null is not a valid element");
<ide> }
<del>
<del> E[] lb = buffer;
<del> if (tail >= batchTail) {
<del> if (null != lvElement(lb, calcOffset(tail))) {
<add> // local load of field to avoid repeated loads after volatile reads
<add> final E[] lElementBuffer = buffer;
<add> if (producerIndex >= producerLookAhead) {
<add> if (null != lvElement(lElementBuffer, calcElementOffset(producerIndex + lookAheadStep))) {// LoadLoad
<ide> return false;
<ide> }
<add> producerLookAhead = producerIndex + lookAheadStep;
<ide> }
<del> soElement(lb, calcOffset(tail), e);
<del> tail++;
<del>
<add> long offset = calcElementOffset(producerIndex);
<add> producerIndex++; // do increment here so the ordered store give both a barrier
<add> soElement(lElementBuffer, offset, e);// StoreStore
<ide> return true;
<ide> }
<del>
<add>
<add> /**
<add> * {@inheritDoc}
<add> * <p>
<add> * This implementation is correct for single consumer thread use only.
<add> */
<ide> @Override
<ide> public E poll() {
<del> final long offset = calcOffset(head);
<del> final E[] lb = buffer;
<del> final E e = lvElement(lb, offset);
<add> final long offset = calcElementOffset(consumerIndex);
<add> // local load of field to avoid repeated loads after volatile reads
<add> final E[] lElementBuffer = buffer;
<add> final E e = lvElement(lElementBuffer, offset);// LoadLoad
<ide> if (null == e) {
<ide> return null;
<ide> }
<del> soElement(lb, offset, null);
<del> head++;
<add> consumerIndex++; // do increment here so the ordered store give both a barrier
<add> soElement(lElementBuffer, offset, null);// StoreStore
<ide> return e;
<ide> }
<ide>
<add> /**
<add> * {@inheritDoc}
<add> * <p>
<add> * This implementation is correct for single consumer thread use only.
<add> */
<ide> @Override
<ide> public E peek() {
<del> return lvElement(calcOffset(head));
<add> return lvElement(calcElementOffset(consumerIndex));
<ide> }
<ide>
<ide> @Override
<ide> public int size() {
<del> // TODO: this is ugly :( the head/tail cannot be counted on to be written out, so must take max
<del> return (int) (Math.max(getTailV(), tail) - Math.max(getHeadV(), head));
<add> /*
<add> * It is possible for a thread to be interrupted or reschedule between the read of the producer and consumer
<add> * indices, therefore protection is required to ensure size is within valid range. In the event of concurrent
<add> * polls/offers to this method the size is OVER estimated as we read consumer index BEFORE the producer index.
<add> */
<add> long after = lvConsumerIndex();
<add> while (true) {
<add> final long before = after;
<add> final long currentProducerIndex = lvProducerIndex();
<add> after = lvConsumerIndex();
<add> if (before == after) {
<add> return (int) (currentProducerIndex - after);
<add> }
<add> }
<ide> }
<ide> }
<ide>\ No newline at end of file | 10 |
PHP | PHP | tweak a few remote functions | 21c86791fd6a4d3f22a4b62464e187919a72d76b | <ide><path>src/Illuminate/Remote/Connection.php
<ide> class Connection implements ConnectionInterface {
<ide> */
<ide> protected $gateway;
<ide>
<add> /**
<add> * The name of the connection.
<add> *
<add> * @var string
<add> */
<add> protected $name;
<add>
<ide> /**
<ide> * The host name of the server.
<ide> *
<ide> class Connection implements ConnectionInterface {
<ide> /**
<ide> * Create a new SSH connection instance.
<ide> *
<add> * @param string $name
<ide> * @param string $host
<ide> * @param string $username
<ide> * @param array $auth
<ide> * @param \Illuminate\Remote\GatewayInterface
<ide> * @param
<ide> */
<del> public function __construct($host, $username, array $auth, GatewayInterface $gateway = null)
<add> public function __construct($name, $host, $username, array $auth, GatewayInterface $gateway = null)
<ide> {
<add> $this->name = $name;
<ide> $this->host = $host;
<ide> $this->username = $username;
<ide> $this->gateway = $gateway ?: new SecLibGateway($host, $auth, new Filesystem);
<ide> public function run($commands, Closure $callback = null)
<ide> */
<ide> public function display($line)
<ide> {
<del> $lead = '<comment>['.$this->username.'@'.$this->host.']</comment>';
<add> $server = $this->username.'@'.$this->host;
<add>
<add> $lead = '<comment>['.$server.']</comment> <info>('.$this->name.')</info>';
<ide>
<ide> $this->getOutput()->writeln($lead.' '.$line);
<ide> }
<ide><path>src/Illuminate/Remote/RemoteManager.php
<ide> public function resolve($name)
<ide> {
<ide> if ( ! isset($this->connections[$name]))
<ide> {
<del> $this->connections[$name] = $this->makeConnection($this->getConfig($name));
<add> $this->connections[$name] = $this->makeConnection($name, $this->getConfig($name));
<ide> }
<ide>
<ide> return $this->connections[$name];
<ide> public function resolve($name)
<ide> /**
<ide> * Make a new connection instance.
<ide> *
<add> * @param string $name
<ide> * @param array $config
<ide> * @return \Illuminate\Remote\Connection
<ide> */
<del> protected function makeConnection(array $config)
<add> protected function makeConnection($name, array $config)
<ide> {
<ide> $this->setOutput($connection = new Connection(
<ide>
<del> $config['host'], $config['username'], $this->getAuth($config)
<add> $name, $config['host'], $config['username'], $this->getAuth($config)
<ide>
<ide> ));
<ide> | 2 |
Javascript | Javascript | reduce rollup rebuilds by restricting inputs.. | 67532742036d74e16e53e02da0559d56457da379 | <ide><path>ember-cli-build.js
<ide> function rollupPackage(packagesES, name) {
<ide> 'backburner',
<ide> ];
<ide>
<del> return new Rollup(packagesES, {
<add> // this prevents broccoli-rollup from "seeing" changes in
<add> // its input that are unrelated to what we are building
<add> // and therefore noop on rebuilds...
<add> let rollupRestrictedInput = new Funnel(packagesES, {
<add> srcDir: name,
<add> destDir: name,
<add> });
<add>
<add> return new Rollup(rollupRestrictedInput, {
<ide> annotation: `rollup ${name}`,
<ide> rollup: {
<ide> input: `${name}/index.js`, | 1 |
Ruby | Ruby | add option for building bottles | a3db9a42e878b04747100f5b70bbd999eac7cdbf | <ide><path>Library/Homebrew/extend/ARGV.rb
<ide> def build_32_bit?
<ide> include? '--32-bit'
<ide> end
<ide>
<add> def build_bottle?
<add> MacOS.bottles_supported? and include? '--build-bottle'
<add> end
<add>
<ide> def build_from_source?
<del> return true if flag? '--build-from-source' or ENV['HOMEBREW_BUILD_FROM_SOURCE'] \
<del> or not MacOS.lion? or HOMEBREW_PREFIX.to_s != '/usr/local'
<del> options = options_only
<del> options.delete '--universal'
<del> not options.empty?
<add> flag? '--build-from-source' or ENV['HOMEBREW_BUILD_FROM_SOURCE'] \
<add> or not MacOS.bottles_supported? or not options_only.empty?
<ide> end
<ide>
<ide> def flag? flag
<ide><path>Library/Homebrew/utils.rb
<ide> def lion?
<ide> def prefer_64_bit?
<ide> Hardware.is_64_bit? and 10.6 <= MACOS_VERSION
<ide> end
<add>
<add> def bottles_supported?
<add> lion? and HOMEBREW_PREFIX.to_s == '/usr/local'
<add> end
<ide> end
<ide>
<ide> module GitHub extend self | 2 |
Javascript | Javascript | simplify the check for isdefaultprevented | c9e8a95709e12c6838a312850ce645e96a53ff5d | <ide><path>src/event.js
<ide> jQuery.Event = function( src ) {
<ide> this.type = src.type;
<ide> // Events bubbling up the document may have been marked as prevented
<ide> // by a handler lower down the tree; reflect the correct value.
<del> this.isDefaultPrevented =
<del> (src.defaultPrevented===true ? true :
<del> src.getPreventDefault ? src.getPreventDefault() :
<del> src.returnValue===false) ? returnTrue : returnFalse;
<add> this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false ||
<add> src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse;
<ide> // Event type
<ide> } else {
<ide> this.type = src; | 1 |
Javascript | Javascript | remove precautionary variable `readyfiring` | fcb8a1b3ebf53007637c12c376e3101681f57c02 | <ide><path>src/core/ready-no-deferred.js
<ide> define( [
<ide> "use strict";
<ide>
<ide> var readyCallbacks = [],
<del> readyFiring = false,
<ide> whenReady = function( fn ) {
<ide> readyCallbacks.push( fn );
<ide> },
<ide> jQuery.extend( {
<ide> whenReady = function( fn ) {
<ide> readyCallbacks.push( fn );
<ide>
<del> if ( !readyFiring ) {
<del> readyFiring = true;
<del>
<del> while ( readyCallbacks.length ) {
<del> fn = readyCallbacks.shift();
<del> if ( jQuery.isFunction( fn ) ) {
<del> executeReady( fn );
<del> }
<add> while ( readyCallbacks.length ) {
<add> fn = readyCallbacks.shift();
<add> if ( jQuery.isFunction( fn ) ) {
<add> executeReady( fn );
<ide> }
<del> readyFiring = false;
<ide> }
<ide> };
<ide> | 1 |
PHP | PHP | remove unneeded stub class | 9003836c20d18b930b6cb9225a78241b3ba22eb9 | <ide><path>tests/Database/DatabaseMigrationMakeCommandTest.php
<ide> public function tearDown()
<ide>
<ide> public function testBasicCreateDumpsAutoload()
<ide> {
<del> $command = new DatabaseMigrationMakeCommandTestStub(
<add> $command = new MigrateMakeCommand(
<ide> $creator = m::mock('Illuminate\Database\Migrations\MigrationCreator'),
<ide> $composer = m::mock('Illuminate\Foundation\Composer'),
<ide> __DIR__.'/vendor'
<ide> public function testBasicCreateDumpsAutoload()
<ide>
<ide> public function testBasicCreateGivesCreatorProperArguments()
<ide> {
<del> $command = new DatabaseMigrationMakeCommandTestStub(
<add> $command = new MigrateMakeCommand(
<ide> $creator = m::mock('Illuminate\Database\Migrations\MigrationCreator'),
<ide> m::mock('Illuminate\Foundation\Composer')->shouldIgnoreMissing(),
<ide> __DIR__.'/vendor'
<ide> public function testBasicCreateGivesCreatorProperArguments()
<ide>
<ide> public function testBasicCreateGivesCreatorProperArgumentsWhenTableIsSet()
<ide> {
<del> $command = new DatabaseMigrationMakeCommandTestStub(
<add> $command = new MigrateMakeCommand(
<ide> $creator = m::mock('Illuminate\Database\Migrations\MigrationCreator'),
<ide> m::mock('Illuminate\Foundation\Composer')->shouldIgnoreMissing(),
<ide> __DIR__.'/vendor'
<ide> protected function runCommand($command, $input = array())
<ide> }
<ide>
<ide> }
<del>
<del>
<del>
<del>class DatabaseMigrationMakeCommandTestStub extends MigrateMakeCommand
<del>{
<del> public function call($command, array $arguments = array())
<del> {
<del> //
<del> }
<del>} | 1 |
Text | Text | fix broken link | e1af2634677b0a301345afa363525bc9268415be | <ide><path>guides/source/3_0_release_notes.md
<ide> Deprecations
<ide>
<ide> More Information:
<ide> * [The Rails 3 Router: Rack it Up](http://yehudakatz.com/2009/12/26/the-rails-3-router-rack-it-up/)
<del>* [Revamped Routes in Rails 3](http://rizwanreza.com/2009/12/20/revamped-routes-in-rails-3)
<add>* [Revamped Routes in Rails 3](https://medium.com/fusion-of-thoughts/revamped-routes-in-rails-3-b6d00654e5b0)
<ide> * [Generic Actions in Rails 3](http://yehudakatz.com/2009/12/20/generic-actions-in-rails-3/)
<ide>
<ide> | 1 |
Mixed | Javascript | add support for abortsignal in readfile | b5a136cd67e39411bb16ae78f7d972846d12e55f | <ide><path>doc/api/fs.md
<ide> If `options.withFileTypes` is set to `true`, the result will contain
<ide> <!-- YAML
<ide> added: v0.1.29
<ide> changes:
<add> - version: REPLACEME
<add> pr-url: https://github.com/nodejs/node/pull/35911
<add> description: The options argument may include an AbortSignal to abort an
<add> ongoing readFile request.
<ide> - version: v10.0.0
<ide> pr-url: https://github.com/nodejs/node/pull/12562
<ide> description: The `callback` parameter is no longer optional. Not passing
<ide> changes:
<ide> * `options` {Object|string}
<ide> * `encoding` {string|null} **Default:** `null`
<ide> * `flag` {string} See [support of file system `flags`][]. **Default:** `'r'`.
<add> * `signal` {AbortSignal} allows aborting an in-progress readFile
<ide> * `callback` {Function}
<ide> * `err` {Error}
<ide> * `data` {string|Buffer}
<ide> fs.readFile('<directory>', (err, data) => {
<ide> });
<ide> ```
<ide>
<add>It is possible to abort an ongoing request using an `AbortSignal`. If a
<add>request is aborted the callback is called with an `AbortError`:
<add>
<add>```js
<add>const controller = new AbortController();
<add>const signal = controller.signal;
<add>fs.readFile(fileInfo[0].name, { signal }, (err, buf) => {
<add> // ...
<add>});
<add>// When you want to abort the request
<add>controller.abort();
<add>```
<add>
<ide> The `fs.readFile()` function buffers the entire file. To minimize memory costs,
<ide> when possible prefer streaming via `fs.createReadStream()`.
<ide>
<add>Aborting an ongoing request does not abort individual operating
<add>system requests but rather the internal buffering `fs.readFile` performs.
<add>
<ide> ### File descriptors
<ide>
<ide> 1. Any specified file descriptor has to support reading.
<ide> added: v10.0.0
<ide>
<ide> * `options` {Object|string}
<ide> * `encoding` {string|null} **Default:** `null`
<add> * `signal` {AbortSignal} allows aborting an in-progress readFile
<ide> * Returns: {Promise}
<ide>
<ide> Asynchronously reads the entire contents of a file.
<ide> print('./').catch(console.error);
<ide> ### `fsPromises.readFile(path[, options])`
<ide> <!-- YAML
<ide> added: v10.0.0
<add>changes:
<add> - version: REPLACEME
<add> pr-url: https://github.com/nodejs/node/pull/35911
<add> description: The options argument may include an AbortSignal to abort an
<add> ongoing readFile request.
<ide> -->
<ide>
<ide> * `path` {string|Buffer|URL|FileHandle} filename or `FileHandle`
<ide> * `options` {Object|string}
<ide> * `encoding` {string|null} **Default:** `null`
<ide> * `flag` {string} See [support of file system `flags`][]. **Default:** `'r'`.
<add> * `signal` {AbortSignal} allows aborting an in-progress readFile
<ide> * Returns: {Promise}
<ide>
<ide> Asynchronously reads the entire contents of a file.
<ide> platform-specific. On macOS, Linux, and Windows, the promise will be rejected
<ide> with an error. On FreeBSD, a representation of the directory's contents will be
<ide> returned.
<ide>
<add>It is possible to abort an ongoing `readFile` using an `AbortSignal`. If a
<add>request is aborted the promise returned is rejected with an `AbortError`:
<add>
<add>```js
<add>const controller = new AbortController();
<add>const signal = controller.signal;
<add>readFile(fileName, { signal }).then((file) => { /* ... */ });
<add>// Abort the request
<add>controller.abort();
<add>```
<add>
<add>Aborting an ongoing request does not abort individual operating
<add>system requests but rather the internal buffering `fs.readFile` performs.
<add>
<ide> Any specified `FileHandle` has to support reading.
<ide>
<ide> ### `fsPromises.readlink(path[, options])`
<ide><path>lib/fs.js
<ide> function readFile(path, options, callback) {
<ide> const context = new ReadFileContext(callback, options.encoding);
<ide> context.isUserFd = isFd(path); // File descriptor ownership
<ide>
<add> if (options.signal) {
<add> context.signal = options.signal;
<add> }
<ide> if (context.isUserFd) {
<ide> process.nextTick(function tick(context) {
<ide> readFileAfterOpen.call({ context }, null, path);
<ide><path>lib/internal/fs/promises.js
<ide> const {
<ide> } = internalBinding('constants').fs;
<ide> const binding = internalBinding('fs');
<ide> const { Buffer } = require('buffer');
<add>
<add>const { codes, hideStackFrames } = require('internal/errors');
<ide> const {
<ide> ERR_FS_FILE_TOO_LARGE,
<ide> ERR_INVALID_ARG_TYPE,
<ide> ERR_INVALID_ARG_VALUE,
<del> ERR_METHOD_NOT_IMPLEMENTED
<del>} = require('internal/errors').codes;
<add> ERR_METHOD_NOT_IMPLEMENTED,
<add>} = codes;
<ide> const { isArrayBufferView } = require('internal/util/types');
<ide> const { rimrafPromises } = require('internal/fs/rimraf');
<ide> const {
<ide> const {
<ide> const getDirectoryEntriesPromise = promisify(getDirents);
<ide> const validateRmOptionsPromise = promisify(validateRmOptions);
<ide>
<add>let DOMException;
<add>const lazyDOMException = hideStackFrames((message, name) => {
<add> if (DOMException === undefined)
<add> DOMException = internalBinding('messaging').DOMException;
<add> return new DOMException(message, name);
<add>});
<add>
<ide> class FileHandle extends JSTransferable {
<ide> constructor(filehandle) {
<ide> super();
<ide> async function writeFileHandle(filehandle, data) {
<ide> }
<ide>
<ide> async function readFileHandle(filehandle, options) {
<add> const signal = options && options.signal;
<add>
<add> if (signal && signal.aborted) {
<add> throw lazyDOMException('The operation was aborted', 'AbortError');
<add> }
<ide> const statFields = await binding.fstat(filehandle.fd, false, kUsePromises);
<ide>
<add> if (signal && signal.aborted) {
<add> throw lazyDOMException('The operation was aborted', 'AbortError');
<add> }
<add>
<ide> let size;
<ide> if ((statFields[1/* mode */] & S_IFMT) === S_IFREG) {
<ide> size = statFields[8/* size */];
<ide> async function readFileHandle(filehandle, options) {
<ide> MathMin(size, kReadFileMaxChunkSize);
<ide> let endOfFile = false;
<ide> do {
<add> if (signal && signal.aborted) {
<add> throw lazyDOMException('The operation was aborted', 'AbortError');
<add> }
<ide> const buf = Buffer.alloc(chunkSize);
<ide> const { bytesRead, buffer } =
<ide> await read(filehandle, buf, 0, chunkSize, -1);
<ide><path>lib/internal/fs/read_file_context.js
<ide> const { Buffer } = require('buffer');
<ide>
<ide> const { FSReqCallback, close, read } = internalBinding('fs');
<ide>
<add>const { hideStackFrames } = require('internal/errors');
<add>
<add>
<add>let DOMException;
<add>const lazyDOMException = hideStackFrames((message, name) => {
<add> if (DOMException === undefined)
<add> DOMException = internalBinding('messaging').DOMException;
<add> return new DOMException(message, name);
<add>});
<add>
<ide> // Use 64kb in case the file type is not a regular file and thus do not know the
<ide> // actual file size. Increasing the value further results in more frequent over
<ide> // allocation for small files and consumes CPU time and memory that should be
<ide> class ReadFileContext {
<ide> this.pos = 0;
<ide> this.encoding = encoding;
<ide> this.err = null;
<add> this.signal = undefined;
<ide> }
<ide>
<ide> read() {
<ide> let buffer;
<ide> let offset;
<ide> let length;
<ide>
<add> if (this.signal && this.signal.aborted) {
<add> return this.close(
<add> lazyDOMException('The operation was aborted', 'AbortError')
<add> );
<add> }
<ide> if (this.size === 0) {
<ide> buffer = Buffer.allocUnsafeSlow(kReadFileUnknownBufferLength);
<ide> offset = 0;
<ide><path>lib/internal/fs/utils.js
<ide> const {
<ide> const { once } = require('internal/util');
<ide> const { toPathIfFileURL } = require('internal/url');
<ide> const {
<add> validateAbortSignal,
<ide> validateBoolean,
<ide> validateInt32,
<ide> validateUint32
<ide> function getOptions(options, defaultOptions) {
<ide>
<ide> if (options.encoding !== 'buffer')
<ide> assertEncoding(options.encoding);
<add>
<add> if (options.signal !== undefined) {
<add> validateAbortSignal(options.signal, 'options.signal');
<add> }
<ide> return options;
<ide> }
<ide>
<ide><path>test/parallel/test-fs-promises-readfile.js
<ide> tmpdir.refresh();
<ide>
<ide> const fn = path.join(tmpdir.path, 'large-file');
<ide>
<del>async function validateReadFile() {
<del> // Creating large buffer with random content
<del> const buffer = Buffer.from(
<del> Array.apply(null, { length: 16834 * 2 })
<del> .map(Math.random)
<del> .map((number) => (number * (1 << 8)))
<del> );
<add>// Creating large buffer with random content
<add>const largeBuffer = Buffer.from(
<add> Array.apply(null, { length: 16834 * 2 })
<add> .map(Math.random)
<add> .map((number) => (number * (1 << 8)))
<add>);
<ide>
<add>async function createLargeFile() {
<ide> // Writing buffer to a file then try to read it
<del> await writeFile(fn, buffer);
<add> await writeFile(fn, largeBuffer);
<add>}
<add>
<add>async function validateReadFile() {
<ide> const readBuffer = await readFile(fn);
<del> assert.strictEqual(readBuffer.equals(buffer), true);
<add> assert.strictEqual(readBuffer.equals(largeBuffer), true);
<ide> }
<ide>
<ide> async function validateReadFileProc() {
<ide> async function validateReadFileProc() {
<ide> assert.ok(hostname.length > 0);
<ide> }
<ide>
<del>validateReadFile()
<del> .then(() => validateReadFileProc())
<del> .then(common.mustCall());
<add>function validateReadFileAbortLogicBefore() {
<add> const controller = new AbortController();
<add> const signal = controller.signal;
<add> controller.abort();
<add> assert.rejects(readFile(fn, { signal }), {
<add> name: 'AbortError'
<add> });
<add>}
<add>
<add>function validateReadFileAbortLogicDuring() {
<add> const controller = new AbortController();
<add> const signal = controller.signal;
<add> process.nextTick(() => controller.abort());
<add> assert.rejects(readFile(fn, { signal }), {
<add> name: 'AbortError'
<add> });
<add>}
<add>
<add>(async () => {
<add> await createLargeFile();
<add> await validateReadFile();
<add> await validateReadFileProc();
<add> await validateReadFileAbortLogicBefore();
<add> await validateReadFileAbortLogicDuring();
<add>})().then(common.mustCall());
<ide><path>test/parallel/test-fs-readfile.js
<ide> for (const e of fileInfo) {
<ide> assert.deepStrictEqual(buf, e.contents);
<ide> }));
<ide> }
<add>{
<add> // Test cancellation, before
<add> const controller = new AbortController();
<add> const signal = controller.signal;
<add> controller.abort();
<add> fs.readFile(fileInfo[0].name, { signal }, common.mustCall((err, buf) => {
<add> assert.strictEqual(err.name, 'AbortError');
<add> }));
<add>}
<add>{
<add> // Test cancellation, during read
<add> const controller = new AbortController();
<add> const signal = controller.signal;
<add> fs.readFile(fileInfo[0].name, { signal }, common.mustCall((err, buf) => {
<add> assert.strictEqual(err.name, 'AbortError');
<add> }));
<add> process.nextTick(() => controller.abort());
<add>} | 7 |
Java | Java | fix outdated javadoc in the testcontext framework | 726655af50b6747b8c87ed023aa7911c2b4fe2ed | <ide><path>spring-test/src/main/java/org/springframework/test/context/junit4/AbstractJUnit4SpringContextTests.java
<ide>
<ide> import org.apache.commons.logging.Log;
<ide> import org.apache.commons.logging.LogFactory;
<add>
<ide> import org.junit.runner.RunWith;
<add>
<ide> import org.springframework.context.ApplicationContext;
<ide> import org.springframework.context.ApplicationContextAware;
<ide> import org.springframework.test.context.ContextConfiguration;
<ide> import org.springframework.test.context.support.DirtiesContextTestExecutionListener;
<ide>
<ide> /**
<del> * <p>
<ide> * Abstract base test class which integrates the <em>Spring TestContext
<ide> * Framework</em> with explicit {@link ApplicationContext} testing support in a
<ide> * <strong>JUnit 4.5+</strong> environment.
<del> * </p>
<del> * <p>
<del> * Concrete subclasses should typically declare a class-level
<add> *
<add> * <p>Concrete subclasses should typically declare a class-level
<ide> * {@link ContextConfiguration @ContextConfiguration} annotation to
<del> * configure the {@link ApplicationContext application context}
<del> * {@link ContextConfiguration#locations() resource locations}.
<del> * <em>If your test does not need to load an application context, you may choose
<del> * to omit the {@link ContextConfiguration @ContextConfiguration} declaration
<del> * and to configure the appropriate
<del> * {@link org.springframework.test.context.TestExecutionListener TestExecutionListeners}
<del> * manually.</em>
<del> * </p>
<del> * <p>
<del> * Note: this class serves only as a convenience for extension. If you do not
<add> * configure the {@link ApplicationContext application context} {@link
<add> * ContextConfiguration#locations() resource locations} or {@link
<add> * ContextConfiguration#classes() annotated classes}. <em>If your test does not
<add> * need to load an application context, you may choose to omit the {@link
<add> * ContextConfiguration @ContextConfiguration} declaration and to configure
<add> * the appropriate {@link org.springframework.test.context.TestExecutionListener
<add> * TestExecutionListeners} manually.</em>
<add> *
<add> * <p>Note: this class serves only as a convenience for extension. If you do not
<ide> * wish for your test classes to be tied to a Spring-specific class hierarchy,
<ide> * you may configure your own custom test classes by using
<ide> * {@link SpringJUnit4ClassRunner}, {@link ContextConfiguration
<ide> * @ContextConfiguration}, {@link TestExecutionListeners
<ide> * @TestExecutionListeners}, etc.
<del> * </p>
<ide> *
<ide> * @author Sam Brannen
<ide> * @since 2.5
<ide><path>spring-test/src/main/java/org/springframework/test/context/junit4/AbstractTransactionalJUnit4SpringContextTests.java
<ide> import org.springframework.transaction.annotation.Transactional;
<ide>
<ide> /**
<del> * <p>
<ide> * Abstract {@link Transactional transactional} extension of
<ide> * {@link AbstractJUnit4SpringContextTests} which adds convenience functionality
<ide> * for JDBC access. Expects a {@link DataSource} bean and a
<ide> * {@link PlatformTransactionManager} bean to be defined in the Spring
<ide> * {@link ApplicationContext application context}.
<del> * </p>
<del> * <p>
<del> * This class exposes a {@link SimpleJdbcTemplate} and provides an easy way to
<del> * {@link #countRowsInTable(String) count the number of rows in a table} ,
<del> * {@link #deleteFromTables(String...) delete from the database} , and
<add> *
<add> * <p>This class exposes a {@link SimpleJdbcTemplate} and provides an easy way
<add> * to {@link #countRowsInTable(String) count the number of rows in a table},
<add> * {@link #deleteFromTables(String...) delete from tables}, and
<ide> * {@link #executeSqlScript(String, boolean) execute SQL scripts} within a
<ide> * transaction.
<del> * </p>
<del> * <p>
<del> * Concrete subclasses must fulfill the same requirements outlined in
<add> *
<add> * <p>Concrete subclasses must fulfill the same requirements outlined in
<ide> * {@link AbstractJUnit4SpringContextTests}.
<del> * </p>
<del> * <p>
<del> * Note: this class serves only as a convenience for extension. If you do not
<add> *
<add> * <p>Note: this class serves only as a convenience for extension. If you do not
<ide> * wish for your test classes to be tied to a Spring-specific class hierarchy,
<ide> * you may configure your own custom test classes by using
<ide> * {@link SpringJUnit4ClassRunner}, {@link ContextConfiguration
<ide> * @ContextConfiguration}, {@link TestExecutionListeners
<ide> * @TestExecutionListeners}, {@link Transactional @Transactional},
<ide> * etc.
<del> * </p>
<ide> *
<ide> * @author Sam Brannen
<ide> * @author Juergen Hoeller
<ide> * @see org.springframework.test.jdbc.SimpleJdbcTestUtils
<ide> * @see org.springframework.test.context.testng.AbstractTransactionalTestNGSpringContextTests
<ide> */
<del>@SuppressWarnings("deprecation")
<ide> @TestExecutionListeners(TransactionalTestExecutionListener.class)
<ide> @Transactional
<add>@SuppressWarnings("deprecation")
<ide> public abstract class AbstractTransactionalJUnit4SpringContextTests extends AbstractJUnit4SpringContextTests {
<ide>
<ide> /**
<ide><path>spring-test/src/main/java/org/springframework/test/context/testng/AbstractTestNGSpringContextTests.java
<ide>
<ide> import org.apache.commons.logging.Log;
<ide> import org.apache.commons.logging.LogFactory;
<add>
<ide> import org.springframework.context.ApplicationContext;
<ide> import org.springframework.context.ApplicationContextAware;
<ide> import org.springframework.test.context.ContextConfiguration;
<ide> import org.springframework.test.context.TestExecutionListeners;
<ide> import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
<ide> import org.springframework.test.context.support.DirtiesContextTestExecutionListener;
<add>
<ide> import org.testng.IHookCallBack;
<ide> import org.testng.IHookable;
<ide> import org.testng.ITestResult;
<ide> import org.testng.annotations.BeforeMethod;
<ide>
<ide> /**
<del> * <p>
<del> * Abstract base test class which integrates the
<del> * <em>Spring TestContext Framework</em> with explicit
<del> * {@link ApplicationContext} testing support in a <strong>TestNG</strong>
<add> * Abstract base test class which integrates the <em>Spring TestContext Framework</em>
<add> * with explicit {@link ApplicationContext} testing support in a <strong>TestNG</strong>
<ide> * environment.
<del> * </p>
<del> * <p>
<del> * Concrete subclasses:
<del> * </p>
<add> *
<add> * <p>Concrete subclasses:
<ide> * <ul>
<ide> * <li>Typically declare a class-level {@link ContextConfiguration
<del> * @ContextConfiguration} annotation to configure the
<del> * {@link ApplicationContext application context}
<del> * {@link ContextConfiguration#locations() resource locations}.
<del> * <em>If your test does not need to load an application context, you may choose
<del> * to omit the {@link ContextConfiguration @ContextConfiguration} declaration
<del> * and to configure the appropriate
<add> * @ContextConfiguration} annotation to configure the {@link ApplicationContext
<add> * application context} {@link ContextConfiguration#locations() resource locations}
<add> * or {@link ContextConfiguration#classes() annotated classes}. <em>If your test
<add> * does not need to load an application context, you may choose to omit the
<add> * {@link ContextConfiguration @ContextConfiguration} declaration and to
<add> * configure the appropriate
<ide> * {@link org.springframework.test.context.TestExecutionListener TestExecutionListeners}
<ide> * manually.</em></li>
<ide> * <li>Must have constructors which either implicitly or explicitly delegate to
<del> * <code>super();</code>.</li>
<add> * {@code super();}.</li>
<ide> * </ul>
<ide> *
<ide> * @author Sam Brannen
<ide><path>spring-test/src/main/java/org/springframework/test/context/testng/AbstractTransactionalTestNGSpringContextTests.java
<ide> import org.springframework.transaction.annotation.Transactional;
<ide>
<ide> /**
<del> * <p>
<ide> * Abstract {@link Transactional transactional} extension of
<ide> * {@link AbstractTestNGSpringContextTests} which adds convenience functionality
<ide> * for JDBC access. Expects a {@link DataSource} bean and a
<ide> * {@link PlatformTransactionManager} bean to be defined in the Spring
<ide> * {@link ApplicationContext application context}.
<del> * </p>
<del> * <p>
<del> * This class exposes a {@link SimpleJdbcTemplate} and provides an easy way to
<del> * {@link #countRowsInTable(String) count the number of rows in a table} ,
<del> * {@link #deleteFromTables(String...) delete from the database} , and
<add> *
<add> * <p>This class exposes a {@link SimpleJdbcTemplate} and provides an easy way
<add> * to {@link #countRowsInTable(String) count the number of rows in a table},
<add> * {@link #deleteFromTables(String...) delete from tables}, and
<ide> * {@link #executeSqlScript(String, boolean) execute SQL scripts} within a
<ide> * transaction.
<del> * </p>
<del> * <p>
<del> * Concrete subclasses must fulfill the same requirements outlined in
<add> *
<add> * <p>Concrete subclasses must fulfill the same requirements outlined in
<ide> * {@link AbstractTestNGSpringContextTests}.
<del> * </p>
<ide> *
<ide> * @author Sam Brannen
<ide> * @author Juergen Hoeller
<ide> * @see org.springframework.test.jdbc.SimpleJdbcTestUtils
<ide> * @see org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests
<ide> */
<del>@SuppressWarnings("deprecation")
<ide> @TestExecutionListeners(TransactionalTestExecutionListener.class)
<ide> @Transactional
<add>@SuppressWarnings("deprecation")
<ide> public abstract class AbstractTransactionalTestNGSpringContextTests extends AbstractTestNGSpringContextTests {
<ide>
<ide> /**
<ide> protected int deleteFromTables(String... names) {
<ide> * and continueOnError was <code>false</code>
<ide> */
<ide> protected void executeSqlScript(String sqlResourcePath, boolean continueOnError) throws DataAccessException {
<del>
<ide> Resource resource = this.applicationContext.getResource(sqlResourcePath);
<ide> SimpleJdbcTestUtils.executeSqlScript(this.simpleJdbcTemplate, new EncodedResource(resource,
<ide> this.sqlScriptEncoding), continueOnError);
<ide><path>spring-test/src/test/java/org/springframework/test/context/testng/AnnotationConfigTransactionalTestNGSpringContextTests.java
<ide> /*
<del> * Copyright 2002-2011 the original author or authors.
<add> * Copyright 2002-2012 the original author or authors.
<ide> *
<ide> * Licensed under the Apache License, Version 2.0 (the "License");
<ide> * you may not use this file except in compliance with the License.
<ide> import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
<ide> import org.springframework.test.annotation.NotTransactional;
<ide> import org.springframework.test.context.ContextConfiguration;
<del>import org.springframework.test.context.support.AnnotationConfigContextLoader;
<ide> import org.springframework.test.context.transaction.AfterTransaction;
<ide> import org.springframework.test.context.transaction.BeforeTransaction;
<ide> import org.springframework.transaction.PlatformTransactionManager;
<ide> * classes with TestNG-based tests.
<ide> *
<ide> * <p>Configuration will be loaded from
<del> * {@link AnnotationConfigTransactionalTestNGSpringContextTestsConfig}.
<add> * {@link AnnotationConfigTransactionalTestNGSpringContextTests.ContextConfiguration}.
<ide> *
<ide> * @author Sam Brannen
<ide> * @since 3.1
<ide> */
<ide> @SuppressWarnings("deprecation")
<del>@ContextConfiguration(loader = AnnotationConfigContextLoader.class)
<add>@ContextConfiguration
<ide> public class AnnotationConfigTransactionalTestNGSpringContextTests extends
<ide> AbstractTransactionalTestNGSpringContextTests {
<ide> | 5 |
Ruby | Ruby | push key checking up | 55d0e6f87719bb9a7040d59db7e5beaa6701e55e | <ide><path>actionpack/lib/action_controller/metal/strong_parameters.rb
<ide> def array_of_permitted_scalars?(value)
<ide> end
<ide>
<ide> def array_of_permitted_scalars_filter(params, key)
<del> if has_key?(key) && array_of_permitted_scalars?(self[key])
<add> if array_of_permitted_scalars?(self[key])
<ide> params[key] = self[key]
<ide> end
<ide> end
<ide> def hash_filter(params, filter)
<ide> # Slicing filters out non-declared keys.
<ide> slice(*filter.keys).each do |key, value|
<ide> next unless value
<add> next unless has_key? key
<ide>
<ide> if filter[key] == EMPTY_ARRAY
<ide> # Declaration { comment_ids: [] }. | 1 |
Go | Go | add detection for f2fs and jfs | 7e2d05b4938c010bf15224bd2857e2dca92ec9b3 | <ide><path>daemon/graphdriver/driver.go
<ide> import (
<ide> type FsMagic uint32
<ide>
<ide> const (
<del> FsMagicBtrfs = FsMagic(0x9123683E)
<ide> FsMagicAufs = FsMagic(0x61756673)
<del> FsMagicExtfs = FsMagic(0x0000EF53)
<add> FsMagicBtrfs = FsMagic(0x9123683E)
<ide> FsMagicCramfs = FsMagic(0x28cd3d45)
<del> FsMagicRamFs = FsMagic(0x858458f6)
<del> FsMagicTmpFs = FsMagic(0x01021994)
<del> FsMagicSquashFs = FsMagic(0x73717368)
<add> FsMagicExtfs = FsMagic(0x0000EF53)
<add> FsMagicF2fs = FsMagic(0xF2F52010)
<add> FsMagicJffs2Fs = FsMagic(0x000072b6)
<add> FsMagicJfs = FsMagic(0x3153464a)
<ide> FsMagicNfsFs = FsMagic(0x00006969)
<add> FsMagicRamFs = FsMagic(0x858458f6)
<ide> FsMagicReiserFs = FsMagic(0x52654973)
<ide> FsMagicSmbFs = FsMagic(0x0000517B)
<del> FsMagicJffs2Fs = FsMagic(0x000072b6)
<del> FsMagicZfs = FsMagic(0x2fc12fc1)
<del> FsMagicXfs = FsMagic(0x58465342)
<add> FsMagicSquashFs = FsMagic(0x73717368)
<add> FsMagicTmpFs = FsMagic(0x01021994)
<ide> FsMagicUnsupported = FsMagic(0x00000000)
<add> FsMagicXfs = FsMagic(0x58465342)
<add> FsMagicZfs = FsMagic(0x2fc12fc1)
<ide> )
<ide>
<ide> var (
<ide> var (
<ide> FsNames = map[FsMagic]string{
<ide> FsMagicAufs: "aufs",
<ide> FsMagicBtrfs: "btrfs",
<del> FsMagicExtfs: "extfs",
<ide> FsMagicCramfs: "cramfs",
<del> FsMagicRamFs: "ramfs",
<del> FsMagicTmpFs: "tmpfs",
<del> FsMagicSquashFs: "squashfs",
<add> FsMagicExtfs: "extfs",
<add> FsMagicF2fs: "f2fs",
<add> FsMagicJffs2Fs: "jffs2",
<add> FsMagicJfs: "jfs",
<ide> FsMagicNfsFs: "nfs",
<add> FsMagicRamFs: "ramfs",
<ide> FsMagicReiserFs: "reiserfs",
<ide> FsMagicSmbFs: "smb",
<del> FsMagicJffs2Fs: "jffs2",
<del> FsMagicZfs: "zfs",
<del> FsMagicXfs: "xfs",
<add> FsMagicSquashFs: "squashfs",
<add> FsMagicTmpFs: "tmpfs",
<ide> FsMagicUnsupported: "unsupported",
<add> FsMagicXfs: "xfs",
<add> FsMagicZfs: "zfs",
<ide> }
<ide> )
<ide> | 1 |
PHP | PHP | fix bug with setting save keys | 3a5f0f1910b2dd76853917277a4531f30d137ed4 | <ide><path>src/Illuminate/Database/Eloquent/Model.php
<ide> abstract class Model implements ArrayAccess, ArrayableInterface, JsonableInterfa
<ide>
<ide> /**
<ide> * The accessors to append to the model's array form.
<del> *
<add> *
<ide> * @var array
<ide> */
<ide> protected $appends = array();
<ide> protected function fireModelEvent($event, $halt = true)
<ide> */
<ide> protected function setKeysForSaveQuery(Builder $query)
<ide> {
<del> $query->where($this->getKeyName(), '=', $this->original[$this->getKeyName()]);
<add> $query->where($this->getKeyName(), '=', $this->getKeyForSaveQuery());
<ide>
<ide> return $query;
<ide> }
<ide>
<add> /**
<add> * Get the primary key value for a save query.
<add> *
<add> * @return mixed
<add> */
<add> protected function getKeyForSaveQuery()
<add> {
<add> if (isset($this->original[$this->getKeyName()]))
<add> {
<add> return $this->original[$this->getKeyName()];
<add> }
<add> else
<add> {
<add> return $this->getAttribute($this->getKeyName());
<add> }
<add> }
<add>
<ide> /**
<ide> * Update the model's update timestamp.
<ide> *
<ide> protected function getArrayableItems(array $values)
<ide> return array_intersect_key($values, array_flip($this->visible));
<ide> }
<ide>
<del> return array_diff_key($values, array_flip($this->hidden));
<add> return array_diff_key($values, array_flip($this->hidden));
<ide> }
<ide>
<ide> /**
<ide> public function getDirty()
<ide>
<ide> /**
<ide> * Get all the loaded relations for the instance.
<del> *
<add> *
<ide> * @return array
<ide> */
<ide> public function getRelations() | 1 |
PHP | PHP | remove duplicate code | 5a5b58849b78359c750270f467a3d9b9376834b8 | <ide><path>src/ORM/Query.php
<ide> public function applyOptions(array $options)
<ide> public function cleanCopy()
<ide> {
<ide> $clone = clone $this;
<del> $clone->_iterator = null;
<ide> $clone->triggerBeforeFind();
<del> $clone->eagerLoader(clone $this->eagerLoader());
<del> $clone->valueBinder(clone $this->valueBinder());
<ide> $clone->autoFields(false);
<ide> $clone->limit(null);
<ide> $clone->order([], true); | 1 |
Text | Text | add load_defaults doc for query_log_tags_format | 8afcad4f1daa86819729aeebe765ff40bb8eced4 | <ide><path>guides/source/configuring.md
<ide> Below are the default values associated with each target version. In cases of co
<ide> - [`config.action_dispatch.default_headers`](#config-action-dispatch-default-headers): `{ "X-Frame-Options" => "SAMEORIGIN", "X-XSS-Protection" => "0", "X-Content-Type-Options" => "nosniff", "X-Permitted-Cross-Domain-Policies" => "none", "Referrer-Policy" => "strict-origin-when-cross-origin" }`
<ide> - [`config.active_job.use_big_decimal_serializer`](#config-active-job-use-big-decimal-serializer): `true`
<ide> - [`config.active_record.allow_deprecated_singular_associations_name`](#config-active-record-allow-deprecated-singular-associations-name): `false`
<add>- [`config.active_record.query_log_tags_format`](#config-active-record-query-log-tags-format): `:sqlcommenter`
<ide> - [`config.active_record.run_commit_callbacks_on_first_saved_instances_in_transaction`](#config-active-record-run-commit-callbacks-on-first-saved-instances-in-transaction): `false`
<ide> - [`config.active_record.sqlite3_adapter_strict_strings_by_default`](#config-active-record-sqlite3-adapter-strict-strings-by-default): `true`
<ide> - [`config.active_support.default_message_encryptor_serializer`](#config-active-support-default-message-encryptor-serializer): `:json` | 1 |
Javascript | Javascript | fix resize issue in outlinepass | 976404aa285c092cdf5dd3d2bd282b4d9b3be94a | <ide><path>examples/js/postprocessing/OutlinePass.js
<ide> THREE.OutlinePass.prototype = Object.assign( Object.create( THREE.Pass.prototype
<ide> setSize: function ( width, height ) {
<ide>
<ide> this.renderTargetMaskBuffer.setSize( width, height );
<add> this.renderTargetDepthBuffer.setSize( width, height );
<ide>
<ide> var resx = Math.round( width / this.downSampleRatio );
<ide> var resy = Math.round( height / this.downSampleRatio );
<ide><path>examples/jsm/postprocessing/OutlinePass.js
<ide> OutlinePass.prototype = Object.assign( Object.create( Pass.prototype ), {
<ide> setSize: function ( width, height ) {
<ide>
<ide> this.renderTargetMaskBuffer.setSize( width, height );
<add> this.renderTargetDepthBuffer.setSize( width, height );
<ide>
<ide> var resx = Math.round( width / this.downSampleRatio );
<ide> var resy = Math.round( height / this.downSampleRatio ); | 2 |
Java | Java | fix accessibility role/label | fa6035bda6c606868977179534cb941f26fbdb92 | <ide><path>ReactAndroid/src/main/java/com/facebook/react/uimanager/AccessibilityDelegateUtil.java
<ide> public static void setDelegate(final View view) {
<ide> // if a view already has an accessibility delegate, replacing it could cause problems,
<ide> // so leave it alone.
<ide> if (!ViewCompat.hasAccessibilityDelegate(view) &&
<del> accessibilityHint != null &&
<del> accessibilityRole != null) {
<add> (accessibilityHint != null || accessibilityRole != null)) {
<ide> ViewCompat.setAccessibilityDelegate(
<ide> view,
<ide> new AccessibilityDelegateCompat() { | 1 |
Ruby | Ruby | keep a cache of writer methods | 55ac7db11bd2fc0cf06d7184f013018fa4be0e9a | <ide><path>activerecord/lib/active_record/attribute_methods/write.rb
<ide> module ActiveRecord
<ide> module AttributeMethods
<ide> module Write
<add> WriterMethodCache = Class.new {
<add> include Mutex_m
<add>
<add> def initialize
<add> super
<add> @module = Module.new
<add> @method_cache = {}
<add> end
<add>
<add> def [](name)
<add> synchronize do
<add> @method_cache.fetch(name) {
<add> safe_name = name.unpack('h*').first
<add> temp_method = "__temp__#{safe_name}="
<add>
<add> ActiveRecord::AttributeMethods::AttrNames.set_name_cache safe_name, name
<add>
<add> @module.module_eval <<-STR, __FILE__, __LINE__ + 1
<add> def #{temp_method}(value)
<add> name = ::ActiveRecord::AttributeMethods::AttrNames::ATTR_#{safe_name}
<add> write_attribute(name, value)
<add> end
<add> STR
<add>
<add> @method_cache[name] = @module.instance_method temp_method
<add> }
<add> end
<add> end
<add> }.new
<add>
<ide> extend ActiveSupport::Concern
<ide>
<ide> included do
<ide> module ClassMethods
<ide> # See define_method_attribute in read.rb for an explanation of
<ide> # this code.
<ide> def define_method_attribute=(name)
<del> safe_name = name.unpack('h*').first
<del> ActiveRecord::AttributeMethods::AttrNames.set_name_cache safe_name, name
<del>
<del> generated_attribute_methods.module_eval <<-STR, __FILE__, __LINE__ + 1
<del> def __temp__#{safe_name}=(value)
<del> name = ::ActiveRecord::AttributeMethods::AttrNames::ATTR_#{safe_name}
<del> write_attribute(name, value)
<del> end
<del> alias_method #{(name + '=').inspect}, :__temp__#{safe_name}=
<del> undef_method :__temp__#{safe_name}=
<del> STR
<add> method = WriterMethodCache[name]
<add> generated_attribute_methods.module_eval {
<add> define_method "#{name}=", method
<add> }
<ide> end
<ide> end
<ide> | 1 |
Text | Text | update citation information. | 659a4ba0b7035380e721db029e64c2b7bf24c07f | <ide><path>docs/templates/getting-started/faq.md
<ide> Please cite Keras in your publications if it helps your research. Here is an exa
<ide> title={Keras},
<ide> author={Chollet, Fran\c{c}ois and others},
<ide> year={2015},
<del> publisher={GitHub},
<del> howpublished={\url{https://github.com/keras-team/keras}},
<add> howpublished={\url{https://keras.io}},
<ide> }
<ide> ```
<ide> | 1 |
Javascript | Javascript | add testid, helps tests find items in the list | b5de89755d15bb9b2d5e8b350cd3c25f302ab71e | <ide><path>packages/rn-tester/js/components/RNTesterExampleList.js
<ide> const ExampleCard = ({
<ide> const onAndroid = !platform || platform === 'android';
<ide> return (
<ide> <TouchableHighlight
<add> testID={item.module.title}
<ide> onShowUnderlay={onShowUnderlay}
<ide> onHideUnderlay={onHideUnderlay}
<ide> accessibilityLabel={item.module.title + ' ' + item.module.description} | 1 |
Text | Text | fix syntax errors in person.js example | badf7bb0949280d543b6928ee1d942eb5a2073f9 | <ide><path>guide/english/react/state-vs-props/index.md
<ide> See the below example to get an idea of state:
<ide> super(props);
<ide> this.state = {
<ide> age:0
<add> }
<ide> this.incrementAge = this.incrementAge.bind(this)
<ide> }
<ide> | 1 |
Javascript | Javascript | return empty object for no user | c459572fcf7d4f0b936b6bb014592e6d25435081 | <ide><path>common/models/user.js
<ide> module.exports = function(User) {
<ide> if (!username) {
<ide> // Zalgo!!
<ide> return nextTick(() => {
<del> cb(new TypeError(
<del> `username should be a string but got ${ username }`
<del> ));
<add> cb(null, {});
<ide> });
<ide> }
<ide> return User.findOne({ where: { username } }, (err, user) => {
<ide> if (err) {
<ide> return cb(err);
<ide> }
<ide> if (!user || user.username !== username) {
<del> return cb(new Error(`no user found for ${ username }`));
<add> return cb(null, {});
<ide> }
<ide> const aboutUser = getAboutProfile(user);
<ide> return cb(null, aboutUser); | 1 |
PHP | PHP | fix readability for api | 240a85802e7afedee8dd0a69ec153478c0175154 | <ide><path>src/ORM/Entity.php
<ide> class Entity implements EntityInterface {
<ide>
<ide> /**
<ide> * Initializes the internal properties of this entity out of the
<del> * keys in an array
<del> *
<del> * ### Example:
<del> *
<del> * ``$entity = new Entity(['id' => 1, 'name' => 'Andrew'])``
<del> *
<del> * @param array $properties hash of properties to set in this entity
<del> * @param array $options list of options to use when creating this entity
<del> * the following list of options can be used:
<add> * keys in an array. The following list of options can be used:
<ide> *
<ide> * - useSetters: whether use internal setters for properties or not
<ide> * - markClean: whether to mark all properties as clean after setting them
<ide> * - markNew: whether this instance has not yet been persisted
<ide> * - guard: whether to prevent inaccessible properties from being set (default: false)
<ide> * - source: A string representing the alias of the repository this entity came from
<add> *
<add> * ### Example:
<add> *
<add> * {{{
<add> * $entity = new Entity(['id' => 1, 'name' => 'Andrew'])
<add> * }}}
<add> *
<add> * @param array $properties hash of properties to set in this entity
<add> * @param array $options list of options to use when creating this entity
<ide> */
<ide> public function __construct(array $properties = [], array $options = []) {
<ide> $options += [ | 1 |
Javascript | Javascript | update atomenvironment specs for async confirm | 58f351e5985c2f2a3e022adc4afd3b7a7294e139 | <ide><path>spec/atom-environment-spec.js
<del>const {it, fit, ffit, fffit, beforeEach, afterEach} = require('./async-spec-helpers')
<add>const {it, fit, ffit, beforeEach, afterEach, conditionPromise} = require('./async-spec-helpers')
<ide> const _ = require('underscore-plus')
<ide> const path = require('path')
<ide> const temp = require('temp').track()
<ide> describe('AtomEnvironment', () => {
<ide> })
<ide> })
<ide>
<del> it('prompts the user to restore the state in a new window, discarding it and adding folder to current window', () => {
<del> spyOn(atom, 'confirm').andReturn(1)
<add> it('prompts the user to restore the state in a new window, discarding it and adding folder to current window', async () => {
<add> jasmine.useRealClock()
<add> spyOn(atom, 'confirm').andCallFake((options, callback) => callback(1))
<ide> spyOn(atom.project, 'addPath')
<ide> spyOn(atom.workspace, 'open')
<ide> const state = Symbol()
<ide>
<ide> atom.attemptRestoreProjectStateForPaths(state, [__dirname], [__filename])
<ide> expect(atom.confirm).toHaveBeenCalled()
<del> expect(atom.project.addPath.callCount).toBe(1)
<add> await conditionPromise(() => atom.project.addPath.callCount === 1)
<add>
<ide> expect(atom.project.addPath).toHaveBeenCalledWith(__dirname)
<ide> expect(atom.workspace.open.callCount).toBe(1)
<ide> expect(atom.workspace.open).toHaveBeenCalledWith(__filename)
<ide> })
<ide>
<del> it('prompts the user to restore the state in a new window, opening a new window', () => {
<del> spyOn(atom, 'confirm').andReturn(0)
<add> fit('prompts the user to restore the state in a new window, opening a new window', () => {
<add> jasmine.useRealClock()
<add> spyOn(atom, 'confirm').andCallFake((options, callback) => callback(0))
<ide> spyOn(atom, 'open')
<ide> const state = Symbol()
<ide>
<ide> atom.attemptRestoreProjectStateForPaths(state, [__dirname], [__filename])
<ide> expect(atom.confirm).toHaveBeenCalled()
<add> await conditionPromise(() => atom.open.callCount === 1)
<ide> expect(atom.open).toHaveBeenCalledWith({
<ide> pathsToOpen: [__dirname, __filename],
<ide> newWindow: true, | 1 |
Text | Text | add snippet for asyncresource and ee integration | db3d6b38b6a20f0caf432077a585bf51af5d06f4 | <ide><path>doc/api/async_hooks.md
<ide> createHook({
<ide> }
<ide> }).enable();
<ide>
<del>const server = createServer(function(req, res) {
<add>const server = createServer((req, res) => {
<ide> executionAsyncResource()[sym] = { state: req.url };
<ide> setTimeout(function() {
<ide> res.end(JSON.stringify(executionAsyncResource()[sym]));
<ide> for (let i = 0; i < 10; i++) {
<ide> }
<ide> ```
<ide>
<add>### Integrating `AsyncResource` with `EventEmitter`
<add>
<add>Event listeners triggered by an [`EventEmitter`][] may be run in a different
<add>execution context than the one that was active when `eventEmitter.on()` was
<add>called.
<add>
<add>The following example shows how to use the `AsyncResource` class to properly
<add>associate an event listener with the correct execution context. The same
<add>approach can be applied to a [`Stream`][] or a similar event-driven class.
<add>
<add>```js
<add>const { createServer } = require('http');
<add>const { AsyncResource, executionAsyncId } = require('async_hooks');
<add>
<add>const server = createServer((req, res) => {
<add> const asyncResource = new AsyncResource('request');
<add> // The listener will always run in the execution context of `asyncResource`.
<add> req.on('close', asyncResource.runInAsyncScope.bind(asyncResource, () => {
<add> // Prints: true
<add> console.log(asyncResource.asyncId() === executionAsyncId());
<add> }));
<add> res.end();
<add>}).listen(3000);
<add>```
<add>
<ide> ## Class: `AsyncLocalStorage`
<ide> <!-- YAML
<ide> added:
<ide> to associate the asynchronous operation with the correct execution context.
<ide> [`destroy` callback]: #async_hooks_destroy_asyncid
<ide> [`init` callback]: #async_hooks_init_asyncid_type_triggerasyncid_resource
<ide> [`promiseResolve` callback]: #async_hooks_promiseresolve_asyncid
<add>[`EventEmitter`]: events.html#events_class_eventemitter
<ide> [Hook Callbacks]: #async_hooks_hook_callbacks
<ide> [PromiseHooks]: https://docs.google.com/document/d/1rda3yKGHimKIhg5YeoAmCOtyURgsbTH_qaYR79FELlk/edit
<add>[`Stream`]: stream.html#stream_stream
<ide> [`Worker`]: worker_threads.html#worker_threads_class_worker
<ide> [promise execution tracking]: #async_hooks_promise_execution_tracking
<ide> [`util.promisify()`]: util.html#util_util_promisify_original | 1 |
Javascript | Javascript | break dependence on api.js | 3972d2a89bfcfe177b12bb225302fc2937a1dbab | <ide><path>src/JSON.js
<ide> function fromJson(json, useNative) {
<ide> // TODO(misko): remove this once the $http service is checked in.
<ide> function transformDates(obj) {
<ide> if (isString(obj) && obj.length === DATE_ISOSTRING_LN) {
<del> return angularString.toDate(obj);
<add> return jsonStringToDate(obj);
<ide> } else if (isArray(obj) || isObject(obj)) {
<ide> forEach(obj, function(val, name) {
<ide> obj[name] = transformDates(val);
<ide> function fromJson(json, useNative) {
<ide> }
<ide> }
<ide>
<del>angular.toJson = toJson;
<del>angular.fromJson = fromJson;
<add>var R_ISO8061_STR = /^(\d{4})-(\d\d)-(\d\d)(?:T(\d\d)(?:\:(\d\d)(?:\:(\d\d)(?:\.(\d{3}))?)?)?Z)?$/;
<add>function jsonStringToDate(string){
<add> var match;
<add> if (isString(string) && (match = string.match(R_ISO8061_STR))){
<add> var date = new Date(0);
<add> date.setUTCFullYear(match[1], match[2] - 1, match[3]);
<add> date.setUTCHours(match[4]||0, match[5]||0, match[6]||0, match[7]||0);
<add> return date;
<add> }
<add> return string;
<add>}
<add>
<add>function jsonDateToString(date){
<add> if (!date) return date;
<add> var isoString = date.toISOString ? date.toISOString() : '';
<add> return (isoString.length==24)
<add> ? isoString
<add> : padNumber(date.getUTCFullYear(), 4) + '-' +
<add> padNumber(date.getUTCMonth() + 1, 2) + '-' +
<add> padNumber(date.getUTCDate(), 2) + 'T' +
<add> padNumber(date.getUTCHours(), 2) + ':' +
<add> padNumber(date.getUTCMinutes(), 2) + ':' +
<add> padNumber(date.getUTCSeconds(), 2) + '.' +
<add> padNumber(date.getUTCMilliseconds(), 3) + 'Z';
<add>}
<add>
<add>function quoteUnicode(string) {
<add> var chars = ['"'];
<add> for ( var i = 0; i < string.length; i++) {
<add> var code = string.charCodeAt(i);
<add> var ch = string.charAt(i);
<add> switch(ch) {
<add> case '"': chars.push('\\"'); break;
<add> case '\\': chars.push('\\\\'); break;
<add> case '\n': chars.push('\\n'); break;
<add> case '\f': chars.push('\\f'); break;
<add> case '\r': chars.push(ch = '\\r'); break;
<add> case '\t': chars.push(ch = '\\t'); break;
<add> default:
<add> if (32 <= code && code <= 126) {
<add> chars.push(ch);
<add> } else {
<add> var encode = "000" + code.toString(16);
<add> chars.push("\\u" + encode.substring(encode.length - 4));
<add> }
<add> }
<add> }
<add> chars.push('"');
<add> return chars.join('');
<add> }
<add>
<ide>
<ide> function toJsonArray(buf, obj, pretty, stack) {
<ide> if (isObject(obj)) {
<ide> function toJsonArray(buf, obj, pretty, stack) {
<ide> if (obj === null) {
<ide> buf.push($null);
<ide> } else if (obj instanceof RegExp) {
<del> buf.push(angularString.quoteUnicode(obj.toString()));
<add> buf.push(quoteUnicode(obj.toString()));
<ide> } else if (isFunction(obj)) {
<ide> return;
<ide> } else if (isBoolean(obj)) {
<ide> function toJsonArray(buf, obj, pretty, stack) {
<ide> buf.push('' + obj);
<ide> }
<ide> } else if (isString(obj)) {
<del> return buf.push(angularString.quoteUnicode(obj));
<add> return buf.push(quoteUnicode(obj));
<ide> } else if (isObject(obj)) {
<ide> if (isArray(obj)) {
<ide> buf.push("[");
<ide> function toJsonArray(buf, obj, pretty, stack) {
<ide> // TODO(misko): maybe in dev mode have a better error reporting?
<ide> buf.push('DOM_ELEMENT');
<ide> } else if (isDate(obj)) {
<del> buf.push(angularString.quoteUnicode(angular.Date.toString(obj)));
<add> buf.push(quoteUnicode(jsonDateToString(obj)));
<ide> } else {
<ide> buf.push("{");
<ide> if (pretty) buf.push(pretty);
<ide> function toJsonArray(buf, obj, pretty, stack) {
<ide> buf.push(",");
<ide> if (pretty) buf.push(pretty);
<ide> }
<del> buf.push(angularString.quote(key));
<add> buf.push(quoteUnicode(key));
<ide> buf.push(":");
<ide> toJsonArray(buf, value, childPretty, stack);
<ide> comma = true;
<ide><path>src/angular-mocks.js
<ide> angular.mock.TzDate = function (offset, timestamp) {
<ide> if (angular.isString(timestamp)) {
<ide> var tsStr = timestamp;
<ide>
<del> this.origDate = angular.String.toDate(timestamp);
<add> this.origDate = angular.fromJson(angular.toJson({date:timestamp})).date;
<ide>
<ide> timestamp = this.origDate.getTime();
<ide> if (isNaN(timestamp))
<ide><path>src/apis.js
<ide> var angularArray = {
<ide> }
<ide> };
<ide>
<del>var R_ISO8061_STR = /^(\d{4})-(\d\d)-(\d\d)(?:T(\d\d)(?:\:(\d\d)(?:\:(\d\d)(?:\.(\d{3}))?)?)?Z)?$/;
<ide>
<ide> var angularString = {
<ide> 'quote':function(string) {
<ide> var angularString = {
<ide> replace(/\t/g, '\\t').
<ide> replace(/\v/g, '\\v') +
<ide> '"';
<del> },
<del> 'quoteUnicode':function(string) {
<del> var str = angular['String']['quote'](string);
<del> var chars = [];
<del> for ( var i = 0; i < str.length; i++) {
<del> var ch = str.charCodeAt(i);
<del> if (ch < 128) {
<del> chars.push(str.charAt(i));
<del> } else {
<del> var encode = "000" + ch.toString(16);
<del> chars.push("\\u" + encode.substring(encode.length - 4));
<del> }
<del> }
<del> return chars.join('');
<del> },
<del>
<del> /**
<del> * Tries to convert input to date and if successful returns the date, otherwise returns the
<del> * input.
<del> *
<del> * @param {string} string
<del> * @return {(Date|string)}
<del> */
<del> 'toDate':function(string){
<del> var match;
<del> if (isString(string) && (match = string.match(R_ISO8061_STR))){
<del> var date = new Date(0);
<del> date.setUTCFullYear(match[1], match[2] - 1, match[3]);
<del> date.setUTCHours(match[4]||0, match[5]||0, match[6]||0, match[7]||0);
<del> return date;
<del> }
<del> return string;
<ide> }
<ide> };
<ide>
<ide> var angularDate = {
<del> 'toString':function(date){
<del> if (!date) return date;
<del>
<del> var isoString = date.toISOString ? date.toISOString() : '';
<del>
<del> return (isoString.length==24) ?
<del> isoString :
<del> padNumber(date.getUTCFullYear(), 4) + '-' +
<del> padNumber(date.getUTCMonth() + 1, 2) + '-' +
<del> padNumber(date.getUTCDate(), 2) + 'T' +
<del> padNumber(date.getUTCHours(), 2) + ':' +
<del> padNumber(date.getUTCMinutes(), 2) + ':' +
<del> padNumber(date.getUTCSeconds(), 2) + '.' +
<del> padNumber(date.getUTCMilliseconds(), 3) + 'Z';
<del> }
<ide> };
<ide>
<ide> var angularFunction = {
<ide><path>src/service/filter/filters.js
<ide> function dateFilter($locale) {
<ide> if (NUMBER_STRING.test(date)) {
<ide> date = parseInt(date, 10);
<ide> } else {
<del> date = angularString.toDate(date);
<add> date = jsonStringToDate(date);
<ide> }
<ide> }
<ide>
<ide><path>test/ApiSpecs.js
<ide> describe('api', function() {
<ide>
<ide> });
<ide>
<del>
<del> describe('string', function() {
<del> it('should quote', function() {
<del> assertEquals(angular.String.quote('a'), '"a"');
<del> assertEquals(angular.String.quote('\\'), '"\\\\"');
<del> assertEquals(angular.String.quote("'a'"), '"\'a\'"');
<del> assertEquals(angular.String.quote('"a"'), '"\\"a\\""');
<del> assertEquals(angular.String.quote('\n\f\r\t'), '"\\n\\f\\r\\t"');
<del> });
<del>
<del> it('should quote slashes', function() {
<del> assertEquals('"7\\\\\\\"7"', angular.String.quote("7\\\"7"));
<del> });
<del>
<del> it('should quote unicode', function() {
<del> assertEquals('"abc\\u00a0def"', angular.String.quoteUnicode('abc\u00A0def'));
<del> });
<del>
<del> it('should read/write to date', function() {
<del> var date = new Date("Sep 10 2003 13:02:03 GMT");
<del> assertEquals("date", angular.Object.typeOf(date));
<del> assertEquals("2003-09-10T13:02:03.000Z", angular.Date.toString(date));
<del> assertEquals(date.getTime(), angular.String.toDate(angular.Date.toString(date)).getTime());
<del> });
<del>
<del> it('should convert to date', function() {
<del> //full ISO8061
<del> expect(angular.String.toDate("2003-09-10T13:02:03.000Z")).
<del> toEqual(new Date("Sep 10 2003 13:02:03 GMT"));
<del>
<del> //no millis
<del> expect(angular.String.toDate("2003-09-10T13:02:03Z")).
<del> toEqual(new Date("Sep 10 2003 13:02:03 GMT"));
<del>
<del> //no seconds
<del> expect(angular.String.toDate("2003-09-10T13:02Z")).
<del> toEqual(new Date("Sep 10 2003 13:02:00 GMT"));
<del>
<del> //no minutes
<del> expect(angular.String.toDate("2003-09-10T13Z")).
<del> toEqual(new Date("Sep 10 2003 13:00:00 GMT"));
<del>
<del> //no time
<del> expect(angular.String.toDate("2003-09-10")).
<del> toEqual(new Date("Sep 10 2003 00:00:00 GMT"));
<del> });
<del>
<del> it('should parse date', function() {
<del> var date = angular.String.toDate("2003-09-10T13:02:03.000Z");
<del> assertEquals("date", angular.Object.typeOf(date));
<del> assertEquals("2003-09-10T13:02:03.000Z", angular.Date.toString(date));
<del> assertEquals("str", angular.String.toDate("str"));
<del> });
<del> });
<ide> });
<ide>
<ide><path>test/JsonSpec.js
<ide> describe('json', function() {
<ide> });
<ide>
<ide> it('should serialize UTC dates', function() {
<del> var date = angular.String.toDate("2009-10-09T01:02:03.027Z");
<add> var date = jsonStringToDate("2009-10-09T01:02:03.027Z");
<ide> expect(toJson(date)).toEqual('"2009-10-09T01:02:03.027Z"');
<ide> expect(fromJson('"2009-10-09T01:02:03.027Z"').getTime()).toEqual(date.getTime());
<ide> });
<ide> describe('json', function() {
<ide>
<ide> });
<ide>
<add>
<add> it('should read/write to date', function() {
<add> var date = new Date("Sep 10 2003 13:02:03 GMT");
<add> assertEquals("2003-09-10T13:02:03.000Z", jsonDateToString(date));
<add> assertEquals(date.getTime(), jsonStringToDate(jsonDateToString(date)).getTime());
<add> });
<add>
<add>
<add> it('should convert to date', function() {
<add> //full ISO8061
<add> expect(jsonStringToDate("2003-09-10T13:02:03.000Z")).
<add> toEqual(new Date("Sep 10 2003 13:02:03 GMT"));
<add>
<add> //no millis
<add> expect(jsonStringToDate("2003-09-10T13:02:03Z")).
<add> toEqual(new Date("Sep 10 2003 13:02:03 GMT"));
<add>
<add> //no seconds
<add> expect(jsonStringToDate("2003-09-10T13:02Z")).
<add> toEqual(new Date("Sep 10 2003 13:02:00 GMT"));
<add>
<add> //no minutes
<add> expect(jsonStringToDate("2003-09-10T13Z")).
<add> toEqual(new Date("Sep 10 2003 13:00:00 GMT"));
<add>
<add> //no time
<add> expect(jsonStringToDate("2003-09-10")).
<add> toEqual(new Date("Sep 10 2003 00:00:00 GMT"));
<add> });
<add>
<add>
<add> it('should parse date', function() {
<add> var date = jsonStringToDate("2003-09-10T13:02:03.000Z");
<add> assertEquals("2003-09-10T13:02:03.000Z", jsonDateToString(date));
<add> assertEquals("str", jsonStringToDate("str"));
<add> });
<add>
<add>
<add> describe('string', function() {
<add> it('should quote', function() {
<add> assertEquals(quoteUnicode('a'), '"a"');
<add> assertEquals(quoteUnicode('\\'), '"\\\\"');
<add> assertEquals(quoteUnicode("'a'"), '"\'a\'"');
<add> assertEquals(quoteUnicode('"a"'), '"\\"a\\""');
<add> assertEquals(quoteUnicode('\n\f\r\t'), '"\\n\\f\\r\\t"');
<add> });
<add>
<add> it('should quote slashes', function() {
<add> assertEquals('"7\\\\\\\"7"', quoteUnicode("7\\\"7"));
<add> });
<add>
<add> it('should quote unicode', function() {
<add> assertEquals('"abc\\u00a0def"', quoteUnicode('abc\u00A0def'));
<add> });
<add>
<add> });
<add>
<ide> });
<ide><path>test/angular-mocksSpec.js
<ide> describe('mocks', function() {
<ide>
<ide>
<ide> //from when created from millis
<del> var date2 = new angular.mock.TzDate(-1, angular.String.toDate('2009-12-31T23:00:00.000Z').getTime());
<add> var date2 = new angular.mock.TzDate(-1, date1.getTime());
<ide> expect(date2.getUTCFullYear()).toBe(2009);
<ide> expect(date2.getUTCMonth()).toBe(11);
<ide> expect(date2.getUTCDate()).toBe(31); | 7 |
Python | Python | fix flaky test | 3f67168c44f8c7d34e5266a99bbdd90669a8eaa6 | <ide><path>tests/keras/test_models.py
<ide> def data_generator(train):
<ide> model.fit_generator(data_generator(True), len(X_train), nb_epoch, show_accuracy=True, validation_data=(X_test, y_test))
<ide>
<ide> loss = model.evaluate(X_train, y_train, verbose=0)
<del> assert(loss < 0.8)
<add> assert(loss < 0.9)
<ide>
<ide>
<ide> def test_sequential(): | 1 |
Python | Python | fix sequence length for prepare_inputs for xlnet | f18ac4c28e6382c9fce4e4a5c8a3c645fe4bdd98 | <ide><path>src/transformers/modeling_xlnet.py
<ide> def prepare_inputs_for_generation(self, input_ids, **model_kwargs):
<ide> # Add dummy token at the end (no attention on this one)
<ide>
<ide> effective_batch_size = input_ids.shape[0]
<del> sequence_length = input_ids.shape[1]
<ide> dummy_token = torch.zeros((effective_batch_size, 1), dtype=torch.long, device=input_ids.device)
<ide> input_ids = torch.cat([input_ids, dummy_token], dim=1)
<ide>
<ide> # Build permutation mask so that previous tokens don't see last token
<add> sequence_length = input_ids.shape[1]
<ide> perm_mask = torch.zeros(
<ide> (effective_batch_size, sequence_length, sequence_length), dtype=torch.float, device=input_ids.device
<ide> ) | 1 |
Python | Python | load all models on cpu | df5d9c3551a6405feb697a1cad903dddffa04bfe | <ide><path>pytorch_pretrained_bert/modeling.py
<ide> def from_pretrained(cls, pretrained_model_name_or_path, state_dict=None, cache_d
<ide> model = cls(config, *inputs, **kwargs)
<ide> if state_dict is None and not from_tf:
<ide> weights_path = os.path.join(serialization_dir, WEIGHTS_NAME)
<del> state_dict = torch.load(weights_path, map_location='cpu' if not torch.cuda.is_available() else None)
<add> state_dict = torch.load(weights_path, map_location='cpu')
<ide> if tempdir:
<ide> # Clean up temp dir
<ide> shutil.rmtree(tempdir)
<ide><path>pytorch_pretrained_bert/modeling_gpt2.py
<ide> def from_pretrained(
<ide> # Instantiate model.
<ide> model = cls(config, *inputs, **kwargs)
<ide> if state_dict is None and not from_tf:
<del> state_dict = torch.load(resolved_archive_file, map_location='cpu' if not torch.cuda.is_available() else None)
<add> state_dict = torch.load(resolved_archive_file, map_location='cpu')
<ide> if from_tf:
<ide> # Directly load from a TensorFlow checkpoint (stored as NumPy array)
<ide> return load_tf_weights_in_gpt2(model, resolved_archive_file)
<ide><path>pytorch_pretrained_bert/modeling_openai.py
<ide> def from_pretrained(
<ide> # Instantiate model.
<ide> model = cls(config, *inputs, **kwargs)
<ide> if state_dict is None and not from_tf:
<del> state_dict = torch.load(resolved_archive_file, map_location='cpu' if not torch.cuda.is_available() else None)
<add> state_dict = torch.load(resolved_archive_file, map_location='cpu')
<ide> if from_tf:
<ide> # Directly load from a TensorFlow checkpoint (stored as NumPy array)
<ide> return load_tf_weights_in_openai_gpt(model, resolved_archive_file)
<ide><path>pytorch_pretrained_bert/modeling_transfo_xl.py
<ide> def from_pretrained(cls, pretrained_model_name_or_path, state_dict=None, cache_d
<ide> # Instantiate model.
<ide> model = cls(config, *inputs, **kwargs)
<ide> if state_dict is None and not from_tf:
<del> state_dict = torch.load(resolved_archive_file, map_location='cpu' if not torch.cuda.is_available() else None)
<add> state_dict = torch.load(resolved_archive_file, map_location='cpu')
<ide> if from_tf:
<ide> # Directly load from a TensorFlow checkpoint
<ide> return load_tf_weights_in_transfo_xl(model, config, pretrained_model_name_or_path) | 4 |
Text | Text | add twitter to obtaining api keys | 1b0fdf33942d17912a0b983de23c248c15b72bd6 | <ide><path>README.md
<ide> Obtaining API Keys
<ide>
<ide> <hr>
<ide>
<del>
<add><img src="https://g.twimg.com/Twitter_logo_blue.png" width="200">
<add>- Sign in at [https://dev.twitter.com](https://dev.twitter.com/)
<add>- From the profile picture dropdown menu select **My Applications**
<add>- Click **Create a new application**
<add>- Enter your application name, website and description
<add>- For **Callback URL**: http://127.0.0.1:3000/auth/twitter/callback
<add>- Go to **Settings** tab
<add>- Under *Application Type* select **Read and Write** access
<add>- Check the box *Allow this application to be used to Sign in with Twitter*
<add>- Click **Update this Twitter's applications settings**
<ide>
<ide> <hr>
<ide> | 1 |
Python | Python | remove private keras api usage | affbaa609d4d3afee36ff08866ecc82dcc0d36de | <ide><path>official/vision/beta/modeling/layers/nn_layers.py
<ide> def get_config(self):
<ide> base_config = super(Conv3D, self).get_config()
<ide> return dict(list(base_config.items()) + list(config.items()))
<ide>
<del> def build(self, input_shape):
<del> """Builds the layer with the given input shape."""
<del> super(Conv3D, self).build(input_shape)
<del>
<del> # TODO(b/177662019): tf.nn.conv3d with depthwise kernels on CPU
<del> # in eager mode may produce incorrect output or cause a segfault.
<del> # To avoid this issue, compile the op to TF graph using tf.function.
<del> self._convolution_op = tf.function(
<del> self._convolution_op, experimental_compile=True)
<add> def call(self, inputs):
<add> """Call the layer with the given inputs."""
<add> # Note: tf.nn.conv3d with depthwise kernels on CPU is currently only
<add> # supported when compiling with TF graph (XLA) using tf.function, so it
<add> # is compiled by default here (b/186463870).
<add> conv_fn = tf.function(super(Conv3D, self).call, jit_compile=True)
<add> return conv_fn(inputs)
<ide>
<ide> def _compute_causal_padding(self, inputs):
<ide> """Computes causal padding dimensions for the given inputs.""" | 1 |
Python | Python | fix various typos | f961ae08d91cbe705df1f63736ebbf9079d554de | <ide><path>airflow/_vendor/connexion/apps/abstract.py
<ide> def add_api(self, specification, base_path=None, arguments=None,
<ide> auth_all_paths = auth_all_paths if auth_all_paths is not None else self.auth_all_paths
<ide> # TODO test if base_path starts with an / (if not none)
<ide> arguments = arguments or dict()
<del> arguments = dict(self.arguments, **arguments) # copy global arguments and update with api specfic
<add> arguments = dict(self.arguments, **arguments) # copy global arguments and update with api specific
<ide>
<ide> if isinstance(specification, dict):
<ide> specification = specification
<ide><path>airflow/_vendor/connexion/decorators/response.py
<ide> def __init__(self, operation, mimetype, validator=None):
<ide> def validate_response(self, data, status_code, headers, url):
<ide> """
<ide> Validates the Response object based on what has been declared in the specification.
<del> Ensures the response body matches the declated schema.
<add> Ensures the response body matches the declared schema.
<ide> :type data: dict
<ide> :type status_code: int
<ide> :type headers: dict
<ide><path>airflow/_vendor/connexion/decorators/security.py
<ide> def wrapper(request, required_scopes):
<ide> if token_info is None:
<ide> return None
<ide>
<del> # Fallback to 'scopes' for backward compability
<add> # Fallback to 'scopes' for backward compatibility
<ide> token_scopes = token_info.get('scope', token_info.get('scopes', ''))
<ide> if not scope_validate_func(required_scopes, token_scopes):
<ide> raise OAuthScopeProblem(
<ide> def verify_security(auth_funcs, required_scopes, function):
<ide> def wrapper(request):
<ide> token_info = get_authorization_info(auth_funcs, request, required_scopes)
<ide>
<del> # Fallback to 'uid' for backward compability
<add> # Fallback to 'uid' for backward compatibility
<ide> request.context['user'] = token_info.get('sub', token_info.get('uid'))
<ide> request.context['token_info'] = token_info
<ide> return function(request)
<ide><path>airflow/_vendor/connexion/operations/compat.py
<del># This is a dummy module for backwards compatability with < v2.0
<add># This is a dummy module for backwards compatibility with < v2.0
<ide> from .secure import * # noqa
<ide> from .swagger2 import * # noqa | 4 |
Javascript | Javascript | cover dgram socket close during bind case | a196895ecceeda4f7ba1059a95a06f1463e517fa | <ide><path>test/parallel/test-dgram-close-during-bind.js
<add>'use strict';
<add>const common = require('../common');
<add>const dgram = require('dgram');
<add>const socket = dgram.createSocket('udp4');
<add>const lookup = socket._handle.lookup;
<add>
<add>// Test the scenario where the socket is closed during a bind operation.
<add>socket._handle.bind = common.mustNotCall('bind() should not be called.');
<add>
<add>socket._handle.lookup = common.mustCall(function(address, callback) {
<add> socket.close(common.mustCall(() => {
<add> lookup.call(this, address, callback);
<add> }));
<add>});
<add>
<add>socket.bind(common.mustNotCall('Socket should not bind.')); | 1 |
Ruby | Ruby | use polymorphic proxies to remove duplicate code | a9da99ee5fd73b6d52c6fb443b2443cdfb262d5f | <ide><path>activerecord/lib/active_record/fixtures.rb
<ide> def table_rows
<ide> end
<ide> when :has_many
<ide> if association.options[:through]
<del> handle_hmt(rows, row, association)
<add> add_join_records(rows, row, HasManyThroughProxy.new(association))
<ide> end
<ide> when :has_and_belongs_to_many
<del> handle_habtm(rows, row, association)
<add> add_join_records(rows, row, HABTMProxy.new(association))
<ide> end
<ide> end
<ide> end
<ide> def table_rows
<ide> rows
<ide> end
<ide>
<del> private
<del> def primary_key_name
<del> @primary_key_name ||= model_class && model_class.primary_key
<add> class ReflectionProxy # :nodoc:
<add> def initialize(association)
<add> @association = association
<ide> end
<ide>
<del> def join_rows(targets, row, lhs_key, rhs_key)
<del> targets = targets.is_a?(Array) ? targets : targets.split(/\s*,\s*/)
<del> targets.map { |target|
<del> { lhs_key => row[primary_key_name],
<del> rhs_key => ActiveRecord::FixtureSet.identify(target) }
<del> }
<add> def join_table
<add> @association.join_table
<ide> end
<ide>
<del> def handle_hmt(rows, row, association)
<del> # This is the case when the join table has no fixtures file
<del> if (targets = row.delete(association.name.to_s))
<del> table_name = association.join_table
<del> lhs_key = association.through_reflection.foreign_key
<del> rhs_key = association.foreign_key
<add> def name
<add> @association.name
<add> end
<add> end
<ide>
<del> rows[table_name].concat join_rows(targets, row, lhs_key, rhs_key)
<del> end
<add> class HasManyThroughProxy < ReflectionProxy # :nodoc:
<add> def rhs_key
<add> @association.foreign_key
<add> end
<add>
<add> def lhs_key
<add> @association.through_reflection.foreign_key
<ide> end
<add> end
<add>
<add> class HABTMProxy < ReflectionProxy # :nodoc:
<add> def rhs_key
<add> @association.association_foreign_key
<add> end
<add>
<add> def lhs_key
<add> @association.foreign_key
<add> end
<add> end
<ide>
<del> def handle_habtm(rows, row, association)
<add> private
<add> def primary_key_name
<add> @primary_key_name ||= model_class && model_class.primary_key
<add> end
<add>
<add> def add_join_records(rows, row, association)
<ide> # This is the case when the join table has no fixtures file
<ide> if (targets = row.delete(association.name.to_s))
<ide> table_name = association.join_table
<del> lhs_key = association.foreign_key
<del> rhs_key = association.association_foreign_key
<del>
<del> rows[table_name].concat join_rows(targets, row, lhs_key, rhs_key)
<add> lhs_key = association.lhs_key
<add> rhs_key = association.rhs_key
<add>
<add> targets = targets.is_a?(Array) ? targets : targets.split(/\s*,\s*/)
<add> rows[table_name].concat targets.map { |target|
<add> { lhs_key => row[primary_key_name],
<add> rhs_key => ActiveRecord::FixtureSet.identify(target) }
<add> }
<ide> end
<ide> end
<ide> | 1 |
Javascript | Javascript | use createelement instead of html generation | cfd6f7a1b8bdbe263ec9a8076ee549171fcb9534 | <ide><path>src/renderers/dom/client/ReactDOMIDOperations.js
<ide>
<ide> 'use strict';
<ide>
<del>var CSSPropertyOperations = require('CSSPropertyOperations');
<ide> var DOMChildrenOperations = require('DOMChildrenOperations');
<ide> var DOMPropertyOperations = require('DOMPropertyOperations');
<ide> var ReactMount = require('ReactMount');
<ide> var INVALID_PROPERTY_ERRORS = {
<ide> };
<ide>
<ide> /**
<del> * Operations used to process updates to DOM nodes. This is made injectable via
<del> * `ReactDOMComponent.BackendIDOperations`.
<add> * Operations used to process updates to DOM nodes.
<ide> */
<ide> var ReactDOMIDOperations = {
<ide>
<ide> var ReactDOMIDOperations = {
<ide> }
<ide> },
<ide>
<del> /**
<del> * Updates a DOM node with new property values.
<del> *
<del> * @param {string} id ID of the node to update.
<del> * @param {string} name A valid property name.
<del> * @param {*} value New value of the property.
<del> * @internal
<del> */
<del> updateAttributeByID: function(id, name, value) {
<del> var node = ReactMount.getNode(id);
<del> invariant(
<del> !INVALID_PROPERTY_ERRORS.hasOwnProperty(name),
<del> 'updatePropertyByID(...): %s',
<del> INVALID_PROPERTY_ERRORS[name]
<del> );
<del> DOMPropertyOperations.setValueForAttribute(node, name, value);
<del> },
<del>
<del> /**
<del> * Updates a DOM node to remove a property. This should only be used to remove
<del> * DOM properties in `DOMProperty`.
<del> *
<del> * @param {string} id ID of the node to update.
<del> * @param {string} name A property name to remove, see `DOMProperty`.
<del> * @internal
<del> */
<del> deletePropertyByID: function(id, name, value) {
<del> var node = ReactMount.getNode(id);
<del> invariant(
<del> !INVALID_PROPERTY_ERRORS.hasOwnProperty(name),
<del> 'updatePropertyByID(...): %s',
<del> INVALID_PROPERTY_ERRORS[name]
<del> );
<del> DOMPropertyOperations.deleteValueForProperty(node, name, value);
<del> },
<del>
<del> /**
<del> * Updates a DOM node with new style values. If a value is specified as '',
<del> * the corresponding style property will be unset.
<del> *
<del> * @param {string} id ID of the node to update.
<del> * @param {object} styles Mapping from styles to values.
<del> * @internal
<del> */
<del> updateStylesByID: function(id, styles) {
<del> var node = ReactMount.getNode(id);
<del> CSSPropertyOperations.setValueForStyles(node, styles);
<del> },
<del>
<del> /**
<del> * Updates a DOM node's text content set by `props.content`.
<del> *
<del> * @param {string} id ID of the node to update.
<del> * @param {string} content Text content.
<del> * @internal
<del> */
<del> updateTextContentByID: function(id, content) {
<del> var node = ReactMount.getNode(id);
<del> DOMChildrenOperations.updateTextContent(node, content);
<del> },
<del>
<ide> /**
<ide> * Replaces a DOM node that exists in the document with markup.
<ide> *
<ide> var ReactDOMIDOperations = {
<ide>
<ide> ReactPerf.measureMethods(ReactDOMIDOperations, 'ReactDOMIDOperations', {
<ide> updatePropertyByID: 'updatePropertyByID',
<del> deletePropertyByID: 'deletePropertyByID',
<del> updateStylesByID: 'updateStylesByID',
<del> updateTextContentByID: 'updateTextContentByID',
<ide> dangerouslyReplaceNodeWithMarkupByID: 'dangerouslyReplaceNodeWithMarkupByID',
<ide> dangerouslyProcessChildrenUpdates: 'dangerouslyProcessChildrenUpdates',
<ide> });
<ide><path>src/renderers/dom/client/ReactMount.js
<ide> var DOMProperty = require('DOMProperty');
<ide> var ReactBrowserEventEmitter = require('ReactBrowserEventEmitter');
<ide> var ReactCurrentOwner = require('ReactCurrentOwner');
<add>var ReactDOMFeatureFlags = require('ReactDOMFeatureFlags');
<ide> var ReactElement = require('ReactElement');
<ide> var ReactEmptyComponent = require('ReactEmptyComponent');
<ide> var ReactInstanceHandles = require('ReactInstanceHandles');
<ide> var ReactReconciler = require('ReactReconciler');
<ide> var ReactUpdateQueue = require('ReactUpdateQueue');
<ide> var ReactUpdates = require('ReactUpdates');
<ide>
<add>var assign = require('Object.assign');
<ide> var emptyObject = require('emptyObject');
<ide> var containsNode = require('containsNode');
<ide> var instantiateReactComponent = require('instantiateReactComponent');
<ide> var ELEMENT_NODE_TYPE = 1;
<ide> var DOC_NODE_TYPE = 9;
<ide> var DOCUMENT_FRAGMENT_NODE_TYPE = 11;
<ide>
<add>var ownerDocumentContextKey =
<add> '__ReactMount_ownerDocument$' + Math.random().toString(36).slice(2);
<add>
<add>
<ide> /** Mapping from reactRootID to React component instance. */
<ide> var instancesByReactRootID = {};
<ide>
<ide> function mountComponentIntoNode(
<ide> shouldReuseMarkup,
<ide> context
<ide> ) {
<add> if (ReactDOMFeatureFlags.useCreateElement) {
<add> context = assign({}, context);
<add> if (container.nodeType === DOC_NODE_TYPE) {
<add> context[ownerDocumentContextKey] = container;
<add> } else {
<add> context[ownerDocumentContextKey] = container.ownerDocument;
<add> }
<add> }
<ide> if (__DEV__) {
<ide> if (context === emptyObject) {
<ide> context = {};
<ide> function mountComponentIntoNode(
<ide> componentInstance, rootID, transaction, context
<ide> );
<ide> componentInstance._renderedComponent._topLevelWrapper = componentInstance;
<del> ReactMount._mountImageIntoNode(markup, container, shouldReuseMarkup);
<add> ReactMount._mountImageIntoNode(
<add> markup,
<add> container,
<add> shouldReuseMarkup,
<add> transaction
<add> );
<ide> }
<ide>
<ide> /**
<ide> function batchedMountComponentIntoNode(
<ide> shouldReuseMarkup,
<ide> context
<ide> ) {
<del> var transaction = ReactUpdates.ReactReconcileTransaction.getPooled();
<add> var transaction = ReactUpdates.ReactReconcileTransaction.getPooled(
<add> /* forceHTML */ shouldReuseMarkup
<add> );
<ide> transaction.perform(
<ide> mountComponentIntoNode,
<ide> null,
<ide> var ReactMount = {
<ide> );
<ide> },
<ide>
<del> _mountImageIntoNode: function(markup, container, shouldReuseMarkup) {
<add> _mountImageIntoNode: function(
<add> markup,
<add> container,
<add> shouldReuseMarkup,
<add> transaction
<add> ) {
<ide> invariant(
<ide> container && (
<ide> container.nodeType === ELEMENT_NODE_TYPE ||
<ide> var ReactMount = {
<ide> 'See React.renderToString() for server rendering.'
<ide> );
<ide>
<del> setInnerHTML(container, markup);
<add> if (transaction.useCreateElement) {
<add> while (container.lastChild) {
<add> container.removeChild(container.lastChild);
<add> }
<add> container.appendChild(markup);
<add> } else {
<add> setInnerHTML(container, markup);
<add> }
<ide> },
<ide>
<add> ownerDocumentContextKey: ownerDocumentContextKey,
<add>
<ide> /**
<ide> * React ID utilities.
<ide> */
<ide><path>src/renderers/dom/client/ReactReconcileTransaction.js
<ide> var CallbackQueue = require('CallbackQueue');
<ide> var PooledClass = require('PooledClass');
<ide> var ReactBrowserEventEmitter = require('ReactBrowserEventEmitter');
<add>var ReactDOMFeatureFlags = require('ReactDOMFeatureFlags');
<ide> var ReactInputSelection = require('ReactInputSelection');
<ide> var Transaction = require('Transaction');
<ide>
<ide> var TRANSACTION_WRAPPERS = [
<ide> *
<ide> * @class ReactReconcileTransaction
<ide> */
<del>function ReactReconcileTransaction() {
<add>function ReactReconcileTransaction(forceHTML) {
<ide> this.reinitializeTransaction();
<ide> // Only server-side rendering really needs this option (see
<ide> // `ReactServerRendering`), but server-side uses
<ide> function ReactReconcileTransaction() {
<ide> // `ReactTextComponent` checks it in `mountComponent`.`
<ide> this.renderToStaticMarkup = false;
<ide> this.reactMountReady = CallbackQueue.getPooled(null);
<add> this.useCreateElement =
<add> !forceHTML && ReactDOMFeatureFlags.useCreateElement;
<ide> }
<ide>
<ide> var Mixin = {
<ide><path>src/renderers/dom/client/utils/DOMChildrenOperations.js
<ide> var DOMChildrenOperations = {
<ide> }
<ide> }
<ide>
<del> var renderedMarkup = Danger.dangerouslyRenderMarkup(markupList);
<add> var renderedMarkup;
<add> // markupList is either a list of markup or just a list of elements
<add> if (markupList.length && typeof markupList[0] === 'string') {
<add> renderedMarkup = Danger.dangerouslyRenderMarkup(markupList);
<add> } else {
<add> renderedMarkup = markupList;
<add> }
<ide>
<ide> // Remove updated children first so that `toIndex` is consistent.
<ide> if (updatedChildren) {
<ide><path>src/renderers/dom/client/wrappers/__tests__/ReactDOMTextarea-test.js
<ide> describe('ReactDOMTextarea', function() {
<ide> });
<ide>
<ide> it('should display "false" for `defaultValue` of `false`', function() {
<del> var stub = <textarea type="text" defaultValue={false} />;
<add> var stub = <textarea defaultValue={false} />;
<ide> stub = renderTextarea(stub);
<ide> var node = ReactDOM.findDOMNode(stub);
<ide>
<ide> describe('ReactDOMTextarea', function() {
<ide> },
<ide> };
<ide>
<del> var stub = <textarea type="text" defaultValue={objToString} />;
<add> var stub = <textarea defaultValue={objToString} />;
<ide> stub = renderTextarea(stub);
<ide> var node = ReactDOM.findDOMNode(stub);
<ide>
<ide><path>src/renderers/dom/server/ReactServerRenderingTransaction.js
<ide> function ReactServerRenderingTransaction(renderToStaticMarkup) {
<ide> this.reinitializeTransaction();
<ide> this.renderToStaticMarkup = renderToStaticMarkup;
<ide> this.reactMountReady = CallbackQueue.getPooled(null);
<add> this.useCreateElement = false;
<ide> }
<ide>
<ide> var Mixin = {
<ide><path>src/renderers/dom/shared/DOMPropertyOperations.js
<ide> var DOMPropertyOperations = {
<ide> quoteAttributeValueForBrowser(id);
<ide> },
<ide>
<add> setAttributeForID: function(node, id) {
<add> node.setAttribute(DOMProperty.ID_ATTRIBUTE_NAME, id);
<add> },
<add>
<ide> /**
<ide> * Creates markup for a property.
<ide> *
<ide><path>src/renderers/dom/shared/Danger.js
<ide> var Danger = {
<ide> 'server rendering. See React.renderToString().'
<ide> );
<ide>
<del> var newChild = createNodesFromMarkup(markup, emptyFunction)[0];
<add> var newChild;
<add> if (typeof markup === 'string') {
<add> newChild = createNodesFromMarkup(markup, emptyFunction)[0];
<add> } else {
<add> newChild = markup;
<add> }
<ide> oldChild.parentNode.replaceChild(newChild, oldChild);
<ide> },
<ide>
<ide><path>src/renderers/dom/shared/ReactDOMComponent.js
<ide> var escapeTextContentForBrowser = require('escapeTextContentForBrowser');
<ide> var invariant = require('invariant');
<ide> var isEventSupported = require('isEventSupported');
<ide> var keyOf = require('keyOf');
<add>var setInnerHTML = require('setInnerHTML');
<add>var setTextContent = require('setTextContent');
<ide> var shallowEqual = require('shallowEqual');
<ide> var validateDOMNesting = require('validateDOMNesting');
<ide> var warning = require('warning');
<ide> function checkAndWarnForMutatedStyle(style1, style2, component) {
<ide> );
<ide> }
<ide>
<del>
<del>/**
<del> * Optionally injectable operations for mutating the DOM
<del> */
<del>var BackendIDOperations = null;
<del>
<ide> /**
<ide> * @param {object} component
<ide> * @param {?object} props
<ide> ReactDOMComponent.Mixin = {
<ide> }
<ide> }
<ide>
<del> var tagOpen = this._createOpenTagMarkupAndPutListeners(transaction, props);
<del> var tagContent = this._createContentMarkup(transaction, props, context);
<add> var mountImage;
<add> if (transaction.useCreateElement) {
<add> var ownerDocument = context[ReactMount.ownerDocumentContextKey];
<add> var el = ownerDocument.createElement(this._currentElement.type);
<add> DOMPropertyOperations.setAttributeForID(el, this._rootNodeID);
<add> // Populate node cache
<add> ReactMount.getID(el);
<add> this._updateDOMProperties({}, props, transaction, el);
<add> this._createInitialChildren(transaction, props, context, el);
<add> mountImage = el;
<add> } else {
<add> var tagOpen = this._createOpenTagMarkupAndPutListeners(transaction, props);
<add> var tagContent = this._createContentMarkup(transaction, props, context);
<add> if (!tagContent && omittedCloseTags[this._tag]) {
<add> mountImage = tagOpen + '/>';
<add> } else {
<add> mountImage =
<add> tagOpen + '>' + tagContent + '</' + this._currentElement.type + '>';
<add> }
<add> }
<ide>
<ide> switch (this._tag) {
<ide> case 'button':
<ide> ReactDOMComponent.Mixin = {
<ide> break;
<ide> }
<ide>
<del> if (!tagContent && omittedCloseTags[this._tag]) {
<del> return tagOpen + '/>';
<del> }
<del> return tagOpen + '>' + tagContent + '</' + this._currentElement.type + '>';
<add> return mountImage;
<ide> },
<ide>
<ide> /**
<ide> ReactDOMComponent.Mixin = {
<ide> }
<ide> },
<ide>
<add> _createInitialChildren: function(transaction, props, context, el) {
<add> // Intentional use of != to avoid catching zero/false.
<add> var innerHTML = props.dangerouslySetInnerHTML;
<add> if (innerHTML != null) {
<add> if (innerHTML.__html != null) {
<add> setInnerHTML(el, innerHTML.__html);
<add> }
<add> } else {
<add> var contentToUse =
<add> CONTENT_TYPES[typeof props.children] ? props.children : null;
<add> var childrenToUse = contentToUse != null ? null : props.children;
<add> if (contentToUse != null) {
<add> // TODO: Validate that text is allowed as a child of this node
<add> setTextContent(el, contentToUse);
<add> } else if (childrenToUse != null) {
<add> var mountImages = this.mountChildren(
<add> childrenToUse,
<add> transaction,
<add> processChildContext(context, this)
<add> );
<add> for (var i = 0; i < mountImages.length; i++) {
<add> el.appendChild(mountImages[i]);
<add> }
<add> }
<add> }
<add> },
<add>
<ide> /**
<ide> * Receives a next element and updates the component.
<ide> *
<ide> ReactDOMComponent.Mixin = {
<ide> break;
<ide> }
<ide>
<add> var node = ReactMount.getNode(this._rootNodeID);
<ide> assertValidProps(this, nextProps);
<del> this._updateDOMProperties(lastProps, nextProps, transaction);
<add> this._updateDOMProperties(lastProps, nextProps, transaction, node);
<ide> this._updateDOMChildren(
<ide> lastProps,
<ide> nextProps,
<ide> ReactDOMComponent.Mixin = {
<ide> * @param {object} nextProps
<ide> * @param {ReactReconcileTransaction} transaction
<ide> */
<del> _updateDOMProperties: function(lastProps, nextProps, transaction) {
<add> _updateDOMProperties: function(lastProps, nextProps, transaction, node) {
<ide> var propKey;
<ide> var styleName;
<ide> var styleUpdates;
<ide> ReactDOMComponent.Mixin = {
<ide> } else if (
<ide> DOMProperty.properties[propKey] ||
<ide> DOMProperty.isCustomAttribute(propKey)) {
<del> BackendIDOperations.deletePropertyByID(
<del> this._rootNodeID,
<del> propKey
<del> );
<add> DOMPropertyOperations.deleteValueForProperty(node, propKey);
<ide> }
<ide> }
<ide> for (propKey in nextProps) {
<ide> ReactDOMComponent.Mixin = {
<ide> deleteListener(this._rootNodeID, propKey);
<ide> }
<ide> } else if (isCustomComponent(this._tag, nextProps)) {
<del> BackendIDOperations.updateAttributeByID(
<del> this._rootNodeID,
<add> DOMPropertyOperations.setValueForAttribute(
<add> node,
<ide> propKey,
<ide> nextProp
<ide> );
<ide> } else if (
<ide> DOMProperty.properties[propKey] ||
<ide> DOMProperty.isCustomAttribute(propKey)) {
<del> BackendIDOperations.updatePropertyByID(
<del> this._rootNodeID,
<del> propKey,
<del> nextProp
<del> );
<add> // If we're updating to null or undefined, we should remove the property
<add> // from the DOM node instead of inadvertantly setting to a string. This
<add> // brings us in line with the same behavior we have on initial render.
<add> if (nextProp != null) {
<add> DOMPropertyOperations.setValueForProperty(node, propKey, nextProp);
<add> } else {
<add> DOMPropertyOperations.deleteValueForProperty(node, propKey);
<add> }
<ide> }
<ide> }
<ide> if (styleUpdates) {
<del> BackendIDOperations.updateStylesByID(
<del> this._rootNodeID,
<del> styleUpdates
<del> );
<add> CSSPropertyOperations.setValueForStyles(node, styleUpdates);
<ide> }
<ide> },
<ide>
<ide> assign(
<ide> ReactMultiChild.Mixin
<ide> );
<ide>
<del>ReactDOMComponent.injection = {
<del> injectIDOperations: function(IDOperations) {
<del> ReactDOMComponent.BackendIDOperations = BackendIDOperations = IDOperations;
<del> },
<del>};
<del>
<ide> module.exports = ReactDOMComponent;
<ide><path>src/renderers/dom/shared/ReactDOMFeatureFlags.js
<add>/**
<add> * Copyright 2013-2015, Facebook, Inc.
<add> * All rights reserved.
<add> *
<add> * This source code is licensed under the BSD-style license found in the
<add> * LICENSE file in the root directory of this source tree. An additional grant
<add> * of patent rights can be found in the PATENTS file in the same directory.
<add> *
<add> * @providesModule ReactDOMFeatureFlags
<add> */
<add>
<add>'use strict';
<add>
<add>var ReactDOMFeatureFlags = {
<add> useCreateElement: false,
<add>};
<add>
<add>module.exports = ReactDOMFeatureFlags;
<ide><path>src/renderers/dom/shared/ReactDOMTextComponent.js
<ide>
<ide> 'use strict';
<ide>
<add>var DOMChildrenOperations = require('DOMChildrenOperations');
<ide> var DOMPropertyOperations = require('DOMPropertyOperations');
<ide> var ReactComponentBrowserEnvironment =
<ide> require('ReactComponentBrowserEnvironment');
<del>var ReactDOMComponent = require('ReactDOMComponent');
<add>var ReactMount = require('ReactMount');
<ide>
<ide> var assign = require('Object.assign');
<ide> var escapeTextContentForBrowser = require('escapeTextContentForBrowser');
<add>var setTextContent = require('setTextContent');
<ide> var validateDOMNesting = require('validateDOMNesting');
<ide>
<ide> /**
<ide> assign(ReactDOMTextComponent.prototype, {
<ide> }
<ide>
<ide> this._rootNodeID = rootID;
<del> var escapedText = escapeTextContentForBrowser(this._stringText);
<add> if (transaction.useCreateElement) {
<add> var ownerDocument = context[ReactMount.ownerDocumentContextKey];
<add> var el = ownerDocument.createElement('span');
<add> DOMPropertyOperations.setAttributeForID(el, rootID);
<add> // Populate node cache
<add> ReactMount.getID(el);
<add> setTextContent(el, this._stringText);
<add> return el;
<add> } else {
<add> var escapedText = escapeTextContentForBrowser(this._stringText);
<ide>
<del> if (transaction.renderToStaticMarkup) {
<del> // Normally we'd wrap this in a `span` for the reasons stated above, but
<del> // since this is a situation where React won't take over (static pages),
<del> // we can simply return the text as it is.
<del> return escapedText;
<del> }
<add> if (transaction.renderToStaticMarkup) {
<add> // Normally we'd wrap this in a `span` for the reasons stated above, but
<add> // since this is a situation where React won't take over (static pages),
<add> // we can simply return the text as it is.
<add> return escapedText;
<add> }
<ide>
<del> return (
<del> '<span ' + DOMPropertyOperations.createMarkupForID(rootID) + '>' +
<del> escapedText +
<del> '</span>'
<del> );
<add> return (
<add> '<span ' + DOMPropertyOperations.createMarkupForID(rootID) + '>' +
<add> escapedText +
<add> '</span>'
<add> );
<add> }
<ide> },
<ide>
<ide> /**
<ide> assign(ReactDOMTextComponent.prototype, {
<ide> // and/or updateComponent to do the actual update for consistency with
<ide> // other component types?
<ide> this._stringText = nextStringText;
<del> ReactDOMComponent.BackendIDOperations.updateTextContentByID(
<del> this._rootNodeID,
<del> nextStringText
<del> );
<add> var node = ReactMount.getNode(this._rootNodeID);
<add> DOMChildrenOperations.updateTextContent(node, nextStringText);
<ide> }
<ide> }
<ide> },
<ide><path>src/renderers/dom/shared/ReactDefaultInjection.js
<ide> var ReactComponentBrowserEnvironment =
<ide> require('ReactComponentBrowserEnvironment');
<ide> var ReactDefaultBatchingStrategy = require('ReactDefaultBatchingStrategy');
<ide> var ReactDOMComponent = require('ReactDOMComponent');
<del>var ReactDOMIDOperations = require('ReactDOMIDOperations');
<ide> var ReactDOMTextComponent = require('ReactDOMTextComponent');
<ide> var ReactEventListener = require('ReactEventListener');
<ide> var ReactInjection = require('ReactInjection');
<ide> function inject() {
<ide> );
<ide>
<ide> ReactInjection.Component.injectEnvironment(ReactComponentBrowserEnvironment);
<del> ReactInjection.DOMComponent.injectIDOperations(ReactDOMIDOperations);
<ide>
<ide> if (__DEV__) {
<ide> var url = (ExecutionEnvironment.canUseDOM && window.location.href) || '';
<ide><path>src/renderers/dom/shared/ReactInjection.js
<ide> var ReactClass = require('ReactClass');
<ide> var ReactEmptyComponent = require('ReactEmptyComponent');
<ide> var ReactBrowserEventEmitter = require('ReactBrowserEventEmitter');
<ide> var ReactNativeComponent = require('ReactNativeComponent');
<del>var ReactDOMComponent = require('ReactDOMComponent');
<ide> var ReactPerf = require('ReactPerf');
<ide> var ReactRootIndex = require('ReactRootIndex');
<ide> var ReactUpdates = require('ReactUpdates');
<ide>
<ide> var ReactInjection = {
<ide> Component: ReactComponentEnvironment.injection,
<ide> Class: ReactClass.injection,
<del> DOMComponent: ReactDOMComponent.injection,
<ide> DOMProperty: DOMProperty.injection,
<ide> EmptyComponent: ReactEmptyComponent.injection,
<ide> EventPluginHub: EventPluginHub.injection,
<ide><path>src/renderers/dom/shared/__tests__/CSSPropertyOperations-test.js
<ide>
<ide> var React = require('React');
<ide> var ReactDOM = require('ReactDOM');
<add>var ReactDOMServer = require('ReactDOMServer');
<ide>
<ide> describe('CSSPropertyOperations', function() {
<ide> var CSSPropertyOperations;
<ide> describe('CSSPropertyOperations', function() {
<ide> display: null,
<ide> };
<ide> var div = <div style={styles} />;
<del> var root = document.createElement('div');
<del> ReactDOM.render(div, root);
<del> expect(/style=".*"/.test(root.innerHTML)).toBe(false);
<add> var html = ReactDOMServer.renderToString(div);
<add> expect(/style=/.test(html)).toBe(false);
<ide> });
<ide>
<ide> it('should warn when using hyphenated style names', function() {
<ide><path>src/renderers/dom/shared/__tests__/Danger-test.js
<ide> describe('Danger', function() {
<ide> Danger = require('Danger');
<ide>
<ide> var ReactReconcileTransaction = require('ReactReconcileTransaction');
<del> transaction = new ReactReconcileTransaction();
<add> transaction = new ReactReconcileTransaction(/* forceHTML */ true);
<ide> });
<ide>
<ide> it('should render markup', function() {
<ide><path>src/renderers/shared/reconciler/ReactUpdates.js
<ide> function ReactUpdatesFlushTransaction() {
<ide> this.dirtyComponentsLength = null;
<ide> this.callbackQueue = CallbackQueue.getPooled();
<ide> this.reconcileTransaction =
<del> ReactUpdates.ReactReconcileTransaction.getPooled();
<add> ReactUpdates.ReactReconcileTransaction.getPooled(/* forceHTML */ false);
<ide> }
<ide>
<ide> assign(
<ide><path>src/renderers/shared/reconciler/__tests__/ReactMultiChild-test.js
<ide> describe('ReactMultiChild', function() {
<ide> }
<ide>
<ide> beforeEach(function() {
<add> var ReactDOMFeatureFlags = require('ReactDOMFeatureFlags');
<add> ReactDOMFeatureFlags.useCreateElement = false;
<add>
<ide> Object.defineProperty(Element.prototype, 'innerHTML', {
<ide> set: setInnerHTML = jasmine.createSpy().andCallFake(
<ide> innerHTMLDescriptor.set
<ide><path>src/test/ReactDefaultPerfAnalysis.js
<ide> var DOM_OPERATION_TYPES = {
<ide> SET_MARKUP: 'set innerHTML',
<ide> TEXT_CONTENT: 'set textContent',
<ide> 'updatePropertyByID': 'update attribute',
<del> 'deletePropertyByID': 'delete attribute',
<del> 'updateStylesByID': 'update styles',
<ide> 'dangerouslyReplaceNodeWithMarkupByID': 'replace',
<ide> };
<ide>
<ide><path>src/test/ReactTestUtils.js
<ide> ReactShallowRenderer.prototype.render = function(element, context) {
<ide> if (!context) {
<ide> context = emptyObject;
<ide> }
<del> var transaction = ReactUpdates.ReactReconcileTransaction.getPooled();
<add> var transaction = ReactUpdates.ReactReconcileTransaction.getPooled(false);
<ide> this._render(element, transaction, context);
<ide> ReactUpdates.ReactReconcileTransaction.release(transaction);
<ide> }; | 19 |
Python | Python | remove obsolete code in genapi | c9505e977de888295e1a912aeb152c95b4562736 | <ide><path>numpy/core/code_generators/genapi.py
<ide> def find_functions(filename, tag='API'):
<ide> fo.close()
<ide> return functions
<ide>
<del>def read_order(order_file):
<del> """
<del> Read the order of the API functions from a file.
<del>
<del> Comments can be put on lines starting with #
<del> """
<del> fo = open(order_file, 'r')
<del> order = {}
<del> i = 0
<del> for line in fo:
<del> line = line.strip()
<del> if not line.startswith('#'):
<del> order[line] = i
<del> i += 1
<del> fo.close()
<del> return order
<del>
<del>def get_api_functions(tagname, order_file):
<del> if not os.path.exists(order_file):
<del> order_file = file_in_this_dir(order_file)
<del> order = read_order(order_file)
<del> functions = []
<del> for f in API_FILES:
<del> functions.extend(find_functions(f, tagname))
<del> dfunctions = []
<del> for func in functions:
<del> o = order[func.name]
<del> dfunctions.append( (o, func) )
<del> dfunctions.sort()
<del> return [a[1] for a in dfunctions]
<del>
<del>def generate_api_func(func, index, api_name):
<del> # Declaration used internally by numpy
<del> intern_decl = "NPY_NO_EXPORT %s %s \\\n (%s);" % \
<del> (func.return_type, func.name, func.argtypes_string())
<del> # Declaration used by extensions
<del> extern_decl = "#define %s \\\n (*(%s (*)(%s)) \\\n"\
<del> " %s[%d])" % (func.name,func.return_type,
<del> func.argtypes_string(), api_name, index)
<del> init_decl = " (void *) %s," % func.name
<del> return intern_decl, extern_decl, init_decl
<del>
<del>def add_api_list(offset, APIname, api_list,
<del> module_list, extension_list, init_list):
<del> """Add the API function declarations to the appropiate lists for use in
<del> the headers.
<del> """
<del> for k, func in enumerate(api_list):
<del> num = offset + k
<del> intern_decl, extern_decl, init_decl = generate_api_func(func, num,
<del> APIname)
<del> module_list.append(intern_decl)
<del> extension_list.append(extern_decl)
<del> init_list.append(init_decl)
<del> return num
<del>
<ide> def should_rebuild(targets, source_files):
<ide> from distutils.dep_util import newer_group
<ide> for t in targets: | 1 |
Text | Text | add v3.8.0-beta.4 to changelog | 0dc1a511f4309fdfdcf109b931b1a9f29f4884b3 | <ide><path>CHANGELOG.md
<ide> # Ember Changelog
<ide>
<add>### v3.8.0-beta.4 (February 4, 2019)
<add>
<add>- [#17552](https://github.com/emberjs/ember.js/pull/17552) [BUGFIX] Support numbers in component names for Angle Brackets
<add>
<ide> ### v3.8.0-beta.3 (January 28, 2019)
<ide>
<ide> - [#17498](https://github.com/emberjs/ember.js/pull/17498) [BUGFIX] Don't remove dep keys in `didUnwatch` | 1 |
Ruby | Ruby | update clang version parsing for clt 12.5 | 0b39690e5c4c8b4b84c8e13c162ef77b8e9a4037 | <ide><path>Library/Homebrew/os/mac/xcode.rb
<ide> def detect_clang_version
<ide> end
<ide>
<ide> def detect_version_from_clang_version
<del> detect_clang_version&.sub(/^(\d+)00\./, "\\1.")
<add> detect_clang_version&.sub(/^(\d+)0(\d)\./, "\\1.\\2.")
<ide> end
<ide>
<ide> # Version string (a pretty long one) of the CLT package. | 1 |
Javascript | Javascript | implement server.prototype.address() for pipes | 9c11e8a1ca75c55b59c2794d3b3840f1df2e2a65 | <ide><path>lib/net.js
<ide> Server.prototype.listen = function() {
<ide>
<ide> } else if (isPipeName(arguments[0])) {
<ide> // UNIX socket or Windows pipe.
<del> listen(self, arguments[0], -1, -1);
<add> var pipeName = self._pipeName = arguments[0];
<add> listen(self, pipeName, -1, -1);
<ide>
<ide> } else if (typeof arguments[1] == 'undefined' ||
<ide> typeof arguments[1] == 'function') {
<ide> Server.prototype.listen = function() {
<ide> };
<ide>
<ide> Server.prototype.address = function() {
<del> return this._handle.getsockname();
<add> if (this._handle && this._handle.getsockname) {
<add> return this._handle.getsockname();
<add> } else if (this._pipeName) {
<add> return this._pipeName;
<add> } else {
<add> return null;
<add> }
<ide> };
<ide>
<ide> function onconnection(clientHandle) {
<ide><path>test/simple/test-pipe-address.js
<add>// Copyright Joyent, Inc. and other Node contributors.
<add>//
<add>// Permission is hereby granted, free of charge, to any person obtaining a
<add>// copy of this software and associated documentation files (the
<add>// "Software"), to deal in the Software without restriction, including
<add>// without limitation the rights to use, copy, modify, merge, publish,
<add>// distribute, sublicense, and/or sell copies of the Software, and to permit
<add>// persons to whom the Software is furnished to do so, subject to the
<add>// following conditions:
<add>//
<add>// The above copyright notice and this permission notice shall be included
<add>// in all copies or substantial portions of the Software.
<add>//
<add>// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
<add>// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
<add>// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
<add>// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
<add>// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
<add>// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
<add>// USE OR OTHER DEALINGS IN THE SOFTWARE.
<add>
<add>var common = require('../common');
<add>var assert = require('assert');
<add>var net = require('net');
<add>
<add>var address = null;
<add>
<add>var server = net.createServer(function() {
<add> assert(false); // should not be called
<add>});
<add>
<add>server.listen(common.PIPE, function() {
<add> address = server.address();
<add> server.close();
<add>});
<add>
<add>process.on('exit', function() {
<add> assert.equal(address, common.PIPE);
<add>}); | 2 |
Text | Text | add a changelog entry for [ci skip] | 9cdf38ff3443ac6de750518c40f696ddece8c288 | <ide><path>activerecord/CHANGELOG.md
<add>* Support index length and order options using both string and symbol
<add> column names.
<add>
<add> Fixes #27243.
<add>
<add> *Ryuta Kamizono*
<add>
<ide> * Raise `ActiveRecord::RangeError` when values that executed are out of range.
<ide>
<ide> *Ryuta Kamizono* | 1 |
Java | Java | fix resourceurlencodingfilter with context mapping | b3bfa95e2bff2a1e06b37c327a70aac54d727a1c | <ide><path>spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceUrlEncodingFilter.java
<ide> private void initIndexLookupPath(ResourceUrlProvider urlProvider) {
<ide> if (this.indexLookupPath == null) {
<ide> String requestUri = urlProvider.getPathHelper().getRequestUri(this.request);
<ide> String lookupPath = urlProvider.getPathHelper().getLookupPathForRequest(this.request);
<del> this.indexLookupPath = requestUri.indexOf(lookupPath);
<add> this.indexLookupPath = requestUri.lastIndexOf(lookupPath);
<ide> }
<ide> }
<ide> }
<ide><path>spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceUrlEncodingFilterTests.java
<add>/*
<add> * Copyright 2002-2014 the original author or authors.
<add> *
<add> * Licensed under the Apache License, Version 2.0 (the "License");
<add> * you may not use this file except in compliance with the License.
<add> * You may obtain a copy of the License at
<add> *
<add> * http://www.apache.org/licenses/LICENSE-2.0
<add> *
<add> * Unless required by applicable law or agreed to in writing, software
<add> * distributed under the License is distributed on an "AS IS" BASIS,
<add> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<add> * See the License for the specific language governing permissions and
<add> * limitations under the License.
<add> */
<add>package org.springframework.web.servlet.resource;
<add>
<add>import java.io.IOException;
<add>import java.util.Arrays;
<add>import java.util.Collections;
<add>import java.util.List;
<add>
<add>import javax.servlet.FilterChain;
<add>import javax.servlet.ServletException;
<add>import javax.servlet.ServletRequest;
<add>import javax.servlet.ServletResponse;
<add>import javax.servlet.http.HttpServletResponse;
<add>
<add>import org.junit.Before;
<add>import org.junit.Test;
<add>
<add>import org.springframework.core.io.ClassPathResource;
<add>import org.springframework.mock.web.test.MockHttpServletRequest;
<add>import org.springframework.mock.web.test.MockHttpServletResponse;
<add>
<add>import static org.junit.Assert.*;
<add>
<add>/**
<add> * Unit tests for {@code ResourceUrlEncodingFilter}.
<add> *
<add> * @author Brian Clozel
<add> */
<add>public class ResourceUrlEncodingFilterTests {
<add>
<add> private ResourceUrlEncodingFilter filter;
<add>
<add> private ResourceUrlProvider resourceUrlProvider;
<add>
<add> @Before
<add> public void createFilter() throws Exception {
<add> VersionResourceResolver versionResolver = new VersionResourceResolver();
<add> versionResolver.setStrategyMap(Collections.singletonMap("/**", new ContentVersionStrategy()));
<add> PathResourceResolver pathResolver = new PathResourceResolver();
<add> pathResolver.setAllowedLocations(new ClassPathResource("test/", getClass()));
<add> List<ResourceResolver> resolvers = Arrays.asList(versionResolver, pathResolver);
<add>
<add> this.filter = new ResourceUrlEncodingFilter();
<add> this.resourceUrlProvider = createResourceUrlProvider(resolvers);
<add> }
<add>
<add> @Test
<add> public void encodeURL() throws Exception {
<add> MockHttpServletRequest request = new MockHttpServletRequest("GET", "/");
<add> request.setAttribute(ResourceUrlProviderExposingInterceptor.RESOURCE_URL_PROVIDER_ATTR, this.resourceUrlProvider);
<add> MockHttpServletResponse response = new MockHttpServletResponse();
<add>
<add> this.filter.doFilterInternal(request, response, new FilterChain() {
<add> @Override
<add> public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
<add> String result = ((HttpServletResponse)response).encodeURL("/resources/bar.css");
<add> assertEquals("/resources/bar-11e16cf79faee7ac698c805cf28248d2.css", result);
<add> }
<add> });
<add> }
<add>
<add> @Test
<add> public void encodeURLWithContext() throws Exception {
<add> MockHttpServletRequest request = new MockHttpServletRequest("GET", "/context/foo");
<add> request.setContextPath("/context");
<add> request.setAttribute(ResourceUrlProviderExposingInterceptor.RESOURCE_URL_PROVIDER_ATTR, this.resourceUrlProvider);
<add> MockHttpServletResponse response = new MockHttpServletResponse();
<add>
<add> this.filter.doFilterInternal(request, response, new FilterChain() {
<add> @Override
<add> public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
<add> String result = ((HttpServletResponse)response).encodeURL("/context/resources/bar.css");
<add> assertEquals("/context/resources/bar-11e16cf79faee7ac698c805cf28248d2.css", result);
<add> }
<add> });
<add> }
<add>
<add> protected ResourceUrlProvider createResourceUrlProvider(List<ResourceResolver> resolvers) {
<add> ResourceHttpRequestHandler handler = new ResourceHttpRequestHandler();
<add> handler.setLocations(Arrays.asList(new ClassPathResource("test/", getClass())));
<add> handler.setResourceResolvers(resolvers);
<add> ResourceUrlProvider urlProvider = new ResourceUrlProvider();
<add> urlProvider.setHandlerMap(Collections.singletonMap("/resources/**", handler));
<add> return urlProvider;
<add> }
<add>
<add>} | 2 |
Go | Go | fix bug in datapath key rotation in 1-1 nat case | 4a04857a681d15e9fed49c6e72ef1e8e11be5962 | <ide><path>libnetwork/drivers/overlay/encryption.go
<ide> func (d *driver) updateKeys(newKey, primary, pruneKey *key) error {
<ide> priIdx = -1
<ide> delIdx = -1
<ide> lIP = net.ParseIP(d.bindAddress)
<add> aIP = net.ParseIP(d.advertiseAddress)
<ide> )
<ide>
<ide> d.Lock()
<ide> func (d *driver) updateKeys(newKey, primary, pruneKey *key) error {
<ide>
<ide> d.secMapWalk(func(rIPs string, spis []*spi) ([]*spi, bool) {
<ide> rIP := net.ParseIP(rIPs)
<del> return updateNodeKey(lIP, rIP, spis, d.keys, newIdx, priIdx, delIdx), false
<add> return updateNodeKey(lIP, aIP, rIP, spis, d.keys, newIdx, priIdx, delIdx), false
<ide> })
<ide>
<ide> d.Lock()
<ide> func (d *driver) updateKeys(newKey, primary, pruneKey *key) error {
<ide> *********************************************************/
<ide>
<ide> // Spis and keys are sorted in such away the one in position 0 is the primary
<del>func updateNodeKey(lIP, rIP net.IP, idxs []*spi, curKeys []*key, newIdx, priIdx, delIdx int) []*spi {
<add>func updateNodeKey(lIP, aIP, rIP net.IP, idxs []*spi, curKeys []*key, newIdx, priIdx, delIdx int) []*spi {
<ide> logrus.Debugf("Updating keys for node: %s (%d,%d,%d)", rIP, newIdx, priIdx, delIdx)
<ide>
<ide> spis := idxs
<ide> func updateNodeKey(lIP, rIP net.IP, idxs []*spi, curKeys []*key, newIdx, priIdx,
<ide> // add new
<ide> if newIdx != -1 {
<ide> spis = append(spis, &spi{
<del> forward: buildSPI(lIP, rIP, curKeys[newIdx].tag),
<del> reverse: buildSPI(rIP, lIP, curKeys[newIdx].tag),
<add> forward: buildSPI(aIP, rIP, curKeys[newIdx].tag),
<add> reverse: buildSPI(rIP, aIP, curKeys[newIdx].tag),
<ide> })
<ide> }
<ide> | 1 |
Text | Text | fix animation grouping | 7985416d39f8850c08f218cd4c6f5a584090cc0b | <ide><path>CHANGELOG.md
<ide>
<ide> ## Bug Fixes
<ide>
<del>### Core `ng` Module
<del>- **$animate:**
<add>- **Animation**
<add> - ensure that animate promises resolve when the document is hidden
<add> ([9a60408c](https://github.com/angular/angular.js/commit/9a60408c804a62a9517857bdb9a42182ab6769e3))
<add> - do not trigger animations if the document is hidden
<add> ([09f6061a](https://github.com/angular/angular.js/commit/09f6061a8ee41cae4268e8d44d727d3bf52e22a9),
<add> [#12842](https://github.com/angular/angular.js/issues/12842), [#13776](https://github.com/angular/angular.js/issues/13776))
<add> - only copy over the animation options once
<add> ([2fc954d3](https://github.com/angular/angular.js/commit/2fc954d33a3a4c5d4f355be1e15a381664e02f1b),
<add> [#13722](https://github.com/angular/angular.js/issues/13722), [#13578](https://github.com/angular/angular.js/issues/13578))
<add> - allow event listeners on document in IE
<add> ([5ba4419e](https://github.com/angular/angular.js/commit/5ba4419e265ff34c6c23bf3533a3332c99c5f014),
<add> [#13548](https://github.com/angular/angular.js/issues/13548), [#13696](https://github.com/angular/angular.js/issues/13696))
<add> - allow removing classes that are added by a running animation
<add> ([6c4581fc](https://github.com/angular/angular.js/commit/6c4581fcb692b17295a41b8918c6038333e7bc3d),
<add> [#13339](https://github.com/angular/angular.js/issues/13339), [#13380](https://github.com/angular/angular.js/issues/13380), [#13414](https://github.com/angular/angular.js/issues/13414), [#13472](https://github.com/angular/angular.js/issues/13472), [#13678](https://github.com/angular/angular.js/issues/13678))
<add> - do not use `event.timeStamp` anymore for time tracking
<add> ([620a20d1](https://github.com/angular/angular.js/commit/620a20d1b3376d95f85004ffa494e36bb19a2e4d),
<add> [#13494](https://github.com/angular/angular.js/issues/13494), [#13495](https://github.com/angular/angular.js/issues/13495))
<add> - ignore children without animation data when closing them
<add> ([be01cebf](https://github.com/angular/angular.js/commit/be01cebfae9ca2383105e535820442b39a96b240),
<add> [#11992](https://github.com/angular/angular.js/issues/11992), [#13424](https://github.com/angular/angular.js/issues/13424))
<add> - do not alter the provided options data
<add> ([7a81e6fe](https://github.com/angular/angular.js/commit/7a81e6fe2db084172e34d509f0baad2b33a8722c),
<add> [#13040](https://github.com/angular/angular.js/issues/13040), [#13175](https://github.com/angular/angular.js/issues/13175))
<ide> - correctly handle `$animate.pin()` host elements
<ide> ([a985adfd](https://github.com/angular/angular.js/commit/a985adfdabd871f3f3f3ee59f371da50cd9611d9),
<ide> [#13783](https://github.com/angular/angular.js/issues/13783))
<ide> - ensure animate runner is the same with and without animations
<ide> ([937942f5](https://github.com/angular/angular.js/commit/937942f5ada6de1bdacdf0ba465f6f118c270119),
<ide> [#13205](https://github.com/angular/angular.js/issues/13205), [#13347](https://github.com/angular/angular.js/issues/13347))
<del>- **$animateCss:**
<ide> - remove animation end event listeners on close
<ide> ([d9157849](https://github.com/angular/angular.js/commit/d9157849df224a3a8d2e0bf03099d137f51499f6),
<ide> [#13672](https://github.com/angular/angular.js/issues/13672))
<ide> ([529b2507](https://github.com/angular/angular.js/commit/529b2507bdb4fcc22dfa0f7ab462c79fc78d1413),
<ide> [#13583](https://github.com/angular/angular.js/issues/13583), [#13583](https://github.com/angular/angular.js/issues/13583), [#13663](https://github.com/angular/angular.js/issues/13663))
<ide>
<del>### `ngAnimate` Module
<del>
<del>- **ngAnimate:**
<del> - ensure that animate promises resolve when the document is hidden
<del> ([9a60408c](https://github.com/angular/angular.js/commit/9a60408c804a62a9517857bdb9a42182ab6769e3))
<del> - do not trigger animations if the document is hidden
<del> ([09f6061a](https://github.com/angular/angular.js/commit/09f6061a8ee41cae4268e8d44d727d3bf52e22a9),
<del> [#12842](https://github.com/angular/angular.js/issues/12842), [#13776](https://github.com/angular/angular.js/issues/13776))
<del> - only copy over the animation options once
<del> ([2fc954d3](https://github.com/angular/angular.js/commit/2fc954d33a3a4c5d4f355be1e15a381664e02f1b),
<del> [#13722](https://github.com/angular/angular.js/issues/13722), [#13578](https://github.com/angular/angular.js/issues/13578))
<del> - allow event listeners on document in IE
<del> ([5ba4419e](https://github.com/angular/angular.js/commit/5ba4419e265ff34c6c23bf3533a3332c99c5f014),
<del> [#13548](https://github.com/angular/angular.js/issues/13548), [#13696](https://github.com/angular/angular.js/issues/13696))
<del> - allow removing classes that are added by a running animation
<del> ([6c4581fc](https://github.com/angular/angular.js/commit/6c4581fcb692b17295a41b8918c6038333e7bc3d),
<del> [#13339](https://github.com/angular/angular.js/issues/13339), [#13380](https://github.com/angular/angular.js/issues/13380), [#13414](https://github.com/angular/angular.js/issues/13414), [#13472](https://github.com/angular/angular.js/issues/13472), [#13678](https://github.com/angular/angular.js/issues/13678))
<del> - do not use `event.timeStamp` anymore for time tracking
<del> ([620a20d1](https://github.com/angular/angular.js/commit/620a20d1b3376d95f85004ffa494e36bb19a2e4d),
<del> [#13494](https://github.com/angular/angular.js/issues/13494), [#13495](https://github.com/angular/angular.js/issues/13495))
<del> - ignore children without animation data when closing them
<del> ([be01cebf](https://github.com/angular/angular.js/commit/be01cebfae9ca2383105e535820442b39a96b240),
<del> [#11992](https://github.com/angular/angular.js/issues/11992), [#13424](https://github.com/angular/angular.js/issues/13424))
<del> - do not alter the provided options data
<del> ([7a81e6fe](https://github.com/angular/angular.js/commit/7a81e6fe2db084172e34d509f0baad2b33a8722c),
<del> [#13040](https://github.com/angular/angular.js/issues/13040), [#13175](https://github.com/angular/angular.js/issues/13175))
<del>
<ide> ## Minor Features
<ide>
<ide> - **ngLocale:** add support for standalone months | 1 |
Ruby | Ruby | fix rubocop warnings | 78603a24f687b75e5487953f9212667e14cba8d2 | <ide><path>Library/Homebrew/language/haskell.rb
<ide> def cabal_install_tools(*tools)
<ide> end
<ide>
<ide> def install_cabal_package(*args)
<del> options = if args[-1].kind_of?(Hash) then args.pop else {} end
<add> options = args[-1].is_a?(Hash) ? args.pop : {}
<ide>
<ide> cabal_sandbox do
<ide> cabal_install_tools(*options[:using]) if options[:using] | 1 |
Go | Go | move convertservice to composetransform package | 655e48e65309f0191bbbb8b2e9730b6976e148cd | <ide><path>cli/command/stack/common.go
<ide> import (
<ide> "github.com/docker/docker/api/types/filters"
<ide> "github.com/docker/docker/api/types/swarm"
<ide> "github.com/docker/docker/client"
<add> "github.com/docker/docker/opts"
<ide> "github.com/docker/docker/pkg/composetransform"
<ide> )
<ide>
<ide> func getStackFilter(namespace string) filters.Args {
<ide> return filter
<ide> }
<ide>
<add>func getStackFilterFromOpt(namespace string, opt opts.FilterOpt) filters.Args {
<add> filter := opt.Value()
<add> filter.Add("label", composetransform.LabelNamespace+"="+namespace)
<add> return filter
<add>}
<add>
<add>func getAllStacksFilter() filters.Args {
<add> filter := filters.NewArgs()
<add> filter.Add("label", composetransform.LabelNamespace)
<add> return filter
<add>}
<add>
<ide> func getServices(
<ide> ctx context.Context,
<ide> apiclient client.APIClient,
<ide><path>cli/command/stack/deploy.go
<ide> import (
<ide> "os"
<ide> "sort"
<ide> "strings"
<del> "time"
<ide>
<ide> "github.com/spf13/cobra"
<ide> "golang.org/x/net/context"
<ide>
<ide> "github.com/aanand/compose-file/loader"
<ide> composetypes "github.com/aanand/compose-file/types"
<ide> "github.com/docker/docker/api/types"
<del> "github.com/docker/docker/api/types/container"
<ide> "github.com/docker/docker/api/types/swarm"
<ide> "github.com/docker/docker/cli"
<ide> "github.com/docker/docker/cli/command"
<ide> dockerclient "github.com/docker/docker/client"
<del> "github.com/docker/docker/opts"
<ide> "github.com/docker/docker/pkg/composetransform"
<del> runconfigopts "github.com/docker/docker/runconfig/opts"
<del> "github.com/docker/go-connections/nat"
<ide> )
<ide>
<ide> const (
<ide> func deployCompose(ctx context.Context, dockerCli *command.DockerCli, opts deplo
<ide> if err := createNetworks(ctx, dockerCli, namespace, networks); err != nil {
<ide> return err
<ide> }
<del> services, err := convertServices(namespace, config)
<add> services, err := composetransform.ConvertServices(namespace, config)
<ide> if err != nil {
<ide> return err
<ide> }
<ide> func createNetworks(
<ide> return nil
<ide> }
<ide>
<del>func convertServiceNetworks(
<del> networks map[string]*composetypes.ServiceNetworkConfig,
<del> networkConfigs map[string]composetypes.NetworkConfig,
<del> namespace composetransform.Namespace,
<del> name string,
<del>) ([]swarm.NetworkAttachmentConfig, error) {
<del> if len(networks) == 0 {
<del> return []swarm.NetworkAttachmentConfig{
<del> {
<del> Target: namespace.scope("default"),
<del> Aliases: []string{name},
<del> },
<del> }, nil
<del> }
<del>
<del> nets := []swarm.NetworkAttachmentConfig{}
<del> for networkName, network := range networks {
<del> networkConfig, ok := networkConfigs[networkName]
<del> if !ok {
<del> return []swarm.NetworkAttachmentConfig{}, fmt.Errorf("invalid network: %s", networkName)
<del> }
<del> var aliases []string
<del> if network != nil {
<del> aliases = network.Aliases
<del> }
<del> target := namespace.scope(networkName)
<del> if networkConfig.External.External {
<del> target = networkName
<del> }
<del> nets = append(nets, swarm.NetworkAttachmentConfig{
<del> Target: target,
<del> Aliases: append(aliases, name),
<del> })
<del> }
<del> return nets, nil
<del>}
<del>
<ide> func deployServices(
<ide> ctx context.Context,
<ide> dockerCli *command.DockerCli,
<ide> services map[string]swarm.ServiceSpec,
<del> namespace namespace,
<add> namespace composetransform.Namespace,
<ide> sendAuth bool,
<ide> ) error {
<ide> apiClient := dockerCli.Client()
<ide> out := dockerCli.Out()
<ide>
<del> existingServices, err := getServices(ctx, apiClient, namespace.name)
<add> existingServices, err := getServices(ctx, apiClient, namespace.Name())
<ide> if err != nil {
<ide> return err
<ide> }
<ide> func deployServices(
<ide> }
<ide>
<ide> for internalName, serviceSpec := range services {
<del> name := namespace.scope(internalName)
<add> name := namespace.Scope(internalName)
<ide>
<ide> encodedAuth := ""
<ide> if sendAuth {
<ide> func deployServices(
<ide>
<ide> return nil
<ide> }
<del>
<del>func convertServices(
<del> namespace namespace,
<del> config *composetypes.Config,
<del>) (map[string]swarm.ServiceSpec, error) {
<del> result := make(map[string]swarm.ServiceSpec)
<del>
<del> services := config.Services
<del> volumes := config.Volumes
<del> networks := config.Networks
<del>
<del> for _, service := range services {
<del> serviceSpec, err := convertService(namespace, service, networks, volumes)
<del> if err != nil {
<del> return nil, err
<del> }
<del> result[service.Name] = serviceSpec
<del> }
<del>
<del> return result, nil
<del>}
<del>
<del>func convertService(
<del> namespace namespace,
<del> service composetypes.ServiceConfig,
<del> networkConfigs map[string]composetypes.NetworkConfig,
<del> volumes map[string]composetypes.VolumeConfig,
<del>) (swarm.ServiceSpec, error) {
<del> name := namespace.scope(service.Name)
<del>
<del> endpoint, err := convertEndpointSpec(service.Ports)
<del> if err != nil {
<del> return swarm.ServiceSpec{}, err
<del> }
<del>
<del> mode, err := convertDeployMode(service.Deploy.Mode, service.Deploy.Replicas)
<del> if err != nil {
<del> return swarm.ServiceSpec{}, err
<del> }
<del>
<del> mounts, err := composetransform.ConvertVolumes(service.Volumes, volumes, namespace)
<del> if err != nil {
<del> // TODO: better error message (include service name)
<del> return swarm.ServiceSpec{}, err
<del> }
<del>
<del> resources, err := convertResources(service.Deploy.Resources)
<del> if err != nil {
<del> return swarm.ServiceSpec{}, err
<del> }
<del>
<del> restartPolicy, err := convertRestartPolicy(
<del> service.Restart, service.Deploy.RestartPolicy)
<del> if err != nil {
<del> return swarm.ServiceSpec{}, err
<del> }
<del>
<del> healthcheck, err := convertHealthcheck(service.HealthCheck)
<del> if err != nil {
<del> return swarm.ServiceSpec{}, err
<del> }
<del>
<del> networks, err := convertServiceNetworks(service.Networks, networkConfigs, namespace, service.Name)
<del> if err != nil {
<del> return swarm.ServiceSpec{}, err
<del> }
<del>
<del> var logDriver *swarm.Driver
<del> if service.Logging != nil {
<del> logDriver = &swarm.Driver{
<del> Name: service.Logging.Driver,
<del> Options: service.Logging.Options,
<del> }
<del> }
<del>
<del> serviceSpec := swarm.ServiceSpec{
<del> Annotations: swarm.Annotations{
<del> Name: name,
<del> Labels: getStackLabels(namespace.name, service.Deploy.Labels),
<del> },
<del> TaskTemplate: swarm.TaskSpec{
<del> ContainerSpec: swarm.ContainerSpec{
<del> Image: service.Image,
<del> Command: service.Entrypoint,
<del> Args: service.Command,
<del> Hostname: service.Hostname,
<del> Hosts: convertExtraHosts(service.ExtraHosts),
<del> Healthcheck: healthcheck,
<del> Env: convertEnvironment(service.Environment),
<del> Labels: getStackLabels(namespace.name, service.Labels),
<del> Dir: service.WorkingDir,
<del> User: service.User,
<del> Mounts: mounts,
<del> StopGracePeriod: service.StopGracePeriod,
<del> TTY: service.Tty,
<del> OpenStdin: service.StdinOpen,
<del> },
<del> LogDriver: logDriver,
<del> Resources: resources,
<del> RestartPolicy: restartPolicy,
<del> Placement: &swarm.Placement{
<del> Constraints: service.Deploy.Placement.Constraints,
<del> },
<del> },
<del> EndpointSpec: endpoint,
<del> Mode: mode,
<del> Networks: networks,
<del> UpdateConfig: convertUpdateConfig(service.Deploy.UpdateConfig),
<del> }
<del>
<del> return serviceSpec, nil
<del>}
<del>
<del>func convertExtraHosts(extraHosts map[string]string) []string {
<del> hosts := []string{}
<del> for host, ip := range extraHosts {
<del> hosts = append(hosts, fmt.Sprintf("%s %s", ip, host))
<del> }
<del> return hosts
<del>}
<del>
<del>func convertHealthcheck(healthcheck *composetypes.HealthCheckConfig) (*container.HealthConfig, error) {
<del> if healthcheck == nil {
<del> return nil, nil
<del> }
<del> var (
<del> err error
<del> timeout, interval time.Duration
<del> retries int
<del> )
<del> if healthcheck.Disable {
<del> if len(healthcheck.Test) != 0 {
<del> return nil, fmt.Errorf("command and disable key can't be set at the same time")
<del> }
<del> return &container.HealthConfig{
<del> Test: []string{"NONE"},
<del> }, nil
<del>
<del> }
<del> if healthcheck.Timeout != "" {
<del> timeout, err = time.ParseDuration(healthcheck.Timeout)
<del> if err != nil {
<del> return nil, err
<del> }
<del> }
<del> if healthcheck.Interval != "" {
<del> interval, err = time.ParseDuration(healthcheck.Interval)
<del> if err != nil {
<del> return nil, err
<del> }
<del> }
<del> if healthcheck.Retries != nil {
<del> retries = int(*healthcheck.Retries)
<del> }
<del> return &container.HealthConfig{
<del> Test: healthcheck.Test,
<del> Timeout: timeout,
<del> Interval: interval,
<del> Retries: retries,
<del> }, nil
<del>}
<del>
<del>func convertRestartPolicy(restart string, source *composetypes.RestartPolicy) (*swarm.RestartPolicy, error) {
<del> // TODO: log if restart is being ignored
<del> if source == nil {
<del> policy, err := runconfigopts.ParseRestartPolicy(restart)
<del> if err != nil {
<del> return nil, err
<del> }
<del> // TODO: is this an accurate convertion?
<del> switch {
<del> case policy.IsNone():
<del> return nil, nil
<del> case policy.IsAlways(), policy.IsUnlessStopped():
<del> return &swarm.RestartPolicy{
<del> Condition: swarm.RestartPolicyConditionAny,
<del> }, nil
<del> case policy.IsOnFailure():
<del> attempts := uint64(policy.MaximumRetryCount)
<del> return &swarm.RestartPolicy{
<del> Condition: swarm.RestartPolicyConditionOnFailure,
<del> MaxAttempts: &attempts,
<del> }, nil
<del> }
<del> }
<del> return &swarm.RestartPolicy{
<del> Condition: swarm.RestartPolicyCondition(source.Condition),
<del> Delay: source.Delay,
<del> MaxAttempts: source.MaxAttempts,
<del> Window: source.Window,
<del> }, nil
<del>}
<del>
<del>func convertUpdateConfig(source *composetypes.UpdateConfig) *swarm.UpdateConfig {
<del> if source == nil {
<del> return nil
<del> }
<del> parallel := uint64(1)
<del> if source.Parallelism != nil {
<del> parallel = *source.Parallelism
<del> }
<del> return &swarm.UpdateConfig{
<del> Parallelism: parallel,
<del> Delay: source.Delay,
<del> FailureAction: source.FailureAction,
<del> Monitor: source.Monitor,
<del> MaxFailureRatio: source.MaxFailureRatio,
<del> }
<del>}
<del>
<del>func convertResources(source composetypes.Resources) (*swarm.ResourceRequirements, error) {
<del> resources := &swarm.ResourceRequirements{}
<del> if source.Limits != nil {
<del> cpus, err := opts.ParseCPUs(source.Limits.NanoCPUs)
<del> if err != nil {
<del> return nil, err
<del> }
<del> resources.Limits = &swarm.Resources{
<del> NanoCPUs: cpus,
<del> MemoryBytes: int64(source.Limits.MemoryBytes),
<del> }
<del> }
<del> if source.Reservations != nil {
<del> cpus, err := opts.ParseCPUs(source.Reservations.NanoCPUs)
<del> if err != nil {
<del> return nil, err
<del> }
<del> resources.Reservations = &swarm.Resources{
<del> NanoCPUs: cpus,
<del> MemoryBytes: int64(source.Reservations.MemoryBytes),
<del> }
<del> }
<del> return resources, nil
<del>}
<del>
<del>func convertEndpointSpec(source []string) (*swarm.EndpointSpec, error) {
<del> portConfigs := []swarm.PortConfig{}
<del> ports, portBindings, err := nat.ParsePortSpecs(source)
<del> if err != nil {
<del> return nil, err
<del> }
<del>
<del> for port := range ports {
<del> portConfigs = append(
<del> portConfigs,
<del> opts.ConvertPortToPortConfig(port, portBindings)...)
<del> }
<del>
<del> return &swarm.EndpointSpec{Ports: portConfigs}, nil
<del>}
<del>
<del>func convertEnvironment(source map[string]string) []string {
<del> var output []string
<del>
<del> for name, value := range source {
<del> output = append(output, fmt.Sprintf("%s=%s", name, value))
<del> }
<del>
<del> return output
<del>}
<del>
<del>func convertDeployMode(mode string, replicas *uint64) (swarm.ServiceMode, error) {
<del> serviceMode := swarm.ServiceMode{}
<del>
<del> switch mode {
<del> case "global":
<del> if replicas != nil {
<del> return serviceMode, fmt.Errorf("replicas can only be used with replicated mode")
<del> }
<del> serviceMode.Global = &swarm.GlobalService{}
<del> case "replicated", "":
<del> serviceMode.Replicated = &swarm.ReplicatedService{Replicas: replicas}
<del> default:
<del> return serviceMode, fmt.Errorf("Unknown mode: %s", mode)
<del> }
<del> return serviceMode, nil
<del>}
<ide><path>cli/command/stack/deploy_bundlefile.go
<ide> import (
<ide> "github.com/docker/docker/api/types"
<ide> "github.com/docker/docker/api/types/swarm"
<ide> "github.com/docker/docker/cli/command"
<add> "github.com/docker/docker/pkg/composetransform"
<ide> )
<ide>
<ide> func deployBundle(ctx context.Context, dockerCli *command.DockerCli, opts deployOptions) error {
<ide> func deployBundle(ctx context.Context, dockerCli *command.DockerCli, opts deploy
<ide> return err
<ide> }
<ide>
<del> namespace := namespace{name: opts.namespace}
<add> namespace := composetransform.NewNamespace(opts.namespace)
<ide>
<ide> networks := make(map[string]types.NetworkCreate)
<ide> for _, service := range bundle.Services {
<ide> for _, networkName := range service.Networks {
<ide> networks[networkName] = types.NetworkCreate{
<del> Labels: getStackLabels(namespace.name, nil),
<add> Labels: composetransform.AddStackLabel(namespace, nil),
<ide> }
<ide> }
<ide> }
<ide>
<ide> services := make(map[string]swarm.ServiceSpec)
<ide> for internalName, service := range bundle.Services {
<del> name := namespace.scope(internalName)
<add> name := namespace.Scope(internalName)
<ide>
<ide> var ports []swarm.PortConfig
<ide> for _, portSpec := range service.Ports {
<ide> func deployBundle(ctx context.Context, dockerCli *command.DockerCli, opts deploy
<ide> nets := []swarm.NetworkAttachmentConfig{}
<ide> for _, networkName := range service.Networks {
<ide> nets = append(nets, swarm.NetworkAttachmentConfig{
<del> Target: namespace.scope(networkName),
<add> Target: namespace.Scope(networkName),
<ide> Aliases: []string{networkName},
<ide> })
<ide> }
<ide>
<ide> serviceSpec := swarm.ServiceSpec{
<ide> Annotations: swarm.Annotations{
<ide> Name: name,
<del> Labels: getStackLabels(namespace.name, service.Labels),
<add> Labels: composetransform.AddStackLabel(namespace, service.Labels),
<ide> },
<ide> TaskTemplate: swarm.TaskSpec{
<ide> ContainerSpec: swarm.ContainerSpec{
<ide> func deployBundle(ctx context.Context, dockerCli *command.DockerCli, opts deploy
<ide> // Service Labels will not be copied to Containers
<ide> // automatically during the deployment so we apply
<ide> // it here.
<del> Labels: getStackLabels(namespace.name, nil),
<add> Labels: composetransform.AddStackLabel(namespace, nil),
<ide> },
<ide> },
<ide> EndpointSpec: &swarm.EndpointSpec{
<ide><path>cli/command/stack/list.go
<ide> import (
<ide> "golang.org/x/net/context"
<ide>
<ide> "github.com/docker/docker/api/types"
<del> "github.com/docker/docker/api/types/filters"
<ide> "github.com/docker/docker/cli"
<ide> "github.com/docker/docker/cli/command"
<ide> "github.com/docker/docker/client"
<add> "github.com/docker/docker/pkg/composetransform"
<ide> "github.com/spf13/cobra"
<ide> )
<ide>
<ide> func getStacks(
<ide> ctx context.Context,
<ide> apiclient client.APIClient,
<ide> ) ([]*stack, error) {
<del>
<del> filter := filters.NewArgs()
<del> filter.Add("label", labelNamespace)
<del>
<ide> services, err := apiclient.ServiceList(
<ide> ctx,
<del> types.ServiceListOptions{Filters: filter})
<add> types.ServiceListOptions{Filters: getAllStacksFilter()})
<ide> if err != nil {
<ide> return nil, err
<ide> }
<ide> m := make(map[string]*stack, 0)
<ide> for _, service := range services {
<ide> labels := service.Spec.Labels
<del> name, ok := labels[labelNamespace]
<add> name, ok := labels[composetransform.LabelNamespace]
<ide> if !ok {
<ide> return nil, fmt.Errorf("cannot get label %s for service %s",
<del> labelNamespace, service.ID)
<add> composetransform.LabelNamespace, service.ID)
<ide> }
<ide> ztack, ok := m[name]
<ide> if !ok {
<ide><path>cli/command/stack/ps.go
<ide> func runPS(dockerCli *command.DockerCli, opts psOptions) error {
<ide> client := dockerCli.Client()
<ide> ctx := context.Background()
<ide>
<del> filter := opts.filter.Value()
<del> filter.Add("label", labelNamespace+"="+opts.namespace)
<add> filter := getStackFilterFromOpt(opts.namespace, opts.filter)
<ide> if !opts.all && !filter.Include("desired-state") {
<ide> filter.Add("desired-state", string(swarm.TaskStateRunning))
<ide> filter.Add("desired-state", string(swarm.TaskStateAccepted))
<ide><path>cli/command/stack/services.go
<ide> func runServices(dockerCli *command.DockerCli, opts servicesOptions) error {
<ide> ctx := context.Background()
<ide> client := dockerCli.Client()
<ide>
<del> filter := opts.filter.Value()
<del> filter.Add("label", labelNamespace+"="+opts.namespace)
<del>
<add> filter := getStackFilterFromOpt(opts.namespace, opts.filter)
<ide> services, err := client.ServiceList(ctx, types.ServiceListOptions{Filters: filter})
<ide> if err != nil {
<ide> return err
<ide><path>pkg/composetransform/service.go
<add>package composetransform
<add>
<add>import (
<add> "fmt"
<add> "time"
<add>
<add> composetypes "github.com/aanand/compose-file/types"
<add> "github.com/docker/docker/api/types/container"
<add> "github.com/docker/docker/api/types/swarm"
<add> "github.com/docker/docker/opts"
<add> runconfigopts "github.com/docker/docker/runconfig/opts"
<add> "github.com/docker/go-connections/nat"
<add>)
<add>
<add>// ConvertServices from compose-file types to engine API types
<add>func ConvertServices(
<add> namespace Namespace,
<add> config *composetypes.Config,
<add>) (map[string]swarm.ServiceSpec, error) {
<add> result := make(map[string]swarm.ServiceSpec)
<add>
<add> services := config.Services
<add> volumes := config.Volumes
<add> networks := config.Networks
<add>
<add> for _, service := range services {
<add> serviceSpec, err := convertService(namespace, service, networks, volumes)
<add> if err != nil {
<add> return nil, err
<add> }
<add> result[service.Name] = serviceSpec
<add> }
<add>
<add> return result, nil
<add>}
<add>
<add>func convertService(
<add> namespace Namespace,
<add> service composetypes.ServiceConfig,
<add> networkConfigs map[string]composetypes.NetworkConfig,
<add> volumes map[string]composetypes.VolumeConfig,
<add>) (swarm.ServiceSpec, error) {
<add> name := namespace.Scope(service.Name)
<add>
<add> endpoint, err := convertEndpointSpec(service.Ports)
<add> if err != nil {
<add> return swarm.ServiceSpec{}, err
<add> }
<add>
<add> mode, err := convertDeployMode(service.Deploy.Mode, service.Deploy.Replicas)
<add> if err != nil {
<add> return swarm.ServiceSpec{}, err
<add> }
<add>
<add> mounts, err := ConvertVolumes(service.Volumes, volumes, namespace)
<add> if err != nil {
<add> // TODO: better error message (include service name)
<add> return swarm.ServiceSpec{}, err
<add> }
<add>
<add> resources, err := convertResources(service.Deploy.Resources)
<add> if err != nil {
<add> return swarm.ServiceSpec{}, err
<add> }
<add>
<add> restartPolicy, err := convertRestartPolicy(
<add> service.Restart, service.Deploy.RestartPolicy)
<add> if err != nil {
<add> return swarm.ServiceSpec{}, err
<add> }
<add>
<add> healthcheck, err := convertHealthcheck(service.HealthCheck)
<add> if err != nil {
<add> return swarm.ServiceSpec{}, err
<add> }
<add>
<add> networks, err := convertServiceNetworks(service.Networks, networkConfigs, namespace, service.Name)
<add> if err != nil {
<add> return swarm.ServiceSpec{}, err
<add> }
<add>
<add> var logDriver *swarm.Driver
<add> if service.Logging != nil {
<add> logDriver = &swarm.Driver{
<add> Name: service.Logging.Driver,
<add> Options: service.Logging.Options,
<add> }
<add> }
<add>
<add> serviceSpec := swarm.ServiceSpec{
<add> Annotations: swarm.Annotations{
<add> Name: name,
<add> Labels: AddStackLabel(namespace, service.Deploy.Labels),
<add> },
<add> TaskTemplate: swarm.TaskSpec{
<add> ContainerSpec: swarm.ContainerSpec{
<add> Image: service.Image,
<add> Command: service.Entrypoint,
<add> Args: service.Command,
<add> Hostname: service.Hostname,
<add> Hosts: convertExtraHosts(service.ExtraHosts),
<add> Healthcheck: healthcheck,
<add> Env: convertEnvironment(service.Environment),
<add> Labels: AddStackLabel(namespace, service.Labels),
<add> Dir: service.WorkingDir,
<add> User: service.User,
<add> Mounts: mounts,
<add> StopGracePeriod: service.StopGracePeriod,
<add> TTY: service.Tty,
<add> OpenStdin: service.StdinOpen,
<add> },
<add> LogDriver: logDriver,
<add> Resources: resources,
<add> RestartPolicy: restartPolicy,
<add> Placement: &swarm.Placement{
<add> Constraints: service.Deploy.Placement.Constraints,
<add> },
<add> },
<add> EndpointSpec: endpoint,
<add> Mode: mode,
<add> Networks: networks,
<add> UpdateConfig: convertUpdateConfig(service.Deploy.UpdateConfig),
<add> }
<add>
<add> return serviceSpec, nil
<add>}
<add>
<add>func convertServiceNetworks(
<add> networks map[string]*composetypes.ServiceNetworkConfig,
<add> networkConfigs networks,
<add> namespace Namespace,
<add> name string,
<add>) ([]swarm.NetworkAttachmentConfig, error) {
<add> if len(networks) == 0 {
<add> return []swarm.NetworkAttachmentConfig{
<add> {
<add> Target: namespace.Scope("default"),
<add> Aliases: []string{name},
<add> },
<add> }, nil
<add> }
<add>
<add> nets := []swarm.NetworkAttachmentConfig{}
<add> for networkName, network := range networks {
<add> networkConfig, ok := networkConfigs[networkName]
<add> if !ok {
<add> return []swarm.NetworkAttachmentConfig{}, fmt.Errorf("invalid network: %s", networkName)
<add> }
<add> var aliases []string
<add> if network != nil {
<add> aliases = network.Aliases
<add> }
<add> target := namespace.Scope(networkName)
<add> if networkConfig.External.External {
<add> target = networkName
<add> }
<add> nets = append(nets, swarm.NetworkAttachmentConfig{
<add> Target: target,
<add> Aliases: append(aliases, name),
<add> })
<add> }
<add> return nets, nil
<add>}
<add>
<add>func convertExtraHosts(extraHosts map[string]string) []string {
<add> hosts := []string{}
<add> for host, ip := range extraHosts {
<add> hosts = append(hosts, fmt.Sprintf("%s %s", ip, host))
<add> }
<add> return hosts
<add>}
<add>
<add>func convertHealthcheck(healthcheck *composetypes.HealthCheckConfig) (*container.HealthConfig, error) {
<add> if healthcheck == nil {
<add> return nil, nil
<add> }
<add> var (
<add> err error
<add> timeout, interval time.Duration
<add> retries int
<add> )
<add> if healthcheck.Disable {
<add> if len(healthcheck.Test) != 0 {
<add> return nil, fmt.Errorf("command and disable key can't be set at the same time")
<add> }
<add> return &container.HealthConfig{
<add> Test: []string{"NONE"},
<add> }, nil
<add>
<add> }
<add> if healthcheck.Timeout != "" {
<add> timeout, err = time.ParseDuration(healthcheck.Timeout)
<add> if err != nil {
<add> return nil, err
<add> }
<add> }
<add> if healthcheck.Interval != "" {
<add> interval, err = time.ParseDuration(healthcheck.Interval)
<add> if err != nil {
<add> return nil, err
<add> }
<add> }
<add> if healthcheck.Retries != nil {
<add> retries = int(*healthcheck.Retries)
<add> }
<add> return &container.HealthConfig{
<add> Test: healthcheck.Test,
<add> Timeout: timeout,
<add> Interval: interval,
<add> Retries: retries,
<add> }, nil
<add>}
<add>
<add>func convertRestartPolicy(restart string, source *composetypes.RestartPolicy) (*swarm.RestartPolicy, error) {
<add> // TODO: log if restart is being ignored
<add> if source == nil {
<add> policy, err := runconfigopts.ParseRestartPolicy(restart)
<add> if err != nil {
<add> return nil, err
<add> }
<add> switch {
<add> case policy.IsNone():
<add> return nil, nil
<add> case policy.IsAlways(), policy.IsUnlessStopped():
<add> return &swarm.RestartPolicy{
<add> Condition: swarm.RestartPolicyConditionAny,
<add> }, nil
<add> case policy.IsOnFailure():
<add> attempts := uint64(policy.MaximumRetryCount)
<add> return &swarm.RestartPolicy{
<add> Condition: swarm.RestartPolicyConditionOnFailure,
<add> MaxAttempts: &attempts,
<add> }, nil
<add> default:
<add> return nil, fmt.Errorf("unknown restart policy: %s", restart)
<add> }
<add> }
<add> return &swarm.RestartPolicy{
<add> Condition: swarm.RestartPolicyCondition(source.Condition),
<add> Delay: source.Delay,
<add> MaxAttempts: source.MaxAttempts,
<add> Window: source.Window,
<add> }, nil
<add>}
<add>
<add>func convertUpdateConfig(source *composetypes.UpdateConfig) *swarm.UpdateConfig {
<add> if source == nil {
<add> return nil
<add> }
<add> parallel := uint64(1)
<add> if source.Parallelism != nil {
<add> parallel = *source.Parallelism
<add> }
<add> return &swarm.UpdateConfig{
<add> Parallelism: parallel,
<add> Delay: source.Delay,
<add> FailureAction: source.FailureAction,
<add> Monitor: source.Monitor,
<add> MaxFailureRatio: source.MaxFailureRatio,
<add> }
<add>}
<add>
<add>func convertResources(source composetypes.Resources) (*swarm.ResourceRequirements, error) {
<add> resources := &swarm.ResourceRequirements{}
<add> if source.Limits != nil {
<add> cpus, err := opts.ParseCPUs(source.Limits.NanoCPUs)
<add> if err != nil {
<add> return nil, err
<add> }
<add> resources.Limits = &swarm.Resources{
<add> NanoCPUs: cpus,
<add> MemoryBytes: int64(source.Limits.MemoryBytes),
<add> }
<add> }
<add> if source.Reservations != nil {
<add> cpus, err := opts.ParseCPUs(source.Reservations.NanoCPUs)
<add> if err != nil {
<add> return nil, err
<add> }
<add> resources.Reservations = &swarm.Resources{
<add> NanoCPUs: cpus,
<add> MemoryBytes: int64(source.Reservations.MemoryBytes),
<add> }
<add> }
<add> return resources, nil
<add>}
<add>
<add>func convertEndpointSpec(source []string) (*swarm.EndpointSpec, error) {
<add> portConfigs := []swarm.PortConfig{}
<add> ports, portBindings, err := nat.ParsePortSpecs(source)
<add> if err != nil {
<add> return nil, err
<add> }
<add>
<add> for port := range ports {
<add> portConfigs = append(
<add> portConfigs,
<add> opts.ConvertPortToPortConfig(port, portBindings)...)
<add> }
<add>
<add> return &swarm.EndpointSpec{Ports: portConfigs}, nil
<add>}
<add>
<add>func convertEnvironment(source map[string]string) []string {
<add> var output []string
<add>
<add> for name, value := range source {
<add> output = append(output, fmt.Sprintf("%s=%s", name, value))
<add> }
<add>
<add> return output
<add>}
<add>
<add>func convertDeployMode(mode string, replicas *uint64) (swarm.ServiceMode, error) {
<add> serviceMode := swarm.ServiceMode{}
<add>
<add> switch mode {
<add> case "global":
<add> if replicas != nil {
<add> return serviceMode, fmt.Errorf("replicas can only be used with replicated mode")
<add> }
<add> serviceMode.Global = &swarm.GlobalService{}
<add> case "replicated", "":
<add> serviceMode.Replicated = &swarm.ReplicatedService{Replicas: replicas}
<add> default:
<add> return serviceMode, fmt.Errorf("Unknown mode: %s", mode)
<add> }
<add> return serviceMode, nil
<add>}
<ide><path>pkg/composetransform/service_test.go
<add>package composetransform
<add>
<add>import (
<add> "testing"
<add>
<add> "github.com/docker/docker/api/types/swarm"
<add> "github.com/docker/docker/pkg/testutil/assert"
<add>)
<add>
<add>func TestConvertRestartPolicyFromNone(t *testing.T) {
<add> policy, err := convertRestartPolicy("no", nil)
<add> var expected *swarm.RestartPolicy
<add> assert.NilError(t, err)
<add> assert.Equal(t, policy, expected)
<add>}
<add>
<add>func TestConvertRestartPolicyFromUnknown(t *testing.T) {
<add> _, err := convertRestartPolicy("unknown", nil)
<add> assert.Error(t, err, "unknown restart policy: unknown")
<add>}
<add>
<add>func TestConvertRestartPolicyFromAlways(t *testing.T) {
<add> policy, err := convertRestartPolicy("always", nil)
<add> expected := &swarm.RestartPolicy{
<add> Condition: swarm.RestartPolicyConditionAny,
<add> }
<add> assert.NilError(t, err)
<add> assert.DeepEqual(t, policy, expected)
<add>}
<add>
<add>func TestConvertRestartPolicyFromFailure(t *testing.T) {
<add> policy, err := convertRestartPolicy("on-failure:4", nil)
<add> attempts := uint64(4)
<add> expected := &swarm.RestartPolicy{
<add> Condition: swarm.RestartPolicyConditionOnFailure,
<add> MaxAttempts: &attempts,
<add> }
<add> assert.NilError(t, err)
<add> assert.DeepEqual(t, policy, expected)
<add>} | 8 |
PHP | PHP | add verbose logging | be211f86922cb69b3fd06eac5bd43749bf3ad380 | <ide><path>src/Console/Command/Task/ProjectTask.php
<ide> protected function _searchPath($path) {
<ide> foreach ($path as $dir) {
<ide> foreach ($composer as $cmd) {
<ide> if (file_exists($dir . DS . $cmd)) {
<add> $this->_io->verbose('Found composer executable on ' . $dir);
<ide> return $dir . DS . $cmd;
<ide> }
<ide> }
<ide> public function bake($path) {
<ide> 1 => ['pipe', 'w'],
<ide> 2 => ['pipe', 'w']
<ide> ];
<add> $this->_io->verbose('Running ' . $command);
<ide> $process = proc_open(
<ide> $command,
<ide> $descriptorSpec, | 1 |
Java | Java | reduce overhead of char[] creation | c9b27af64f41cc4fd06ee41a0faaca867e3cba4e | <ide><path>spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscoverer.java
<ide> private String maybeExtractVariableName(@Nullable String candidateToken) {
<ide> }
<ide> if (Character.isJavaIdentifierStart(candidateToken.charAt(0)) &&
<ide> Character.isLowerCase(candidateToken.charAt(0))) {
<del> char[] tokenChars = candidateToken.toCharArray();
<del> for (char tokenChar : tokenChars) {
<add> for (int i = 1; i < candidateToken.length(); i++) {
<add> char tokenChar = candidateToken.charAt(i);
<ide> if (!Character.isJavaIdentifierPart(tokenChar)) {
<ide> return null;
<ide> }
<ide><path>spring-core/src/main/java/org/springframework/core/Conventions.java
<ide> /*
<del> * Copyright 2002-2019 the original author or authors.
<add> * Copyright 2002-2020 the original author or authors.
<ide> *
<ide> * Licensed under the Apache License, Version 2.0 (the "License");
<ide> * you may not use this file except in compliance with the License.
<ide> public static String attributeNameToPropertyName(String attributeName) {
<ide> if (!attributeName.contains("-")) {
<ide> return attributeName;
<ide> }
<del> char[] chars = attributeName.toCharArray();
<del> char[] result = new char[chars.length -1]; // not completely accurate but good guess
<add> char[] result = new char[attributeName.length() -1]; // not completely accurate but good guess
<ide> int currPos = 0;
<ide> boolean upperCaseNext = false;
<del> for (char c : chars) {
<add> for (int i = 0; i < attributeName.length(); i++ ) {
<add> char c = attributeName.charAt(i);
<ide> if (c == '-') {
<ide> upperCaseNext = true;
<ide> }
<ide><path>spring-web/src/main/java/org/springframework/http/ContentDisposition.java
<ide> private static String escapeQuotationsInFilename(String filename) {
<ide> }
<ide> boolean escaped = false;
<ide> StringBuilder sb = new StringBuilder();
<del> for (char c : filename.toCharArray()) {
<add> for (int i = 0; i < filename.length() ; i++) {
<add> char c = filename.charAt(i);
<ide> if (!escaped && c == '"') {
<ide> sb.append("\\\"");
<ide> }
<ide><path>spring-web/src/main/java/org/springframework/http/ResponseCookie.java
<ide> public static void validateCookieValue(@Nullable String value) {
<ide> start = 1;
<ide> end--;
<ide> }
<del> char[] chars = value.toCharArray();
<ide> for (int i = start; i < end; i++) {
<del> char c = chars[i];
<add> char c = value.charAt(i);
<ide> if (c < 0x21 || c == 0x22 || c == 0x2c || c == 0x3b || c == 0x5c || c == 0x7f) {
<ide> throw new IllegalArgumentException(
<ide> "RFC2616 cookie value cannot have '" + c + "'");
<ide><path>spring-web/src/main/java/org/springframework/http/server/DefaultPathContainer.java
<ide> private static class DefaultPathSegment implements PathSegment {
<ide>
<ide> private final String valueToMatch;
<ide>
<del> private final char[] valueToMatchAsChars;
<del>
<ide> private final MultiValueMap<String, String> parameters;
<ide>
<ide>
<ide> private static class DefaultPathSegment implements PathSegment {
<ide> DefaultPathSegment(String value, String valueToMatch, MultiValueMap<String, String> params) {
<ide> this.value = value;
<ide> this.valueToMatch = valueToMatch;
<del> this.valueToMatchAsChars = valueToMatch.toCharArray();
<ide> this.parameters = CollectionUtils.unmodifiableMultiValueMap(params);
<ide> }
<ide>
<ide> private static class DefaultPathSegment implements PathSegment {
<ide> this.value = value;
<ide> this.valueToMatch = value.contains(separator.encodedSequence()) ?
<ide> value.replaceAll(separator.encodedSequence(), separator.value()) : value;
<del> this.valueToMatchAsChars = this.valueToMatch.toCharArray();
<ide> this.parameters = EMPTY_PARAMS;
<ide> }
<ide>
<ide> public String valueToMatch() {
<ide>
<ide> @Override
<ide> public char[] valueToMatchAsChars() {
<del> return this.valueToMatchAsChars;
<add> return this.valueToMatch.toCharArray();
<ide> }
<ide>
<ide> @Override
<ide><path>spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java
<ide> public String apply(String source, Type type) {
<ide> clear(this.currentLiteral);
<ide> clear(this.currentVariable);
<ide> clear(this.output);
<del> for (char c : source.toCharArray()) {
<add> for (int i = 0; i < source.length(); i++) {
<add> char c = source.charAt(i);
<ide> if (c == '{') {
<ide> level++;
<ide> if (level == 1) {
<ide><path>spring-web/src/main/java/org/springframework/web/util/UriComponents.java
<ide> private static String sanitizeSource(String source) {
<ide> int level = 0;
<ide> int lastCharIndex = 0;
<ide> char[] chars = new char[source.length()];
<del> for (char c : source.toCharArray()) {
<add> for (int i = 0; i < source.length(); i++) {
<add> char c = source.charAt(i);
<ide> if (c == '{') {
<ide> level++;
<ide> }
<ide><path>spring-web/src/main/java/org/springframework/web/util/pattern/LiteralPathElement.java
<ide> /*
<del> * Copyright 2002-2018 the original author or authors.
<add> * Copyright 2002-2020 the original author or authors.
<ide> *
<ide> * Licensed under the Apache License, Version 2.0 (the "License");
<ide> * you may not use this file except in compliance with the License.
<ide> public boolean matches(int pathIndex, MatchingContext matchingContext) {
<ide> return false;
<ide> }
<ide>
<del> char[] data = ((PathContainer.PathSegment)element).valueToMatchAsChars();
<ide> if (this.caseSensitive) {
<ide> for (int i = 0; i < this.len; i++) {
<del> if (data[i] != this.text[i]) {
<add> if (value.charAt(i) != this.text[i]) {
<ide> return false;
<ide> }
<ide> }
<ide> }
<ide> else {
<ide> for (int i = 0; i < this.len; i++) {
<ide> // TODO revisit performance if doing a lot of case insensitive matching
<del> if (Character.toLowerCase(data[i]) != this.text[i]) {
<add> if (Character.toLowerCase(value.charAt(i)) != this.text[i]) {
<ide> return false;
<ide> }
<ide> }
<ide><path>spring-web/src/main/java/org/springframework/web/util/pattern/SingleCharWildcardedPathElement.java
<ide> /*
<del> * Copyright 2002-2018 the original author or authors.
<add> * Copyright 2002-2020 the original author or authors.
<ide> *
<ide> * Licensed under the Apache License, Version 2.0 (the "License");
<ide> * you may not use this file except in compliance with the License.
<ide> public boolean matches(int pathIndex, MatchingContext matchingContext) {
<ide> return false;
<ide> }
<ide>
<del> char[] data = ((PathSegment)element).valueToMatchAsChars();
<ide> if (this.caseSensitive) {
<ide> for (int i = 0; i < this.len; i++) {
<ide> char ch = this.text[i];
<del> if ((ch != '?') && (ch != data[i])) {
<add> if ((ch != '?') && (ch != value.charAt((i)))) {
<ide> return false;
<ide> }
<ide> }
<ide> public boolean matches(int pathIndex, MatchingContext matchingContext) {
<ide> for (int i = 0; i < this.len; i++) {
<ide> char ch = this.text[i];
<ide> // TODO revisit performance if doing a lot of case insensitive matching
<del> if ((ch != '?') && (ch != Character.toLowerCase(data[i]))) {
<add> if ((ch != '?') && (ch != Character.toLowerCase(value.charAt(i)))) {
<ide> return false;
<ide> }
<ide> } | 9 |
Python | Python | use malformed response in ec2 driver | b11eb94452c5bbab2c1b87265db2f280448b4880 | <ide><path>libcloud/drivers/ec2.py
<ide> def parse_error(self):
<ide> raise InvalidCredsError(msg)
<ide>
<ide> try:
<del> body = ET.XML(self.body)
<add> body = ET.XML(self.body)
<ide> except:
<del> raise MalformedResponseError("Failed to parse XML", body=self.body, driver=EC2NodeDriver)
<add> raise MalformedResponseError("Failed to parse XML", body=self.body, driver=EC2NodeDriver)
<ide>
<ide> for err in body.findall('Errors/Error'):
<ide> code, message = err.getchildren() | 1 |
PHP | PHP | add more quotes | 92b7bdeb4b8c40848fa276cfe1897c656302942f | <ide><path>src/Illuminate/Foundation/Inspiring.php
<ide> public static function quote()
<ide> 'Waste no more time arguing what a good man should be, be one. - Marcus Aurelius',
<ide> 'Well begun is half done. - Aristotle',
<ide> 'When there is no desire, all things are at peace. - Laozi',
<add> 'Walk as if you are kissing the Earth with your feet. - Thich Nhat Hanh',
<add> 'Because you are alive, everything is possible. - Thich Nhat Hanh',
<add> 'Breathing in, I calm body and mind. Breathing out, I smile. - Thich Nhat Hanh',
<add> 'Life is available only in the present moment. - Thich Nhat Hanh',
<add> 'The best way to take care of the future is to take care of the present moment. - Thich Nhat Hanh',
<ide> ])->random();
<ide> }
<ide> } | 1 |
Javascript | Javascript | remove unused argument | ccb6c39451b502c6b3ff3c014962827c54bae548 | <ide><path>packages/react-reconciler/src/ReactFiberWorkLoop.new.js
<ide> function handleError(root, thrownValue): void {
<ide> } while (true);
<ide> }
<ide>
<del>function pushDispatcher(root) {
<add>function pushDispatcher() {
<ide> const prevDispatcher = ReactCurrentDispatcher.current;
<ide> ReactCurrentDispatcher.current = ContextOnlyDispatcher;
<ide> if (prevDispatcher === null) {
<ide> export function renderHasNotSuspendedYet(): boolean {
<ide> function renderRootSync(root: FiberRoot, lanes: Lanes) {
<ide> const prevExecutionContext = executionContext;
<ide> executionContext |= RenderContext;
<del> const prevDispatcher = pushDispatcher(root);
<add> const prevDispatcher = pushDispatcher();
<ide>
<ide> // If the root or lanes have changed, throw out the existing stack
<ide> // and prepare a fresh one. Otherwise we'll continue where we left off.
<ide> function workLoopSync() {
<ide> function renderRootConcurrent(root: FiberRoot, lanes: Lanes) {
<ide> const prevExecutionContext = executionContext;
<ide> executionContext |= RenderContext;
<del> const prevDispatcher = pushDispatcher(root);
<add> const prevDispatcher = pushDispatcher();
<ide>
<ide> // If the root or lanes have changed, throw out the existing stack
<ide> // and prepare a fresh one. Otherwise we'll continue where we left off.
<ide><path>packages/react-reconciler/src/ReactFiberWorkLoop.old.js
<ide> function handleError(root, thrownValue): void {
<ide> } while (true);
<ide> }
<ide>
<del>function pushDispatcher(root) {
<add>function pushDispatcher() {
<ide> const prevDispatcher = ReactCurrentDispatcher.current;
<ide> ReactCurrentDispatcher.current = ContextOnlyDispatcher;
<ide> if (prevDispatcher === null) {
<ide> export function renderHasNotSuspendedYet(): boolean {
<ide> function renderRootSync(root: FiberRoot, lanes: Lanes) {
<ide> const prevExecutionContext = executionContext;
<ide> executionContext |= RenderContext;
<del> const prevDispatcher = pushDispatcher(root);
<add> const prevDispatcher = pushDispatcher();
<ide>
<ide> // If the root or lanes have changed, throw out the existing stack
<ide> // and prepare a fresh one. Otherwise we'll continue where we left off.
<ide> function workLoopSync() {
<ide> function renderRootConcurrent(root: FiberRoot, lanes: Lanes) {
<ide> const prevExecutionContext = executionContext;
<ide> executionContext |= RenderContext;
<del> const prevDispatcher = pushDispatcher(root);
<add> const prevDispatcher = pushDispatcher();
<ide>
<ide> // If the root or lanes have changed, throw out the existing stack
<ide> // and prepare a fresh one. Otherwise we'll continue where we left off. | 2 |
Javascript | Javascript | deprecate computed.any in favor of computed.or | e4392eb84f87504bf5748277dcc13c925ccd8ba1 | <ide><path>packages/ember-metal/lib/computed_macros.js
<ide> registerComputedWithProperties('or', function(properties) {
<ide> @param {String} dependentKey*
<ide> @return {Ember.ComputedProperty} computed property which returns
<ide> the first truthy value of given list of properties.
<add> @deprecated Use `Ember.computed.or` instead.
<ide> */
<ide> registerComputedWithProperties('any', function(properties) {
<ide> for (var key in properties) { | 1 |
Text | Text | improve node.js+fips instructions | 71b2df253d015dcb526af9fc1fb4ca21893a8d24 | <ide><path>BUILDING.md
<ide> to enable FIPS using the configuration flag `--openssl-is-fips`.
<ide> ### Configuring and building quictls/openssl for FIPS
<ide>
<ide> For quictls/openssl 3.0 it is possible to enable FIPS when dynamically linking.
<del>Node.js currently uses openssl-3.0.0+quic which can be configured as
<del>follows:
<del>```console
<del>$ git clone git@github.com:quictls/openssl.git
<del>$ cd openssl
<del>$ ./config --prefix=/path/to/install/dir/ shared enable-fips linux-x86_64
<add>If you want to build Node.js using openssl-3.0.0+quic, you can follow these
<add>steps:
<add>
<add>**clone OpenSSL source and prepare build**
<add>```bash
<add>git clone git@github.com:quictls/openssl.git
<add>
<add>cd openssl
<add>
<add>./config \
<add> --prefix=/path/to/install/dir/ \
<add> shared \
<add> enable-fips \
<add> linux-x86_64
<ide> ```
<del>This can be compiled and installed using the following commands:
<add>
<add>The `/path/to/install/dir` is the path in which the `make install` instructions
<add>will publish the OpenSSL libraries and such. We will also use this path
<add>(and sub-paths) later when compiling Node.js.
<add>
<add>**compile and install OpenSSL**
<ide> ```console
<del>$ make -j8
<del>$ make install_ssldirs
<del>$ make install_fips
<add>make -j8
<add>make install
<add>make install_ssldirs
<add>make install_fips
<ide> ```
<ide>
<del>After the FIPS module and configuration file have been installed by the above
<del>instructions we also need to update `/path/to/install/dir/ssl/openssl.cnf` to
<del>use the generated FIPS configuration file (`fipsmodule.cnf`):
<add>After the OpenSSL (including FIPS) modules have been compiled and installed
<add>(into the `/path/to/install/dir`) by the above instructions we also need to
<add>update the OpenSSL configuration file located under
<add>`/path/to/install/dir/ssl/openssl.cnf`. Right next to this file, you should
<add>find the `fipsmodule.cnf` file - let's add the following to the end of the
<add>`openssl.cnf` file.
<add>
<add>**alter openssl.cnf**
<ide> ```text
<ide> .include fipsmodule.cnf
<ide>
<ide> fips = fips_sect
<ide> activate = 1
<ide> ```
<ide>
<del>In the above case OpenSSL is not installed in the default location so two
<del>environment variables need to be set, `OPENSSL_CONF`, and `OPENSSL_MODULES`
<del>which should point to the OpenSSL configuration file and the directory where
<del>OpenSSL modules are located:
<add>You can e.g. accomplish this by running the following command - be sure to
<add>replace `/path/to/install/dir/` with the path you have selected. Please make
<add>sure that you specify an absolute path for the `.include fipsmodule.cnf` line -
<add>using relative paths did not work on my system!
<add>
<add>**alter openssl.cnf using a script**
<ide> ```console
<del>$ export OPENSSL_CONF=/path/to/install/dir/ssl/openssl.cnf
<del>$ export OPENSSL_MODULES=/path/to/install/dir/lib/ossl-modules
<add>cat <<EOT >> /path/to/install/dir/ssl/openssl.cnf
<add>.include /path/to/install/dir/ssl/fipsmodule.cnf
<add>
<add># List of providers to load
<add>[provider_sect]
<add>default = default_sect
<add># The fips section name should match the section name inside the
<add># included /path/to/install/dir/ssl/fipsmodule.cnf.
<add>fips = fips_sect
<add>
<add>[default_sect]
<add>activate = 1
<add>EOT
<ide> ```
<ide>
<del>Node.js can then be configured to enable FIPS:
<add>As you might have picked a non-custom path for your OpenSSL install dir, we
<add>have to export the following two environment variables in order for Node.js to
<add>find our OpenSSL modules we built beforehand:
<ide> ```console
<del>$ ./configure --shared-openssl --shared-openssl-libpath=/path/to/install/dir/lib --shared-openssl-includes=/path/to/install/dir/include --shared-openssl-libname=crypto,ssl --openssl-is-fips
<del>$ export LD_LIBRARY_PATH=/path/to/install/dir/lib
<del>$ make -j8
<add>export OPENSSL_CONF=/path/to/install/dir/ssl/openssl.cnf
<add>export OPENSSL_MODULES=/path/to/install/dir/lib/ossl-modules
<ide> ```
<ide>
<del>Verify the produced executable:
<add>**build Node.js**
<ide> ```console
<del>$ ldd ./node
<add>./configure \
<add> --shared-openssl \
<add> --shared-openssl-libpath=/path/to/install/dir/lib \
<add> --shared-openssl-includes=/path/to/install/dir/include \
<add> --shared-openssl-libname=crypto,ssl \
<add> --openssl-is-fips
<add>
<add>export LD_LIBRARY_PATH=/path/to/install/dir/lib
<add>
<add>make -j8
<add>```
<add>
<add>**verify the produced executable**
<add>```console
<add>ldd ./node
<ide> linux-vdso.so.1 (0x00007ffd7917b000)
<ide> libcrypto.so.81.3 => /path/to/install/dir/lib/libcrypto.so.81.3 (0x00007fd911321000)
<ide> libssl.so.81.3 => /path/to/install/dir/lib/libssl.so.81.3 (0x00007fd91125e000)
<ide> $ ldd ./node
<ide> libc.so.6 => /usr/lib64/libc.so.6 (0x00007fd910cec000)
<ide> /lib64/ld-linux-x86-64.so.2 (0x00007fd9117f2000)
<ide> ```
<add>
<ide> If the `ldd` command says that `libcrypto` cannot be found one needs to set
<ide> `LD_LIBRARY_PATH` to point to the directory used above for
<ide> `--shared-openssl-libpath` (see previous step).
<ide>
<del>Verify the OpenSSL version:
<add>**verify the OpenSSL version**
<ide> ```console
<del>$ ./node -p process.versions.openssl
<add>./node -p process.versions.openssl
<ide> 3.0.0-alpha16+quic
<ide> ```
<ide>
<del>Verify that FIPS is available:
<add>**verify that FIPS is available**
<ide> ```console
<del>$ ./node -p 'process.config.variables.openssl_is_fips'
<add>./node -p 'process.config.variables.openssl_is_fips'
<ide> true
<del>$ ./node --enable-fips -p 'crypto.getFips()'
<add>
<add>./node --enable-fips -p 'crypto.getFips()'
<ide> 1
<ide> ```
<ide> | 1 |
Python | Python | replace labels with -100 to skip loss calc | 0a3d0e02c5af20bfe9091038c4fd11fb79175546 | <ide><path>src/transformers/data/data_collator.py
<ide> def __call__(self, examples: List[torch.Tensor]) -> Dict[str, torch.Tensor]:
<ide> inputs, labels = self.mask_tokens(batch)
<ide> return {"input_ids": inputs, "labels": labels}
<ide> else:
<del> return {"input_ids": batch, "labels": batch}
<add> labels = batch.clone().detach()
<add> labels[labels == self.tokenizer.pad_token_id] = -100
<add> return {"input_ids": batch, "labels": labels}
<ide>
<ide> def _tensorize_batch(self, examples: List[torch.Tensor]) -> torch.Tensor:
<ide> length_of_first = examples[0].size(0) | 1 |
Javascript | Javascript | fix dropdown bug in searches | 6c55e9fc32d342d63208897a4f2128c30c069c01 | <ide><path>docs/source/_static/js/custom.js
<ide> function addVersionControl() {
<ide> const parts = location.toString().split('/');
<ide> let versionIndex = parts.length - 2;
<ide> // Index page may not have a last part with filename.html so we need to go up
<del> if (parts[parts.length - 1] != "" && ! parts[parts.length - 1].match(/\.html$/)) {
<add> if (parts[parts.length - 1] != "" && ! parts[parts.length - 1].match(/\.html$|^search.html?/)) {
<ide> versionIndex = parts.length - 1;
<ide> }
<ide> // Main classes and models are nested so we need to go deeper | 1 |
Javascript | Javascript | remove scrollto on unload | eda1fe74f4cd8979226444f0e99cc120f563cc2a | <ide><path>web/viewer.js
<ide> window.addEventListener('load', function webViewerLoad(evt) {
<ide> sidebarScrollView.addEventListener('scroll', updateThumbViewArea, true);
<ide> }, true);
<ide>
<del>window.addEventListener('unload', function webViewerUnload(evt) {
<del> window.scrollTo(0, 0);
<del>}, true);
<del>
<ide> /**
<ide> * Render the next not yet visible page already such that it is
<ide> * hopefully ready once the user scrolls to it. | 1 |
Javascript | Javascript | support the old format of ember.binding.transform | 158195a4d5a427ae414e9fde4bc6c72b8f944748 | <ide><path>packages/ember-metal/lib/binding.js
<ide> mixinProperties(Binding,
<ide> @see Ember.Binding.prototype.transform
<ide> */
<ide> transform: function(from, func) {
<add> if (!func) {
<add> func = from;
<add> from = null;
<add> }
<ide> var C = this, binding = new C(null, from);
<ide> return binding.transform(func);
<ide> }, | 1 |
PHP | PHP | fix error when wrapping email message content | 4e6c83595102f7071fd00374708edf3838d3566b | <ide><path>src/Mailer/Message.php
<ide> protected function wrap(?string $message = null, int $wrapLength = self::LINE_LE
<ide> $tmpLine .= $char;
<ide> $tmpLineLength++;
<ide> if ($tmpLineLength === $wrapLength) {
<del> $nextChar = $line[$i + 1];
<add> $nextChar = $line[$i + 1] ?? '';
<ide> if ($nextChar === ' ' || $nextChar === '<') {
<ide> $formatted[] = trim($tmpLine);
<ide> $tmpLine = '';
<ide><path>tests/TestCase/Mailer/MessageTest.php
<ide> public function testWrap()
<ide> '',
<ide> ];
<ide> $this->assertSame($expected, $result);
<add>
<add> /** @see https://github.com/cakephp/cakephp/issues/14459 */
<add> $line = 'some text <b>with html</b>';
<add> $trailing = str_repeat('X', Message::LINE_LENGTH_MUST - strlen($line));
<add> $result = $renderer->doWrap($line . $trailing, Message::LINE_LENGTH_MUST);
<add> $expected = [
<add> 'some text <b>with',
<add> 'html</b>' . $trailing,
<add> '',
<add> ];
<add> $this->assertSame($expected, $result);
<ide> }
<ide>
<ide> /** | 2 |
PHP | PHP | remove unneeded use statements | 894ec17dace6ca1d5e57adaa24555c6b81c38729 | <ide><path>src/Database/Dialect/PostgresDialectTrait.php
<ide> namespace Cake\Database\Dialect;
<ide>
<ide> use Cake\Database\Expression\FunctionExpression;
<del>use Cake\Database\Query;
<ide> use Cake\Database\SqlDialectTrait;
<ide>
<ide> /**
<ide><path>src/Database/Driver/PDODriverTrait.php
<ide> */
<ide> namespace Cake\Database\Driver;
<ide>
<del>use Cake\Database\Query;
<ide> use Cake\Database\Statement\PDOStatement;
<ide> use PDO;
<ide>
<ide><path>src/Database/Driver/Sqlite.php
<ide> namespace Cake\Database\Driver;
<ide>
<ide> use Cake\Database\Dialect\SqliteDialectTrait;
<del>use Cake\Database\Query;
<ide> use Cake\Database\Statement\PDOStatement;
<ide> use Cake\Database\Statement\SqliteStatement;
<ide> use PDO;
<ide><path>src/Database/Type/FloatType.php
<ide> namespace Cake\Database\Type;
<ide>
<ide> use Cake\Database\Driver;
<del>use Cake\Error;
<ide> use PDO;
<ide>
<ide> /**
<ide><path>src/Database/Type/IntegerType.php
<ide> namespace Cake\Database\Type;
<ide>
<ide> use Cake\Database\Driver;
<del>use Cake\Error;
<ide> use PDO;
<ide>
<ide> /**
<ide><path>src/Datasource/QueryTrait.php
<ide> use Cake\Collection\Iterator\MapReduce;
<ide> use Cake\Datasource\QueryCacher;
<ide> use Cake\Datasource\RepositoryInterface;
<del>use Cake\Datasource\ResultSetDecorator;
<ide>
<ide> /**
<ide> * Contains the characteristics for an object that is attached to a repository and
<ide><path>src/I18n/I18n.php
<ide> */
<ide> namespace Cake\I18n;
<ide>
<del>use Aura\Intl\Exception as LoadException;
<ide> use Aura\Intl\FormatterLocator;
<ide> use Aura\Intl\PackageLocator;
<ide> use Aura\Intl\TranslatorFactory;
<ide><path>src/Network/Email/Email.php
<ide> use Cake\Network\Http\FormData\Part;
<ide> use Cake\Utility\Hash;
<ide> use Cake\Utility\String;
<del>use Cake\View\View;
<ide> use InvalidArgumentException;
<ide> use LogicException;
<ide>
<ide><path>src/ORM/Association.php
<ide> use Cake\Core\ConventionsTrait;
<ide> use Cake\Database\Expression\IdentifierExpression;
<ide> use Cake\Datasource\ResultSetDecorator;
<del>use Cake\Event\Event;
<ide> use Cake\ORM\Entity;
<ide> use Cake\ORM\Query;
<ide> use Cake\ORM\Table;
<ide> protected function _joinCondition($options) {
<ide> /**
<ide> * Helper method to infer the requested finder and its options.
<ide> *
<del> * Returns the inferred options from the finder $type.
<add> * Returns the inferred options from the finder $type.
<ide> *
<ide> * ### Examples:
<ide> *
<ide><path>src/Routing/Router.php
<ide> use Cake\Network\Request;
<ide> use Cake\Routing\RouteBuilder;
<ide> use Cake\Routing\RouteCollection;
<del>use Cake\Routing\Route\Route;
<ide> use Cake\Utility\Inflector;
<ide>
<ide> /**
<ide><path>src/TestSuite/ControllerTestCase.php
<ide> use Cake\Controller\Error\MissingComponentException;
<ide> use Cake\Controller\Error\MissingControllerException;
<ide> use Cake\Core\App;
<del>use Cake\Error;
<ide> use Cake\Event\Event;
<ide> use Cake\Network\Request;
<ide> use Cake\Network\Session;
<ide><path>src/TestSuite/Fixture/FixtureManager.php
<ide> use Cake\Datasource\ConnectionManager;
<ide> use Cake\Core\Exception\Exception;
<ide> use Cake\TestSuite\Fixture\TestFixture;
<del>use Cake\TestSuite\TestCase;
<ide> use Cake\Utility\Inflector;
<ide>
<ide> /**
<ide><path>src/View/Helper/StringTemplateTrait.php
<ide> */
<ide> namespace Cake\View\Helper;
<ide>
<del>use Cake\View\StringTemplate;
<del>
<ide> /**
<ide> * Adds string template functionality to any class by providing methods to
<ide> * load and parse string templates. | 13 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.