]> git.lyx.org Git - lyx.git/commit
Bulk cleanup/fix incorrect annotation at the end of namespaces.
authorChristian Ridderström <christian.ridderstrom@profoto.com>
Sun, 23 Jul 2017 11:11:54 +0000 (13:11 +0200)
committerChristian Ridderström <christian.ridderstrom@profoto.com>
Sun, 23 Jul 2017 11:11:54 +0000 (13:11 +0200)
commite30f3d76d2bee0011ceaeb5f0cc221156458cbad
tree03bfeedeebfc20bd6ddfcfe79e7d762c89069f33
parentd50e2aa7bf4686be9bc17d6282fd14f8517c4475
Bulk cleanup/fix incorrect annotation at the end of namespaces.

This commit does a bulk fix of incorrect annotations (comments) at the
end of namespaces.

The commit was generated by initially running clang-format, and then
from the diff of the result extracting the hunks corresponding to
fixes of namespace comments. The changes being applied and all the
results have been manually reviewed. The source code successfully
builds on macOS.

Further details on the steps below, in case they're of interest to
someone else in the future.

1. Checkout a fresh and up to date version of src/

    git pull && git checkout -- src && git status src

2. Ensure there's a suitable .clang-format in place, i.e. with options
   to fix the comment at the end of namespaces, including:

    FixNamespaceComments:                           true
    SpacesBeforeTrailingComments:                   1

and that clang-format is >= 5.0.0, by doing e.g.:

    clang-format -dump-config | grep Comments:
    clang-format --version

3. Apply clang-format to the source:

    clang-format -i $(find src -name "*.cpp" -or -name "*.h")

4. Create and filter out hunks related to fixing the namespace

    git diff -U0 src > tmp.patch
    grepdiff '^} // namespace' --output-matching=hunk tmp.patch  > fix_namespace.patch

5. Filter out hunks corresponding to simple fixes into to a separate patch:

    pcregrep -M -e '^diff[^\n]+\nindex[^\n]+\n--- [^\n]+\n\+\+\+ [^\n]+\n'  \
        -e '^@@ -[0-9]+ \+[0-9]+ @@[^\n]*\n-\}[^\n]*\n\+\}[^\n]*\n'         \
        fix_namespace.patch > fix_namespace_simple.patch

6. Manually review the simple patch and then apply it, after first
   restoring the source.

    git checkout -- src
    patch -p1 < fix_namespace_simple.path

7. Manually review the (simple) changes and then stage the changes

    git diff src
    git add src

8. Again apply clang-format and filter out hunks related to any
   remaining fixes to the namespace, this time filter with more
   context. There will be fewer hunks as all the simple cases have
   already been handled:

    clang-format -i $(find src -name "*.cpp" -or -name "*.h")
    git diff src > tmp.patch
    grepdiff '^} // namespace' --output-matching=hunk tmp.patch  > fix_namespace2.patch

9. Manually review/edit the resulting patch file to remove hunks for files
   which need to be dealt with manually, noting the file names and
   line numbers. Then restore files to as before applying clang-format
   and apply the patch:

    git checkout src
    patch -p1 < fix_namespace2.patch

10. Manually fix the files noted in the previous step. Stage files,
    review changes and commit.
