Perforce sync all files with a specific extension to revision #0 [closed] - perforce

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed last year.
Improve this question
I would like to be able to sync to revision #0 for all files with a specific extension (so they get deleted). These files are taking up too much space and I don't use them.
I have tried a few different things with no luck:
p4 sync //root/.../*.psd#0
p4 sync //root/...#0/*.psd
p4 sync //root/.../*.psd#0

The syntax you want is:
p4 sync //....psd#none
(#none is the idiomatic way to specify "no revision", but #0 and #0 should also work.)
The revision specifier always goes immediately after the file path, never in the middle of it. Providing a path like //root/...#0/*.psd should have gotten you an error like Invalid revision number '0/*.psd'.
Note that if your server is case-sensitive (the default if it's hosted on a Unix platform), all parts of a file path are case-sensitive, so you may need to do both .psd and .PSD to cover all your bases.
The following variations might work, with caveats:
p4 sync //.../*.psd#0 -- this works, but is slower due to the double wildcard. You almost never want to do .../* in place of simply ....
p4 sync //root/.../*.psd#0 -- this should also work, but only in a depot that is literally called root. The "root" of the repository (i.e. the parent "directory" of all depots) is just //. If you ran a command against a //root/... path and there is no root depot, you should have gotten an error like //root/... - must refer to client 'yourclient', which is the error you get if you try to reference a specific domain (//something) that isn't a depot and isn't your current client.

Related

How to get the last added folder to a directory [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I work in a software development company and every day upon my machine boot I have to execute the same commands to start coding. I recently decided to create a bash script to do that for me. The problem is that the commands I need to type have a single difference from one another, and that is the folder I need to access.
I always have to access a directory where it will contain folders with different versions of the company code (let's call it "codes" for the sake of the discussion), and everyday another folder is added to the "codes" directory (they update the company code everyday) with name as timestamp e.g. 2021-07-05-17-52-51.
To be able to create my automation script I need to be able to get into the "codes" directory and get the most recent folder added to it, or get the latest timestamp.
I am new to bash and I couldn't find answers on how to get the last added folder to a directory using bash or someway to use tab and get the last one.
You can use something like this:
directory=$(ls -At1 | head -n 1)
An explanation in parts:
ls -At1 lists sorted by time with one entry per line
head -n 1 returns the first entry
$(...) runs the command as a subshell, evaluates, and sets directory to the name of the item with the most recent modified datestamp. If you want to ignore hidden files and folders, you can lose the -A flag from ls.

Is there a way to automatically backup files everyday and highlight diffs everyday [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
Background: Sometime while editing my code, an important line had gotten deleted. I do not know how. In any case, I had a backup I had manually made of the code elsewhere with which I was able to do a diff and incorporate the missed line.
Is there a way/application to make the above process automatic daily either on windows or on linux?
That is, is there a way without manual intervention, to backup specific files (text-based code files) on a daily basis (ideally, this should be user specified) and each time the user wants to check the change from any of the previous versions (including, say, yesterday's), the change can be highlighted?
Can this be setup on git, say? From what I understand, even on git, this would be a manual process. Is there a way to automate this by writing a batch file or script, etc.? For some reason, git appears a bad idea for this since ideally, I would like to save on git only working code and not buggy code. I'd like to do this backup and daily diff on code that is in development and nowhere close to being in production.
Based on this link, I was able to create a batch file on windows that does this using 7zip. I have the following structure: c:\myproject\ under which there is \src\ and \include\. A date-stamped zip file, src_date.zip and include_date.zip get created on running the following batch file in c:\myproject\zipdir\.
#ECHO OFF
SETLOCAL EnableExtensions EnableDelayedExpansion
REM ---- change according to your 7-zip path
set path="c:\Program Files\7-Zip";%path%
set "zipdirsrc=C:\myproject\src"
set "zipdirinc=C:\myproject\include"
set "movedir=C:\myproject\zipdir"
REM ---- end change accordingly
pushd %zipdirsrc%
Set TODAY=%date:~4,2%-%date:~7,2%-%date:~10,4%
ECHO Zipping all contents of %zipdirsrc% and moving archive src to %movedir%
7z a -tzip "%movedir%\src_%TODAY%.zip" -r "%zipdirsrc%\*.*" -mx5
ECHO SRC Task Complete ...
pushd %zipdirinc%
Set TODAY=%date:~4,2%-%date:~7,2%-%date:~10,4%
ECHO Zipping all contents of %zipdirinc% and moving archive include to %movedir%
7z a -tzip "%movedir%\include_%TODAY%.zip" -r "%zipdirinc%\*.*" -mx5
ECHO INCLUDE Task Complete ...
EXIT /B 0
It does not automatically highlight the diff (that is something I would have to do outside, I suppose), and I would have to run this manually, but before I embark on any major code change in development, this creates a zipped copy of the folders I need.

Restructuring the directories in linux/unix [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have several directories structured like this in a parent directory:
/app/bpp/cpp/dpp/ASM/Report
/ghh/hhh/hhh/ASM/Report
/hh/ASM/Report
As we see above, all the ASM directories have Report directories in them along with other sub directories and files. I want a separate directory that has a parent directory to ASM (with ASM only), and ASM with Report directory in it. The result should look like this:
/dpp/ASM/Report
/hhh/ASM/Report
/hh/ASM/Report
It's not absolutely clear what you are asking; do you want to make a copy of the initial directories; do you want rather to move the initial directory to a new location? (Since you seem to want something related to "shell script" you should also tag your question with these words).
The best would probably to start with find; the following command:
find / -type d -name Report
will list all directories called Report; you could pipe the output of this command to grep in order to select those ending with /ASM/Report with:
find / -type d -name Report | grep "\/ASM\/Report$"
this would give to you a good starting point for detecting the directories to be moved/copied.
You can also use the -exec option of find for directly perform some action on a file or directory found by the command. You should type man find in order to see all the power of this tool.
It looks like you will have to search in the whole filesystem; thus find may print some warnings (related to permissions), but it shouldn't hurt; you can discard these warnings (if any) by ending the find command with 2>/dev/null for discarding the stderr stream (the error messages).

What is the p4 command equivalent to something like svn status [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to find untracked files in a Perforce tree? (analogue of svn status)
I want to know what p4 command that will show me which files have changed, which files are not checked in, etc.
If you're using perforce properly, "p4 opened" is what you're looking for. It will tell you what files you have opened for change. If you want to be able to change files locally, THEN open them for edit (or delete, etc.,) then you're walking out of the usage patterns that perforce expects users to abide by and you're treading on dangerous ground.
Perforce does provide mechanisms that will allow you to detect these things - if you're going to insist on working this way. "p4 fstat" will allow you to get the expected md5sum for a file from the server. Comparing that with the local md5sum will tell you if the file has changed. You could, alternatively, compare file dates - if the modification date on your local machine does not match that given by fstat, you can be fairly certain that it has changed, but to be certain, you'd have to do the md5sum check.
In the upcoming 2012.1 release there a new command named p4 status that will do the equivalent to that as if you were using SVN.
p4 status
src/tools/this.rb - reconcile to edit //depot/stuff/src/tools/this.rb#3
src/tools/that.rb - reconcile to add //depot/stuff/src/tools/that.rb#1
src/tools/other.rb - reconcile to delete //depot/stuff/src/tools/other.rb#2
For more information, read the announcement on the Perforce Blog.
While awaiting the official 2012.1 release you have basically two options:
Do it yourself using the command line
Use P4Vs "Reconcile Offline Work"
More details can be found in the Perforce KB.

Perforce: Linux based 3-way merge/resolve tool? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
I'm looking for a Linux-based tool for 3 way merging/resolving, using Perforce. I'm familiar with vim/vimdiff, but I don't know how/if they can be used for 3 way merging. In either case, do let me know what, according to you, is the best merge/resolve tool on Linux.
For clarity, let me add that I'd prefer a tool which doesn't requires X server i.e. can be used through putty.
I prefer meld It is powerful yet lightweight and has no KDE deps as Kdiff3 does.
Look at official homepage
If you're dead set on not using an X client, try taking a look at emacs' ediff. That works in text mode (though it's easier in X).
I guess you are talking about resolving files in three way diff tool. The different versions are,
ORIGINAL
THEIRS
YOURS
Now, to do that a little setup is needed in linux. I have a .p4config file that defines my preferable diff tool.
P4CLIENT=mywork
P4DIFF=diff -u
P4EDITOR=vi
P4IGNORE=.p4ignore
Here P4DIFF is set to diff -u. To make the whole thing work the .p4config file needs to be plugged to perforce by environment variable.
export P4CONFIG=.p4config
Now it is the sweet-spot. We need to actually do the resolve by p4 resolve command.
p4 resolve /path/to/mysource.h
As soon as we do that, it shows that there is conflict as someone modified the original version we were working. So it prompts for our action.
/path/to/mysource.h - merging //stream/version/path/to/mysource.h#2
Diff chunks: 13 yours + 2 theirs + 0 both + 1 conflicting
Accept(a) Edit(e) Diff(d) Merge (m) Skip(s) Help(?) e: d
We can see the diff by pressing d.
--- /path/to/mysource.h 2016-09-28 18:34:54.918709150 -0400
+++ /path/to/tmp.6365.102 2016-09-29 11:05:32.228946564 -0400
## -16,6 +16,7 ##
we are same in all branches
same as everywhere
+ added line
more same
## -28,7 +29,12 ##
here you go the conflict
+>>>> ORIGINAL //stream/version/path/to/mysource.h#1
+ the original line is here
+==== THEIRS //stream/version/path/to/mysource.h#2
+ their line is here
+==== YOURS /path/to/mysource.h
my line is here
+<<<<
Accept(a) Edit(e) Diff(d) Merge (m) Skip(s) Help(?) e: e
Now it is possible to fix this typing e. It will open an editor where we can compare the different versions in between the +==== lines and +<<<< lines.
Once we are done with editing we can accept by typing a.
Accept(a) Edit(e) Diff(d) Merge (m) Skip(s) Help(?) ae: a
The whole process can be done from remote command/shell window. So there is no X-server is needed.
I have something called diff3, which has a merge option. I'm not sure where it came from and I have not used it. diff3 -m file1 file2 file3. Take it for what it's worth.
Btw, I'm running OpenSuSE 11.2, if that helps.

Resources