p4.cpp #49

  • //
  • guest/
  • perforce_software/
  • p4ruby/
  • main/
  • p4.cpp
  • Commits
# Change User Description Committed
#49 14682 Git Fusion Git Fusion branch management

Imported from Git
 ghost-of-change-num: 960958
 ghost-of-sha1: 005052ae424bd69f426f7209e741ca1c8c3253c7
 ghost-precedes-sha1: ad052c71a568ef12165e143a6866ad9ceffbb4a1
 parent-branch: None@960958
 push-state: incomplete
#48 14676 tony Rework P4Ruby unit tests so they they are actually units.
Now the
test order is irrelevant as all tests are standalone. Tidied up
the code formatting as well and removed all the tabs from the ruby
sources files. Added a modeline for vim users so consistent
indentation will be used.
#47 14659 tony Add ignore file support to P4Ruby.
This change adds
three new methods:

    P4#ignore_file        - Return current ignore file
    P4#ignore_file=        - Set ignore file name
    P4#ignored?        - Test if a path is ignored

It also removes the check which objected to the use of Ruby 2.0
since we now support it. Now we simply check that you're not
using 2.1 (still a development release).
#46 14655 tony Fix crashing bug in P4Ruby when an exception is raised from within
the block passed to P4#run_resolve. This happened because the
P4::MergeData object was attached to the exception and so survived
longer than the resolve process itself. Ruby's exception handling
then tries to call P4::MergeData#to_s to format the object as a
string, but some of the internal pointers inside the MergeData object
(provided by P4Api) have already been deleted. The to_s method tried
to access those objects and caused the crash.

This change ensures that the MergeData object invalidates its pointers
to objects owned by P4Api and passed in with the scope of an individual
resolve as soon as that resolve is completed (successfully or otherwise).
#45 14650 jmistry Progress indicator for P4Ruby.

