3 repository - Using the Perl repository
7 First, we assume here that you have already decided that you will
8 need B<write> access to the repository. If all you need is B<read>
9 access, there are much better ways to access the most current state of
10 the perl repository, or explore individual files and patches therein.
11 See L<perlhack> for details.
13 This document describes what a Perl Porter needs to do to start using
18 You'll need to get hold of the following software.
24 Download a perforce client from:
26 http://www.perforce.com/perforce/loadprog.html
28 You'll probably also want to look at:
30 http://www.perforce.com/perforce/technical.html
32 where you can look at or download its documentation.
36 If you don't already have access to an ssh client, then look at its
37 home site C<http://www.cs.hut.fi/ssh> which mentions ftp sites from
38 which it's available. You only need to build the client parts (ssh
39 and ssh-keygen should suffice).
43 =head1 Creating an SSH Key Pair
45 If you already use ssh and want to use the same key pair for perl
46 repository access then you can skip the rest of this section.
47 Otherwise, generate an ssh key pair for use with the repository
52 After generating a key pair and testing it, ssh-keygen will ask you
53 to enter a filename in which to save the key. The default it offers
54 will be the file F<~/.ssh/identity> which is suitable unless you
55 particularly want to keep separate ssh identities for some reason.
56 If so, you could save the perl repository private key in the file
57 F<~/.ssh/perl>, for example, but I will use the standard filename
58 in the remainder of the examples of this document.
60 After typing in the filename, it will prompt you to type in a
61 passphrase. The private key will itself be encrypted so that it is
62 usable only when that passphrase is typed. (When using ssh, you will
63 be prompted when it requires a pass phrase to unlock a private key.)
64 If you provide a blank passphrase then no passphrase will be needed
65 to unlock the key and, as a consequence, anyone who gains access to
66 the key file gains access to accounts protected with that key
67 (barring additional configuration to restrict access by IP address).
69 When you have typed the passphrase in twice, ssh-keygen will confirm
70 where it has saved the private key (in the filename you gave and
71 with permissions set to be only readable by you), what your public
72 key is (don't worry: you don't need to memorise it) and where it
73 has saved the corresponding public key. The public key is saved in
74 a filename corresponding to your private key's filename but with
75 ".pub" appended, usually F<~/.ssh/identity.pub>. That public key
76 can be (but need not be) world readable. It is not used by your
79 =head1 Notifying the Repository Keeper
81 Mail the contents of that public key file to the keeper of the perl
82 repository (see L</Contact Information> below).
83 When the key is added to the repository host's configuration file,
84 you will be able to connect to it with ssh by using the corresponding
85 private key file (after unlocking it with your chosen passphrase).
87 =head1 Connecting to the Repository
89 Connections to the repository are made by using ssh to provide a
90 TCP "tunnel" rather than by using ssh to login to or invoke any
91 ordinary commands on the repository. When you want to start a
92 session using the repository, use the command
94 ssh -l perlrep -f -q -x -L 1666:127.0.0.1:1666 sickle.activestate.com foo
96 If you are not using the default filename of F<~/.ssh/identity>
97 to hold your perl repository private key then you'll need to add
98 the option B<-i filename> to tell ssh where it is. Unless you chose
99 a blank passphrase for that private key, ssh will prompt you for the
100 passphrase to unlock that key. Then ssh will fork and put itself
101 in the background, returning you (silently) to your shell prompt.
102 The tunnel for repository access is now ready for use.
104 For the sake of completeness (and for the case where the chosen
105 port of 1666 is already in use on your machine), I'll briefly
106 describe what all those ssh arguments are for.
112 Use a remote username of perlrep. (The account on the repository which
113 provides the end-point of the ssh tunnel is named "perlrep".)
117 Tells ssh to fork and remain running in the background. Since ssh
118 is only being used for its tunnelling capabilities, the command
119 that ssh runs never does any I/O and can sit silently in the
124 Tells ssh to be quiet. Without this option, ssh will output a
125 message each time you use a p4 command (since each p4 command
126 tunnels over the ssh connection to reach the repository).
130 Tells ssh not to bother to set up a tunnel for X11 connections.
131 The repository doesn't allow this anyway.
133 =item B<-L 1666:127.0.0.1:1666>
135 This is the important option. It tells ssh to listen out for
136 connections made to port 1666 on your local machine. When such
137 a connection is made, the ssh client tells the remote side
138 (the corresponding ssh daemon on the repository) to make a
139 connection to IP address 127.0.0.1, port 1666. Data flowing
140 along that connection is tunnelled over the ssh connection
141 (encrypted). The perforce daemon running on the repository
142 only accepts connections from localhost and that is exactly
143 where ssh-tunnelled connections appear to come from.
145 If port 1666 is already in use on your machine then you can
146 choose any non-privileged port (a number between 1024 and 65535)
147 which happens to be free on your machine. It's the first of the
148 three colon separated values that you should change. Picking
149 port 2345 would mean changing the option to
150 B<-L 2345:127.0.0.1:1666>. Whatever port number you choose should
151 be used for the value of the P4PORT environment variable (q.v.).
153 =item sickle.activestate.com
155 This is the canonical name of the host on which the perl repository
160 This is a dummy place holder argument. Without an argument
161 here, ssh will try to perform an interactive login to the
162 repository which is not allowed. Ordinarily, this argument
163 is for the one-off command which is to be executed on the
164 remote host. However, the repository's ssh configuration
165 file uses the "command=" option to force a particular
166 command to run so the actual value of the argument is
167 ignored. The command that's actually run merely pauses and
168 waits for the ssh connection to drop, then exits.
174 You should normally get a prompt that asks for the passphrase
175 for your RSA key when you connect with the ssh command shown
176 above. If you see a prompt that looks like:
178 perlrep@sickle.activestate.com's password:
180 Then you either don't have a ~/.ssh/identity file corresponding
181 to your public key, or your ~/.ssh/identity file is not readable.
182 Fix the problem and try again.
184 =head1 Using the Perforce Client
186 Remember to read the documentation for Perforce. You need
187 to make sure that three environment variable are set
188 correctly before using the p4 client with the perl repository.
194 Set this to localhost:1666 (the port for your ssh client to listen on)
195 unless that port is already in use on your host. If it is, see
196 the section above on the B<-L 1666:127.0.0.1:1666> option to ssh.
200 The value of this is the name by which Perforce knows your
201 host's workspace. You need to pick a name (normally, your
202 Perforce username, a dash, and your host's short name)
203 when you first start using the perl repository and then
206 Perforce keeps track of the files you have on your machine. It
207 does this through your client. When you first sync a version of a
208 file, the file comes from the server to your machine. If you sync
209 the same file again the server does nothing because it
210 knows you already have the file.
212 You should NOT use the same client on different machines. If you do
213 you probably won't get the files you expect, and may end up with
214 nasty corruption. Perforce allows you to have as many clients as
215 you want. For example, sally-home, sally-openbsd, sally-laptop.
217 Also, never change the client's root and view at the same time.
218 See C<http://www.perforce.com/perforce/doc.002/manuals/p4guide/04_details.html#1048341>
220 If you have multiple hosts sharing the same directory structure
221 via NFS then you may be able to get away with only one client name,
224 The C<p4 clients> command lists all currently known clients.
228 This is the username by which perforce knows you. Use your
229 username if you have a well known or obvious one or else pick
230 a new one which other perl5-porters will recognise. There is
231 a licence limit on the number of these usernames, so be sure not
232 to use more than one.
234 It is very important to set a password for your Perforce username,
235 or else anyone can impersonate you. Use the C<p4 passwd> command
236 to do this. Once a password is set for your account, you'll need
237 to tell Perforce what it is. You can do this by setting the
238 environment variable P4PASSWD, or you can use the C<-P> flag
239 with the C<p4> command.
241 There are a few techniques you can use to avoid having to either
242 set an environment variable or type the password on every command.
243 One is to create a shell alias, for example, in bash, add something like
244 alias p4='p4 -P secret'
245 to your F<.bash_profile> file. Another way is to create a small shell
249 And use this instead of running C<p4> directly.
251 With either of these, be sure the file containing your password
252 (the F<.bash_profile> or shell script file) is only readable by you.
254 The C<p4 users> command lists all currently known users.
258 Once these three environment variables are set, you can use the
259 perforce p4 client exactly as described in its documentation.
260 After setting these variables and connecting to the repository
261 for the first time, you should use the C<p4 user> command to
262 set a valid email address for yourself. Also use the C<p4 client>
263 command to specify your workspace specifications for each
264 individual client from which you will interact with the repository.
266 =head1 Ending a Repository Session
268 When you have finished a session using the repository, you
269 should kill off the ssh client process to break the tunnel.
270 Since ssh forked itself into the background, you'll need to use
271 something like ps with the appropriate options to find the ssh
272 process and then kill it manually. The default signal of
275 =head1 Overview of the Repository
277 Please read at least the introductory sections of the Perforce
278 User Guide (and perhaps the Quick Start Guide as well) before
279 reading this section.
281 Every repository user typically "owns" a "branch" of the mainline
282 code in the repository. They hold the "pumpkin" for things in this
283 area, and are usually the only user who will modify files there.
284 This is not strictly enforced in order to allow the flexibility
285 of other users stealing the pumpkin for short periods with the
288 Here is the current structure of the repository:
290 /----+-----perl - Mainline development (bleadperl)
291 +-----perlio - PerlIO Pumpkin's Perl
292 +-----vmsperl - VMS Pumpkin's Perl
293 +-----maint-5.004------perl - Maintainance branches
294 +-----maint-5.005------perl
295 +-----maint-5.6------perl
296 +-----maint-5.6------pureperl
298 Perforce uses a branching model that simply tracks relationships
299 between files. It does not care about directories at all, so
300 any file can be a branch of any other file--the fully qualified
301 depot path name (of the form //depot/foo/bar.c) uniquely determines
302 a file for the purpose of establishing branching relationships.
303 Since a branch usually involves hundreds of files, such relationships
304 are typically specified en masse using a branch map (try `p4 help branch`).
305 `p4 branches` lists the existing branches that have been set up.
306 `p4 branch -o branchname` can be used to view the map for a particular
307 branch, if you want to determine the ancestor for a particular set of
310 The mainline (aka "trunk") code in the Perl repository is under
311 "//depot/perl/...". Most branches typically map its entire
312 contents under a directory that goes by the same name as the branch
313 name. Thus the contents of the perlio branch are to be found
316 Run `p4 client` to specify how the repository contents should map to
317 your local disk. Most users will typically have a client map that
318 includes at least their entire branch and the contents of the mainline.
320 Run `p4 changes -l -m10` to check on the activity in the repository.
321 //depot/perl/Porting/genlog is useful to get an annotated changelog
322 that shows files and branches. You can use this listing to determine
323 if there are any changes in the mainline that you need to merge into
324 your own branch. A typical merging session looks like this:
327 % p4 integrate -b perlio # to bring parent changes into perlio
328 % p4 resolve -am ./... # auto merge the changes
329 % p4 resolve ./... # manual merge conflicting changes
330 % p4 submit ./... # check in
332 If the owner of the mainline wants to bring the changes in perlio
333 back into the mainline, they do:
335 % p4 integrate -r -b perlio
338 Generating a patch for change#42 is done as follows:
340 % p4genpatch 42 > change-42.patch
342 F<p4genpatch> is to be found in //depot/perl/Porting/.
344 The usual routine to apply a patch is
346 % p4 edit file.c file.h
349 (any necessary, re-Configure, make regen_headers, make clean, etc, here)
353 (preferably make all test in several platforms and under several
354 different Configurations)
363 Other useful Perforce commands
365 % p4 describe -du 12345 # show change 12345
367 Note: the output of "p4 describe" is not in proper diff format, use
368 the F<Porting/p4genpatch> to get a diff-compatible format.
369 (Note that it may be easier to get one already prepared: grep
370 L<perlhack> for APC, and append eg "/diffs/12345.gz" to one of the
371 URLs to get a usable patch.)
373 % p4 diff -se ./... # have I modified something but forgotten
374 # to "p4 edit", easy faux pas with autogenerated
375 # files like proto.h, or if one forgets to
376 # look carefully which files a patch modifies
377 % p4 sync file.h # if someone else has modified file.h
378 % p4 opened # which files are opened (p4 edit) by me
379 % p4 opened -a # which files are opened by anybody
380 % p4 diff -du file.c # what changes have I done
381 % p4 revert file.h # never mind my changes
382 % p4 sync -f argh.c # forcibly synchronize your file
383 # from the repository
384 % p4 diff -sr | p4 -x - revert
385 # throw away (opened but) unchanged files
386 # (in Perforce it's a little bit too easy
387 # to checkin unchanged files)
389 Integrate patch 12345 from the mainline to the maint-5.6 branch:
390 (you have to in the directory that has both the mainline and
391 the maint-5.6/perl as subdirectories)
393 % p4 integrate -d perl/...@12345,12345 maint-5.6/perl/...
395 Integrate patches 12347-12350 from the perlio branch to the mainline:
397 % p4 integrate -d perlio/...@12347,12350 perl/...
399 =head1 Contact Information
401 The mail alias <perl-repository-keepers@perl.org> can be used to reach
402 all current users of the repository.
404 The repository keeper is currently Gurusamy Sarathy
405 <gsar@activestate.com>.
409 Malcolm Beattie, mbeattie@sable.ox.ac.uk, 24 June 1997.
411 Gurusamy Sarathy, gsar@activestate.com, 8 May 1999.
413 Slightly updated by Simon Cozens, simon@brecon.co.uk, 3 July 2000.
415 More updates by Jarkko Hietaniemi, jhi@iki.fi, 28 June 2001.
417 Perforce clarifications by Randall Gellens, rcg@users.sourceforge.net, 12 July 2001.