Mercurial > hgrepos > DevTools > mercurial-extensions
changeset 152:609aa7efd051
Begin a new "timestamps" extensions with some reasonings about it
| author | Franz Glasner <hg@dom66.de> |
|---|---|
| date | Sun, 26 Aug 2018 17:57:47 +0200 |
| parents | 11b39af77153 |
| children | 5587c90d5544 |
| files | extensions/timestamps.py |
| diffstat | 1 files changed, 86 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/extensions/timestamps.py Sun Aug 26 17:57:47 2018 +0200 @@ -0,0 +1,86 @@ +# -*- coding: utf-8 -*- +# @(#) $HGheader$ +# $HGnodeid$ +# +"""save and restore file timestamps for files in the repository + +Some initial reasonings: + +- configuration: versioned file :file:`.hgtimestamps` + + Mercurial ini-style with a `[patterns]` section + + patterns for timestamped files: default: all files w/o leading ".hg" + +- file timestamps to be stored in a versioned file :file:`.hgtimestamps.db` + + * no JSON because in JSON all strings are Unicode, in Mercurials + filenames are **not** Unicode + + * parsed as *binary* file + + * set of record separators: CR and/or LF (0x0d, 0x0a) + + * field separator: SPACE (0x20) + + if fields contain a space or ``#`` or ``@``: put them into ``@``; + eventually duplicate ``@`` characters within + + * comment block at the begin: retained by the writer + + lines starting with: ``#`` to CR and/or LF + + * first non-comment line: :version: VERSION + + * optional second non-comment line: :encoding: ENCODING + + (This is roughly simalar to a Perforce checkpoint.) + +- Otherwise mostly modelled after TimestampMod + +(rev |VCSRevision|) + +""" + +from __future__ import absolute_import + + +__revision__ = "$Revision$" + +__author__ = "Franz Glasner" + + +import io + +from mercurial.i18n import _ +from mercurial import cmdutil, scmutil, util, error, archival, pycompat + + +cmdtable = {} + +command = cmdutil.command(cmdtable) + +testedwith = "4.5.2" + + +def getversion(): + """Provide the version information for verbose :hg:`version` output. + + Read the :file:`VERSION` from the parent of the :file:`extensions` + directory. + + """ + import re + import os + try: + fn = __file__ + except NameError: + return "<unknown>" + else: + try: + verdata = open(os.path.join(os.path.dirname(fn), + "../VERSION"), + "r").read() + return re.search("^(.*)", verdata,).group(1) + except OSError: + return "<not found>"