There is a new class P4::Progress that is set up to be subclassed by a user.
It has the following interface and P4Ruby expects the following class methods to
be defined by the user (even if it's an empty implementation):

    class Progress:
        def init(type)
        end

        def description(description, units )
        end

        def total( total )
        end

        def update( position )
        end

        def done( fail )
        end
    end

Users need to create a subclass of P4::Progress and assign an instance to P4
to enable the progress indicator:

class MyProgress < P4::Progress
    def update(pos):
       # do something with the value here

    # other methods

p4 = P4.new
p4.progress = MyProgress.new

New feature to be documented in the release notes.
#44 14629 jmistry Implemented 'action resolve' in P4Ruby.

This extends the existing P4MergeData class to support action resolve.  Users
will need to test the MergeData object passed to the block to determine if the
resolve is for content (P4::MergeData#content_resolve?) or action
(P4::MergeData#action_resolve?).  The attributes available in
'P4::MergeDatamerge' for an action resolve are:

merge_action : The action chosen for the merge, can be emtpy
yours_action: your action/filetype
their_action: their action/filetype
type: the type of merge. Can be
         "Branch resolve",
         "Filetype resolve",
         "Delete resolve"
         "Filename resolve"
info: a dictionary with additional information that can vary with the resolve
type.

Updated unit test to test action resolve.

User visible change, to be documented in the release notes for 2012.1.
#43 14611 jmistry Support setting values in the registry through P4Ruby.
The command P4.set_env( var, val ) will set a registry variably on platforms
that support this action or through an exception on Unix.
The command P4.set_env( var ) resets a registry variable.

Updated unit test '02_environment.rb' to include registry set/check.

User visible change to be documented in release notes.
#42 14608 jmistry Add encoding to Strings

As part of adding Ruby 1.9 support we need to associate the encoding
for Ruby's strings from the server.  This approach is similar to Sven's
(in changelist 257263), where everything but the 'content' charset was
set to 'utf8'.  The content charset is picked up from P4CHARSET and this
is used to translate any file content.

Also disabled the Ruby 1.9 warning for each compile.

User visible change to be documented in release notes.
#41 14595 jmistry P4.identify now includes API change

P4.identify output now includes C/C++ API change and report product
name as P4RUBY, instead of P4Ruby.

So, the output now looks like this:
    Rev. P4RUBY/DARWIN10U/2011.1.MAIN/279655 (2011.1.MAIN/279655 API) (2011/01/04).
#40 14593 Sven Erik Knop P4Ruby implementation of OutputHandler.
Also, debug is now treated as a normal attribute and can be read.

Test cases still missing.

New functionality, to be documented in release notes.
#39 14592 Sven Erik Knop Enable P4-Ruby to compile and test with Ruby 1.9.

The current solution is far from ideal because it is not possible to compile
and test both Ruby 1.8 and Ruby 1.9 in parallel. The Makefile writes both
artifacts and binaries to the same location.

This means a user/tester/builder needs to choose on Ruby platform or ensure
'make clean' is called first.

Many of the test cases also still fail in Ruby 1.9. We also need to investigate
the Unicode story with Ruby 1.9 and see if the lessons learned from Python 3
can be applied somehow.

Infrastructure change, no functional change yet.
#38 14589 Sven Erik Knop Pulled P4Ruby p10.2 changes back to main.
#37 14586 tony Streams method tidying.
Change P4#streams into P4#streams? as it
returns a boolean, and change the implementation to use
SetVar() instead of SetProtocol() now that Mark's made it work for
us.

Change to undocumented functionality
#36 14584 psoccard Added method to enable streams
#35 14583 psoccard Added support for -Ztrack
#34 14580 tony Added P4::Message#msgid method that returns the UniqueCode
of any error message - much easier than matching it's output
text.

User-visible enhancement documented in p4rubynotes.txt
#33 14579 tony Make new class P4::Message for returning Error objects
to the user. Currently handles errors and warnings, but
could potentially be used for output too (might bloat
people's code though).

Essentially, if you're using a 2010.2 or later client,
or if you've set your api_level to 68 or higher, the
P4#errors and P4#warnings arrays will be populated
with P4::Message objects instead of strings. Users of
older API's, or those who set their api_level to 67
or lower in their scripts will get the old behaviour.

P4::Message objects have the following methods:

  severity() - returns the severity
  generic()  - returns the generic code
  to_s()     - converts the message to a string
  inspect()  - returns a string showing the message details.

User-visible enhancement documented in p4rubynotes.txt
#32 14571 tony Tidy P4Ruby's connection state management.
P4ClientApi was accumulating
a lot of 'int' flags. This change combines them all into a bitmask with some
methods to encapsulate the manipulation of the mask.

I've also removed the code which worked around a very old and obscure
protocol bug in 2000.1/2000.2 servers. Anyone using a server that old
doesn't deserve the modern P4Ruby.

To test P4#server_case_sensitive? I have adapted the test suite so that
the server it runs uses the -C1 flag - so it's case-folding on all
platforms. The reason for this is that it enables the tests to  succeed
on Windows and Mac OS where case-folding is the norm.

Infrastructure change only. No functional change.
#31 14570 tony Add new P4#server_unicode?
method to P4Ruby. This allows you to
test for unicode mode servers once you've executed at least one
Perforce command. That's because the server only sends the
protocol block in response to the first command these days, and
that's when we'll find out if unicode mode is enabled.
#30 14569 tony Add P4::OS and P4::PATCHLEVEL variables so people can work out
details of the P4Ruby installation without having to parse
P4::Identify().

User-visible enhancement documented in p4rubynotes.txt
#29 14561 tony Prevent users from changing the port once they've connected to
the server.

User-visible enhancement documented in p4rubynotes.txt
#28 14560 tony Add a P4#server_case_sensitive?
method that returns true if the server
is base sensitive, and false otherwise. Raises a P4Exception if it's
used before a command has been executed.

User-visible enhancement documented in p4rubynotes.txt
#27 14558 tony Add undoc'd P4#protocol( var, val) method for calling ClientApi::SetProtocol().

I would prefer to have named methods for the important protocol variables,
or to wrap their use in other ways (see tag and specstring), but for
tunables and other ad-hoc settings, sometimes direct access is required.

User-visible change, not documented anywhere.
#26 14553 ateague Integrate change for Map::reverse bug fix where it used to change
the map instead of returning a reversed copy of the map.

Already in the release notes for 8.2.
#25 14548 tony Add new P4#tagged() method, that takes a bool, and a block.
It sets/clears
tagged output (as specified by the boolean), and runs the block. It then
resets the tagged output to its previous value. For example

   p4.tagged( false ) { ctr = p4.run_counter( 'change' ).to_i }

This is in fact the best use-case, since getting a counter value is
harder in tagged mode than in non-tagged mode. Most users
will not need this method.

User-visible enhancement documented in p4rubynotes.txt
#24 14541 tony Copyright notice housekeeping: update all notices to 2008, and
correct start date from 1997 to 2001 when P4Ruby was first released
from the public depot.

No functional change
#23 14540 tony Eliminate P4::Map.load() method, and make P4::Map.new() take
an optional array of mappings instead. Taken from P4Python.

Change to unreleased new feature
#22 14536 tony Correct prototype and returns for P4::Map stuff.
The p4_map_free
function needs to return void, not a VALUE, and the insert
method needs to return something in every code path.

Bug fixes to unreleased functionality
#21 14534 tony Add support for the MapApi class in P4Ruby.
This change adds a new
class, P4::Map, to P4Ruby's canon. The methods on P4::Map are:

    P4::Map.new        - Constructor
    P4::Map.load        - Load a map from an array
    P4::Map.join        - Join two maps to create a third

    P4::Map#clear        - Empty a map
    P4::Map#count        - Return the number of entries
    P4::Map#empty?        - Tests whether a map object is empty
    P4::Map#translate    - Translate a string through a map
    P4::Map#includes?    - Tests whether a path is mapped
    P4::Map#lhs        - Returns the left side as an array
    P4::Map#rhs        - Returns the right side as an array
    P4::Map#to_a        - Returns the map as an array

(Note, the first three are class methods, the rest instance methods)

There is also P4::Map#reverse(), but I'm not documenting that yet as
I'm not sure I understand the semantics of reversing complex maps
well enough.

User-visible enhancement documented in p4rubynotes.txt and slated
for 2008.2 release.
#20 14531 tony Add P4#env() method to allow users to read the P4 object's environment
using the same rules that P4 does. This allows values from P4CONFIG
files to be picked up automatically.

P4#cwd=() now calls Enviro::Config() to reload any config file when
the user changes directory.

User-visible enhancement documented in p4rubynotes.txt
#19 14529 tony Pull 2007.3 p4-ruby changes back to main.

Integration only change
#18 14511 tony Add P4#api_level method to get the current API level.

User-visible new feature to be documented in Scripting Interfaces
Guide.
#17 14508 tony Add 'getters': P4#maxresults, P4#maxscanrows and P4#maxlocktime to
complement the equivalent setters.

User-visible change to be documented in Scripting Interface Guide
#16 14502 tony Rework spec handling somewhat so that:

(a) P4Ruby knows about the default spec types for 2007.2 so it
    doesn't have to connect to the server to parse and format specs,
    and nor does it have to do the ugly hack of running a 'p4 xxx -o'
    and discarding the result just to get the specDef.

(b) If a user's got a custom spec then the spec cache will be updated
    if they fetch an object of that type. So basically, if the
    server's given us a specdef for a class of spec, we use it.
    Otherwise, we fall back on the builtin defaults

This reworks SpecMgr quite a bit - renaming methods so it's clearer
what they do, and making it own the spec cache. We also pass the
SpecMgr object created by P4ClientApi down to ClientUserRuby now,
so that whenever the server sends us a spec, we can update the cache.
#15 14500 tony Add P4#version= and P4#version methods to get/set the version of
the program.

User-visible change to be documented in Scripting Interface Guide
#14 14498 tony Add P4#ticket_file and P4#ticket_file= methods to get and set the
ticket file. Note that P4#ticket_file will only return something if
a value has been previously set using P4#ticket_file=(). There's
no way, in the existing P4 API to get the current ticket file.

User-visible change to be documented in Scripting Interfaces Guide
#13 14496 tony Remove implementation of P4#output.
Missed in previous change
#12 14495 tony Remove P4#output() method used to refetch the output if you've
somehow lost it. Really shouldn't be needed and we don't want
to implement this in the other languages. So...

User-visible change to be de-documented in the Scripting Interfaces
Guide.
#11 14494 tony Add P4#maxlocktime=( int ) method to allow users to specify the
maximum number of milliseconds for which locks may be held.
#10 14493 tony Turn on tagged mode by default, and make parse_forms mode
always on (it only works when tagged mode is on too). Now
users can turn tagged mode off if they want to by calling:

    p4.tagged = false

and turn it back on by calling:

    p4.tagged = true

You can test the current state of affairs using:

    p4.tagged?

User-visible change to be documented in Scripting Interface Guide
#9 14492 tony Rename P4#input to P4#input=, and fix all pre-existing calls.
The
main existing callers are p4.run_password, p4.run_submit and
and p4.run_login. There was also a bug with p4.run_password() which
meant that you couldn't change a user's password if they hadn't
already set one. Fixed that while I was there and added a test
case to check that password setting, use and clearing works.
#8 14489 tony Add P4#server_level method to return the protocol level of the
server. Raises a P4Exception if you attempt to use it before
running a command (since the server2 variable is only sent to
the client after the client runs a command).

New method to be documented in Scripting Interfaces Guide
#7 14488 tony Add P4#language and P4#language= methods to allow users to get/set
their language (mostly applies to Japanese I guess)

Change to unreleased functionality
#6 14487 tony Add P4#connected?
to test whether or not the session (a) has been
connected and (b) has not been dropped.

Functional change to unreleased code.
#5 14486 tony Add P4#config_file method to return the path to the P4CONFIG file
in use.
#4 14485 tony Rename P4#api= to P4#api_level=

User visible change to be documented in Scripting Interfaces Guide
#3 14483 tony Method name rationalisation, part 1.
All the methods with names ending
with '?' that do not return booleans now have the '?' dropped. This
will be used to ensure consistency across the scripting interfaces.

Added P4#prog() -> <string> to partner P4#prog=( <string> )

Removed some redundant aliases that we're dropping support for in
future versions
#2 14482 tony Use Ident from Perforce API to identify P4Ruby instead of home-grown
equivalent. The extra information included in the original output
will be added into new methods later.
#1 14480 tony Add P4Ruby 1.5944 to main as start-point for the first
productized release of P4Ruby