Discussion:
[p4] Trigger doesn't?
Jonathan Biggar
2008-06-05 05:11:21 UTC
Permalink
I've got a trigger script I wrote to not allow C++ source files to be
checked in that contain tabs. I've hand tested it by running it with an
already checked in changelist and it does the right thing. I've
attached it just in case there's something wrong that I can't see.

I installed the trigger with p4 triggers like this:

Triggers:
tab_check change-context //depot/project/...
"/perforce/no-tabs.sh %change%"

But when I check in files ending in .hpp and .cpp with tabs, nothing
happens.

Anybody able to give me a clue?
--
Jon Biggar
Floorboard Software
***@floorboard.com
***@biggar.org
Robert Cowham
2008-06-05 10:20:48 UTC
Permalink
It's probably your environment - some tips:

http://www.robertcowham.com/blog/scm/p4_triggers.html
-----Original Message-----
Jonathan Biggar
Sent: 05 June 2008 06:11
Subject: [p4] Trigger doesn't?
I've got a trigger script I wrote to not allow C++ source
files to be checked in that contain tabs. I've hand tested
it by running it with an already checked in changelist and it
does the right thing. I've attached it just in case there's
something wrong that I can't see.
tab_check change-context //depot/project/...
"/perforce/no-tabs.sh %change%"
But when I check in files ending in .hpp and .cpp with tabs,
nothing happens.
Anybody able to give me a clue?
--
Jon Biggar
Floorboard Software
Robert Cowham
2008-06-05 10:22:47 UTC
Permalink
P.s. I always pass in %serverport% and a user to use to execute the trigger.

To test if env is wrong, hardcode P4PORT and P4USER in your script.
-----Original Message-----
Sent: 05 June 2008 11:21
Subject: RE: [p4] Trigger doesn't?
http://www.robertcowham.com/blog/scm/p4_triggers.html
-----Original Message-----
Biggar
Sent: 05 June 2008 06:11
Subject: [p4] Trigger doesn't?
I've got a trigger script I wrote to not allow C++ source
files to be
checked in that contain tabs. I've hand tested it by
running it with
an already checked in changelist and it does the right thing. I've
attached it just in case there's something wrong that I can't see.
tab_check change-context //depot/project/...
"/perforce/no-tabs.sh %change%"
But when I check in files ending in .hpp and .cpp with
tabs, nothing
happens.
Anybody able to give me a clue?
--
Jon Biggar
Floorboard Software
Jonathan Biggar
2008-06-05 15:37:55 UTC
Permalink
It is a programming question, and so it's time to debug the sucker.
I'd start with the following, because triggers are always fun to
debug. (Why? Because the run-time environment and the development
environment have different userids, permissions, and environment
variables/registries unless you are very careful.)
I'm willing to bet that the output of "p4 info" when run "by you" and
then when run "by the trigger" produce wildly different output.
Redirect that output to a file (hard-code the name for debugging) and
see how different.
Odds are good that your trigger needs to set environment variables
like "P4USER" and perhaps even "P4CLIENT" (or workspace) and the like.
-Jeff Bowles
ps. Throw in a "p4 clients" and "p4 users" into the script,
redirecting the output, just to see if that behavior's different also.
It'll revolve around authentication / environment, I betcha.
That's good advice, but the problem is that the trigger doesn't even
run. I put a simple:

touch /tmp/notabs

as the first line of the script, and the file doesn't get created.

Somehow my trigger specification is broken. Any ideas?
--
Jon Biggar
Floorboard Software
***@floorboard.com
***@biggar.org
Jeff A. Bowles
2008-06-05 17:06:54 UTC
Permalink
Looking at your "trigger line", it should fire when there is a change to
files in: //depot/project/...

Looking at your "trigger script", it runs the command:
/usr/local/bin/p4 files //depot/orb_main/...@=$CHANGE

Comments:

1. I'm sure there's a reason why the directory names are different, but
it looks like a coding error to me. If you submit changes to
//depot/orb_main and expect this trigger to you, the trigger line needs to
be changed.
2. I would not put a "p4 print" (or "p4 anything") inside a loop, if I
had a choice. It is not efficient server usage. You might consider this:


- "p4 print -q @=$CHANGE | grep-for-tabs"

I suggest the above command because it's short, has one-trip-to-server
(protocol people would quibble, but they also would understand the
motivation for this recommendation), and because you do not *CARE* which
file has a tab except (perhaps) to have a better error message. (Do not
misunderstand me - the better error message is worth the time, but there are
more efficient ways to get to that better error message.)

Anyhow, the directory names are wrong. Start there, and change the 'p4cmd='
to include port / user. Pass the port/user/etc from the server as part of
the trigger spec, and you avoid a later headache. (That headache is, "I have
multiple servers on the same machines, but the triggers are trying to
connect to the wrong server.")

-jab
Post by Jonathan Biggar
It is a programming question, and so it's time to debug the sucker.
I'd start with the following, because triggers are always fun to
debug. (Why? Because the run-time environment and the development
environment have different userids, permissions, and environment
variables/registries unless you are very careful.)
I'm willing to bet that the output of "p4 info" when run "by you" and
then when run "by the trigger" produce wildly different output.
Redirect that output to a file (hard-code the name for debugging) and
see how different.
Odds are good that your trigger needs to set environment variables
like "P4USER" and perhaps even "P4CLIENT" (or workspace) and the like.
-Jeff Bowles
ps. Throw in a "p4 clients" and "p4 users" into the script,
redirecting the output, just to see if that behavior's different also.
It'll revolve around authentication / environment, I betcha.
That's good advice, but the problem is that the trigger doesn't even
touch /tmp/notabs
as the first line of the script, and the file doesn't get created.
Somehow my trigger specification is broken. Any ideas?
--
Jon Biggar
Floorboard Software
_______________________________________________
http://maillist.perforce.com/mailman/listinfo/perforce-user
--
---
Jeff Bowles - ***@gmail.com
Dan Wierenga
2008-06-05 17:08:56 UTC
Permalink
-----Original Message-----
That's good advice, but the problem is that the trigger doesn't even
touch /tmp/notabs
as the first line of the script, and the file doesn't get created.
Somehow my trigger specification is broken. Any ideas?
My "p4 help triggers" says "change-conteXt" isn't a valid trigger type,
but "change-conteNt" is. Could that be your problem?
Jonathan Biggar
2008-06-05 17:13:12 UTC
Permalink
I assume you're on Unix and that the file /perforce/no-tabs.sh has
"execute" bit set.
You might change the trigger line to look like
"sh /perforce/no-tabs.sh .....args...."
The "touch" idea is the right direction. Yes, it's icky. Yes, this
sequence will lead you to the answers you need.
I found the problem. Turns out my server was backrev and apparently it
was ignoring the trigger.
--
Jon Biggar
Floorboard Software
***@floorboard.com
***@biggar.org
Peter Weldon
2008-06-05 16:35:38 UTC
Permalink
tab_check change-context //depot/project/... "/perforce/no-tabs.sh
%change%"
You have a typo it should be change-content not change-context.
Loading...