phpwindowssvntagscmd

Subversion find tag by part of its name (on Windows)


How do I find tag by part of its name?

I have this structure in a repository:

/trunk
/tags
   /Revert
   /86__20140206_123000
   /85__20140205_123000
   /{rev_no}{2x_}{YYYYMMHH}{1x_}{HHiiss}

I am working on a revert procedure: Trunk is faulty, so PHP script will do:

  1. copy /tags/Revert tag to /trunk
  2. copy tag with top number of revision no to /tags/Revert
  3. remove copied in point 2. tag

So the next commit (via PHP) will be:

  1. copy /tags//Revert to /tags/{rev_no}{2x__}{now_date_time} tag
  2. copy /trunk to Revert tag
  3. put (copy from dev branch) the new staff to /trunk/

Creating, removing, copying works fine. The only problem is that I need to find (on Windows) the tag to copy to Revert, base only on part of its name: I have {rev_no}{2x__}

svn copy [repo]/tags/ | find "86__*" /. [repo]/trunk gives as result: File not found - "86__*"/;

In fact, I tried many options, but all failed.

I am issuing those commands via php execute, so I think I need to try a single command to capture tag name and next command to copy its content to trunk.

How do I achieve this?


Solution

  • Preface

    1. Undo revisions in natural, brain-powered way performed by reverse-merge bad revisions (to "Last-Known-Good")
    2. Single Last-Known-Good may be stored as custom svn-property inside trunk instead of cluttering of tags

    Tags (and any other node) per se contain all needed data, reachable by svn ls or svn log (src, src rev, timestamp of creating)

    If you want to eliminate future headaches for all, best choice will be re-design all from scratch (see my notes 1-2 above)

    Face

    The only problem is that I need to find (on windows) tag to copy to Revert

    If revision is leading part of tag-name and because Windows sort it worse than terrible, you must to rename all tags and add leading zeroes for correct numerical sorting, without it sort will give you something like

    /125__20140207_123000
    /85__20140203_123000
    /86__20140204_123000
    /99__20140205_123000
    

    or, with thousands in set

    /125__20140207_123000
    /4025__20140307_123000
    /85__20140203_123000
    /86__20140204_123000
    /99__20140205_123000
    

    contrary to

    /0085__20140203_123000
    /0086__20140204_123000
    /0099__20140205_123000
    /0125__20140207_123000
    /4025__20140307_123000
    

    in any case, list of all existing tags is svn ls URL. AFAICR (TBT!!!), newest tags are always on bottom, regardless of name

    > svn ls http://websvn.tigris.org/svn/websvn/tags
    1.00/
    1.01/
    1.02/
    ...
    2.3.3/
    

    you can use tag-name from last line and combine URL, or use svn ls -v

    >svn ls -v http://websvn.tigris.org/svn/websvn/tags
       1268 dirkthom              июн 27  2011 ./
          2 tarmes                фев 04  2004 1.00/
          7 tarmes                фев 05  2004 1.01/
         14 tarmes                фев 06  2004 1.02/
        ...
       1268 dirkthom              июн 27  2011 2.3.3/
    

    and find freshest tag (last column) by max revision in first column (1268 dirkthom июн 27 2011 2.3.3/) or use svn log for tags, only for latest revision, with filelist, and get last tag as part of affected files

    >svn log -l 1 http://websvn.tigris.org/svn/websvn/tags -q -v
    ------------------------------------------------------------------------
    r1268 | dirkthomas | 2011-06-27 15:12:51 +0600 (Пн, 27 июн 2011)
    Changed paths:
       M /package.cmd
       M /package.sh
       A /tags/2.3.3 (from /branches/2.3:1266)
       ...
    

    A /tags/2.3.3 will identify for you latest tag