There is interchanges command in perforce which lists changelists between two branches that have not been integrated with the convenience of a branchspec.
Is there something that shows the changelists that have been integrated something like the reverse of interchanges and also works with a branchspec?
More interested in terminal perforce rather than p4v.
Thanks
My recommended approach would be to do p4 changes on the source, run p4 interchanges between the source and target to get the source changes that have not been integrated, and diff the two to find the ones that have been integrated.
I'll also describe two other approaches that I would not recommend since they're a bit harder (but you might find elements of them useful):
Run p4 changes -i on the target and then run lots of p4 files commands to filter it down to the changes that originated on the source.
Run p4 integrated -b branch, run lots of p4 changes commands to convert the integration records into changelist ranges, and then sort them into a unified list.
Finding out if a changelist has been integrated into another branch in perforce is not simple. 'p4 interchanges' may not report everything as it relies on meta data and may 'think' that some changelists have been integrated.
Consider the case where CL10 was merged to branch B and then the changes were manually reverted via a 'p4 edit' instead of 'p4 undo' on B. Then if you run 'p4 integrate' with CL10 perforce returns with 'already integrated' message even though the code is no longer there (but might need to be).
Perhaps a solution to your question may involve combining ideas from Sam's answer above, 'p4 interchanges' and also running 'p4 integrate [-f]' within a loop to confirm that a set of changelists was indeed integrated. This is some work since the outputs of 'p4 resolve' and 'p4 diff/diff2' need to be considered.
My point is: do not solely rely on 'p4 interchanges'.
Related
Is there any CLI command that can be used to open Accurev Merge window from command line. Assume, I have already logged into Accurev.
I analysed, and understood till these commands
accurev guimerge - to get file's most recent version, merging version and common ancestor version.
accurev cat - to get the contents of a version of an element.
But, using these, I am not sure what is the command that can show the merge window so that user can merge the files manually.
I know that accurev merge command can display the result in command line. But, I am looking for the Accurev merge GUI to open up for me. I am sure this can be achieved but don't know how to proceed.
I can see there are tools like acdiffgui.exe in my accurev installation directory. Can I use it somehow to display Accurev Merge window?
Also, one more point is, I donot want to change Accurev preferences on the user's machine.
Use the -G option with the merge command.
From the CLI manual under section merge:
-G - Use AccuRev’s graphical Merge tool to perform the merge if there are conflicts which require human interaction (any value set in AC_MERGE_CLI is ignored).
I have a branch in Perforce on which I have checked in changes to several thousand files, and then later backed out the changes to approximately half of those files - so the latest revision of some of the files on the branch is unchanged from the baseline, but there are intermediate revisions with changes.
In many cases there have also been out-merges from mainline in the meantime, so the history is a bit more complicated, but the eventual result is that there are no content changes left to merge back to mainline.
I now want to merge that branch to mainline, but I don't want to check in "null" changes to the files that in the end were not modified on the branch.
Normally one can avoid checking in unchanged files with "Revert unchanged files" in p4v, but in this case it won't revert the files, because it believes that the file needs to be checked in to update the integration record. The help for p4 revert confirms this:
The -a flag reverts only files that are open for edit or integrate
and are unchanged or missing. Files with pending integration records
are left open. The file arguments are optional when -a is specified.
Is there any way I can avoid checking these files in without going through them one by one? I'm happy to do whatever is necessary on the branch, and I'm not too worried about it it causes future merges to the branch as I will be abandoning it soon after this merge.
If you're looking to revert files that have no differing content (i.e., where the only change is to update the integration record) you can do something like this batch file (you'll need to translate to a shell script if running on Linux):
for /f "tokens=2 delims=# " %%x in ('p4 diff -Od //depot/path/you/care/about/... 2^>nul ^| findstr /c:"//depot"') do (
p4 revert %%x
)
We use something similar where I work because we have a number of files that are marked +l and if we're doing an integration that takes a while to validate, the people that need to work on those files are locked out.
Assuming that the changes that got reverted were actually checked into the branch, and then backed out, my suggestion would be to (using extreme caution) obliterate the two revisions of the files that got reverted (the initial change, and the change that put it back to the initial state). I think that should prevent them from getting merged back into the mainline.
I would strongly suggest testing this out on a test branch before trying it on your live branch.
The client has asked me to submit changes into a different, pre-existing branch in their Perforce repo, but I'm having a tough time figuring out the process for that.
What's the Perforce equivalent of git checkout other-branch? Search engines are failing me; possibly because I'm using Git terminology and/or concepts that don't actually exist in p4.
Once I have the other branch "checked out" or whatever the correct p4 terminology is, can I just create and submit my changesets in the normal way?
Are there any caveats to doing this in the CLI versus p4v? I've mostly been using the latter because I'm a n00b.
Branch specs in Perforce are just different paths. If you have something like
//depot/product/main/...
in your p4 client spec, you'd change it to
//depot/product/branch/...
to get the branch, and use p4 sync to get the files and p4 add/edit/delete/submit as per usual to make changes. You'd merge changes between branches using p4 integrate.
See the Perforce docs for more info.
p4 workspace is the command you want. If you're using p4v you can just add that branch to a new workspace.
You may also find this handy dandy comparison chart useful. http://www.perforce.com/sites/default/files/command-comparison.pdf
Or this cheat sheet: https://jira.atlassian.com/secure/attachment/91198/cheat_sheet.pdf
When merging files it will be helpful (as for me) to show an author of each line. Is there any diff or merge tool supporting that?
The bundled gitk tool is not really a merge tool, but it shows conflicted lines with red and blue and "+"'s in front, and you can Rightclick->"Show origin of this line" on any of them, to go to the commit which introduced the line:
You can run your mergetool, or just a text editor with diffmarks in parallel
So what you really want is a tool that can easily identify your changes
relative to other's changes in a merge conflict, rather actually identify
the author of each line (which would be a mean to achieve that), right?
If I understood you correctly, I have some relatively good news: It
can be done with git + kdiff3. For merging you can just use git mergetool
(which you can configure to use kdiff3). But it is not supported natively
if you get a merge conflict when doing interactive rebase, so for that
some manual scripting is required.
Instead of making up my own simple merge conflict example, I will use
http://www.gitguys.com/topics/merging-with-a-conflict-conflicts-and-resolutions/
as an basis. Follow that page to git merge test. From after the merge
command I diverge a bit from that example by running different commands
(but basically doing the same job). I'll do all the manuall steps first.
So we have a merge conflict and git has inserted content from both
contributing sources into the file in this <<<<<<<...>>>>>>> format,
which I really do not like at all and never consider even looking at it.
Instead I use my favourite merge tool, kdiff3.
First we need to find which versions that are involved.
$ git ls-files -u
100644 b0ed415d15862ac5582b51e4de65528e86934cd2 1 README
100644 56300e3ac4e4521c3500618a301bb2ab2d6a52f5 2 README
100644 9585db7d9c2d9ca05075f67a878f2554886d7b1a 3 README
$
Basted that information we can perform a three way merge:
$ git cat-file blob b0ed415d15862ac5582b51e4de65528e86934cd2 > v1
$ git cat-file blob 56300e3ac4e4521c3500618a301bb2ab2d6a52f5 > v2
$ git cat-file blob 9585db7d9c2d9ca05075f67a878f2554886d7b1a > v3
$ kdiff3 -o merge_result v1 v2 v3 &
[2] 18394
$
Which gives the following view where you can select from which ancestor
you want to merge from.
Afterwords (if you are satisfied with the merge result)
you need to
$ rm v1 v2 v3
$ mv merge_result README
$ git add README
All the manual steps above are done automatically with git mergetool.
So why showing all that then? Well, because if you get a corresponding
conflict during git rebase -i, then it has to be done that way (before running git rebase --continue).
In this small example there is only one conflict
line, so it does not show the more typical case where a lot of lines
are automatically resolved, leaving you to just manually resolve the
ones that was not done automatically.
A more real life example might look more like the following:
Notice that in the merge result you now clearly see the origin of the C lines that
were automatically resolved. I think this is sort of what you were asking for when asking for getting the author for each line, right?
That information is completely absent in the <<<<<<<...>>>>>>> text (and it is difficult/impossible to spot that you should update the printed string in the hello function).
I cannot recommend kdiff3 highly enough. Using a graphical merge tool like that compared to some lines from both sources mixed inline in the file is like using an excavator versus a spade.
No. And, I think, never will be - when we merge, we think about content, not authorship
I am looking for a perforce command to get the list of the files that have been modified locally and "not" checked-in to the repository.
I understand that I "should" get the list of modified files in Pending changelist, but there are scenarios when I don't get to see a modified file in that list. And then on "manually" checking out a file and doing a diff i realize the difference.
Is there any command that could check all the files in a given folder and provide me a list of files that are not same as there state in the repository?
I tried "p4 sync", but that did not work.
Thanks for your interest.
Try
p4 diff -f -sa
(see manual for further details)
I use "p4 revert -n ./..."
where
-n
List the files that would be reverted without actually performing the revert.
This lets you make sure the revert does what you think it does before actually reverting the files.
In the recent versions of Perforce, try "p4 reconcile -e"
see: http://www.perforce.com/perforce/r12.1/manuals/cmdref/reconcile.html
It certainly takes its time though (not very fast).
I think, the modified files are submitted locallay (Otherwise, p4 opened ./... will help to find)
If files are already submitted to local perforce and still want to know which all are modified..
p4 changes -m 5 ./... (Should give changes lists)
p4 integrate -n ./... //server/code/base/... (This should list the files to be integrated to mainline.