retry / redo question

Discussion in 'Ruby' started by Rebhan, Gilbert, Feb 26, 2007.

  1. Hi,

    i have a ruby script that does for 1 - n folders a
    cp_r of every folder to an existing cvs workspace
    and afterwards the cvs operations=20
    update to determine if add is needed
    add if needed 1-n times
    commit

    As the cvs CLI lacks a recursive parameter for
    the update / add commands, means when a new file
    like subfolder/subfile.txt comes in=20
    the add command only recognizes subfolder, but the=20
    subfile.txt only after a 2nd add command

    i have to do =3D

    1. updpipe=3DIO.popen("#{CVSEXE} -d #{CVSROOT} update")
    updpipe.readlines.each { |x|=20
    updfiles<<'.'<<'/'<<x[2..-2]<<' ' }

    to determine whether there are new files to be added

    if updfiles !=3D 0 i have to execute the cvs add command =3D

    2.addpipe=3DIO.popen("#{CVSEXE} -d #{CVSROOT} add #{updfiles.to_s}")
    addpipe.readlines.each { |x|=20
    addfiles<<'.'<<'/'<<x[2..-2]<<' ' }

    this add command gives me other folders or files that are also to be
    added, if there are more to be added, i.e subfolders/subfiles ...

    so i have to do the cvs add in a loop until nothing more comes
    back from that cvs add command.=20

    then i have to do a final commit =3D

    3.system("#{CVSEXE}","-d","#{CVSROOT}","commit","-m","bla bla bla bla")


    Now i'm looking for the best loop construct, i know
    the addfiles array has to be cleared after every cvs add before
    executing cvs add again

    There is something like retry/redo i tried with retry after and before
    the end of a while loop=20

    updfiles=3DArray.new
    updpipe=3DIO.popen("#{CVSEXE} -d #{CVSROOT} update")
    updpipe.readlines.each { |x|=20
    updfiles<<'.'<<'/'<<x[2..-2]<<' ' }

    while updfiles.length > 0
    addfiles=3DArray.new
    addpipe=3DIO.popen("#{CVSEXE} -d #{CVSROOT} add #{updfiles.to_s}")
    addpipe.readlines.each { |x|=20
    addfiles<<'.'<<'/'<<x[2..-2]<<' ' }=09
    updfiles.clear
    addfiles.clear
    updpipe.readlines.each { |x|=20
    updfiles<<'.'<<'/'<<x[2..-2]<<' ' }
    end
    *retry*

    but got :

    retry outside of rescue clause (LocalJumpError)


    What's the right loop ?
    Is there a solution without retry / redo ?


    Regards, Gilbert
     
    Rebhan, Gilbert, Feb 26, 2007
    #1
    1. Advertising

  2. On 26.02.2007 13:40, Rebhan, Gilbert wrote:
    > Hi,
    >
    > i have a ruby script that does for 1 - n folders a
    > cp_r of every folder to an existing cvs workspace
    > and afterwards the cvs operations
    > update to determine if add is needed
    > add if needed 1-n times
    > commit
    >
    > As the cvs CLI lacks a recursive parameter for
    > the update / add commands, means when a new file
    > like subfolder/subfile.txt comes in
    > the add command only recognizes subfolder, but the
    > subfile.txt only after a 2nd add command
    >
    > i have to do =
    >
    > 1. updpipe=IO.popen("#{CVSEXE} -d #{CVSROOT} update")
    > updpipe.readlines.each { |x|
    > updfiles<<'.'<<'/'<<x[2..-2]<<' ' }
    >
    > to determine whether there are new files to be added
    >
    > if updfiles != 0 i have to execute the cvs add command =
    >
    > 2.addpipe=IO.popen("#{CVSEXE} -d #{CVSROOT} add #{updfiles.to_s}")
    > addpipe.readlines.each { |x|
    > addfiles<<'.'<<'/'<<x[2..-2]<<' ' }
    >
    > this add command gives me other folders or files that are also to be
    > added, if there are more to be added, i.e subfolders/subfiles ...
    >
    > so i have to do the cvs add in a loop until nothing more comes
    > back from that cvs add command.
    >
    > then i have to do a final commit =
    >
    > 3.system("#{CVSEXE}","-d","#{CVSROOT}","commit","-m","bla bla bla bla")
    >
    >
    > Now i'm looking for the best loop construct, i know
    > the addfiles array has to be cleared after every cvs add before
    > executing cvs add again
    >
    > There is something like retry/redo i tried with retry after and before
    > the end of a while loop
    >
    > updfiles=Array.new
    > updpipe=IO.popen("#{CVSEXE} -d #{CVSROOT} update")
    > updpipe.readlines.each { |x|
    > updfiles<<'.'<<'/'<<x[2..-2]<<' ' }
    >
    > while updfiles.length > 0
    > addfiles=Array.new
    > addpipe=IO.popen("#{CVSEXE} -d #{CVSROOT} add #{updfiles.to_s}")
    > addpipe.readlines.each { |x|
    > addfiles<<'.'<<'/'<<x[2..-2]<<' ' }
    > updfiles.clear
    > addfiles.clear
    > updpipe.readlines.each { |x|
    > updfiles<<'.'<<'/'<<x[2..-2]<<' ' }
    > end
    > *retry*
    >
    > but got :
    >
    > retry outside of rescue clause (LocalJumpError)
    >
    >
    > What's the right loop ?
    > Is there a solution without retry / redo ?


    If you want to use retry you need to do that in an rescue clause as the
    error message indicates.

    However, I think, you should rather change the logic.

    First, I'd start with using http://raa.ruby-lang.org/project/ruby-cvs/
    to make CVS accesses more efficient (you do not start a process for each
    CVS command).

    Then, if you do the recursive traversal through the file tree (probably
    using Find.find) I'd add a non existing directory immediately whenever I
    see it. That way you can be sure that all directories on the path are
    present in the repository before you add individual files. HTH

    Regards

    robert
     
    Robert Klemme, Feb 26, 2007
    #2
    1. Advertising

  3. =20
    Hi,


    /*
    However, I think, you should rather change the logic.

    First, I'd start with using http://raa.ruby-lang.org/project/ruby-cvs/=20
    to make CVS accesses more efficient (you do not start a process for each

    CVS command).
    */

    I already thought of that too, need to have a detailled look,
    whether this library works also with cvsnt, which we use here
    as cvs server for windows.

    i.e. cvsnt stores it's passwords in the registry, not in
    user.home/.cvspass
    etc.

    /*
    Then, if you do the recursive traversal through the file tree (probably=20
    using Find.find)=20
    I'd add a non existing directory immediately whenever I=20
    see it. That way you can be sure that all directories on the path are=20
    present in the repository before you add individual files.
    */

    i thought of something similar and tried with :

    newfiles=3DDir["Y:/test_deploy/**/*.*"] - Dir["Y:/cvsworkspace/**/*.*"]

    but that gives me the whole path, i.e.=20
    Y:/test_deploy/subfolder7/subsub7/bla.txt, whereas i need it as space
    separated list for :
    cvs add ./subfolder7 ./subfolder7/subsub7 ./subfolder7/subsub7/bla.txt

    Any idea how this could get a working solution ?!


    Regards, Gilbert
     
    Rebhan, Gilbert, Feb 26, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lloyd Sheen

    Please help, cannot redo server

    Lloyd Sheen, Feb 25, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    277
    Lloyd Sheen
    Feb 25, 2004
  2. Andreas Wachhold

    Undo/Redo Java?

    Andreas Wachhold, May 4, 2004, in forum: Java
    Replies:
    2
    Views:
    4,969
    Mykola Rabchevskiy
    May 4, 2004
  3. black

    undo and redo

    black, Dec 23, 2003, in forum: Python
    Replies:
    0
    Views:
    376
    black
    Dec 23, 2003
  4. black

    undo and redo ?

    black, Jan 2, 2004, in forum: Python
    Replies:
    1
    Views:
    375
    Diez B. Roggisch
    Jan 2, 2004
  5. John Benson

    undo/redo, windows clipboard

    John Benson, Jan 2, 2004, in forum: Python
    Replies:
    0
    Views:
    362
    John Benson
    Jan 2, 2004
Loading...

Share This Page