Mercurial > hg
view tests/fakepatchtime.py @ 33048:46fa46608ca5
namespaces: record and expose whether namespace is built-in
Currently, the templating layer tends to treat each namespace
as a one-off, with explicit usage of {bookmarks}, {tags}, {branch},
etc instead of using {namespaces}. It would be really useful if
we could iterate over namespaces and operate on them generically.
However, some consumers may wish to differentiate namespaces by
whether they are built-in to core Mercurial or provided by extensions.
Expected use cases include ignoring non-built-in namespaces or
emitting a generic label for non-built-in namespaces.
This commit introduces an attribute on namespace instances
that says whether the namespace is "built-in" and then exposes
this to the templating layer.
As part of this, we implement a reusable extension for defining
custom names on each changeset for testing. A second consumer
will be introduced in a subsequent commit.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 24 Jun 2017 14:52:15 -0700 |
parents | f624b0e69105 |
children | 7be2f229285b |
line wrap: on
line source
# extension to emulate invoking 'patch.internalpatch()' at the time # specified by '[fakepatchtime] fakenow' from __future__ import absolute_import from mercurial import ( extensions, patch as patchmod, util, ) def internalpatch(orig, ui, repo, patchobj, strip, prefix='', files=None, eolmode='strict', similarity=0): if files is None: files = set() r = orig(ui, repo, patchobj, strip, prefix=prefix, files=files, eolmode=eolmode, similarity=similarity) fakenow = ui.config('fakepatchtime', 'fakenow') if fakenow: # parsing 'fakenow' in YYYYmmddHHMM format makes comparison between # 'fakenow' value and 'touch -t YYYYmmddHHMM' argument easy fakenow = util.parsedate(fakenow, ['%Y%m%d%H%M'])[0] for f in files: repo.wvfs.utime(f, (fakenow, fakenow)) return r def extsetup(ui): extensions.wrapfunction(patchmod, 'internalpatch', internalpatch)