diff --git a/tren.py b/tren.py index f8e6ff2..133b032 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.207 2010/03/19 17:50:22 tundra Exp $" +RCSID = "$Id: tren.py,v 1.208 2010/03/23 17:53:29 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -572,7 +572,8 @@ # *would* do. Without this, backup generation is not properly # reported in test mode. - self.NewNames = [] + self.RenamedFiles = [] + self.NewFiles = [] # Dictionary of all rename targets and their stat info @@ -1049,7 +1050,10 @@ # backups-of-backups are preserved. doit = True - if os.path.exists(fullnew) or fullnew in self.NewNames: + newexists = os.path.exists(fullnew) + + if (not ProgramOptions[TESTMODE] and newexists) or \ + (ProgramOptions[TESTMODE] and fullnew not in self.RenamedFiles and (newexists or fullnew in self.NewFiles)): if ProgramOptions[FORCERENAME]: @@ -1098,8 +1102,16 @@ # In test mode, track file names that would be produced. if ProgramOptions[TESTMODE]: - self.NewNames.append(fullnew) + + self.NewFiles.append(fullnew) + self.RenamedFiles.append(fullold) + if fullold in self.NewFiles: + self.NewFiles.remove(fullold) + + if fullnew in self.RenamedFiles: + self.RenamedFiles.remove(fullnew) + InfoMsg(indent + iRENAMING % (fullold, fullnew)) if not ProgramOptions[TESTMODE]: