clientuserruby.cpp #27

  • //
  • guest/
  • perforce_software/
  • p4ruby/
  • main/
  • clientuserruby.cpp
  • Commits
# Change User Description Committed
#27 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
#26 14656 tony Squelch annoying compiler warnings when building P4Ruby
#25 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).
#24 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.
#23 14636 jmistry Fix binary file resolve

Accessing the base_name attribute of a P4::MergeData object resulted
in a segmentation fault when resolving binary files. This is because the
base file is empty for binary files, and the Name() method invoked on it does
not protect itself in case of a NULL value.

User visible change, to be documented in the release notes.
#22 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.
#21 14628 jmistry Quit resolve if there is an exception.

Follow-on from change @410702, which raised exceptions up to the user from
P4#run_resolve.  Further testing showed that if multiple resolves are
scheduled and an exception is raised, then subsequent resolves would clear
that.  We now check if an exception has been raised by an earlier resolve and
return early if there has been.

Unit test has been updated with this case.

User visible change to be documented in release notes.
#20 14626 jmistry raise exceptions in P4#run_resolve

Any exceptions raised during the block passed to P4#run_resolve were silently
swallowed.  We still use 'rb_protect()' to run the block in the user's script;
however, we now stash where the exception happened in 'rubyExcept' (a member of
'ClientUserRuby') instead of just a local variable.  After running a command, I
now run 'ClientUserRuby::RaiseRubyException()' - if an exception has been
caught by 'rb_protect()' we now run 'rb_jump_tag()' to jump to the exception
and raise it up.

User visible change to be documented in release notes.
#19 14624 jmistry Pull p11.1 changes back to main
#18 14622 jmistry Pull 10.2 changes to main

Pick up missing changes in p10.2 and integrate to main.

As part of the integrate I also moved the unit tests '16_streams.rb' and
'17_streaming_handler.rb' because the integration introduced collisions with
the unit test names. Updated MANIFEST with new names for unit tests and also
added '98_unicode.rb', which was missing from it.
#17 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.
#16 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.
#15 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.
#14 14589 Sven Erik Knop Pulled P4Ruby p10.2 changes back to main.
#13 14583 psoccard Added support for -Ztrack
#12 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
#11 14573 tony Remove old Ruby 1.6 cruft from P4Ruby.
This has the beneficial
side effect of allowing it to build with Ruby 1.9. It seems
to work with Ruby 1.9 now, but the test harness doesn't so
Ruby 1.9 support remains unofficial for now.

User-visible infrastructure change. Documented in p4rubynotes.txt
#10 14547 tony Ensure that P4Ruby does not go into an infinite loop when resolve
is executed without a block.

User-visible bug fix documented in p4rubynotes.txt
#9 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
#8 14525 tony Fix for bug reported for P4Perl by Bob Bell.
P4Ruby's also
affected. ClientUserRuby::OutputText() assumed the data was
null terminated, but in the case of unicode data, it won't be.
This change ensures that all the data makes it through to
Ruby space.
#7 14521 tony Update copyright notices in all applicable P4Ruby files.
#6 14504 tony Disambiguate my specs: rename AddSpec() to AddSpecDef() and
HaveSpec() to HaveSpecDef() since those methods deal with
manipulating the specdef cache rather than producing specs
themselves.
#5 14503 tony Followon to previous change.
Remove overloaded SpecMgr::SpecToString()
as, now that ClientUserRuby knows which command we're running, we can
dispense with it.
#4 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.
#3 14484 tony Remove the old const_char macro from P4Perl and P4Ruby (P4Python
never used it). Since we're going to insist on an API later than
2006.1, we can ditch this piece of legacy compatibility.
#2 14481 tony Update P4Ruby in main with fixes made to public depot
#1 14480 tony Add P4Ruby 1.5944 to main as start-point for the first
productized release of P4Ruby