Mercurial > hgrepos > DevTools > mercurial-extensions
changeset 363:cdd94f12d93d
"show_timestamps()", "gen_matcher_from_tsconfig()", "import_timestamps()", "save_timestamps()" and "restore_timestamps()" do not need a "repo" parameter because they can use the context's repository
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 18 Feb 2019 00:36:18 +0100 |
| parents | 22b0d520dadd |
| children | 9ff000a03a71 |
| files | extensions/timestamps.py |
| diffstat | 1 files changed, 18 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/extensions/timestamps.py Mon Feb 18 00:19:53 2019 +0100 +++ b/extensions/timestamps.py Mon Feb 18 00:36:18 2019 +0100 @@ -168,35 +168,33 @@ raise error.Abort(_("no Mercurial working directory")) if opts.get("import"): import_timestamps(ui, - repo, ctx, tsconfig=opts.get("tsconfig"), amend=opts.get("amend"), all=opts.get("all")) elif opts.get("save"): save_timestamps(ui, - repo, ctx, tsconfig=opts.get("tsconfig"), amend=opts.get("amend")) elif opts.get("restore"): - restore_timestamps(ui, repo, ctx, tsconfig=opts.get("tsconfig")) + restore_timestamps(ui, ctx, tsconfig=opts.get("tsconfig")) elif opts.get("show"): with ui.formatter("timestamps", opts) as fm: - show_timestamps(ui, repo, ctx, fm, tsconfig=opts.get("tsconfig")) + show_timestamps(ui, ctx, fm, tsconfig=opts.get("tsconfig")) else: raise error.Abort(_("must give a command:" "--save or --restore, --show or --import")) def save_timestamps(ui, - repo, ctx, tsconfig=None, amend=False): + repo = ctx.repo() if not repo.local(): raise error.Abort(_("repository is not local")) - matcher = gen_matcher_from_tsconfig(repo, ctx, tsconfig=tsconfig, ui=ui) + matcher = gen_matcher_from_tsconfig(ctx, tsconfig=tsconfig, ui=ui) if matcher is None: raise error.Abort(_("timestamps are not activated/configured")) if amend: @@ -216,14 +214,14 @@ def import_timestamps(ui, - repo, ctx, tsconfig=None, amend=False, all=False): + repo = ctx.repo() if not repo.local(): raise error.Abort(_("repository is not local")) - matcher = gen_matcher_from_tsconfig(repo, ctx, tsconfig=tsconfig, ui=ui) + matcher = gen_matcher_from_tsconfig(ctx, tsconfig=tsconfig, ui=ui) if matcher is None: raise error.Abort(_("timestamps are not activated/configured")) if amend: @@ -249,13 +247,14 @@ ts.write(fp) -def restore_timestamps(ui, repo, ctx, +def restore_timestamps(ui, ctx, tsconfig=None): + repo = ctx.repo() if not repo.local(): raise error.Abort(_("repository is not local")) cmdutil.checkunfinished(repo) cmdutil.bailifchanged(repo) - matcher = gen_matcher_from_tsconfig(repo, ctx, tsconfig=tsconfig, ui=ui) + matcher = gen_matcher_from_tsconfig(ctx, tsconfig=tsconfig, ui=ui) if matcher is None: raise error.Abort(_("timestamps are not activated/configured")) ts = Timestamps.from_filename(ui, name=repo.wjoin(TIMESTAMPS_DATABASE)) @@ -264,7 +263,7 @@ _restore_timestamps(repo, ctx, matcher, ts, ui=ui) -def show_timestamps(ui, repo, ctx, formatter, +def show_timestamps(ui, ctx, formatter, tsconfig=None): def _tsv(v): @@ -273,8 +272,8 @@ # # NOTE: no need for a local repo here # - matcher = gen_matcher_from_tsconfig(repo, ctx, tsconfig=tsconfig, ui=ui) \ - or _matchmod.never(repo.root, '') + matcher = gen_matcher_from_tsconfig(ctx, tsconfig=tsconfig, ui=ui) \ + or _matchmod.never(ctx.repo().root, '') ts = Timestamps.from_ctx(ctx, ui, name=TIMESTAMPS_DATABASE) if ts is None: raise error.Abort(_("timestamps database file does not exist")) @@ -313,7 +312,7 @@ f) -def gen_matcher_from_tsconfig(repo, ctx, tsconfig=None, ui=None): +def gen_matcher_from_tsconfig(ctx, tsconfig=None, ui=None): """Read the configuration file and return a Mercurial matcher which is configured. @@ -321,6 +320,7 @@ configuration file could be found """ + repo = ctx.repo() ui = ui or repo.ui configdata = configname = None if tsconfig: @@ -910,7 +910,7 @@ return if hooktype == "post-revert": wctx = repo[None] - matcher = gen_matcher_from_tsconfig(repo, wctx, ui=ui) + matcher = gen_matcher_from_tsconfig(wctx, ui=ui) if matcher is None: return ts = Timestamps.from_filename(ui, name=repo.wjoin(TIMESTAMPS_DATABASE)) @@ -927,7 +927,7 @@ _restore_timestamps(repo, candidates, matcher, ts, ui=ui) elif hooktype == "post-resolve": wctx = repo[None] - matcher = gen_matcher_from_tsconfig(repo, wctx, ui=ui) + matcher = gen_matcher_from_tsconfig(wctx, ui=ui) if matcher is None: return ts = Timestamps.from_filename(ui, name=repo.wjoin(TIMESTAMPS_DATABASE)) @@ -980,7 +980,7 @@ def _ts_commit(self, match): wctx = self[None] - tsmatch = gen_matcher_from_tsconfig(self, wctx) + tsmatch = gen_matcher_from_tsconfig(wctx) if tsmatch is not None: self.ui.debug("TimestampedRepo.commit():" " handling timestamps\n") @@ -1089,7 +1089,7 @@ return self.ui.note(_("restoring timestamps\n")) wctx = self[None] - tsmatch = gen_matcher_from_tsconfig(self, wctx) + tsmatch = gen_matcher_from_tsconfig(wctx) if tsmatch is not None: ts = Timestamps.from_ctx(wctx, self.ui, name=TIMESTAMPS_DATABASE)