154 files changed:
src/AspellChecker.cpp
src/BiblioInfo.cpp
src/BranchList.cpp
src/Buffer.cpp
src/Buffer.h
src/BufferList.h
src/BufferParams.cpp
src/BufferView.cpp
src/Changes.cpp
src/CiteEnginesList.cpp
src/CiteEnginesList.h
src/Converter.cpp
src/ConverterCache.cpp
src/Counters.cpp
src/Cursor.cpp
src/CutAndPaste.cpp
src/CutAndPaste.h
src/DocumentClassPtr.h
src/EnchantChecker.cpp
src/Encoding.cpp
src/Font.cpp
src/FontInfo.cpp
src/Format.cpp
src/FuncRequest.cpp
src/HunspellChecker.cpp
src/IndicesList.cpp
src/InsetList.cpp
src/LaTeX.cpp
src/LaTeXFeatures.cpp
src/Language.cpp
src/Layout.cpp
src/LayoutModuleList.h
src/Lexer.cpp
src/LyX.cpp
src/LyXRC.cpp
src/ModuleList.h
src/Paragraph.cpp
src/Server.cpp
src/Session.cpp
src/Session.h
src/Spacing.cpp
src/Text.cpp
src/Text3.cpp
src/TextClass.cpp
src/TextMetrics.cpp
src/Thesaurus.cpp
src/frontends/qt4/CategorizedCombo.cpp
src/frontends/qt4/ColorCache.cpp
src/frontends/qt4/DockView.cpp
src/frontends/qt4/DockView.h
src/frontends/qt4/FancyLineEdit.cpp
src/frontends/qt4/FancyLineEdit.h
src/frontends/qt4/GuiApplication.cpp
src/frontends/qt4/GuiCharacter.cpp
src/frontends/qt4/GuiClipboard.cpp
src/frontends/qt4/GuiCommandBuffer.cpp
src/frontends/qt4/GuiDelimiter.cpp
src/frontends/qt4/GuiDocument.cpp
src/frontends/qt4/GuiErrorList.cpp
src/frontends/qt4/GuiExternal.cpp
src/frontends/qt4/GuiFontLoader.cpp
src/frontends/qt4/GuiFontMetrics.cpp
src/frontends/qt4/GuiGraphics.cpp
src/frontends/qt4/GuiHyperlink.cpp
src/frontends/qt4/GuiIdListModel.h
src/frontends/qt4/GuiImage.cpp
src/frontends/qt4/GuiPrefs.cpp
src/frontends/qt4/GuiProgressView.cpp
src/frontends/qt4/GuiSymbols.cpp
src/frontends/qt4/GuiToolbar.cpp
src/frontends/qt4/GuiView.cpp
src/frontends/qt4/LengthCombo.h
src/frontends/qt4/Menus.cpp
src/frontends/qt4/qt_helpers.cpp
src/graphics/PreviewLoader.cpp
src/insets/ExternalSupport.cpp
src/insets/ExternalTemplate.cpp
src/insets/ExternalTransforms.cpp
src/insets/InsetBibtex.cpp
src/insets/InsetBibtex.h
src/insets/InsetBox.cpp
src/insets/InsetExternal.cpp
src/insets/InsetGraphics.cpp
src/insets/InsetGraphics.h
src/insets/InsetIPAMacro.cpp
src/insets/InsetInclude.cpp
src/insets/InsetIndex.cpp
src/insets/InsetInfo.cpp
src/insets/InsetLayout.cpp
src/insets/InsetListingsParams.cpp
src/insets/InsetNomencl.cpp
src/insets/InsetNote.cpp
src/insets/InsetPhantom.cpp
src/insets/InsetQuotes.cpp
src/insets/InsetRef.cpp
src/insets/InsetScript.cpp
src/insets/InsetSpecialChar.cpp
src/insets/InsetTOC.cpp
src/insets/InsetTabular.cpp
src/insets/InsetVSpace.cpp
src/insets/RenderGraphic.cpp
src/insets/RenderPreview.cpp
src/lengthcommon.cpp
src/lyxfind.cpp
src/mathed/InsetMathDecoration.cpp
src/mathed/InsetMathFrac.cpp
src/mathed/InsetMathHull.cpp
src/mathed/InsetMathSideset.cpp
src/mathed/InsetMathSpace.cpp
src/mathed/MathAutoCorrect.cpp
src/mathed/MathExtern.cpp
src/mathed/MathFactory.cpp
src/mathed/MathRow.cpp
src/mathed/MathSupport.cpp
src/output.cpp
src/output_docbook.cpp
src/output_latex.cpp
src/output_xhtml.cpp
src/support/Changer.h
src/support/ForkedCalls.cpp
src/support/ForkedCalls.h
src/support/Messages.cpp
src/support/Package.cpp
src/support/RefChanger.h
src/support/Systemcall.cpp
src/support/bind.h
src/support/convert.cpp
src/support/debug.cpp
src/support/debug.h
src/support/docstream.cpp
src/support/docstream.h
src/support/docstring.cpp
src/support/lstrings.cpp
src/support/numpunct_lyx_char_type.h
src/support/os.cpp
src/support/os_cygwin.cpp
src/support/os_unix.cpp
src/support/os_win32.cpp
src/support/pmprof.h
src/support/regex.h
src/support/strfwd.h
src/support/tests/dummy_functions.cpp
src/support/unicode.cpp
src/support/unique_ptr.h
src/tests/check_layout.cpp
src/tests/dummy_functions.cpp
src/tex2lyx/Context.cpp
src/tex2lyx/Parser.cpp
src/tex2lyx/dummy_impl.cpp
src/tex2lyx/tex2lyx.cpp
src/tex2lyx/text.cpp
src/texstream.cpp
src/texstream.h
src/update_flags.h