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

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'.

Related

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.

Move large number of files in Fossil repo

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.

Installing OpenCart extensions locally

When installing OpenCart extensions, you´re generally given a bunch of folders that should be copied to the root directory and the extension files will find their way to the right subfolders. This works great in FTP software, but on a local installation (Mac OSX) using Finder, this operation makes Finder want to overwrite the folders completely, deleting the actual site and just keep the extension.
I can hold Alt when dragging the folders and it will give me the option to not overwrite, the problem is I have hidden files visible, which means there's now a .DS_STORE file in each folder and the ”Hold ALT”-approach doesn’t work in case there are ANY duplicate files in any of the folders.
I’m sure someone out there has stumbled upon the same problem, any ideas for how to solve such a simple but annoying problem? I do not wish to use FTP software for local file management.
I have the same problem, and i found 3 different ways to solve this:
a - use another file manager, i personally use "Transmit" to do this sort of things;
b - use terminal, like: ditto <source> <destination>. Or easier way just type ditto, and drag the source folder, then drag the destination folder, all inside source will merge inside destination;
c - unzip the plugin, inside the OC folder using the terminal, like: tar -zxvf plugin.zip;

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.

Mercurial ignore part of a directory

Been fighting with Mercurial's .hgignore for a while under Windows.
I have a folder named Upload which is currently empty. I do want it tracked so I added a .empty file in it which work fine. I want this so that new developers doing an hg clone get the Upload document required for the application.
Thing is I never want the folder to be populated with anything on the source control itself (test uploads from a development machine).
Example:
If I add Public/image.jpg it wouldn't be tracked.
Additionally I would like it for sub directory to be tracked. So if developer adds
Upload/users/.empty I would like this to be tracked.
Is this possible with regex voodoo?
In mercurial (and unlike in svn and cvs) adding a file overrides the .hgignore file, so you can put this in your .hgignore:
^Uploads/.*
and your Upload/.empty that you added will still be created on update and thus they'll get the directory.
Getting it to ignore files in upload but not not ignore files in subdirectories in Upload could be done with:
^Uploads/[^/]*$
which says: ignore anything that Starts with Uploads and has no further slashes in it.
Really though, you should be creating Uploads with your build/install/configure script when possible, not with the clone/update.
Try putting
Uploads/(?!.empty)
in .hgignore in the root of the repository
Try
^Uploads\b.*/(?!\.empty)[^/]+$
This should match any path starting with Uploads where the text after the last slash (=filename) is anything but .empty.