I'm using a single depot containing multiple projects stored in a directory-file structure. Each project can have multiple revisions, assigned outside of Perforce, e.g. A, B, C...
In Perforce (command line) I would like to assign these revision codes to corresponding perforce versions/changes, so that I can easily look up commits from each revision etc.
Multiple commits (changelists) can be attributed to each revision code.
My first thought was to somehow tag the files/changelists/? using labels called "A", "B", "C", etc., but as a given label can only be assigned to one version of a given file this would mean only one commit (the latest?) would be tagged for each revision. Plus, I'm not sure this would work for multiple projects.
So, is there a relatively simple way to achieve this within perforce?
Perforce File Attributes may allow you to achieve what you want, as they can be propagated to future revisions and allow you to set per revision attributes.
More information about them can be found here:
http://www.perforce.com/perforce/doc.current/manuals/cmdref/p4_attribute.html
You can't parse a changelist number to this command, but a bit of scripting could get you the revision numbers for files in particular changelist, which you could then tag with a particular attribute.
Hope this helps,
Jen.
Related
Here's the scenario -
Development branch was created from mainline, with many thousands
of files in it
A couple of thousand files were modified.
Changes from mainline were "p4 integrated" into the branch.
Hopefully integrations always included the complete mainline as of a
known-good label, but I'm not sure of this
Steps 2 and 3 were repeated an unknown number of times - let's guess
a dozen integrates, and probably another 1000 or more changes,
usually to files already modified
I am now in the painful position of trying to code review this.
Are there any commands that can help me get the diffs for each modified file between the version last integrated to it, and the version in the branch?
Or do I need to write:
A script which will identify all locally changed files.
A script which will find the integration point for each file in the above list
Another script which will use (2) to purge the list in (1) of files with no net change
A wrapper on (2) that will issue an appropriate p4 diff2 command
FWIW, I basically know how to do this manually, file by file. It's the scale that's daunting. Also, there are changes still going into the branch, in response to code review feedback, so I'll probably be recreating my lists repeatedly.
If you know what the known-good label in the mainline was that was used to do the last integrate, this should just be:
p4 diff2 main/...#good-label dev-branch/...
since for each file "the version last integrated" will be #good-label. Files that weren't locally modified won't have any diffs, so there's no special need to filter them out.
FWIW if I were in your position I'd be making use of "p4 ichanges dev-branch/... main/..." and going through by changelist, since diffs make more sense when each is in the context of its changelist, rather than looking at one monster diff per file that each contains a dozen unrelated changes.
I have some files, like upgrade01.x and upgrade02.x, where the name defines some order. Due to external constraints, I must use this naming convention but I want so swap them, 01 become 02 and 02 become 01. I tried renaming update01.x to a temp name (without submitting it), then tried change update02.x to be update01.x but perforce doesn't let me do that.
I can submit the rename to something temporary, then rename one to the other, then the rename the temp, but is a monster pain. Also, the history looks really weird (but that might be unavoidable).
Is there a way to do this in one sane operation?
Doing the rename in two steps (rename both to intermediate names, then each back into the place of the other) might be the preferred option if you want the "identity" of each file to follow it to the new name (e.g. when you merge from other branches, you want merges to be remapped according to the new name rather than going to the old one).
If your priority is to have this happen in a single changelist, though, and you're not so concerned about whether the history preserves the notion of which file is which, I'd do it like this:
p4 copy upgrade01.x upgrade02.x
p4 copy upgrade02.x upgrade01.x
p4 submit
This will get you a nice neat little X in the revision graph (which I suspect is what you want), but not a true rename.
Merging to/from other branches will be a little tricky either way; if you go the true rename option, when you merge the rename to other branches you'll need to go change by change to repeat the process of renaming to something intermediate and then back (since the target branch will have the same constraint of not being able to rename onto something that is itself already open for rename). If you go the copy option, you'll need to manually specify which file to merge into which depending on what state each branch is in and whether there are outstanding changes requiring an actual merge.
I've looked at this similar question but I'm still fairly lost. I have one file which I want to be a part of multiple changelists. I seem to remember that doing this involves creating multiple clients, but that's stumping me, too. I can create a client just fine, but I can't figure out how to "check out" that client and start creating a separate CL in that client, one that is independent from the CLs I have started in my original client.
Any help would be hugely appreciated!
(It's also worth mentioning that I'm working on a source control system that's forked from perforce, not exactly perforce).
One file can only be part of multiple submitted changelists if each changelist has a different revision -- e.g. if you add a file to the depot its revision #1 is in one changelist, when you edit it and submit that its revision #2 is in another changelist, and so on. Same file, different revisions.
One file can be part of multiple pending changelists at the same time (all derived from the same revision) if each changelist is on a different client. If you're creating different clients on one machine, make sure that each has its own unique client root, since you'll want to have unique copies of the file(s) on your local machine. Then you don't need to do anything special to open the file; each client is independent of the others. Just "p4 sync" and "p4 edit" the same way you did on your first client. (Make sure to use P4CLIENT or the equivalent to specify which client you're using at any given time; P4CONFIG files make this easier by associating a P4CLIENT setting with a particular working direcotory.) The only difference you'll see is an informational message from "p4 edit" that the file is already open by another client. Creating changelists works the same way as it always does; run "p4 change" to create a pending change, "p4 reopen -c change" to move files around between changes.
There is also shelving, which is similar in some ways to having multiple pending changelists on different clients (except that the changelists are all stored on the server rather than in a bunch of different client workspaces) but if you happen to be using a very old version of Perforce (or something similar to it) that's probably not an option.
Let's say I've shelved files A,B,C
I now want to unshelf this into a different branch, but my spec only has files A,B
Is there any way to do this so that perforce will unshelf the files that are mapped and ignore the rest? Right now I get an error which prevents me from doing any unshelving.
The use case here is I have one branch where I compile a third party lib, and I'd like to move over just the binaries and the public header changes. This changelist is huge so I'd rather not have to manually shelf only what is mapped.
To my knowledge I don't think you can use shelving to move changes from one branch to another. That would be a Merge/Copy depending on the situation.
Using shelving to do that would be a bypass of the (not saying malicious or intentional) versioning process.
(I am a new perforce user, but have used lots of other source code control systems in the past.)
We use a change list to check-in each bug fix; the change list comment includes the bug ID therefore it is easy to track when a bug fix has been checked into a branch.
However I can’t see an easy way to find all branches a given bug fix has been merged into, or to find all bug fixes that have been merged into a given branch.
As far as I can tell perforce does not track all the branches a change list have been merged into. As I understand it, when a merge is done in perforce the history is not copied into the target branch so the only history in the target in the comment on the change list the merge was done into.
What am I missing?
Perforce tracks where revisions of a file have been integrated, but it doesn't automatically propagate check-in comments with your bug-tracking metadata.
Given a changelist on a particular branch, you can tell whether Perforce thinks the changelist has been integrated by asking Perforce to integrate the changelist. (I'm using "branch" in the more traditional source-control sense, to mean a particular branch of the source code tree, rather than in the specific Perforce sense to mean the path of integration between these two source code trees.) Let's say you've been working in //source/project/trunk/... and you have a changelist #1234 that you'd like to check whether it's been integrated into your release branch //source/project/rel/.... Create a client that maps //source/project/rel/... and execute:
$ p4 integrate -n //source/project/trunk/...#1234,1234 //source/project/rel/...
If Perforce tells you "All revision(s) already integrated.", changelist #1234 has been integrated, and that bugfix ought to be available on the release branch. If Perforce lists files that have changed, those files have not been integrated. (It's also possible for some files in a changelist to be integrated and not others, which may make for some interesting problems.)
This doesn't scale especially well -- you need to check each bugfix on each branch you care about, though it does lend itself to automation.
You can use the "unsupported" Perforce command interchanges to get a quick idea of what changelists have not been integrated from one branch into another. (In Perforce parlance, "unsupported" means something like "might not work the same in the next revision, but we think it could be useful so we'll release it anyway".) To see what changelists haven't been integrated from our example trunk to release branches, execute:
$ p4 interchanges //source/project/trunk/... //source/project/rel/...
Change 1236 on 2010/10/10 by user#client 'Fixed some bug you don't care about'
Change 1235 on 2010/10/09 by user#other_client 'Fixed some other random bug'
In this example, I haven't listed changelist #1234 because it's already been integrated into the release branch. One problem I've experienced using interchanges is it'll list every newer revision after an unintegrated change, even if the newer revisions themselves have been integrated, so if you're cherry-picking revisions for a release branch you may see changelists listed again. I use interchanges as a first pass to get a rough idea of what I need to integrate, then look at integrate to get a better idea of what's really missing.
(Perforce also supports a similar concept of "jobs", that let one attach particular fixes to particular changelists, but my organization doesn't use them so I don't know how well they work or whether they are propagated automatically on integration.)