Extract defaultdateformats and extendeddateformats from util.py to
utils/dateutil.py
Details
Details
- Reviewers
- lothiraldan 
- Group Reviewers
- hg-reviewers 
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
- Lint Skipped 
- Unit
- Unit Tests Skipped 
| lothiraldan | 
| hg-reviewers | 
Extract defaultdateformats and extendeddateformats from util.py to
utils/dateutil.py
| Lint Skipped | 
| Unit Tests Skipped | 
| Path | Packages | |||
|---|---|---|---|---|
| M | mercurial/util.py (52 lines) | |||
| M | mercurial/utils/dateutil.py (42 lines) | 
| Status | Author | Revision | |
|---|---|---|---|
| Abandoned | durin42 | D2056 util: extract matchdate  | |
| Abandoned | durin42 | D2055 util: extract parsedate  | |
| Abandoned | durin42 | D2054 util: extract strdate  | |
| Abandoned | durin42 | ||
| Abandoned | durin42 | D2052 util: extract shortdate  | |
| Abandoned | durin42 | D2051 util: extract datestr  | |
| Abandoned | durin42 | D2050 util: extract makedate  | |
| Abandoned | durin42 | ||
| Abandoned | lothiraldan | ||
| Abandoned | lothiraldan | ||
| Abandoned | durin42 | 
| encoding, | encoding, | ||||
| error, | error, | ||||
| i18n, | i18n, | ||||
| node as nodemod, | node as nodemod, | ||||
| policy, | policy, | ||||
| pycompat, | pycompat, | ||||
| urllibcompat, | urllibcompat, | ||||
| ) | ) | ||||
| from .utils import dateutil | |||||
| base85 = policy.importmod(r'base85') | base85 = policy.importmod(r'base85') | ||||
| osutil = policy.importmod(r'osutil') | osutil = policy.importmod(r'osutil') | ||||
| parsers = policy.importmod(r'parsers') | parsers = policy.importmod(r'parsers') | ||||
| b85decode = base85.b85decode | b85decode = base85.b85decode | ||||
| b85encode = base85.b85encode | b85encode = base85.b85encode | ||||
| if n == 2: | if n == 2: | ||||
| return (vints[0], vints[1]) | return (vints[0], vints[1]) | ||||
| if n == 3: | if n == 3: | ||||
| return (vints[0], vints[1], vints[2]) | return (vints[0], vints[1], vints[2]) | ||||
| if n == 4: | if n == 4: | ||||
| return (vints[0], vints[1], vints[2], extra) | return (vints[0], vints[1], vints[2], extra) | ||||
| # 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', | |||||
| '%I:%M%p', | |||||
| ) | |||||
| extendeddateformats = defaultdateformats + ( | |||||
| "%Y", | |||||
| "%Y-%m", | |||||
| "%b", | |||||
| "%b %Y", | |||||
| ) | |||||
| def cachefunc(func): | def cachefunc(func): | ||||
| '''cache the result of function calls''' | '''cache the result of function calls''' | ||||
| # XXX doesn't handle keywords args | # XXX doesn't handle keywords args | ||||
| if func.__code__.co_argcount == 0: | if func.__code__.co_argcount == 0: | ||||
| cache = [] | cache = [] | ||||
| def f(): | def f(): | ||||
| if len(cache) == 0: | if len(cache) == 0: | ||||
| cache.append(func()) | cache.append(func()) | ||||
| result = 0 | result = 0 | ||||
| shift = 0 | shift = 0 | ||||
| while True: | while True: | ||||
| byte = ord(readexactly(fh, 1)) | byte = ord(readexactly(fh, 1)) | ||||
| result |= ((byte & 0x7f) << shift) | result |= ((byte & 0x7f) << shift) | ||||
| if not (byte & 0x80): | if not (byte & 0x80): | ||||
| return result | return result | ||||
| shift += 7 | shift += 7 | ||||
| ### | |||||
| # Deprecation warnings for util.py splitting | |||||
| ### | |||||
| defaultdateformats = dateutil.defaultdateformats | |||||
| extendeddateformats = dateutil.extendeddateformats | |||||
| # util.py - Mercurial utility functions relative to dates | # util.py - Mercurial utility functions relative to dates | ||||
| # | # | ||||
| # Copyright 2018 Boris Feld <boris.feld@octobus.net> | # Copyright 2018 Boris Feld <boris.feld@octobus.net> | ||||
| # | # | ||||
| # This software may be used and distributed according to the terms of the | # This software may be used and distributed according to the terms of the | ||||
| # GNU General Public License version 2 or any later version. | # GNU General Public License version 2 or any later version. | ||||
| from __future__ import absolute_import, print_function | from __future__ import absolute_import, print_function | ||||
| # 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', | |||||
| '%I:%M%p', | |||||
| ) | |||||
| extendeddateformats = defaultdateformats + ( | |||||
| "%Y", | |||||
| "%Y-%m", | |||||
| "%b", | |||||
| "%b %Y", | |||||
| ) | |||||