D2003: util: extract all date-related utils in utils/dateutil module

2018-02-05 Thread lothiraldan (Boris Feld)
lothiraldan abandoned this revision.
lothiraldan added a comment.


  I updated the series with copying util.py to utils/dateutil.py.
  
  I've also added the deprecation warnings but I'm not sure how to add 
deprecation warnings for variables.
  
  I also splitted the change as copying util.py made the change harder to read.
  
  Abandoned in favor of" https://phab.mercurial-scm.org/D2056

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2003

To: lothiraldan, #hg-reviewers, durin42
Cc: indygreg, mharbison72, durin42, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2003: util: extract all date-related utils in utils/dateutil module

2018-02-05 Thread lothiraldan (Boris Feld)
lothiraldan updated this revision to Diff 5205.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2003?vs=5153=5205

REVISION DETAIL
  https://phab.mercurial-scm.org/D2003

AFFECTED FILES
  contrib/synthrepo.py
  hgext/blackbox.py
  hgext/churn.py
  hgext/convert/common.py
  hgext/convert/convcmd.py
  hgext/convert/cvs.py
  hgext/convert/cvsps.py
  hgext/convert/darcs.py
  hgext/convert/gnuarch.py
  hgext/convert/hg.py
  hgext/convert/monotone.py
  hgext/convert/p4.py
  hgext/convert/subversion.py
  hgext/fetch.py
  hgext/gpg.py
  hgext/journal.py
  hgext/keyword.py
  hgext/mq.py
  hgext/notify.py
  hgext/patchbomb.py
  hgext/shelve.py
  mercurial/changelog.py
  mercurial/cmdutil.py
  mercurial/commands.py
  mercurial/context.py
  mercurial/debugcommands.py
  mercurial/formatter.py
  mercurial/hgweb/hgwebdir_mod.py
  mercurial/mdiff.py
  mercurial/obsolete.py
  mercurial/obsutil.py
  mercurial/patch.py
  mercurial/revset.py
  mercurial/subrepo.py
  mercurial/templatefilters.py
  mercurial/templater.py
  mercurial/ui.py
  mercurial/util.py
  mercurial/utils/dateutil.py
  tests/fakedirstatewritetime.py
  tests/fakepatchtime.py
  tests/test-journal.t

To: lothiraldan, #hg-reviewers, durin42
Cc: indygreg, mharbison72, durin42, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2003: util: extract all date-related utils in utils/dateutil module

2018-02-02 Thread durin42 (Augie Fackler)
durin42 added a comment.


  Probably, but I'd also like to time-box how long we do those exports to a 
release cycle or two so we can get out from under the mess.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2003

To: lothiraldan, #hg-reviewers, durin42
Cc: indygreg, mharbison72, durin42, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2003: util: extract all date-related utils in utils/dateutil module

2018-02-02 Thread indygreg (Gregory Szorc)
indygreg added a comment.


  Should we alias the symbols into `util` to avoid the massive API break? We 
already re-export a number of symbols from `util`.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2003

To: lothiraldan, #hg-reviewers, durin42
Cc: indygreg, mharbison72, durin42, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2003: util: extract all date-related utils in utils/dateutil module

2018-02-02 Thread durin42 (Augie Fackler)
durin42 added a comment.


  I think this is a reasonable approach. Do mark the copy though for blame 
preservation, and make sure to add utils/__init__.py and add mercurial.utils to 
the setup.py
  
  Thanks!

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2003

To: lothiraldan, #hg-reviewers, durin42
Cc: mharbison72, durin42, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2003: util: extract all date-related utils in utils/dateutil module

2018-02-02 Thread mharbison72 (Matt Harbison)
mharbison72 added a comment.


  Should dateutil.py be created with ‘hg cp’ to make annotate easier?

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2003

To: lothiraldan, #hg-reviewers, durin42
Cc: mharbison72, durin42, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2003: util: extract all date-related utils in utils/dateutil module

2018-02-02 Thread lothiraldan (Boris Feld)
lothiraldan created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  With this commit, util.py lose 313 lines

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2003

AFFECTED FILES
  contrib/synthrepo.py
  hgext/blackbox.py
  hgext/churn.py
  hgext/convert/common.py
  hgext/convert/convcmd.py
  hgext/convert/cvs.py
  hgext/convert/cvsps.py
  hgext/convert/darcs.py
  hgext/convert/gnuarch.py
  hgext/convert/hg.py
  hgext/convert/monotone.py
  hgext/convert/p4.py
  hgext/convert/subversion.py
  hgext/fetch.py
  hgext/gpg.py
  hgext/journal.py
  hgext/keyword.py
  hgext/mq.py
  hgext/notify.py
  hgext/patchbomb.py
  hgext/shelve.py
  mercurial/changelog.py
  mercurial/cmdutil.py
  mercurial/commands.py
  mercurial/context.py
  mercurial/debugcommands.py
  mercurial/formatter.py
  mercurial/hgweb/hgwebdir_mod.py
  mercurial/mdiff.py
  mercurial/obsolete.py
  mercurial/obsutil.py
  mercurial/patch.py
  mercurial/revset.py
  mercurial/subrepo.py
  mercurial/templatefilters.py
  mercurial/templater.py
  mercurial/ui.py
  mercurial/util.py
  mercurial/utils/dateutil.py
  tests/fakedirstatewritetime.py
  tests/fakepatchtime.py
  tests/test-journal.t

