Patchwork [5,of,8] devel: use default-date config field when creating obsmarkers

login
register
mail settings
Submitter Boris Feld
Date May 22, 2017, 6:46 p.m.
Message ID <6b36945e7ac9b0c32098.1495478785@FB>
Download mbox | patch
Permalink /patch/20831/
State Accepted
Headers show

Comments

Boris Feld - May 22, 2017, 6:46 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1495188527 -7200
#      Fri May 19 12:08:47 2017 +0200
# Node ID 6b36945e7ac9b0c32098e382ee6b100080d8deec
# Parent  93f928e5fc97a1a2f6419382da1687582dbcca03
# EXP-Topic develforcedate
devel: use default-date config field when creating obsmarkers

Also use the default-date when creating obsmarkers. Currently they are created
with the current date and without any option to force their value.

To test the feature, we remove some of the many 'glob' used to match obsmarker
date in the tests.

Patch

diff -r 93f928e5fc97a1a2f6419382da1687582dbcca03 -r 6b36945e7ac9b0c32098e382ee6b100080d8deec mercurial/debugcommands.py
--- a/mercurial/debugcommands.py	Mon May 22 16:59:57 2017 +0200
+++ b/mercurial/debugcommands.py	Fri May 19 12:08:47 2017 +0200
@@ -1360,7 +1360,7 @@ 
                     parents = tuple(p.node() for p in parents)
                 repo.obsstore.create(tr, prec, succs, opts['flags'],
                                      parents=parents, date=date,
-                                     metadata=metadata)
+                                     metadata=metadata, ui=ui)
                 tr.close()
             except ValueError as exc:
                 raise error.Abort(_('bad obsmarker input: %s') % exc)
diff -r 93f928e5fc97a1a2f6419382da1687582dbcca03 -r 6b36945e7ac9b0c32098e382ee6b100080d8deec mercurial/obsolete.py
--- a/mercurial/obsolete.py	Mon May 22 16:59:57 2017 +0200
+++ b/mercurial/obsolete.py	Fri May 19 12:08:47 2017 +0200
@@ -584,7 +584,7 @@ 
         return self._readonly
 
     def create(self, transaction, prec, succs=(), flag=0, parents=None,
-               date=None, metadata=None):
+               date=None, metadata=None, ui=None):
         """obsolete: add a new obsolete marker
 
         * ensuring it is hashable
@@ -603,6 +603,10 @@ 
             if 'date' in metadata:
                 # as a courtesy for out-of-tree extensions
                 date = util.parsedate(metadata.pop('date'))
+            elif ui is not None:
+                date = ui.configdate('devel', 'default-date')
+                if date is None:
+                    date = util.makedate()
             else:
                 date = util.makedate()
         if len(prec) != 20:
@@ -1285,7 +1289,8 @@ 
         for args in markerargs:
             nprec, nsucs, npare, localmetadata = args
             repo.obsstore.create(tr, nprec, nsucs, flag, parents=npare,
-                                 date=date, metadata=localmetadata)
+                                 date=date, metadata=localmetadata,
+                                 ui=repo.ui)
             repo.filteredrevcache.clear()
         tr.close()
     finally:
diff -r 93f928e5fc97a1a2f6419382da1687582dbcca03 -r 6b36945e7ac9b0c32098e382ee6b100080d8deec tests/test-obsolete.t
--- a/tests/test-obsolete.t	Mon May 22 16:59:57 2017 +0200
+++ b/tests/test-obsolete.t	Fri May 19 12:08:47 2017 +0200
@@ -1252,7 +1252,7 @@ 
   $ hg debugobsolete --index --rev "3+7" -Tjson
   [
    {
-    "date": *, (glob)
+    "date": [0.0, 0],
     "flag": 0,
     "index": 1,
     "metadata": {"user": "test"},
@@ -1260,7 +1260,7 @@ 
     "succnodes": ["d27fb9b066076fd921277a4b9e8b9cb48c95bc6a"]
    },
    {
-    "date": *, (glob)
+    "date": [0.0, 0],
     "flag": 0,
     "index": 3,
     "metadata": {"operation": "amend", "user": "test"},
@@ -1271,14 +1271,14 @@ 
 
 Test the --delete option of debugobsolete command
   $ hg debugobsolete --index
-  0 cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b f9bd49731b0b175e42992a3c8fa6c678b2bc11f1 0 \(.*\) {'user': 'test'} (re)
-  1 6fdef60fcbabbd3d50e9b9cbc2a240724b91a5e1 d27fb9b066076fd921277a4b9e8b9cb48c95bc6a 0 \(.*\) {'user': 'test'} (re)
-  2 1ab51af8f9b41ef8c7f6f3312d4706d870b1fb74 29346082e4a9e27042b62d2da0e2de211c027621 0 \(.*\) {'user': 'test'} (re)
-  3 4715cf767440ed891755448016c2b8cf70760c30 7ae79c5d60f049c7b0dd02f5f25b9d60aaf7b36d 0 (*) {'operation': 'amend', 'user': 'test'} (glob)
+  0 cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b f9bd49731b0b175e42992a3c8fa6c678b2bc11f1 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
+  1 6fdef60fcbabbd3d50e9b9cbc2a240724b91a5e1 d27fb9b066076fd921277a4b9e8b9cb48c95bc6a 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
+  2 1ab51af8f9b41ef8c7f6f3312d4706d870b1fb74 29346082e4a9e27042b62d2da0e2de211c027621 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
+  3 4715cf767440ed891755448016c2b8cf70760c30 7ae79c5d60f049c7b0dd02f5f25b9d60aaf7b36d 0 (Thu Jan 01 00:00:00 1970 +0000) {'operation': 'amend', 'user': 'test'}
   $ hg debugobsolete --delete 1 --delete 3
   deleted 2 obsolescence markers
   $ hg debugobsolete
-  cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b f9bd49731b0b175e42992a3c8fa6c678b2bc11f1 0 \(.*\) {'user': 'test'} (re)
-  1ab51af8f9b41ef8c7f6f3312d4706d870b1fb74 29346082e4a9e27042b62d2da0e2de211c027621 0 \(.*\) {'user': 'test'} (re)
+  cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b f9bd49731b0b175e42992a3c8fa6c678b2bc11f1 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
+  1ab51af8f9b41ef8c7f6f3312d4706d870b1fb74 29346082e4a9e27042b62d2da0e2de211c027621 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
   $ cd ..