summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-12-11 21:31:46 +0000
committerZac Medico <zmedico@gentoo.org>2009-12-11 21:31:46 +0000
commitc8d6ae7b93b13984f6a4b1b4d38210284dd8181b (patch)
treeeb87e10579be7cbe0d684047c056fe70e027c1cd
parent3780f0f6bcf3bc12082f3b0ee63f29b808fa530c (diff)
downloadportage-c8d6ae7b93b13984f6a4b1b4d38210284dd8181b.tar.gz
portage-c8d6ae7b93b13984f6a4b1b4d38210284dd8181b.tar.bz2
portage-c8d6ae7b93b13984f6a4b1b4d38210284dd8181b.zip
Tweak movefile() timestamp preservation code to maximize precision for old
timestamps that are closer to the epoch. svn path=/main/trunk/; revision=15039
-rw-r--r--pym/portage/__init__.py42
1 files changed, 21 insertions, 21 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 953d403e8..863af1203 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -7676,28 +7676,28 @@ def movefile(src, dest, newmtime=None, sstat=None, mysettings=None,
else:
# Prevent mtime from rounding up to the next second.
int_mtime = sstat[stat.ST_MTIME]
- mtime_str = "%i.9999999" % int_mtime
- min_len = len(str(int_mtime)) + 2
- while True:
- mtime_str = mtime_str[:-1]
- newmtime = float(mtime_str)
- if int_mtime == long(newmtime):
- another_digit = None
- for i in range(1, 9):
- i_str = str(i)
- if int_mtime != long(float(mtime_str + i_str)):
- break
- else:
- another_digit = i_str
- if another_digit is not None:
- mtime_str += another_digit
- newmtime = float(mtime_str)
- break
- elif len(mtime_str) <= min_len:
- # This shouldn't happen, but let's make sure
- # we can never have an infinite loop.
- newmtime = int_mtime
+ mtime_str = "%i." % int_mtime
+ digits = 0
+ max_digits = 9
+ while digits < max_digits:
+ if int_mtime == long(float(mtime_str + "9")):
+ mtime_str += "9"
+ digits += 1
+ else:
+ if digits < max_digits:
+ another_digit = None
+ for i in range(1, 9):
+ i_str = str(i)
+ if int_mtime != \
+ long(float(mtime_str + i_str)):
+ break
+ else:
+ another_digit = i_str
+ if another_digit is not None:
+ mtime_str += another_digit
+ digits += 1
break
+ newmtime = float(mtime_str)
os.utime(dest, (newmtime, newmtime))
newmtime = sstat[stat.ST_MTIME]