CHANGE DETAILS

diff --git a/tests/test-journal.t b/tests/test-journal.t
--- a/tests/test-journal.t
+++ b/tests/test-journal.t
@@ -4,6 +4,7 @@
   > # mock out util.getuser() and util.makedate() to supply testable values
   > import os
   > from mercurial import util
+  > from mercurial.utils import dateutil
   > def mockgetuser():
   > return 'foobar'
   > 
@@ -19,7 +20,7 @@
   > return (time, 0)
   > 
   > util.getuser = mockgetuser
-  > util.makedate = mockmakedate
+  > dateutil.makedate = mockmakedate
   > EOF
 
   $ cat >> $HGRCPATH << EOF
diff --git a/tests/fakepatchtime.py b/tests/fakepatchtime.py
--- a/tests/fakepatchtime.py
+++ b/tests/fakepatchtime.py
@@ -7,8 +7,8 @@
 extensions,
 patch as patchmod,
 registrar,
-util,
 )
+from mercurial.utils import dateutil
 
 configtable = {}
 configitem = registrar.configitem(configtable)
@@ -30,7 +30,7 @@
 if fakenow:
 # parsing 'fakenow' in mmddHHMM format makes comparison between
 # 'fakenow' value and 'touch -t mmddHHMM' argument easy
-fakenow = util.parsedate(fakenow, ['%Y%m%d%H%M'])[0]
+fakenow = dateutil.parsedate(fakenow, ['%Y%m%d%H%M'])[0]
 for f in files:
 repo.wvfs.utime(f, (fakenow, fakenow))
 
diff --git a/tests/fakedirstatewritetime.py b/tests/fakedirstatewritetime.py
--- a/tests/fakedirstatewritetime.py
+++ b/tests/fakedirstatewritetime.py
@@ -13,8 +13,8 @@
 extensions,
 policy,
 registrar,
-util,
 )
+from mercurial.utils import dateutil
 
 configtable = {}
 configitem = registrar.configitem(configtable)
@@ -49,7 +49,7 @@
 
 # parsing 'fakenow' in mmddHHMM format makes comparison between
 # 'fakenow' value and 'touch -t mmddHHMM' argument easy
-fakenow = util.parsedate(fakenow, ['%Y%m%d%H%M'])[0]
+fakenow = dateutil.parsedate(fakenow, ['%Y%m%d%H%M'])[0]
 
 orig_pack_dirstate = parsers.pack_dirstate
 orig_dirstate_getfsnow = dirstate._getfsnow
diff --git a/mercurial/utils/dateutil.py b/mercurial/utils/dateutil.py
new file mode 100644
--- /dev/null
+++ b/mercurial/utils/dateutil.py
@@ -0,0 +1,336 @@
+# util.py - Mercurial utility functions relative to dates
+#
+#  Copyright 2018 Boris Feld 
+#
+# This software may be used and distributed according to the terms of the
+# GNU General Public License version 2 or any later version.
+
+"""Mercurial utility functions and platform specific implementations.
+
+This contains helper routines that are independent of the SCM core and
+hide platform-specific details from the core.
+"""
+
+from __future__ import absolute_import, print_function
+
+import calendar
+import datetime
+import time
+
+from ..i18n import _
+from .. import (
+encoding,
+error,
+pycompat,
+)
+
+# used by parsedate
+defaultdateformats = (
+'%Y-%m-%dT%H:%M:%S', # the 'real' ISO8601
+'%Y-%m-%dT%H:%M',#   without seconds
+'%Y-%m-%dT%H%M%S',   # another awful but legal variant without :
+'%Y-%m-%dT%H%M', #   without seconds
+'%Y-%m-%d %H:%M:%S', # our common legal variant
+'%Y-%m-%d %H:%M',#   without seconds
+'%Y-%m-%d %H%M%S',   # without :
+'%Y-%m-%d %H%M', #   without seconds
+'%Y-%m-%d %I:%M:%S%p',
+'%Y-%m-%d %H:%M',
+'%Y-%m-%d %I:%M%p',
+'%Y-%m-%d',
+'%m-%d',
+'%m/%d',
+'%m/%d/%y',
+'%m/%d/%Y',
+'%a %b %d %H:%M:%S %Y',
+'%a %b %d %I:%M:%S%p %Y',
+'%a, %d %b %Y %H:%M:%S',#  GNU coreutils "/bin/date --rfc-2822"
+'%b %d %H:%M:%S %Y',
+'%b %d %I:%M:%S%p %Y',
+'%b %d %H:%M:%S',
+'%b %d %I:%M:%S%p',
+'%b %d %H:%M',
+'%b %d %I:%M%p',
+'%b %d %Y',
+'%b %d',
+'%H:%M:%S',
+'%I:%M:%S%p',
+'%H:%M',
+

D2003: util: extract all date-related utils in utils/dateutil module

2018-02-02 Thread lothiraldan (Boris Feld)
lothiraldan added a reviewer: durin42.
lothiraldan added a subscriber: durin42.
lothiraldan added a comment.


  @durin42 please tell me if I am on the right tracks

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2003

To: lothiraldan, #hg-reviewers, durin42
Cc: durin42, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel