diff --git a/tren.py b/tren.py index 5e4a6bf..b74f132 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.184 2010/03/10 22:18:20 tundra Exp $" +RCSID = "$Id: tren.py,v 1.185 2010/03/10 23:37:27 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -440,6 +440,13 @@ def __init__(self, targs): + # Keep track of all the new filenames we write (or would have) + # so test mode can correctly report just what the the progam + # *would* do. Without this, backup generation is not properly + # reported in test mode. + + self.NewNames = [] + # Dictionary of all rename targets and their stat info self.RenNames = {} @@ -758,7 +765,7 @@ # backups-of-backups are preserved. doit = True - if os.path.exists(fullnew): + if os.path.exists(fullnew) or fullnew in self.NewNames: if ProgramOptions[FORCERENAME]: @@ -774,6 +781,7 @@ if doit: + self.NewNames.append(fullnew) InfoMsg(indent + iRENAMING % (fullold, fullnew)) if not ProgramOptions[TESTMODE]: @@ -969,7 +977,7 @@ if precision < 1: ErrorMsg(eTOKRANDIG % str(precision)) - fmt = '"%0' + str(precision) + 'd" % random.randint(0, pow(10, precision))' + fmt = '"%0' + str(precision) + 'd" % random.randint(0, pow(10, precision)-1)' r[2] = eval(fmt) ###