Mercurial > hg
comparison mercurial/context.py @ 36607:c6061cadb400
util: extract all date-related utils in utils/dateutil module
With this commit, util.py lose 262 lines
Note for extensions author, if this commit breaks your extension, you can pull
the step-by-step split here to help you more easily pinpoint the renaming that
broke your extension:
hg pull https://bitbucket.org/octobus/mercurial-devel/ -r ac1f6453010d
Differential Revision: https://phab.mercurial-scm.org/D2282
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Thu, 15 Feb 2018 17:18:26 +0100 |
parents | 38f480502043 |
children | 334da951a50b |
comparison
equal
deleted
inserted
replaced
36606:4de15c54e59f | 36607:c6061cadb400 |
---|---|
47 sparse, | 47 sparse, |
48 subrepo, | 48 subrepo, |
49 subrepoutil, | 49 subrepoutil, |
50 util, | 50 util, |
51 ) | 51 ) |
52 from .utils import dateutil | |
52 | 53 |
53 propertycache = util.propertycache | 54 propertycache = util.propertycache |
54 | 55 |
55 nonascii = re.compile(r'[^\x21-\x7f]').search | 56 nonascii = re.compile(r'[^\x21-\x7f]').search |
56 | 57 |
1285 self._repo = repo | 1286 self._repo = repo |
1286 self._rev = None | 1287 self._rev = None |
1287 self._node = None | 1288 self._node = None |
1288 self._text = text | 1289 self._text = text |
1289 if date: | 1290 if date: |
1290 self._date = util.parsedate(date) | 1291 self._date = dateutil.parsedate(date) |
1291 if user: | 1292 if user: |
1292 self._user = user | 1293 self._user = user |
1293 if changes: | 1294 if changes: |
1294 self._status = changes | 1295 self._status = changes |
1295 | 1296 |
1362 @propertycache | 1363 @propertycache |
1363 def _date(self): | 1364 def _date(self): |
1364 ui = self._repo.ui | 1365 ui = self._repo.ui |
1365 date = ui.configdate('devel', 'default-date') | 1366 date = ui.configdate('devel', 'default-date') |
1366 if date is None: | 1367 if date is None: |
1367 date = util.makedate() | 1368 date = dateutil.makedate() |
1368 return date | 1369 return date |
1369 | 1370 |
1370 def subrev(self, subpath): | 1371 def subrev(self, subpath): |
1371 return None | 1372 return None |
1372 | 1373 |
2109 | 2110 |
2110 def write(self, path, data, flags='', **kwargs): | 2111 def write(self, path, data, flags='', **kwargs): |
2111 if data is None: | 2112 if data is None: |
2112 raise error.ProgrammingError("data must be non-None") | 2113 raise error.ProgrammingError("data must be non-None") |
2113 self._auditconflicts(path) | 2114 self._auditconflicts(path) |
2114 self._markdirty(path, exists=True, data=data, date=util.makedate(), | 2115 self._markdirty(path, exists=True, data=data, date=dateutil.makedate(), |
2115 flags=flags) | 2116 flags=flags) |
2116 | 2117 |
2117 def setflags(self, path, l, x): | 2118 def setflags(self, path, l, x): |
2118 self._markdirty(path, exists=True, date=util.makedate(), | 2119 self._markdirty(path, exists=True, date=dateutil.makedate(), |
2119 flags=(l and 'l' or '') + (x and 'x' or '')) | 2120 flags=(l and 'l' or '') + (x and 'x' or '')) |
2120 | 2121 |
2121 def remove(self, path): | 2122 def remove(self, path): |
2122 self._markdirty(path, exists=False) | 2123 self._markdirty(path, exists=False) |
2123 | 2124 |
2402 removed and the new file added with copy information (see | 2403 removed and the new file added with copy information (see |
2403 memfilectx). | 2404 memfilectx). |
2404 | 2405 |
2405 user receives the committer name and defaults to current | 2406 user receives the committer name and defaults to current |
2406 repository username, date is the commit date in any format | 2407 repository username, date is the commit date in any format |
2407 supported by util.parsedate() and defaults to current date, extra | 2408 supported by dateutil.parsedate() and defaults to current date, extra |
2408 is a dictionary of metadata or is left empty. | 2409 is a dictionary of metadata or is left empty. |
2409 """ | 2410 """ |
2410 | 2411 |
2411 # Mercurial <= 3.1 expects the filectxfn to raise IOError for missing files. | 2412 # Mercurial <= 3.1 expects the filectxfn to raise IOError for missing files. |
2412 # Extensions that need to retain compatibility across Mercurial 3.1 can use | 2413 # Extensions that need to retain compatibility across Mercurial 3.1 can use |
2617 'parents' is a sequence of two parent revisions identifiers (pass None for | 2618 'parents' is a sequence of two parent revisions identifiers (pass None for |
2618 every missing parent), 'text' is the commit. | 2619 every missing parent), 'text' is the commit. |
2619 | 2620 |
2620 user receives the committer name and defaults to current repository | 2621 user receives the committer name and defaults to current repository |
2621 username, date is the commit date in any format supported by | 2622 username, date is the commit date in any format supported by |
2622 util.parsedate() and defaults to current date, extra is a dictionary of | 2623 dateutil.parsedate() and defaults to current date, extra is a dictionary of |
2623 metadata or is left empty. | 2624 metadata or is left empty. |
2624 """ | 2625 """ |
2625 def __new__(cls, repo, originalctx, *args, **kwargs): | 2626 def __new__(cls, repo, originalctx, *args, **kwargs): |
2626 return super(metadataonlyctx, cls).__new__(cls, repo) | 2627 return super(metadataonlyctx, cls).__new__(cls, repo) |
2627 | 2628 |