Exclude everything under folder *but* certain filetypes (at any nesting level) - unison

Using version 2.51.2 (ocaml 4.04.0).
Trying to exclude a folder at the root (called build), but include any files ending in .err and .out at any depth underneath it.
Structure looks like
build/a/b/c/test/1.0/test.out
build/a/d/whatever/2.0/whatever.err
build/a/test.err
I tried
ignore = Path build
ignorenot = Regex·arnold-build\/(.*).(err|out)⬎
... this coughs up a "Malformed pattern" error. Also tried just to sync an entire subdir explicitly with this:
ignorenot = Path a/b/c/test/
But the "test" folder still doesn't sync.
How do I get just all the .err/.out files to sync, while ignoring everything else?

Unison's "ignorenot" preference is somewhat counterintuitive
https://www.cis.upenn.edu/~bcpierce/unison/download/releases/stable/unison-manual.html#ignore
If a directory is ignored, all its descendents are ignored too, everything below that tree will be ignored and not checked anymore.
Ignorenot only blocks ignores at the same level, so you must cover all the tree, up to the ignorenot you want to apply, with pairs of ignore and ignorenot. For example, in the case you cited above, if you want to ignore everything in build, except build/a/b/c/test, build/a/d/whatever, and everything inside them, your preferences profile should include:
ignore = Path build/*
ignorenot = Path build/a
ignore = Path build/a/*
ignorenot = Path build/a/b
ignorenot = Path build/a/d
ignore = Path build/a/b/*
ignore = Path build/a/d/*
ignorenot = Path build/a/b/c
ignorenot = Path build/a/d/whatever
ignore = Path build/a/b/c/*
ignorenot = Path build/a/b/c/test
This way Unison will ignore everything in the build folder, except for build/a/d/whatever and build/a/b/c/test

Related

file system watcher doesn't work when used full filename as filter

I'm trying setup a file watcher for one specific file C:\test.json via workspace.createFileSystemWatcher
This is the code I use:
const watcher = vscode.workspace.createFileSystemWatcher(new vscode.RelativePattern("C:\\", "test.json"));
watcher.onDidChange(uri => console.log("change", uri));
watcher.onDidCreate(uri => console.log("create", uri));
watcher.onDidDelete(uri => console.log("delete", uri));
For some reason events are not triggered, unless I replace filter test.json with *.json - then it works just fine.
Any ideas why complete filename doesn't work?
I see your question(s) ;>} on github. I'll post there as well.
It is interesting that this works:
const watcher = vscode.workspace.createFileSystemWatcher(new vscode.RelativePattern(vscode.Uri.file("C:\\Testing"), "test.json"));
Note that test.json is in a folder Testing.
This does not work - when test.json is at the root of C:
const watcher = vscode.workspace.createFileSystemWatcher(new vscode.RelativePattern(vscode.Uri.file("C:\\"), "test.json"));
So it looks like either vscode.Uri.file("C:\\") doesn't work properly at the drive root level or vscode.RelativePattern() doesn't work properly at the drive root level.
As we discussed on github (see API: createFileSystemWatcher() doesn't work when filter set to a specific file), the problem appears to be the trailing slash in C:\\. Since relative patterns like new vscode.RelativePattern(vscode.Uri.file("C:\\Testing"), "test.json") work and patterns like new vscode.RelativePattern(vscode.Uri.file("C:\\Testing\\"), "test.json") do not work.
But a backslash is required for a drive root level designation:
No, it doesn't. But it's because drive path requires trailing slash,
otherwise it's treated as relative path instead:
Use a backslash as required as part of volume names, for example, the
"C:" in "C:\path\file" or the "\server\share" in
"\server\share\path\file" for Universal Naming Convention (UNC)
names.
from your comment at https://github.com/microsoft/vscode/issues/162498#issuecomment-1295628237
so it does seem that vscode.RelativePattern() will not work at the drive root level because of the trailing slash (but the trailing slash is necessary and a simple vscode.workspace.createFileSystemWatcher(vscode.Uri.file("C:\\test.json")); does not work either).
We should update this answer with however the github issue is resolved - can your original new vscode.RelativePattern(vscode.Uri.file("C:\\"), "test.json") be made to work.

Unison's "ignorenot" parameter does not work

I have the following instruction in my unison profile:
ignore = Path node_modules
ignorenot = Path node_modules/scaffold
Easy enough, right? Except that it doesn't work. It keeps on ignoring the node_modules/scaffold folder.
I even tried it with a regex:
ignorenot = Regex /node_modules/scaffold/.*
So what's going on here? I'm running unison 2.48.4
Apparently, when you ignore a directory, there is no way to un-ignore a descendant.
What you should do instead is ignore the directory's contents, and then un-ignore a specific child. This will work for example:
ignore = Path node_modules/*
ignorenot = Path node_modules/scaffold

set a cmake variable if it is not changed by the user

How can i (re)set cmake variable only when it is not changed by the user?
I have this variables:
set(DIR "testdir" CACHE PATH "main directory")
set(SUBDIR ${DIR}/subdir CACHE PATH "subdirectory")
On the first run the variables are initialized to testdir and testdir/subdir.
When the user changed DIR and reruns cmake without changing SUBDIR, i would like to generate a new SUBDIR path, while i want to keep the SUBDIR path, when the user changed it.
So SUBDIR should be set to the new default value based on the new value of DIR, if DIR was changed and SUBDIR was never changed before.
Turning my comment into an answer
You could use MODIFIED cache variable property, but the documentation says
Do not set or get.
Maybe a better approach would be to check the modification with if statements:
set(DIR "testdir" CACHE PATH "main directory")
if (NOT DEFINED SUBDIR OR SUBDIR MATCHES "/subdir$")
set(SUBDIR "${DIR}/subdir" CACHE PATH "subdirectory" FORCE)
endif()
Or you just don't put DIR inside SUBDIR and put the details into the description:
set(SUBDIR "subdir" CACHE PATH "subdirectory of main directory (see DIR)")
Along with cache variable SUBDIR visible to the user, you may store another cache variable, say SUBDIR_old, which contains the last value of SUBDIR and marked as INTERNAL (that is not intended to be modified by the user).
Next launching of cmake you may compare values of SUBDIR and SUBDIR_old, and if they differ, then user has modified SUBDIR:
if(NOT DEFINED SUBDIR_old OR (SUBDIR EQUAL SUBDIR_old))
# User haven't changed SUBDIR since previous configuration. Rewrite it.
set(SUBDIR <new-value> CACHE PATH "<documentation>" FORCE)
endif()
# Store current value in the "shadow" variable unconditionally.
set(SUBDIR_old ${SUBDIR} CACHE INTERNAL "Copy of SUBDIR")
Problem with that approach that user cannot say:
I have checked value of SUBDIR and found it already correct.
Without modification we assume that user don't bother about variable's value.

Why CMake doubles the path?

I am using UseLATEX, with commands
set(MainFile "Demo.tex")
set(InputFiles ${MainFile} Main.tex OtherFiles.tex)
then later I use it like
ADD_LATEX_DOCUMENT( ${MyFileName}
INPUTS "${InputFiles}" )
and everything works fine. If I change to
file(GLOB_RECURSE InputFiles src/*.tex)
then I receive messages with a list of files I wanted to put into InputFiles,
but preceeded with
"Could not find input file ${CMAKE_SOURCE_DIR}/${CMAKE_SOURCE_DIR}/OtherFiles.tex"
and of course that path does not exist. What is wrong?
Turning my comment into answer
Haven't worked with ADD_LATEX_DOCUMENT(), but it seems it appends the current directory itself and would need relative paths.
Just change your file(GLOB ...) command to output relative paths:
file(GLOB_RECURSE InputFiles RELATIVE "${CMAKE_SOURCE_DIR}" src/*.tex)

BigQuery loading batch folders error

I'm trying to load group of folders files in one time with when
i set
sourceURI = 'gs://ybbi/bi_landing_zone/files_to_load/app/reports/app_network_analytics_report/201409011*'
all the folders that i'm want to load start with 20140911
but i get the error:
ERROR: Invalid path: gs://ybbi/bi_landing_zone/files_to_load/apn/reports/appnexus_network_analytics_report/20140901191111_3bab8ec0_092a_43de_a157_db35d1555ea0/
20140901191111_3bab8ec0_092a_43de_a157_db35d1555ea0 is one of these folders(don't know why it's print the all folder name of this specific folder)
in some other folder tree cases it's works, but in this specific folder tree it's return the same error .
i know that cloud storage don't have real folders and it's part of the name of the object, but you understand what i mean.
is it bug?
Without more information, what it looks like is that you have a object file called gs://ybbi/bi_landing_zone/files_to_load/apn/reports/appnexus_network_analytics_report/20140901191111_3bab8ec0_092a_43de_a157_db35d1555ea0/ that is not a csv/json file. Some tools may create these dummy files in order to simulate directories. BigQuery requires all objects that match the input glob path to be importable files.
One solution would be to change the glob path to include a narrower set of files. You can pass multiple paths if that makes things easier. For example, you could pass
gs://ybbi/bi_landing_zone/files_to_load/apn/reports/appnexus_network_analytics_report/20140901191111_3bab8ec0_092a_43de_a157_db35d1555ea0/*
and
gs://ybbi/bi_landing_zone/files_to_load/apn/reports/appnexus_network_analytics_report/20140901191111_some_other_path/*