Mercurial > hgrepos > DevTools > mercurial-extensions
changeset 393:dbf995ba1b75
Refactor: Rename some timestamps-specific variables and methods.
Do not rely on Python's "__" mangling for "private" variables
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sun, 04 Aug 2019 12:58:48 +0200 |
| parents | b61ceb9d86cd |
| children | 0fd1473ff168 |
| files | extensions/timestamps.py |
| diffstat | 1 files changed, 26 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/extensions/timestamps.py Sun Aug 04 11:01:48 2019 +0200 +++ b/extensions/timestamps.py Sun Aug 04 12:58:48 2019 +0200 @@ -220,13 +220,14 @@ def __init__(self, *args, **kwds): super(TimestampedRepo, self).__init__(*args, **kwds) - self.__hooktype = None - self.__from_parents = None - self.ui.debug(b"init of a TimestampedRepo\n") + self._tss_hooktype = None + self._tss_hook_pats = None + self._tss_from_parents = None + ui.warn(b"end init of a TimestampedRepo\n") def commit(self, text=b"", user=None, date=None, match=None, force=False, editor=False, extra=None, **kwds): - match = self._ts_commit(match) + match = self._tss_commit(match) return super(TimestampedRepo, self).commit(text=text, user=user, date=date, @@ -236,7 +237,7 @@ extra=extra, **kwds) - def _ts_commit(self, match): + def _tss_commit(self, match): # # histedit commits directly without setting a match -> # cannot amend and/or leave alone @@ -332,20 +333,20 @@ b" timestamps not activated/configured\n") return match - def _ts_record_pre_data(self, hooktype): - if not self.local(): - return - self.__hooktype = hooktype - self.__from_parents = [p.hex() for p in self[None].parents()] + def _tss_record_pre_data(self, hooktype, **kwds): + """Called by generic pre-hooks""" + self._tss_hooktype = hooktype + self._tss_hook_pats = kwds.get("pats", None) + self._tss_from_parents = [p.hex() for p in self[None].parents()] - def _ts_on_update(self, parent1=None, parent2=None, error=0, preview=False): + def _tss_on_update(self, parent1=None, parent2=None, error=0, preview=False): """Called on :hg:`hg update` and :hg:`hg merge` """ - if not self.__hooktype \ - or self.__hooktype not in (b"pre-update", - b"pre-merge"): - self.ui.warn(_(b"timestamps: no recorded update hook data for use in `_ts_on_update()'\n")) + if not self._tss_hooktype \ + or self._tss_hooktype not in (b"pre-update", + b"pre-merge"): + self.ui.warn(_(b"timestamps: no recorded update hook data for use in `_tss_on_update()'\n")) return if preview: self.ui.note(_(b"skipping updating timestamps in preview mode\n")) @@ -360,17 +361,17 @@ self.ui.warn(_(b"update.timestamps: timestamps database file could not be found or read\n")) else: if not parent2: - self._ts_update_update(tsconfmatch, ts) + self._tss_update_update(tsconfmatch, ts) else: - self._ts_update_update(tsconfmatch, ts, - allow_other_region=True) + self._tss_update_update(tsconfmatch, ts, + allow_other_region=True) else: self.ui.debug(b"update.timestamps: timestamps not activated/configured\n") - def _ts_update_update(self, tsconfmatch, ts, allow_other_region=False): + def _tss_update_update(self, tsconfmatch, ts, allow_other_region=False): """:hg:`update`, :hg:`merge --abort`""" to_update = set() - for p in self.__from_parents: + for p in self._tss_from_parents: status = self.status(p) if _DEV: self.ui.debug(b"FROM PARENT: " + p + b" Status: " @@ -403,7 +404,7 @@ """ if not repo.local(): return - repo._ts_record_pre_data(hooktype) + repo._tss_record_pre_data(hooktype, **kwds) def generic_post_hook(ui, repo, hooktype, **kwds): @@ -465,10 +466,10 @@ # if not repo.local(): return - repo._ts_on_update(parent1=kwds.get("parent1"), - parent2=kwds.get("parent2"), - error=kwds.get("error"), - preview=kwds.get("preview", False)) + repo._tss_on_update(parent1=kwds.get("parent1"), + parent2=kwds.get("parent2"), + error=kwds.get("error"), + preview=kwds.get("preview", False)) def _save_timestamps(ui,
