[p4] converting static labels to automatic labels

Jay Glanville Jay.Glanville at naturalconvergence.com
Fri Jul 20 10:32:51 PDT 2007


Thanks for the suggestion Stephen.  I was originally thinking of writing
a script that would make an automatic label based on the static label
(using templates), set the auto label's revision to the highest change
list, and then perform a label diff.

>From a procedural prospective, something like this:

  For lbl in "p4 labels" {
    # find largest change list
    last_cl = "p4 changes -m 1 @lbl"

    # duplicate the label, making it an auto label
    label_spec = "p4 label -o -t lbl auto-lbl"
    label_spec = printf "label_spec\nRevsion: @last_cl"
    echo "label_spec" | p4 label -i auto-lbl

    # perform a diff between the two labels,
    # counting differences
    diff_cnt = "p4 files //depot/...@>lbl,auto-lbl | wc -l"

    if diff_cnt > 0
      echo "lbl is not convertible to auto"
    else
      echo "lbl can be converted to auto"

    # cleanup
    p4 label -d auto-lbl
  }


If I've thought this through right, I don't need to worry about my
workspace definition, just like in your second suggestion.

I'm just trying to figure out which is more taxing on Perforce: the
constantly updating of the 'have' table (sync -k) or constantly updating
the 'label' table (make label, diff label, delete label) .....

JDG




> There are a couple of things to consider. Which ones you worry about
> depends on your trust in the orderliness of your environment.
> 
> The easy part is
> 
> p4 changes -m 1 @label
> 
> which, as you note, answers the question "What is the highest 
> changelist
> number that contributes to the label?"
> 
> Next, if you create a workspace and
> 
> p4 sync -k @label
> p4 sync -k -n @changelist
> 
> you will find out if the label purely represents the 
> changelist *within
> the constraints of your views*.
> 
> However, both your workspace view and your label view can potentially
> split changelists. If you open up those views to include your entire
> repository, you could use a combination of 'p4 sync -k -n @changelist'
> and 'p4 labelsync -n -l label @changelist' to easily 
> determine if it was
> truly pure. If you need to keep the views restrictive then it's a more
> computational task to determine.
> 
> Steve
> 
> Jay Glanville wrote:
> > Hello all.
> >
> > I'm wanting to convert some of the old static labels we have (many
> > containing over 60k files) into automatic ones, in the hopes that it
> > will make label diffs more efficient.  The conversion process itself
> > isn't that hard.
> >
> > The hard bit is trying to determine if an automatic label 
> can represent
> > a static label.  The only way I can think of right now is 
> to find the
> > highest change list in the label, and then perform a diff 
> between the
> > label and the change list.  But, is that the best way?  Is there a
> > simpler way (that just hasn't occurred to me yet...).
> >
> >
> > So, my question to these eminent minds is this: what is the 
> best way to
> > determine if a static label can represented by an automatic label?


---
Jay Dickon Glanville



More information about the perforce-user mailing list