[p4] Better understanding of +/- client spec syntax
Robert Cowham
robert at vaccaperna.co.uk
Thu Aug 10 15:04:45 PDT 2006
> MINUS SIGNS
> I can use the "-" to prevent something from being selected.
> That's fine with me.
> 1. Is the "-" of use if I'm depending on multiple mappings?
> IOW, if I expect a file to be created and it could come from
> more than one place, is there value in deselecting it from
> where I don't want it even though I get it from the later match?
Generally I would say no.
> Here's a contrived example:
> //depot/a/b/... /view/a/b/...
> -//depot/a/b/c /view/a/b/c
> //depot/x/y/c /view/a/b/c
>
> Is the deselected line of any use?
No.
> 2. Is the right hand side of a "-" a dummy or does it have
> any value at all?
Oh it absolutely does have value - just try without it!
Quick summary on views:
They are left to right AND right to left mappings. Perforce looks at all of
them and later ones may override earlier ones (either on left or right).
Don't forget that you will never get more than 1 file mapped, and in some
cases you will get 0 files mapped (imagine 2 files being mapped to 2
different places - you could update them independently and when it came time
to check in - errrr which one?!).
Looking at ordinary mappings for a bit:
//depot/main/... //view/main/...
//depot/other/... //view/main/...
In the above, the LHSs are different but the RHSs are the same. What
happens? Well line 2 overrides line 1 totally.
Let's take a different case:
//depot/main/... //view/main/...
-//depot/main/a/... //view/main/a/...
This is actually quite useful in the case that there are 10 subdirs under
main and we want to use 9 of them. It is easier to maintain 2 lines than 9
mappings to explicitly map each subdir we want.
Now let's look at a variant:
//depot/main/... //view/main/...
//depot/other/a/... //view/main/a/...
This takes the whole of main, except for a/... which comes from other/a/...
Again this can be quite useful in practice - trying out a subcomponent with
stuff from a different branch.
If we don't have an appropriate RHS for a minus mapping we can get into
trouble.
//depot/main/... //view/main/...
-//depot/main/a/... //view/...
The RHS of line 2 includes everything in line 1. Perforce also sees the
minus sign at the start and doesn't map anything. Thus if you have any
variant on this (with a RHS which "contains" the RHS of previous lines), and
you sync it, you will get NO files (as in zero). Try it!
I have been trying out in my training classes some diagrams involving sets
and mapping functions etc overwriting each other to try and explain this,
but it seems to only appeal to those of a mathematical bent which is not the
majority, so will probably abandon the idea! Who knows I may blog about it
instead.
> PLUS SIGNS
> I have no idea what the value of "+" is. If I specify a plus
> sign to override something that was previously selected
> earlier, then it would have been picked off anyways.
>
> //depot/a/b/... /view/a/b/...
> +//depot/x/y/c /view/a/b/c
>
> Does someone have an example of a plus usage that makes sense?
I have seen various people using + mappings when they should have just used
an ordinary mapping to override something more specific. + mappings make
life a bit tricky in that they really work left to right rather than right
to left as well. Thus their usage is pretty specific I suggest.
Have a look at my blog article on sparse branching for a "reasonable" use:
http://www.robertcowham.com/blog/scm/p4_sparse_branching.html
HTH
Robert
More information about the perforce-user
mailing list