I tried to find in the documentation and I did not find indication.
I read the win32 watch code (because I am familiar with the API and it seems it does not).
Tracking for file deletion is extremely convoluted on windows, because the API provides the file names "randomly" mangled and if the file is not there anymore to resolve the real name "long path" it is hard to say what was the original.
I have implemented such thing for my previous company, with preserving the current state of files and reconciling the list of files for every directory that changes were happening inside. It worked well.
My question is: did I miss it and watchman notifies for deleted files? And if it does not - is there plans for these notifications to be added in the near future.
The short answer: yes.
The longer answer: the more convoluted portions are not entirely windows specific.
The bit that handles the mangled names can be found here:
https://github.com/facebook/watchman/blob/master/root.c#L748
The bit that handles deletes is in two parts; the first handles things when we're checking exactly the file that we were notified about:
https://github.com/facebook/watchman/blob/master/root.c#L853
The second is a kind of "garbage collection" approach where we're looking at the containing directory and discover that the file has gone away:
https://github.com/facebook/watchman/blob/master/root.c#L1353
Related
Disclaimer: I am posting a self-answer to this. Even though it's something that's rather unusual to do, hopefully someone will benefit from reading this.
I recently replaced my original Entity Framework Core DbContext with a new one because I renamed the database (among other things). Let's call the original one OriginalDbContext and NewDbContext for convenience.
The table structure itself remained unchanged.
Naturally, I had to replace all instances of OriginalDbContext with NewDbContext. I was expecting that, once I did that, it would simply compile (since I didn't make any database changes other than replace OriginalDbContext with NewDbContext). However, even after I did that, I got numerous error messages stating to the effect that OldDbContext did not have a definition for my table clases.
I searched all files in my solution for any reference to OriginalDbContext and found none. I even deleted OriginalDbContext.cs entirely (including in version control).
Why would it continue to "look for" OriginalDbContext even though I verified that it was removed from all of my .cs files?
I finally did a "Find All" on the entire directory. It turns out that the only place that referred to OriginalDbContext was one of my publish profiles (which did not appear when I searched only in the solution). I deleted the profile and was able to compile again.
I guess the broader lesson here is that there could be references to your DbContext class that do not appear in your code base and may not even show up if you do a "Find All" on the entire solution.
Worse yet, when I double-clicked the original error messages, it made it appear like the errors were coming from my code base.
I'm looking for pointers to solutions for a problem that must have been solved multiple times (or pointers to the proper terms to search for):
How to get a reasonably quick/cheap directory snapshot/hash that can be used to determine whether something has changed compared to a previous state (which can be during a previous run of the code)?
Edit: I'm thinking here in the 1st place of added or deleted files/directories, but also of file changes that can be determined without reading the entire file.
Edit2: I'm looking for something cross-platform, and not a notification mechanism (sadly).
Thanks!
Tried searching for this a number of ways and have not yet found an answer ...
Background
I am working on a legacy Perl application that has a lot of hard-coded values in it which should be configurable depending on where the app is installed. So, obviously, I am looking to externalize these values into a configuration file that may be located in one of a few "expected" locations. That is, using a traditional approach of checking for the configuration file in:
the current working directory,
the user's home directory (or a sub-folder therein), and
the system configuration directory (or a sub-folder therein)
where the first one found wins.
Where I am at
Perused the CPAN site a bit and found the Config::Any package, which looks promising. I can give it a list of files to use:
use Config::Any;
my $config = Config::Any->load_files(
{
files => [qw(sample.conf /home/william/.config/sample.conf /etc/sample.conf)],
use_ext => 0,
});
This will check for the existence of each of these files, and, if found, load the contents into an array reference of hash references. Not bad, but I still have to hard-code the locations where I search for my sample.conf file. Here, I assume that I am working on a Linux system, and that the location for the configuration file for all users of the application is /etc/. I could always add /usr/local/etc/ as well, but regardless, this is not system agnostic.
I can locate the user home folder using File::HomeDir for searching there, and it works correctly regardless of the system on which the application is running. So is there a similar package that would provide the /etc/ folder (or its equivalent on other platforms)?
Questions
Is there a way to do this without having to know what particular OS I am on? (Perl package or code snippet)
What is the "Perl best practice" way of accomplishing this? I cannot imagine that no one else has run into this previously.
Unless you don't plan to run your code on non unix-based hosts, according to the conventional directory layout and filesystem hierarchy standard, you may rely on a quite large set of well known places.
Anyway, nothing prevents you to dynamically build the file search specification to take account of platform oddities and their specific ways to get them (eg. File::HomeDir::Win32 vs File::HomeDir).
Is anyone aware of a hybrid version control and synchronising system?
I'm currently a happy mercurial user, but my projects usually contain a mixture of files.
Most of these (code, documentation, ...) I want to be version-controlled. This is why I use mercurial.
However, on the rare occasion I have files that I would like to synchronise between my working copies, but not version control.
For example, I version control the code I write to do image processing. This code can produce a whole bunch of output images which I'd like to have synchronised so I don't have to remember to shuffle them around my various computers, but there's no point having these version controlled.
To clarify - I am aware of extension to mercurial such as bfiles and bigfiles, which are handy for my image example, but I was just wondering if anyone out there knows of alternative ways to handle this. I just want the one system that I can tell "version control all files except those ones, which should be synced but have no history".
cheers!
EDIT: I could do something like adding a hg marksync <filename> that added <filename> to a list of files to be synced, and then adding a hook to hg push/hg pull that would (say) run rsync (or whichever sync tool) in the background, but I wondered if there was a less hacky solution (I think bfiles/bigfiles do something along these lines anyway).
Version Control System (any) doesn't care about synchronization of
not versioned data
besides default pathes
If you want sync any files - use specially designed for this task tools: f.e. rsync
This code can produce a whole bunch of output images which I'd like to have synchronised
Is this DATA or part of your CODE?
If data: Keep out of your versioning system, just don't go there. If it is part of your code (like layout images) check it in. Those are the only ways which are the generally accepted.
A nice solution for the data would be syncing OR generating them. So you might add a step after deployment to a server: GenerateImages().
edit: In addition to the comment made by the thread starter:
If the images are data and you need to process them on a different system don't think about the version control for your code. It is unrelated. The steps which would make sense to me, in order of processing:
Start with updating your image code, check it in versioning. Then deploy (yes this is deployment) the updated code to the cruncher computer. Now code is done.
Then you have tasks which the number cruncher should handle. Like processing the images. So start that processing from either the cruncher itself (probably some queue happens there) or from a central dispatcher.
Then you have the results locally at the cruncher. Now something has to happen with that data, so that's also part of your software. Decide whether you want the cruncher to send them to some central storage, your workstation or another location. Let the software handle that. This is the most hard part as I read through your question. Many solutions are possible from just FTP/network transfers to specific storage solutions. Willing to help but need more info about the real issues, amounts, sizes etc. on these parts.
If the new updated version of the image processor makes the old generated images obsolete implement that also in your code, by for example attaching an attribute to the files generated, a seperate folder or another indication. That way you could request the cruncher after update to re-generate any obsolete files.
Does anyone know of a software or system for automatically tracking and logging exact line code changes into a log file?
For example, lets say I edit 7 files on Jan 16th, and I add and modify several lines of code in each file.
Is there a software or tool of any kind that would automagically know what edits I made, what was changed, and log the details in date order line-item file?
I am guessing something exists like this, but I cannot find out what I should be searching for. I looked at SVN and some other similar, but didn't get these capabilities from the descriptions I read.
There's nothing that would automagically know this. This sort of information is easy to come by as a side-effect of using virtually any version control system though. It sounds like you're not using any VCS, you should start doing so now. SVN is a good option to start with.