Get latest transaction ID for AccuRev stream - version-control

I want to find out what the ID was of the latest transaction that changed a stream.
I figured I could use accurev hist -s NameOfStream -t now -fx, but I am not sure if this would also show changes that I get from upstream.
Let's assume I have the following tree in AccuRev:
MyDepot
StreamA
StreamA1
StreamA2
StreamB
In case I promote a change from StreamB to MyDepot, that also affects StreamA and its children, I want to see the transaction when calling accurev hist -s StreamA1 -t now -fx. Does this happen or do I need a different command?
Update: I checked and the hist command only shows transactions that occured in the specific stream I mentioned and not any upstream changes.
How can I detect a change in a stream with a single command, without having a local workspace?

You can't do it with Accurev alone but I wrote a python script that can. It is a part of my Accurev to Git conversion tool which you can find here:
https://github.com/NavicoOS/ac2git
If you clone that repository all that you need is the accurev.py script and its deep-hist sub-command. Use ./accurev.py -h and ./accurev.py deep-hist -h to see the usage.
Example use:
./accurev.py deep-hist -p MyDepot -s MyStream -t 20-highest
This will recursively run the accurev hist command on the stream and its parents and will print out the result. It shows you all the transactions that have the potential to change your stream. Not all of these transactions listed will have changed your stream, but you can use accurev diff -v MyStream -V MyStream -t 19-20 to see if your stream has changed at transaction 20 and applying to list of returned transactions should give you only the transactions that have changed something in your stream.

Related

Get all changelists (excluding user) between "mainline" and branch

Background
I have a "mainline" depot and a "beta" branch in Perforce (using simple branches: no streams, etc).
I would like to merge the latest code from "mainline" to my "beta" branch. I have to do this about once every day, and there are about 100+ commits/submissions to the "mainline branch" every day.
Normally, I would do something like so:
p4 integ //prod/mainline/... //prod/beta/...
cd $(p4 where //prod/beta/... | cut -d ' ' -f3 | sed 's/\.\.\.$//g')
p4 resolve ./...
Problem
However, we have an annoying hourly build process that updates version numbers in various Makefiles, build scripts, etc; that updates version/branch numbers, and is checked in to Perforce using a "dummy" account (i.e. dummy_user) by our build servers. This is done across all branches, causing any merge operation to have arbitrary conflicts.
This version number submission now prevents my p4 integ/p4 resolve operation from completing cleanly, and I have to hand-merge all of these files affected by the "version number update operation". I would like to just have to hand-merge actual code changes, rather than this version number nonsense.
Question
Is there a way to p4 integ a set of change-lists not yet present in the branch (but present in main/another-branch), excluding a user? I could always do something like:
for i in $(p4 changes //prod/mainline/... | grep -v dummy_user | cut -d ' ' -f2)
do
p4 integ //prod/mainline/...#${i},${i} //prod/beta/...
done
However, I don't have an automated way to get a list of all change-lists that:
Exist in mainline...
But haven't yet been merged/integrated into beta...
And aren't authored by dummy_user.
How can I accomplish this?
Sounds like you've found a solution that works for you, but FWIW here's what I'd do:
0) Make a branchspec since that makes this next part easier:
p4 --field "View=//prod/mainline/... //prod/beta/..." branch -o prod-main-beta | p4 branch -i
1) Ignore the robo-commits (I assume you want to just leave these things alone):
p4 -Ztag -F #=%change% ichanges -u dummy_user -b prod-main-beta | p4 -x - integ -b prod-main-beta
p4 resolve -ay
p4 submit -d "Begone, robo-cruft!"
2) Do the "real" integrate. If you find yourself still having to pick around the "dummy" changes, try the -Rs option -- that might give you more merges to do but it will bend over backwards to make sure those merges don't include anything you've already integrated.
p4 integ -b prod-main-beta [-Rs]
p4 resolve [-am]
p4 submit
Optional 3) Improve your build tooling so that the version info is located in a dedicated file, and other build files link to it. Then you can exclude your version file from your branch specs, or just always ignore changes to it without having to cherry-pick, or whatever. Here's a real-world example: https://swarm.workshop.perforce.com/files/guest/perforce_software/p4/2015-1/Version

Perforce: merge/integrate a release stream to the parent virtual stream

