Mercurial > hg
comparison hgext/censor.py @ 25806:5e18f6e39006
censor: make various path forms available like other Mercurial commands
Before this patch, censored file should be exactly "a path relative to
repository root" regardless of current working directory, because "hg
censor" passes "path" to "repo.file()" directly without any
preparations.
To make various path forms available like other Mercurial commands,
this patch gets a target file path in the way of "hg parents FILE".
Getting "wctx" is relocated to reuse "wctx" for efficiency.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Fri, 17 Jul 2015 00:22:16 +0900 |
parents | 328739ea70c3 |
children | 56b2bcea2529 |
comparison
equal
deleted
inserted
replaced
25805:584044e5ad57 | 25806:5e18f6e39006 |
---|---|
45 if not path: | 45 if not path: |
46 raise util.Abort(_('must specify file path to censor')) | 46 raise util.Abort(_('must specify file path to censor')) |
47 if not rev: | 47 if not rev: |
48 raise util.Abort(_('must specify revision to censor')) | 48 raise util.Abort(_('must specify revision to censor')) |
49 | 49 |
50 wctx = repo[None] | |
51 | |
52 m = scmutil.match(wctx, (path,)) | |
53 if m.anypats() or len(m.files()) != 1: | |
54 raise util.Abort(_('can only specify an explicit filename')) | |
55 path = m.files()[0] | |
50 flog = repo.file(path) | 56 flog = repo.file(path) |
51 if not len(flog): | 57 if not len(flog): |
52 raise util.Abort(_('cannot censor file with no history')) | 58 raise util.Abort(_('cannot censor file with no history')) |
53 | 59 |
54 rev = scmutil.revsingle(repo, rev, rev).rev() | 60 rev = scmutil.revsingle(repo, rev, rev).rev() |
68 if heads: | 74 if heads: |
69 headlist = ', '.join([short(c.node()) for c in heads]) | 75 headlist = ', '.join([short(c.node()) for c in heads]) |
70 raise util.Abort(_('cannot censor file in heads (%s)') % headlist, | 76 raise util.Abort(_('cannot censor file in heads (%s)') % headlist, |
71 hint=_('clean/delete and commit first')) | 77 hint=_('clean/delete and commit first')) |
72 | 78 |
73 wctx = repo[None] | |
74 wp = wctx.parents() | 79 wp = wctx.parents() |
75 if ctx.node() in [p.node() for p in wp]: | 80 if ctx.node() in [p.node() for p in wp]: |
76 raise util.Abort(_('cannot censor working directory'), | 81 raise util.Abort(_('cannot censor working directory'), |
77 hint=_('clean/delete/update first')) | 82 hint=_('clean/delete/update first')) |
78 | 83 |