Robert Cowham's Weblog 5 of 43 articles Syndicate: full/short

Custom Perforce GUi Installers (for large sites)   04 Dec 07
[print permalink all comment ]

For quite a while there has been an option to create your own custom installer for Perforce deployments (including automation). This can be particularly useful for larger sites with lots of new users coming along regularly.

The customizable element of the scripted installer is a configuration file named perforce.cfg. The Perforce Administrator edits this file, and places it on a shared network drive along with the expanded contents of the perforce.zip file. Perforce client programs can then be installed by running setup.exe from each desktop.

One of the annoyances with this approach is that you have to expand the .zip file and put things on a network drive. It is not easy to do this sort of thing within a single executable for example (which makes it hard to put on your intranet and get users to double click).

Well, having played around with various installers and options, I have discovered a fairly simple way of doing this via a self extracting executable (SFX), and the open source 7-Zip program.

Instructions

Create a directory structure:

  • some root dir
    • 7-zip - contains a batch file, a couple of config files and perforce.cfg - see below for contents.
    • p4winst - contains expanded p4winst.zip (without the perforce.cfg)
    • p4vinst - contains expanded p4vinst.zip (without the perforce.cfg)

Currently (as of 2007.2) the perforce.cfg file is the same for both P4Win and P4V.

You need to get a couple of files from 7-zip.org/download.html

Edit perforce.cfg to customize for your installation.

Create a p4winst.conf and p4v.conf (which must both be UTF-8 - Notepad can save this format, as can Notepad++ or other editors) in that directory.

Run make_installers.bat from the command line in the appropriate directory and check that the following are created (which you can put on an intranet or whatever):

  • p4winst.exe
  • p4vinst.exe

You can then send your users a single exectuable which unzips itself and automatically runs the perforce setup.exe with the included perforce.cfg - QED!

make_installers.bat

This contains something like the following:

:: Batch file to package up P4Win using .zip file and the 7-Zip freely available 
:: Zip program (which can create SFX - Self Extracting Archives). 

@echo off 

:: May need to customize the following 
set ZIP_DIR="d:\apps\7-zip" 

call :make_install p4winst 
call :make_install p4vinst 
goto :exit 

:make_install 

set INSTALLER=%1 

:: First create new clean versions of the zip files (including current directory version of perforce.cfg in preference) 
if exist %INSTALLER%.7z del %INSTALLER%.7z 
if exist %INSTALLER%.exe del %INSTALLER%.exe 

%ZIP_DIR%\7z a %INSTALLER%.7z ..\%INSTALLER%\* perforce.cfg 
:: Copy SFX file plus config file plus zipped installer into a single SFX .exe
copy /b %ZIP_DIR%\7zsd.sfx + %INSTALLER%.conf + %INSTALLER%.7z %INSTALLER%.exe 
if not errorlevel 1 goto :EOF 
if exist %INSTALLER%.exe goto :EOF 

echo *** ERROR: failed to create %INSTALLER%.exe 
goto :exit 

:exit 

p4winst.conf (and p4vinst.conf)

These are simple UTF8 format file with contents similar to:

;!@Install@!UTF-8!
Title="P4Win Custom Installer"
BeginPrompt="Do you want to install P4Win?"
RunProgram="setup.exe"
;!@InstallEnd@!

Subconf 2007 - Subversion and the Enterprise   31 Oct 07
[print permalink all comment ]

This article is a result of my visit to Subconf in Munich a couple of weeks ago.

The first thing to say is that Subconf was very enjoyable and interesting and my compliments to the organisers. There were some excellent speakers and it was good to chat to various vendors too. I also had a very good time at the dinner that evening - the only slight fly in the ointment was the S-Bahn strike the following morning which meant a rather earlier taxi to the airport than I might have wished!

