hgext/censor.py
changeset 25806 5e18f6e39006
parent 25660 328739ea70c3
child 26587 56b2bcea2529
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