#65: failure to rename back from -TAILOR-HACKED-TEMP-NAME
---------------------+------------------------------------------------------
  Reporter:  dato    |       Owner:  lele      
      Type:  defect  |      Status:  new       
  Priority:  major   |   Milestone:  VersionOne
 Component:  tailor  |     Version:  0.9       
Resolution:          |    Keywords:            
---------------------+------------------------------------------------------

Comment(by HenryN):

 This is more that should do for directory renamings on SVN:
 {{{
 [PATCH] Ticket #97: Rename direcory fails, because exist .svn directory

 # Ticket #97: If the target reposity has files in subdirectory, then
 remove
 # the complete dir. But keep the dir '.svn'

 # Hack for the hack:
 # Remove back all directories '.svn' from the old to new directory.
 # Remember: TAILOR-HACKED-TEMP-NAME contains the new files!
 #
 # FIXME:
 # o This is only a warkarround for Subversion and should be generaly
 #   rewriten for all repositories generaly.
 # o The UTF-8 support for filenames is broken, becaus len of filename is
 not
 #   the real stringlength. The line
 #   join(absnew + '-TAILOR-HACKED-TEMP-NAME' + root[len(absnew):], '.svn')
 #   should written by path splitting and re-join the path.
 #   Or working relative from TAILOR-HACKED-TEMP-NAME (not absolute)?
 # o shared_basedirs are untouched, not tested and would have same
 problems.

 Index: tailor-snapshot-modify/vcpx/target.py
 ===================================================================
 --- tailor-snapshot-modify.orig/vcpx/target.py
 +++ tailor-snapshot-modify/vcpx/target.py
 @@ -429,8 +429,9 @@
          of each entry.
          """

 -        from os import rename
 -        from os.path import split, join, exists
 +        from os import rename, walk
 +        from shutil import rmtree
 +        from os.path import split, join, exists, isdir

          added = []
          for e in entries:
 @@ -464,7 +465,6 @@
                  # rename the new one, perform the target system rename
                  # and replace back the real content (it may be a
                  # renamed+edited event).
 -                renamed = False
                  absnew = join(self.repository.basedir, e.name)
                  renamed = exists(absnew)
                  if renamed:
 @@ -477,6 +477,49 @@
                      if self.shared_basedirs:
                          rename(absold + '-TAILOR-HACKED-TEMP-NAME',
 absold)
                      else:
 +
 +                        # before rsync      after rsync      the HACK
 after "svn mv"           result
 +                        # /basedir          /basedir         /basedir
 /basedir                 /basedir
 +                        # |                 |                |
 |                        |
 +                        # +- /dirold        +- /dirold       +- /dirold
 +- /dirnew        move   |
 +                        #    |              |  |             |  |
 |  |~~~~~~        hack   |
 +                        #    +- /.svn       |  +- /.svn      |  +- /.svn
 |  +- /.svn  >-------+   |
 +                        #    |              |  |             |  |
 |  |                 |   |
 +                        #    +- /subdir     |  +- /subdir    |  +-
 /subdir       |  +- /subdir        v   |
 +                        #       |           |     |          |     |
 |     |              |   |
 +                        #       +- /.svn    |     +- /.svn   |     +-
 /.svn      |     +- /.svn  >--+ |   |
 +                        #                   |                |
 |                  | |   |
 +                        #                   +- /dirnew       +- /dirnew-
 HACKED   +- /dirnew-HACKED  v |   +- /dirnew
 +                        #                      |~~~~~~          |
 ~~~~~~~      |               | |      |
 +                        #                      |                |
 |               +-|--->  +- /.svn
 +                        #                      |                |
 |                 |      |   ~~~~
 +                        #                      +- /subdir       +-
 /subdir          +- /subdir        |      +- /subdir
 +                        #                          ~~~~~~
 |        |
 +                        #
 +----->  +- /.svn
 +                        #
 ~~~~
 +
 +                        # Ticket #97
 +                        # If the target reposity has files in
 subdirectory,
 +                        # then remove the complete dir.
 +                        # But keep the dir '.svn'
 +                        # FIXME: should do in repository/svn.py, and also
 in
 +                        #        cvs and all other repositories with
 book-
 +                        #        kepping dir or file in subdirs
 +                        if isdir(absnew):
 +                            if exists(absnew + '/.svn'):
 +                                rename(absnew + '/.svn', absnew +
 '-TAILOR-HACKED-TEMP-NAME/.svn')
 +
 +                            for root, dirs, files in walk(absnew):
 +                                if '.svn' in dirs:
 +                                    dirs.remove('.svn')  # don't visit
 SVN directories
 +
 +                                svnnew = join(root, '.svn')
 +                                if exists(svnnew):
 +                                    hacked = join(absnew + '-TAILOR-
 HACKED-TEMP-NAME' + root[len(absnew):], '.svn')
 +                                    rename(svnnew, hacked)
 +
 +                            rmtree(absnew)
 +
                          rename(absnew + '-TAILOR-HACKED-TEMP-NAME',
 absnew)

      def _renamePathname(self, oldname, newname):
 }}}

-- 
Ticket URL: <http://progetti.arstecnica.it/tailor/ticket/65#comment:7>
Tailor <http://progetti.arstecnica.it/tailor>
An inter-VCs changeset exchanger
_______________________________________________
Tailor mailing list
[email protected]
http://lists.zooko.com/mailman/listinfo/tailor

Reply via email to