I have a main stream and a child virtual stream (say ProjVirt whose parent is Main). I created a release stream say rel1.0 from the ProjVirt stream - so that the changes can migrate from rel1.0 to ProjVirt.
Even the graph view shows the green merge arrow going from rel1.0 to ProjVirt (saying a merge is possible), but I cannot merge the changes from rel1.0 to the parent virtual stream. I keep getting the following warning:
p4 merge -c 324065 -S //depot/rel1.0 -P //depot/ProjVirt -s //depot/Main/myProj/...
no files opened
1 warning reported
No target file(s) in both client and branch view.
What am I doing wrong?
I am not sure that p4 merge take a -s parameter according to this documentation
p4 merge -c 324065 -S //depot/rel1.0 would merge from parent to child (this is the default direction).
If you want to merge in the other direction, you have to use the reverse syntax -r :
p4 merge -c 324065 -r -S //depot/rel1.0
I don't think you need anything else as target, because p4 can deduce the parent stream automatically from your stream config.
I think the original error message was due to the fact that changelist 324065 has no file in parent stream, but rather files in rel1.0. And since you were merging from parent, p4 found no file to merge.

Perforce - getting stream name in a trigger script

I want to create a trigger for preventing check-out on files if they belong to a specific stream.
I am using the pre-user-edit trigger.
The trigger executes a Perl script.
When I execute in the Perl script a p4 command, then I get this error:
Perforce password (P4PASSWD) invalid or unset.
What I did is getting the stream name out of the client name (which is passed to the Perl script):
$ stream = `p4 client -o $ client | grep ^Stream: | awk '{print \$ 2}'`;
chomp $ stream;
This does not work.
Also, trying to assign $p4 with new P4, fails.
Anyone has a clue how to solve this?
At least, give me a way to extract the stream name out the client name?
Thanks,
You must be logged in to Perforce to run p4 client. In interactive shell you do this by p4 login which prompts you for a password. Once that's validated, Perforce keeps you logged in for a week or so (depends on your P4 server setting). During that week your command should succeed, but once your session expires it will start failing again.
If session expiry is a problem for you, you will need to get hold of a non-expiring ticket. That must be enabled by your server admin (read "To create tickets that do not expire..." att p4 login). See also P4TICKETS.
As an alternative,
$ stream = p4 -F "%Stream%" -ztag client -o;
This would just give you the stream name(no trimming is required)
As an other alternative, use p4 switch to show the name of the current stream.

rsync using both --update and --append

I have a problem using rsync. Actually I want to synchronize 2 folders, one on the server (192.168.1.5) and one on my pc, the rsync command that I use is:
rsync -rvzru --exclude=._* xxx#192.168.1.5::Folder /Users/blabla/boh/received
It works fine, if a file has been modified on my server it modifies it also on my pc, skipping all the others. Now I want to introduce the resume feature, so I add --append like this:
rsync -rvzru --exclude=._* --append xxx#192.168.1.5::Folder /Users/blabla/boh/received
I also tried with --partial, but it doesn't work at all, it skips the uncompleted files while updates all the others if there was a modification. If I remove -U from the command the resume works fine, but if I modify a file on the server, I can't see the modification on my PC.
rsync -rvzr --exclude=._* --append xxx#192.168.1.5::Folder /Users/blabla/boh/received
There's a way to let this work both resuming and updating new files? Thanks

p4 sync Perforce command line to sync multiple trees to one changelist by entering the changelist only once

How can I sync 2 completely separate trees at a given changelist by entering the changelist only once, e.g. giving the same result as
p4 sync //tree1/a/b/c/...#1234 //tree2/d/e/...#1234
which works, but requires entering 1234 twice?
This gives "syntax error near unexpected token `('":
p4 sync (//tree1/a/b/c/... //tree2/d/e/...)#1234
This syncs //tree1/a/b/c/... to head instead:
p4 sync //tree1/a/b/c/... //tree2/d/e/...#1234
The main reason is that I want to make a shell alias but the 1234 part is user-entered, so it must be entered only once. I know I can use a shell script or function but for various reasons, I must use an alias.
From the comments, the (bash, at least) shell syntax of
p4 sync {//tree1/a/b/c/...,//tree2/d/e/...}#1234
should work. For more explanation, see the brace expansion section of the bash reference.