how to exclude all target subfolders in perforce - perforce

I have a project like:
/a
/a/one/src/...
/a/one/target/...
/a/second/src/...
/a/second/target/...
/a/third/one/target/...
....
/a/million/staff/other/target/xxx.class
I need to make p4 status to ignore all target subfolders:
cd a
p4 status
<do not output anything is */target/*>
cd one
p4 status
<do not output anything is */target/*>
Within p4 ignore documents looks like it's all about single folder, that is not my case

Add target/ to your P4IGNORE file.
C:\test>p4 status
dir\target\foo - reconcile to add //stream/main/dir/target/foo#1
dir1\target\bar - reconcile to add //stream/main/dir1/target/bar#1
C:\test>echo "target/" >> p4ignore.txt
C:\test>p4 status
No file(s) to reconcile.
If you need something a little stronger than P4IGNORE (e.g. you want to exclude target/ folders that other people have already added to the depot), you can exclude these folders from your client view like this:
View:
//depot/... //client/...
-//depot/.../target/... //client/.../target/...

Related

In perforce, how to remove a symlink to a directory and add files in the same directory?

This can be done like this:
1. p4 delete dir,
p4 submit;
2. p4 add dir/file,
p4 submit;
Is there a way to do this in one go?
I don't want to do p4 submit in step 1 because not having that directory will break things at my end.
There does not seem to be anything preventing this:
C:\Perforce\test\dir>p4 opened
//stream/main/dir#1 - delete default change (symlink)
//stream/main/dir/bar#1 - add default change (text)
//stream/main/dir/foo#1 - add default change (text)
C:\Perforce\test\dir>p4 submit -d "presto"
Submitting change 106.
Locking 3 files ...
delete //stream/main/dir#2
add //stream/main/dir/bar#1
add //stream/main/dir/foo#1
Change 106 submitted.

rsync is nesting the source directory in the destination as if it had no trailing slash when --files-from option is used

Pulling my hair out here trying to get this to work. Heres an example of the details and command.
I have a file with a list of directories named list.txt The contents look like this:
HYTTCCCXX
HYTVNCCXX
HYV5TCCXX
My rsync command looks like:
rsync -av --recursive --files-from='/tmp/list.txt' /test/apple/ /destination/files/
The issue is that when I run the command, it includes both
/test/ (which is an autofs top level, so contains nothing really) and /test/apple/ in the files to be transferred. Causing the files to be written twice into the destination as if I left the trailing slash off my source.
So the destination ends up with both the directories in the list, and another copy of the source like:
/destination/files/HYW22CCXX
/destination/files/HYTVNCCXX
/destination/files/HYV5TCCXX
/destination/files/test/apple/HYW22CCXX
/destination/files/test/apple/HYW22CCXX
/destination/files/test/apple/HYTVNCCXX
So I end up with 2 copies of everything.
Ive tried every combination of exclude like --exclude='/test/apple/' or --exclude='/test/* or --exclude='apple/* to try and keep it from being included. But nothing works.
Any ideas? Im going bananas trying to figure this out.
Thank you!
This is due to the fact that the --files-from option implies --relative.
Quote from the rsync man page, the section on --files-from:
The --relative (-R) option is implied, which preserves the path information that is specified for each item in the file (use --no-relative or --no-R if you want to turn that off).
Try the following options and see if it helps:
rsync -av --recursive --no-relative --files-from='/tmp/list.txt' /test/apple/ /destination/files/

Can't add files in perforce

As far as I can tell, my client is setup correctly:
$ p4 client -o
# A Perforce Client Specification.
# ...
Client: stephen-dev1-stephen
Update: 2014/06/26 17:41:14
Access: 2014/06/26 17:45:47
Owner: StephenRasku
Host: stephen-dev1
Description:
Created by StephenRasku.
Root: /home/stephen/Code
Options: noallwrite noclobber nocompress unlocked nomodtime rmdir
SubmitOptions: submitunchanged
LineEnd: local
View:
//depot/labs/products/component/SpamView-URI/... //stephen-dev1-stephen/SpamView-URI/...
//version/... //stephen-dev1-stephen/version/...
//thirdparty/... //stephen-dev1-stephen/thirdparty/...
//starteam/... //stephen-dev1-stephen/starteam/...
//specs/... //stephen-dev1-stephen/specs/...
//release/... //stephen-dev1-stephen/release/...
//projects/... //stephen-dev1-stephen/projects/...
//main/... //stephen-dev1-stephen/main/...
//features/... //stephen-dev1-stephen/features/...
//dev/... //stephen-dev1-stephen/dev/...
//depot/... //stephen-dev1-stephen/depot/...
The files exist:
$ pwd
/home/stephen/Code/SpamView-URI
$ ls mainline/EBUILD_VERSION mainline/package.sh mainline/ebuild
mainline/ebuild mainline/EBUILD_VERSION mainline/package.sh
But it complains when I try and add them:
$ p4 add mainline/EBUILD_VERSION mainline/package.sh mainline/ebuild
mainline/EBUILD_VERSION - file(s) not in client view.
mainline/package.sh - file(s) not in client view.
mainline/ebuild - file(s) not in client view.
What's the problem? I checked out the file using git p4 clone if that makes a difference.
Check the "View" lines in the client workspace specification to confirm
that the file specification used in your Perforce command (or appearing in the error message)
falls within your workspace view. If you see an error attempting to add a file,
for example, you might want to check your mapping to confirm that the
file resides in a directory that is within your client view.
See the section under 'Client Workspace View':
http://answers.perforce.com/articles/KB_Article/Common-Permissions-and-File-Access-Problems
Are the files under this exact directory structure below?
/home/stephen/Code/SpamView-URI/mainline/EBUILD_VERSION
/home/stephen/Code/SpamView-URI/mainline/package.sh
/home/stephen/Code/SpamView-URI/mainline/ebuild
Judging by the first View mapping line of:
//depot/labs/products/component/SpamView-URI/... //stephen-dev1-stephen/SpamView-URI/...
I would guess that is the path they should be under.
If you 'cd' into the '/home/stephen/Code/SpamView-URI/mainline'
directory are you able to add these files?
Your client spec isn't right, as you noticed. With these 2 lines,
//depot/labs/products/component/SpamView-URI/... //stephen-dev1-stephen/SpamView-URI/...
//depot/... //stephen-dev1-stephen/depot/...
Your trying to map the files under //depot/labs/products/component/SpamView-URI/... to both //stephen-dev1-stephen/SpamView-URI/... and //stephen-dev1-stephen/depot/labs/products/component/SpamView-URI/... Since perforce reads top to bottom, it will overwrite your first mapping with the second mapping, basically removing the second mapping. \
Move your //depot/labs/products/component/SpamView-URI/... //stephen-dev1-stephen/SpamView-URI/... to the last line, and you should be ok.

How to find (grep) text for files in a perforce changelist?

How to grep/find for a particular text in all files within a pending changelist?
My use case:
I have a debug_flag in my code and would want to make sure I do not check-in any code with the debug_flag which will cause a compiler error for all others. (Not for me since I have the debug_flag declared locally)
p4 describe changelist# gives you the list of the files in a changelist, but it has some extra information, and the paths are with respect to the depo. Example:
p4 describe 12334
output:
Change 12334 by me on 2014/01/04 00:57:08 pending
Some test changelist
Affected files ...
... //depot/path/to/my/files/file1#15 edit
... //depot/path/to/my/files/file2#12 edit
With a few search/replace or a simple perls script, you can change this text output to a list of files with actual path and then run grep on them:
xargs grep "debug_flag" < file_list.txt

Using Rsync include and exclude options to include directory and file by pattern

I'm having problems getting my rsync syntax right and I'm wondering if my scenario can actually be handled with rsync. First, I've confirmed that rsync is working just fine between my local host and my remote host. Doing a straight sync on a directory is successful.
Here's what my filesystem looks like:
uploads/
1260000000/
file_11_00.jpg
file_11_01.jpg
file_12_00.jpg
1270000000/
file_11_00.jpg
file_11_01.jpg
file_12_00.jpg
1280000000/
file_11_00.jpg
file_11_01.jpg
file_12_00.jpg
What I want to do is run rsync only on files that begin with "file_11_" in the subdirectories and I want to be able to run just one rsync job to sync all of these files in the subdirectories.
Here's the command that I'm trying:
rsync -nrv --include="**/file_11*.jpg" --exclude="*" /Storage/uploads/ /website/uploads/
This results in 0 files being marked for transfer in my dry run. I've tried various other combinations of --include and --exclude statements, but either continued to get no results or got everything as if no include or exclude options were set.
Anyone have any idea how to do this?
The problem is that --exclude="*" says to exclude (for example) the 1260000000/ directory, so rsync never examines the contents of that directory, so never notices that the directory contains files that would have been matched by your --include.
I think the closest thing to what you want is this:
rsync -nrv --include="*/" --include="file_11*.jpg" --exclude="*" /Storage/uploads/ /website/uploads/
(which will include all directories, and all files matching file_11*.jpg, but no other files), or maybe this:
rsync -nrv --include="/[0-9][0-9][0-9]0000000/" --include="file_11*.jpg" --exclude="*" /Storage/uploads/ /website/uploads/
(same concept, but much pickier about the directories it will include).
rsync include exclude pattern examples:
"*" means everything
"dir1" transfers empty directory [dir1]
"dir*" transfers empty directories like: "dir1", "dir2", "dir3", etc...
"file*" transfers files whose names start with [file]
"dir**" transfers every path that starts with [dir] like "dir1/file.txt", "dir2/bar/ffaa.html", etc...
"dir***" same as above
"dir1/*" does nothing
"dir1/**" does nothing
"dir1/***" transfers [dir1] directory and all its contents like "dir1/file.txt", "dir1/fooo.sh", "dir1/fold/baar.py", etc...
And final note is that simply dont rely on asterisks that are used in the beginning for evaluating paths; like "**dir" (its ok to use them for single folders or files but not paths) and note that more than two asterisks dont work for file names.
Here's my "teach a person to fish" answer:
Rsync's syntax is definitely non-intuitive, but it is worth understanding.
First, use -vvv to see the debug info for rsync.
$ rsync -nr -vvv --include="**/file_11*.jpg" --exclude="*" /Storage/uploads/ /website/uploads/
[sender] hiding directory 1280000000 because of pattern *
[sender] hiding directory 1260000000 because of pattern *
[sender] hiding directory 1270000000 because of pattern *
The key concept here is that rsync applies the include/exclude patterns for each directory recursively. As soon as the first include/exclude is matched, the processing stops.
The first directory it evaluates is /Storage/uploads. Storage/uploads has 1280000000/, 1260000000/, 1270000000/ dirs/files. None of them match file_11*.jpg to include. All of them match * to exclude. So they are excluded, and rsync ends.
The solution is to include all dirs (*/) first. Then the first dir component will be 1260000000/, 1270000000/, 1280000000/ since they match */. The next dir component will be 1260000000/. In 1260000000/, file_11_00.jpg matches --include="file_11*.jpg", so it is included. And so forth.
$ rsync -nrv --include='*/' --include="file_11*.jpg" --exclude="*" /Storage/uploads/ /website/uploads/
./
1260000000/
1260000000/file_11_00.jpg
1260000000/file_11_01.jpg
1270000000/
1270000000/file_11_00.jpg
1270000000/file_11_01.jpg
1280000000/
1280000000/file_11_00.jpg
1280000000/file_11_01.jpg
https://download.samba.org/pub/rsync/rsync.1

Resources