The two keynotes by Brian Behlendorf and Karl Fogel respectively were particularly good. Indeed it was good to get them at the conference since both guys seem to be scaling down their Subversion involvement - Brian has stepped down as CTO at Collabnet and Karl is running QuestionCopyright.org (although remains as President of Subversion Corporation.

Some of the slides are now available online.

Brian's Keynote

Brian mentioned his involvement in Apache and some of the lessons learnt about creating a community that worked. These lessons were then applied by Collab.net to get Subversion going. If you create a high quality community, you will create high quality software.

  • Need to be nice to people to avoid a "fork" - Development leaders exhibit good communication skills, and can bring different ideas together.
  • Conscious effort to bring new developers along the path: from “consumers”, to bug reporters, to patch submitters, to active contributors. 

Brian was asked the question in his talk about Linus's somewhat inflammatory video about Git where various sideswipes about brain-dead CVS and Subversion people are made. Brian had no particular axe to grind about this and said that the Subversion camp bore no ill will to the distributed crowd and were rather surprised at some of the venom coming back - a very measured and mature response.

Brian mention the difference between a centralised model and a distributed model - there is a lot that enterprise like about the control of a centralised model. For example, laptops get stolen (he lost his a few weeks ago), and a laptop might contain a whole distributed repository. Enterprises prefer more control!

Martin Doettling's Intro to Karl

The key points of this were:

  • Estimated user base now exceeds 2 million
  • 10x growth since 1.4
  • Large numbers of enterprise users

Karl's Keynote - How Stuff Happens

Karl picked up on some of Brian's points about the community, and showed various ways in which they have been able to get hackers to create software that the enterprise can use!

  • There is a very comprehensive guide to how to contribute - 43 pages of it! This is where people start.
  • Some principles:
    • Make it easy to do things right
    • Make it rewarding to do things right
    • Influence proportional to effort
      • Moving from contributor to partial-committer to commiter
      • Tracking no of patches etc by user - all automated with links (see Contribulyzer)

Other Notes

I couldn't stay for the second day, but some other points of interest:

  • There are increasing numbers of tools based around Subversion - Collabnet, Polarion, CodeBeamer etc
  • Subversion command line is increasingly irrelevant as people use it through Tortoise, Eclipse etc.
  • Merge tracking there at long last with 1.5 just around the corner
  • Really being used in the industry
  • SVK provides an interesting distributed method

I also had some chats with Collabnet around the idea of perhaps the BCS CMSG working with them to put on an event in London next year - definitely something to look into.

Well worth a visit as a conference.

Directing vs. Managing Configurations   10 Jul 07
[print permalink all comment ]

In a recent CM Crossroads article on defining Agile SCM I included the quote from Charles Handy that I recently picked up on my travels through an airport:

Go to the theatre and look at the programme. Everyone connected with the performance is listed, no matter how small their contribution. People like to be recognised as individuals. The word "manager" is reserved for those in charge of things, not people, the stage manager and the lighting manager. The people who are in direct communication with the customer, the actors, are directed, not managed, by someone who actually leaves the scene once the project is under way. He or she trusts the cast to go it alone, and as often as not, they improve on the production once the director departs. Trust inspires. One more thing - at the end of each performance they receive an expression of appreciation from their audience, direct feedback from the people who matter. No waiting for the annual performance appraisal.

Charles Handy, Myself and Other More Important Matters, Arrow Books, 2007 - ISBN 9780099481881

This obviously applies to more than just the directing vs. managing debate (e.g. feedback/appreciation), but really hit home for me as an expression of what those of us in the Configuration Management arena need to be doing. We should be directing our colleagues and developers rather than managing them (although we can of course manage actual configurations as before!). We need to get out and about amongst our congregation of developers and others, and infect them with enthusiasm and skills for the delights and benefits of good CM.

There is a huge danger, which I come across fairly frequently, of sitting in your ivory tower wondering why developers aren't doing what you know is "the right thing". They haven't got the message, they aren't doing what they should, and management isn't helping you to beat them up with a big stick to force them into doing it. Sometimes it seems we are just on a hiding to nothing...

In CM we need to aspire to the director (servant-leader) mold - we provide a support service for people to get on with their jobs and we help them do it, but it is they that do (most of) it, not us. There is obviously some level at which CM is still responsible for certain things - in particular processes and systems, and for auditing to ensure things have been done correctly.

Thus I am more and more convinced that, particularly for Agile teams, CM should be the responsibility of everyone not just the CM person(s). This means that as CM professionals our job is:

  • to sell the ideas, principles and tools of sound CM while supporting people in getting their jobs done and delivering value to the business (not just ticking CM boxes)
  • to solve people's day-to-day issues through education and tool/automation support
  • to show how it is easier to do "the right thing" than it is not to do it - a little discipline is worth a ton of lost time due to bugs introduced, or things suddenly not working
  • to get out and about and work with developers, pairing with them and demonstrating good CM practice, discovering those little niggling things that cause lost time and productivity or pain and solving them
  • to ensure that our own working practices are suitable role models (avoid "do as we do not as we say...")
  • to focus on continuous process improvement - there is almost always something more we can do (but again focus on value)

There are many challenges, and in an Agile world, it is more about working with people to define just enough process to be useful, and not too much to get in the way. I was fascinated to hear a vendor representative complaining that some of their customer had developers who were downloading and using Subversion for their day to day work as opposed to using the corporate tool. I wondered what had happened to make the tool or the configured process so unfriendly as to force the developers down this path.

Perforce Branch Naming and Repository Structure Guidelines   19 Jun 07
[print permalink all comment ]

One of the the things that comes up just about every time I go in to do some Perforce related consulting for a client is that of repository structure - how do you map some particular branching scheme (combination of branching patterns) onto the repository?

This of course necessary since Perforce uses the repository structure to represent branches as well as other directory structures. This way of recording branches is feature one might occasionally wish were implemented otherwise, but it does have its attractions, and is the same model as used in Subversion and also Microsoft's new Team Foundation Server product (as an aside, it is perhaps not surprising that Microsoft chose this model since it is a not very well kept "secret" that their in house SCM tool called SourceDepot, introduced during the development of Windows 2000, was a re-badged copy of Perforce. Team Foundation Server is obviously a total rewrite on top of SQL Server, but they seem to be comfortable with the "branch in path space" model).

Some clients need help working out a good branching scheme, and some have relevant experience with other tools so are comfortable with that part, but many need help with the mapping. I have covered a little of this in my article Introduction to Perforce Branching, but this article expands on that.

For their flexibility, I would generally recommend people use branch specs (e.g. created by "p4 branch" command) for branching since you can add view mappings to address not propagating renames, and branch extra components. However, if you can keep the branch spec to a single view mapping then that is great! (Note that the P4V GUI allows integration via drag-and-drop - sometimes convenient, but can be somewhat dangerous...).

Guidelines

A repository branch structure is about creating an appropriate information hierarchy (designing an information architecture). So here are some guidelines that I have found useful over the years and seen successfully used in many organisations (and I certainly didn't invent any of them!). Maybe in the future I can come up with some appropriate pattern like descriptions, but for now, here they are:

  • Standardise naming conventions - make branch directories obvious
  • Keep branch spec mappings and client workspace spec mappings as simple as possible (and permissions)
  • Make it as easy as possible for users (new and experienced) to visualise the branching scheme as they click down through the hierarchy
  • Find the right balance between broad & shallow vs. narrow & deep hierarchies
  • Keep branches of a similar type at similar depths in the structure
  • Make branch directories sort sensibly
  • Plan for the future: 2, 3, 5 years down the line - include things like the year (and optionally month) somewhere in the path to provide a natural sorting.
  • Provide Guidelines and Delegate!
  • Remember - there is no one best solution, but there are many good enough solutions!

Some of what comes below is also covered by Laura Wingerd in her recent book "Practical Perforce" (O'Reilly) - you really need to get this book if you are responsible in any way for Perforce usage at your company! Her quote which sums things up nicely is:

"There is no reason that the repository structure should match the release lineage, but when it doesn’t it causes confusion to new users [and cognitive dissonance to all users]."

Now while I agree with the intent of what Laura has written, I find her suggested option is perhaps a little too restrictive, and it doesn't take into account organisations with many branches at a particular level (and indeed many different types of branches).

Standardise Naming Conventions - Make Branch Directories Obvious

Laura gives a very simple example in her book of naming convention - just use uppercase for the branch component. Thus she has:

//depot/MAIN/...
//depot/REL1/...
//depot/SOME_PROJECT/...
//depot/ANOTHER_PROJECT/...

This is simple and can work very well (although it rather suggests that you don't use uppercase for any other paths which might be unnatural in certain companies for certain items). Another alternative is to append (or prepend) something to the name indicating that it is a branch directory, e.g. ".branch" or or "-branch", or ".br" for those who don't like typing! Thus the above becomes:

//depot/main.br/...
//depot/rel1.br/...
//depot/some_project.br/...

I am happy to have other suggestions recommended!

Sensible Sorting

Directory (and thus branch) names should sort sensibly at any point in the hierarchy, thus

  • use leading zeros for numeric components, such as 01 instead of 1 if you are going to have more than 10, or indeed 4, 5 or 6 leading zeroes where necessary
  • reverse the order of dates using yyyy-mm rather than mm-yyyy

Examples:

//depot/main.br/...
//depot/rel_01_00.br/...
//depot/rel_02_00.br/...
//depot/rel_02_01.br/...
//depot/rel_02_02.br/...
//depot/dev/2007_06_some_project.br/...

Broad & Shallow vs. Narrow & Deep

At any one level the number of choices (sub-directories/branches) should be appropriate and naturally limiting (note that the structure needs to be as useable in several years time as it is now). For example, a structure which ends up with thousands of branches in a single directory will become unwieldy over time. Divide these branches into sub-directories using appropriate naming (and sorting). For example if you wish to create lots of branches for individual change requests then the obvious structure is very wide and shallow at some point in your repository:

~/rel 	/CR000001/...
	/CR000002/...
	:
	/CR000099/...
	/CR000100/...
	:
	/CR009100/... 
	:

Instead of that, try:

~/rel 	/CR0000xx	/01/...
			/02/...
			:
			/99/...
	/CR0001xx	/01/...
			:
	/CR0091xx/	/01/... 
			:

This naturally splits things up and also sorts at all levels.

As a corollary of the above you should split things up even if they don’t have a “natural” dividing component. One alternative is to use the date as an element of the path (or even a prefix) as YYYY or YYYY-MM to give some sort of natural sorting by date. Examples being:

~/2006-01/some_project/...
Or without introducing another level but using a prefix (which is often just a matter of personal preference):
~/2006-01-another_project/...

In 2 or 5 years time it should be obvious to any user which are the which are the “new” ones where they are likely to be spending most of their time, and which are the “old” branches which can typically be ignored.

Hiding or Retiring Old Branches

It is possible “hide” old branches by removing read permissions on those repository paths (leaving them visible to superusers or perhaps an "archive" user). There are some potential performance implications to doing a lot of this (the more lines you add to the protections table the more work the server has to do for commands).

Often the easiest way is just to make them easily ignored via an appropriate hierarchical naming convention as shown above.

Provide Guidelines and Delegate Responsibility

Larger organisations may have a number of teams or units each of which is responsible for products with sometimes quite different lifecycles and thus branching schemes. In these cases it makes sense to set the guidelines and principles and delegate to the teams the work of defining the precise conventions to be used.

Automation

If your repository structure is simple enough and regular enough then it is easy for tools or scripts to:

  • create them (perhaps with input from a user), including adding a mapping to the current client workspace view
  • have triggers that validate that they are being created in the correct place (e.g. don't allow a branch with wrong naming convention to be created in certain directories or levels of the repository). This prevents user error.
  • work out the relationship between branches automatically and thus be able to produce simple reports for things like changes that need to be propagated etc. While this is often done by means of some configuration file (stored in the repository), and indeed this is sometimes necessary anyway, it is easier if it can be automatically deduced from the structure (so that a new branch "popping up" is automatically included into the reporting mechanism).
  • make your protections table easier to maintain

There is No One Best Design!

And remember that this is always true - there are always many ways that are good enough, and the final choice often comes down to personal preference.

However, every type of branch should have a “home”, so that when a user creates a type of branch your CM Plan should have simple guidelines so the user is never at a loss as to where to create one. This requires identifying the types of branches likely to be used.

You need to do enough thinking and planning to get at least 80% of it right. It is of course possible to re-structure your repository (by branching from old name to new name and deleting the old within the same atomic changelist). However, this can cause you quite a few problems if the branch you are re-structuring has relationships with lots of other branches (e.g. release branches being maintained).

People who are aware of the issues and have experience, can slot in a new branch type fairly easily (though they can still end up making sub-optimal choices that they regret).

P4Web Usage and Action Codes   08 Jun 07
[print permalink all comment ]

People ask from time to time how to browse a Perforce repository, and the easiest answer is to use p4web.

Some advantages:

  • It's free, and in browse-only mode doesn't consume extra licenses - which means that you can "publish" changes via your Perforce server to managers and other people who may not normally have a Perforce license.
  • It will "serve up" things like Word documents such that they are typically opened in Word by your browser
  • It can give "canoical" or fixed URLs for documents or other configuration items stored in Perforce, so that fixed references always get the latest versions (as opposed to a file share where it is often unclear which is the latest and if there are any other versions etc)
  • The default URL to get the head revision is very simple:
    • <p4web-base-url>/<document path within perforce without double slash at start>, e.g.
    • http://p4web-machine/depot/some/path/to/document.doc

Example of Accessing a Document

A test document has been setup in the Perforce Public Depot.

The direct URL to load the document is http://public.perforce.com/guest/robert_cowham/test/testdoc.doc 

Alternatively it can be accessed for example with the history via p4web as:

http://public.perforce.com:8080/guest/robert_cowham/test/testdoc.doc?ac=22

Bear Security in Mind

If you setup in browse only mode as a user with access to the whole repository, you may be bypassing other security requirements and protections.

Consider setting up different p4web instances with different access permissions. Putting a separate layer on top of p4web with usernames and passwords, while possible, is likely to lead to maintenance problems.

DNS Alias to keep the URL fixed

If you start referring to a Canonical URL which then becomes used inside documents, make sure that the machine where p4web is running is accessed via a DNS alias so that it can be moved easily without breaking the references.

Also consider having a setup (e.g. via Apache or IIS virtual server settings) where the default web port of 80 is used to avoid ugly port components of the path such as :8080 or some other port  being required.

Parameters

The following were culled from personal experience and postings on perforce-user (by Noah Salzman  and Nick Levine )

Action Codes
10	Changelist Detail
http://p4web.example.com:8080/12345?ac=10

14	Branch Specification
http://p4web.example.com:8080/foo_branch?ac=14

16	Label Spec
http://p4web.example.com:8080/build_tag_123?ac=16

22	Revision History
http://p4web.example.com:8080//depot/main/foo.c?ac=22

64	View Head Revision
http://p4web.example.com:8080//depot/main/rel1/foo.c?ac=64

69	Submitted Changelists
http://p4web.example.com:8080//depot/main/rel1/foo.c?ac=69
http://p4web.example.com:8080//depot/main/rel1/...@build_tag_123?ac=69

142	View Annotated
http://p4web.example.com:8080//depot/main/rel1/foo.c?ac=142

143	View Fully Annotated
http://p4web.example.com:8080//depot/main/rel1/foo.c?ac=143

Note: the single forward slash (versus a double forward slash) is  
important in URLs that do not include depot paths.
107	List Jobs  (p4 jobs)
http://clrfi.alu.org:8080/?ac=107
http://clrfi.alu.org:8080/?ac=107&jsf=Job&jsf=Status&jsf=Date&jsf=Title&jsf=Area&jsf=Priority&ft=status%3Dopen

111	Describe Job (p4 job)
http://clrfi.alu.org:8080/job000005?ac=111
URLEncode the "@" (%40) or "#" (%23), for example, show contents of head rev

//public/jam/src/Build.com#2 is
http://public.perforce.com:8080/public/jam/src/Build.com%232?ac=64 

For #1
http://public.perforce.com:8080/public/jam/src/Build.com%231?ac=64 

For label @jam2-2-0 it is:
http://public.perforce.com:8080/public/jam/src/Build.com%40jam2-2-0?ac=64 

 

 

Copyright © 2008 Robert Cowham