#	CancelActive - Cancel checkout of the active window
#
#	Usage:	Called by a userdefined menu item
#
#	CancelActive was cribbed from CheckInActive.  Instead of checking
#   in the active window, it cancels the checkout (reverting the changes).
#
#   CancelActive- hacked by Andy Stadler
#
#	 Apple Computer, Inc. 1988
#	All rights reserved.

Set Exit 0
Set error 0
Begin

	#	First see if the active window belongs to a project.
	
	(Set info "`ProjectInfo "{Active}"`" || Set error 1)
	Evaluate "{info}" =~ /,[0-9a-z.]+([+*])1 +/
	Evaluate "{info}" =~ /Project: (ź)2 +Checked out/
	If {error}  0 || "{info}" == ""
		Alert ""{Active}" cant be cancelled because 
it doesnt belong to a project."
		Exit 0 
	End
	
	#	Find out if the active window is checked out for modification.

	If "'{1}'"  "'+'" &&  "'{1}'"  "'*'"
		Alert ""{Active}" cant be cancelled because 
it wasnt checked out for modification."
		Exit 0 
	End
	
	#	Is the right project mounted?
	
	(Set info "`ProjectInfo "{2}"`" || Set error 1)
	If "{info}" == ""
		Alert ""{Active}" cant be cancelled because the project 
"{2}" is not mounted."
		Exit 0 
	End

	#	Now cancel the file.
	set echo 1	
    CheckOut -cancel "{Active}"
	If {Status}  0
		Alert "There was a problem checking in "{Active}". 
You need to check it in on a branch."
	End
End  dev:null
