diff --git a/tren.py b/tren.py index 54ad8b2..13bc53c 100755 --- a/tren.py +++ b/tren.py @@ -8,7 +8,7 @@ PROGNAME = "tren.py" BASENAME = PROGNAME.split(".py")[0] PROGENV = BASENAME.upper() -RCSID = "$Id: tren.py,v 1.162 2010/02/26 18:56:41 tundra Exp $" +RCSID = "$Id: tren.py,v 1.163 2010/02/26 20:11:29 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -574,17 +574,7 @@ # Nothing to do, if old- and new names are the same if newname != oldname: - - # If we're in test mode, just show what we would do - - if ProgramOptions[TESTMODE]: - - InfoMsg(iRENAMING % (pathname+oldname, pathname+newname)) - - # Otherwise, actually do the renaming - - else: - self.__RenameIt(pathname, oldname, newname) + self.__RenameIt(pathname, oldname, newname) # End of 'ProcessRenameRequests()' @@ -614,17 +604,13 @@ fullold = pathname + oldname fullnew = pathname + newname - # Let the user know what we're trying to do - - InfoMsg(indent + iRENAMING % (fullold, fullnew)) - # See if our proposed renaming is about to stomp on an # existing file, and create a backup if forced renaming - # requested. We such backups with a recursive call to - # ourselves so that length and backups of backups are - # enforced. + # requested. We do such backups with a recursive call to + # ourselves so that filename length limits are observed and + # backups-of-backups are preserved. - + doit = True if os.path.exists(fullnew): if ProgramOptions[FORCERENAME]: @@ -635,21 +621,20 @@ InfoMsg(indent + iRENFORCED % fullnew) self.__RenameIt(pathname, newname, bkuname) - # Rename the original - - self.__RenameIt(pathname, oldname, newname) - - else: InfoMsg(indent + iRENSKIPPED % (fullnew, fullold)) + doit = False - # No target conflict, just do the requested renaming + if doit: - else: - try: - os.rename(fullold, fullnew) - except OSError as e: - ErrorMsg(eRENAMEFAIL % (fullold, fullnew, e.args[1])) + InfoMsg(indent + iRENAMING % (fullold, fullnew)) + + if not ProgramOptions[TESTMODE]: + + try: + os.rename(fullold, fullnew) + except OSError as e: + ErrorMsg(eRENAMEFAIL % (fullold, fullnew, e.args[1])) self.indentlevel -= 1