Move large number of files in Fossil repo - fossil

Is there a way to move a large number of files in a Fossil repo?
Ideally, I'd be able to move them to a new directory, and Fossil would detect that and keep tracking them. fossil mv requires specifying the filenames individually. fossil add can be used to start tracking the files once they've been moved, but then I have to use fossil rm to delete the existing files one at a time. Neither of these is practical for more than a handful of files.

Fossil mv can take a directory as argument and it will move every files inside recursively. But the semantic is not exactly like the unix "mv" command and it doesn't works with the "--hard" option (probably a bug).
Example, if you have a directory "dir" and want to move it inside a new
directory "subdir", this will works.
$ mkdir subdir
$ mv dir subdir/
$ fossil mv dir subdir/dir
   note: You have to use "subdir/dir" for the destination argument. Otherwise it will not do what you what, it will move all files that is inside dir directly in subdir. (so it doesn't use the same semantic as the unix "mv" command).

fossil addremove does this. It's the equivalent of fossil add . to add all new files, followed by fossil rm for each missing file.
Moving files is only one use for this command. You can also use it if you've deleted multiple files.
The downside is that moved files will be treated as new files, so you will have to keep that in mind when viewing the repo history.

Related

Copy files from multiple folders to corresponding folders within the same gcp bucket folder

I have a gcp bucket say gs://my-folder that contains folders that either start with newVersion or don't. Each of these folders contain files. For example I have gs://my-folder/newVersion=1, gs://my-folder/newVersion=2, gs://my-folder/newVersion=3. I want to copy whatever is in these folders into gs://my-folder/1, gs://my-folder/2 and gs://my-folder/3 respectively. Is there a way of using gsutil cp command to do this? It would have much been easier if the these were different folders.
I don't want to copy folders individually. I want a script maybe that could identify all the newVersion= folders and copy them to the corresponding folders.
If it doesn't have to be a copy then just:
Renaming Groups Of Objects
You can use the gsutil mv command to rename all objects with a given prefix to have a new prefix. For example, the following command renames all objects under gs://my_bucket/oldprefix to be under gs://my_bucket/newprefix, otherwise preserving the naming structure:
gsutil mv gs://my_bucket/oldprefix gs://my_bucket/newprefix
Note that when using mv to rename groups of objects with a common prefix, you cannot specify the source URL using wildcards; you must spell out the complete name.
If you do a rename as specified above and you want to preserve ACLs, you should use the -p option (see OPTIONS).
If you have a large number of files to move you might want to use the gsutil -m option, to perform a multi-threaded/multi-processing move:
gsutil -m mv gs://my_bucket/oldprefix gs://my_bucket/newprefix
ref: https://cloud.google.com/storage/docs/gsutil/commands/mv
You can simply use the gsutil cp command if you want to copy a folder and its content.
gsutil cp gs://my-folder/newVersion=1/* gs://my-folder/1
To copy the entire directory tree, you can use -r command.
gsutil cp -r gs://my-folder/newVersion=1/* gs://my-folder/1
However, note that this will only work if the folder to copy contains files. Since it expects actual objects/files to be copied and not empty directories.
On the other hand, using gsutil mv command will allow you to perform a copy from source to destination followed by removing the source for each object. If you don't want your original file/object to be removed, you can use the cp instead of mv.

FOSSIL: file outside of checkout tree

As I understand the directories of each file fossil.exe, repository-file and files (to be versioned) can be in totally different pathes, is that right?
However, I get the following error:
file outside of checkout tree: path_to_file\filename
My structure is as follows:
FOSSIL\fossil.exe
NewFolder\repo.fossil
NewFolder\Subfolder\sample_table.csv
When opening the repo and then running fossil add full_path\sample_table.csv I get the above mentioned error.
A few things:
It doesn't matter where the fossil executable is located, as long as it's somewhere in the search path (otherwise you have to use the full path every time).
It doesn't really matter where the repository file is located either, as long as it doesn't move after you've opened it. (If you do want to move it, close the repository first).
You're missing a work directory. You need to open the repository first, into a work directory (also called the checkout tree). That work directory will be where you'll be working on your files.
In the situation you describe, you'd need to run the following command:
cd <topmost folder of your code>
fossil open NewFolder\repo.fossil
After that, you can do whatever you need in that folder (and its subfolders), and anytime you perform a commit or checkin, the changes you've made will end up in the repository.
fossil add NewFolder\Subfolder\sample_table.csv
fossil commit --comment "Added sample table"
There's usually no reason to close the working directory again; except perhaps if you want to move the repository: you'd then use fossil close to close the working directory, move the repository, and then use fossil open <new_repo_path> from the working directory again.
Note that the repository can be located somewhere else entirely; and also that a single repository can be opened into several different work directories at the same time.

How to add file with specific extension into fossil repository?

As title, I have several types of file stored in a folder (with sub-folders) that I use Fossil to keep a repository (e.g. foo.R; foo.xls; foo.csv), I only want my R files to be added into the repository. I only know using fossil add . to add all the files, and then use fossil delete *.csv to remove the files I don't need.
Is there a more efficient way?
In addition to Reimer Behrends’ answer: on the Windows command line, you can use the recursive for loop:
for /r . %F in (*.r) do #fossil add %F
to add all your .r files to the repository, including those in subfolders. (If your files are all in the same folder, fossil add *.r will do).
Note that if you want to use this in a batch or .cmd file, you'll have to double the percentage characters (%%):
for /r . %%F in (*.r) do fossil add %%F
There is no direct way to whitelist certain extensions, but there is a way to blacklist ones you don't need. This can be done via the fossil settings command, which can also be abbreviated as fossil set. For example, to exclude .xls and .csv files, you can do:
fossil set ignore-glob '*.xls,*.csv'
The ignore-glob setting is a variable that will accept a comma- or newline-separated list of glob patterns. These will be ignored by fossil add, fossil addremove, fossil clean and fossil extra. You can use fossil set ignore-glob to query the current value of this variable.
The alternative (which allows for whitelisting) is to explicitly specify the files that you are adding. For example, if you're on Unix, you can do something like:
fossil add $(find . -name '*.R')
to only add the files that you need. For some shells, fossil add **/*.R may also work, and if you don't have any subdirectories, fossil add *.R should work anywhere.

Using %{buildroot} in a SPEC file

I'm creating a simple RPM installer, I just have to copy files to a directory structure I create in the %install process.
The %install process is fine, I create the following folder /opt/company/application/ with the command mkdir -p %{buildroot}/opt/company/%{name} and then I proceed to copy the files and subdirectories from my package. I've tried to install it and it works.
The doubt I have comes when uninstalling. I want to remove the folder /opt/company/application/ and I thought you're supposed to use %{buildroot} anywhere when referencing the install location. Because my understanding is the user might have a different structure and you can't assume that rmdir /opt/company/%{name}/ will work. Using that command in the %postun section deletes succesfully the directories whereas using rmdir ${buildroot}/opt/company/%{name} doesn't delete the folders.
My question is, shouldn't you be using ${buildroot} in the %postun in order to get the proper install location? If that's not the case, why?
Don't worry about it. If you claim the directory as your own in the %files section, RPM will handle it for you.
FYI, %{buildroot} probably won't exist on the target machine.

How to replace a folder in a pending cl in p4?

I want to replace folder A in P4 by another folder A.
The two folders have different files and sub folders.
I know, we can do it by deleting old folder A then adding new folder A.
But, can I do it with only one step in a pending changelist ?
As following result in that pending cl:
If this file is in old folder, but not in new folder, then it is marked by "delete".
If this file is in new folder, but not in old folder, then it is marked by "add".
If this file is in new folder and also in old folder, then it is marked by "modify".
Thank you
Are both these folders under source control?
That is, are you trying to make //depot/folder/A contain what //depot/other/A_prime contains?
If so, consider using 'p4 copy':
p4 copy //depot/other/A_prime/... //depot/folder/A/...
If the other folder A is just something you have on your hard disk, then consider using 'reconcile':
p4 edit //depot/folder/A/...
rm -r /path/to/depot/folder/A/*
cp -r /path/to/other/folder/A/* /path/to/depot/folder/A
p4 reconcile -aed //depot/folder/A/...
I kind of like the 'p4 copy' approach, myself, so I'd be tempted to check that other folder into Perforce (in a different location in the repository, naturally), so that I could then run 'p4 copy'.