changeset 385:74f893d470a5

More compliance with the private Mercurial extension style guide: - Metadata - order of functions
author Franz Glasner <fzglas.hg@dom66.de>
date Tue, 16 Jul 2019 21:33:45 +0200
parents 97de030f8c92
children 1c1a360edc86
files extensions/timestamps.py
diffstat 1 files changed, 76 insertions(+), 74 deletions(-) [+]
line wrap: on
line diff
--- a/extensions/timestamps.py	Tue Jul 16 21:01:43 2019 +0200
+++ b/extensions/timestamps.py	Tue Jul 16 21:33:45 2019 +0200
@@ -1,12 +1,13 @@
 # -*- coding: utf-8 -*-
 # @(#) $HGheader$
 #      $HGnodeid$
-#
+# :-
 # :Copyright: (C) 2018-2019 Franz Glasner <fzglas.hg@dom66.de>
 # :License:   This software may be used and distributed according to the
 #             terms of the GNU General Public License version 2 or any
 #             later version.
 #             The license is incorporated herein by reference.
+# :-
 #
 """save and restore file timestamps for files in the repository
 
@@ -62,8 +63,8 @@
 from __future__ import absolute_import
 
 
-__revision__ = "$Revision$"
-
+__revision__ = "|VCSRevision|"
+__date__ = "|VCSJustDate|"
 __author__ = "Franz Glasner"
 
 
@@ -208,77 +209,6 @@
     ui.setconfig(b"hooks", b"post-revert.timestamps", generic_post_hook)
 
 
-def generic_pre_hook(ui, repo, hooktype, **kwds):
-    """Generic pre-xxx hook: just forwards to the corresponding repo method.
-
-    This generic dispatcher hook simplifies configuration.
-
-    """
-    repo._ts_record_pre_data(hooktype)
-
-
-def generic_post_hook(ui, repo, hooktype, **kwds):
-    """Generic post-xxx hook: just forward to the `hooktype` related
-    implementations.
-
-    This generic dispatcher hook simplifies configuration.
-
-    Current implementations exist for :hg:`revert` and :hg:`resolve`.
-
-    """
-    ui.debug(b"POST HOOK: " + hooktype + b'\n')
-    ui.debug("POST HOOK: " + repr(kwds) + '\n')
-
-    if not repo.local():
-        return
-    opts = kwds.get("opts")
-    if hooktype == b"post-revert":
-        wctx = repo[None]
-        tsconfmatch = _gen_matcher_from_tsconfig(wctx, ui=ui)
-        if tsconfmatch is None:
-            return
-        ts = _Timestamps.from_filename(ui, name=repo.wjoin(TIMESTAMPS_DATABASE))
-        if ts is None:
-            return
-        ui.note(_(b"restoring timestamps\n"))
-        if opts.get(b"all"):
-            candidates = wctx
-        else:
-            # the same as in revert's implementation in `cmdutil.revert`
-            patterns = scmutil.match(wctx, kwds.get("pats"), opts=opts)
-            candidates = wctx.walk(patterns)
-        _do_restore_timestamps(repo, candidates, None, tsconfmatch, ts, ui=ui)
-    elif hooktype == b"post-resolve":
-        wctx = repo[None]
-        tsconfmatch = _gen_matcher_from_tsconfig(wctx, ui=ui)
-        if tsconfmatch is None:
-            return
-        ts = _Timestamps.from_filename(ui, name=repo.wjoin(TIMESTAMPS_DATABASE))
-        if ts is None:
-            ui.warn(_(b"update.timestamps: timestamps database file could not be found or read\n"))
-        if opts.get(b"list") or opts.get(b"mark") or opts.get(b"unmark"):
-            return
-        ui.note(_(b"restoring timestamps\n"))
-        tool = opts.get(b"tool")
-        patsmatch = scmutil.match(wctx, kwds.get("pats"), opts)
-
-
-def update_hook(ui, repo, hooktype, **kwds):
-    """Hook called by :hg:`update` and :hg:`merge` if configured correctly.
-
-    """
-    if _DEV:
-        ui.debug("UPDATE: " + repr(repo) + '\n')
-        ui.debug("UPDATE: " + repr(kwds) + '\n')
-    #
-    # Note: We get only the target revisions. We cannot just compute the
-    #       difference
-    repo._ts_on_update(parent1=kwds.get("parent1"),
-                       parent2=kwds.get("parent2"),
-                       error=kwds.get("error"),
-                       preview=kwds.get("preview", False))
-
-
 def reposetup(ui, repo):
 
     class TimestampedRepo(repo.__class__):
@@ -466,6 +396,78 @@
     ui.setconfig(b'hooks', b'update.timestamps', update_hook)
 
 
+def generic_pre_hook(ui, repo, hooktype, **kwds):
+    """Generic pre-xxx hook: just forwards to the corresponding repo method.
+
+    This generic dispatcher hook simplifies configuration.
+
+    """
+    repo._ts_record_pre_data(hooktype)
+
+
+def generic_post_hook(ui, repo, hooktype, **kwds):
+    """Generic post-xxx hook: just forward to the `hooktype` related
+    implementations.
+
+    This generic dispatcher hook simplifies configuration.
+
+    Current implementations exist for :hg:`revert` and :hg:`resolve`.
+
+    """
+    ui.debug(b"POST HOOK: " + hooktype + b'\n')
+    ui.debug("POST HOOK: " + repr(kwds) + '\n')
+
+    if not repo.local():
+        return
+    opts = kwds.get("opts")
+    if hooktype == b"post-revert":
+        wctx = repo[None]
+        tsconfmatch = _gen_matcher_from_tsconfig(wctx, ui=ui)
+        if tsconfmatch is None:
+            return
+        ts = _Timestamps.from_filename(ui, name=repo.wjoin(TIMESTAMPS_DATABASE))
+        if ts is None:
+            return
+        ui.note(_(b"restoring timestamps\n"))
+        if opts.get(b"all"):
+            candidates = wctx
+        else:
+            # the same as in revert's implementation in `cmdutil.revert`
+            patterns = scmutil.match(wctx, kwds.get("pats"), opts=opts)
+            candidates = wctx.walk(patterns)
+        _do_restore_timestamps(repo, candidates, None, tsconfmatch, ts, ui=ui)
+    elif hooktype == b"post-resolve":
+        wctx = repo[None]
+        tsconfmatch = _gen_matcher_from_tsconfig(wctx, ui=ui)
+        if tsconfmatch is None:
+            return
+        ts = _Timestamps.from_filename(ui, name=repo.wjoin(TIMESTAMPS_DATABASE))
+        if ts is None:
+            ui.warn(_(b"update.timestamps: timestamps database file could not be found or read\n"))
+        if opts.get(b"list") or opts.get(b"mark") or opts.get(b"unmark"):
+            return
+        ui.note(_(b"restoring timestamps\n"))
+        tool = opts.get(b"tool")
+        patsmatch = scmutil.match(wctx, kwds.get("pats"), opts)
+
+
+def update_hook(ui, repo, hooktype, **kwds):
+    """Hook called by :hg:`update` and :hg:`merge` if configured correctly.
+
+    """
+    if _DEV:
+        ui.debug("UPDATE: " + repr(repo) + '\n')
+        ui.debug("UPDATE: " + repr(kwds) + '\n')
+    #
+    # Note: We get only the target revisions. We cannot just compute the
+    #       difference
+    #
+    repo._ts_on_update(parent1=kwds.get("parent1"),
+                       parent2=kwds.get("parent2"),
+                       error=kwds.get("error"),
+                       preview=kwds.get("preview", False))
+
+
 def _save_timestamps(ui,
                      ctx,
                      pats,