[PATCH] archive: pass thru mtime for directory archives, like the other archive types do

James May james.may at draeger.com
Fri Dec 1 06:41:31 UTC 2017


# HG changeset patch
# User James May <james.may at draeger.com>
# Date 1512110361 -39600
#      Fri Dec 01 17:39:21 2017 +1100
# Node ID b7a1f6fbfe150ab776c2cb48c120aab97f6d7e7f
# Parent  6864c405f0235d5c42937658049f0405d5d1abdc
archive: pass thru mtime for directory archives, like the other archive types do

Without this files in the output archive directory have their mtimes set to
whatever time they were written their.  This is in this inconsistent with
the other archivers, eg. zip, which use exactly the same time for all files.

Works on my machine (Windows), but I don't have a *nix box avaialble to run
anything more thourugh, unfortunately.

diff -r 6864c405f023 -r b7a1f6fbfe15 mercurial/archival.py
--- a/mercurial/archival.py	Thu Nov 30 22:32:13 2017 +0900
+++ b/mercurial/archival.py	Fri Dec 01 17:39:21 2017 +1100
@@ -262,6 +262,7 @@
     def __init__(self, name, mtime):
         self.basedir = name
         self.opener = vfsmod.vfs(self.basedir)
+        self.mtime = mtime
 
     def addfile(self, name, mode, islink, data):
         if islink:
@@ -272,6 +273,8 @@
         f.close()
         destfile = os.path.join(self.basedir, name)
         os.chmod(destfile, mode)
+        if self.mtime is not None:
+            os.utime(destfile, (self.mtime, self.mtime))
 
     def done(self):
         pass
@@ -299,7 +302,11 @@
 
     matchfn is function to filter names of files to write to archive.
 
-    prefix is name of path to put before every archive member.'''
+    prefix is name of path to put before every archive member.
+    
+    mtime is the modified time, in seconds, or None to use the changeset time
+    
+    subrepos tells whether to include subrepos'''
 
     if kind == 'files':
         if prefix:
--- This communication contains confidential information. If you are not the intended recipient please return this email to the sender and delete it from your records. Diese Nachricht enthaelt vertrauliche Informationen. Sollten Sie nicht der beabsichtigte Empfaenger dieser E-mail sein, senden Sie bitte diese an den Absender zurueck und loeschen Sie die E-mail aus Ihrem System.



More information about the Mercurial-devel mailing list