changeset 2299:dacf718e1d48

Add timestamp field to export format. Make import and mq use it.
author Danek Duvall <danek.duvall@sun.com>
date Wed, 17 May 2006 18:54:30 +0200
parents 936b615eb44e
children 52b9b6751b2c
files hgext/mq.py mercurial/commands.py
diffstat 2 files changed, 13 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Wed May 17 14:46:12 2006 +0200
+++ b/hgext/mq.py	Wed May 17 18:54:30 2006 +0200
@@ -102,6 +102,7 @@
         message = []
         comments = []
         user = None
+        date = None
         format = None
         subject = None
         diffstart = 0
@@ -119,6 +120,8 @@
                 # parse values when importing the result of an hg export
                 if line.startswith("# User "):
                     user = line[7:]
+                elif line.startswith("# Timestamp "):
+                    date = line[12:]
                 elif not line.startswith("# ") and line:
                     message.append(line)
                     format = None
@@ -149,7 +152,7 @@
         if format and format.startswith("tag") and subject:
             message.insert(0, "")
             message.insert(0, subject)
-        return (message, comments, user, diffstart > 1)
+        return (message, comments, user, date, diffstart > 1)
 
     def mergeone(self, repo, mergeq, head, patch, rev, wlock):
         # first try just applying the patch
@@ -179,7 +182,7 @@
             self.ui.warn("repo commit failed\n")
             sys.exit(1)
         try:
-            message, comments, user, patchfound = mergeq.readheaders(patch)
+            message, comments, user, date, patchfound = mergeq.readheaders(patch)
         except:
             self.ui.warn("Unable to read %s\n" % patch)
             sys.exit(1)
@@ -267,7 +270,7 @@
             pf = os.path.join(patchdir, patch)
 
             try:
-                message, comments, user, patchfound = self.readheaders(patch)
+                message, comments, user, date, patchfound = self.readheaders(patch)
             except:
                 self.ui.warn("Unable to read %s\n" % pf)
                 err = 1
@@ -326,7 +329,7 @@
             if len(files) > 0:
                 commands.addremove_lock(self.ui, repo, files,
                                         opts={}, wlock=wlock)
-            n = repo.commit(files, message, user, force=1, lock=lock,
+            n = repo.commit(files, message, user, date, force=1, lock=lock,
                             wlock=wlock)
 
             if n == None:
@@ -716,7 +719,7 @@
         top = revlog.bin(top)
         cparents = repo.changelog.parents(top)
         patchparent = self.qparents(repo, top)
-        message, comments, user, patchfound = self.readheaders(patch)
+        message, comments, user, date, patchfound = self.readheaders(patch)
 
         patchf = self.opener(patch, "w")
         if comments:
--- a/mercurial/commands.py	Wed May 17 14:46:12 2006 +0200
+++ b/mercurial/commands.py	Wed May 17 18:54:30 2006 +0200
@@ -1392,6 +1392,7 @@
 
     fp.write("# HG changeset patch\n")
     fp.write("# User %s\n" % change[1])
+    fp.write("# Timestamp %d %d\n" % (change[2][0], change[2][1]))
     fp.write("# Node ID %s\n" % hex(node))
     fp.write("# Parent  %s\n" % hex(prev))
     if len(parents) > 1:
@@ -1687,6 +1688,7 @@
 
         message = []
         user = None
+        date = None
         hgpatch = False
         for line in file(pf):
             line = line.rstrip()
@@ -1703,6 +1705,8 @@
                 if line.startswith("# User "):
                     user = line[7:]
                     ui.debug(_('User: %s\n') % user)
+                elif line.startswith("# Timestamp "):
+                    date = line[12:]
                 elif not line.startswith("# ") and line:
                     message.append(line)
                     hgpatch = False
@@ -1723,7 +1727,7 @@
 
         if len(files) > 0:
             addremove_lock(ui, repo, files, {})
-        repo.commit(files, message, user)
+        repo.commit(files, message, user, date)
 
 def incoming(ui, repo, source="default", **opts):
     """show new changesets found in source