Changeset 852 in tailor


Ignore:
Timestamp:
09/27/05 23:01:30 (8 years ago)
Author:
lele@…
Hash name:
20050927210130-97f81-631fb1bfd4a04fd079182d4588b1a98ba4e576ca
Message:

Under hg, the rename must walk over old directory contents

Location:
vcpx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • vcpx/hg.py

    r850 r852  
    8989 
    9090        from os.path import join, isdir 
    91         from os import walk 
    92         from dualwd import IGNORED_METADIRS 
    9391 
    9492        cmd = self.repository.command("rename", "--after") 
     
    9694        if isdir(join(self.basedir, newname)): 
    9795            # Given lack of support for directories in current HG, 
    98             # loop over all files under the new directory and 
    99             # do a copy on them. 
    100             skip = len(self.basedir)+len(newname)+2 
    101             for dir, subdirs, files in walk(join(self.basedir, newname)): 
    102                 prefix = dir[skip:] 
    103  
    104                 for excd in IGNORED_METADIRS: 
    105                     if excd in subdirs: 
    106                         subdirs.remove(excd) 
    107  
    108                 for f in files: 
    109                     copy.execute(join(oldname, prefix, f), 
    110                                  join(newname, prefix, f)) 
     96            # loop over all files presented by "hg manifest" under the 
     97            # old directory and do a copy on them. 
     98            cmd = self.repository.command("manifest") 
     99            manifest = ExternalCommand(cwd=self.basedir, command=cmd) 
     100            output = manifest.execute(stdout=PIPE)[0] 
     101            for row in output: 
     102                sha, mode, oldpath = row[:-1].split(' ') 
     103                if oldpath.startswith(oldname): 
     104                    tail = oldpath[len(oldname)+2:] 
     105                    copy.execute(oldpath, join(newname, tail)) 
    111106                    if copy.exit_status: 
    112107                        raise ChangesetReplayFailure("Could not rename %r " 
  • vcpx/hglib.py

    r850 r852  
    6868        """Rename an entry""" 
    6969 
    70         from os.path import join, isdir 
    71         from os import walk 
    72         from dualwd import IGNORED_METADIRS 
     70        from os.path import join, isdir, normpath 
    7371 
    7472        if isdir(join(self.basedir, newname)): 
    7573            # Given lack of support for directories in current HG, 
    76             # loop over all files under the new directory and 
     74            # loop over all files under the old directory and 
    7775            # do a copy on them. 
    78             skip = len(self.basedir)+len(newname)+2 
    79             for dir, subdirs, files in walk(join(self.basedir, newname)): 
    80                 prefix = dir[skip:] 
    81  
    82                 for excd in IGNORED_METADIRS: 
    83                     if excd in subdirs: 
    84                         subdirs.remove(excd) 
    85  
    86                 for f in files: 
    87                     self._hg.copy(join(oldname, prefix, f), 
    88                                   join(newname, prefix, f)) 
    89                     self._hg.remove([join(oldname, prefix, f)]) 
     76            for src, oldpath in self._hg.dirstate.walk(oldname): 
     77                tail = oldpath[len(oldname)+2:] 
     78                self._hg.copy(oldpath, join(newname, tail)) 
     79                self._hg.remove([oldpath]) 
    9080        else: 
    9181            self._hg.copy(oldname, newname) 
Note: See TracChangeset for help on using the changeset viewer.