hgext/censor.py
changeset 43077 687b865b95ad
parent 43076 2372284d9457
child 43434 bec734015b70
--- a/hgext/censor.py	Sun Oct 06 09:45:02 2019 -0400
+++ b/hgext/censor.py	Sun Oct 06 09:48:39 2019 -0400
@@ -42,49 +42,55 @@
 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
 # be specifying the version(s) of Mercurial they are tested with, or
 # leave the attribute unspecified.
-testedwith = 'ships-with-hg-core'
+testedwith = b'ships-with-hg-core'
 
 
 @command(
-    'censor',
+    b'censor',
     [
-        ('r', 'rev', '', _('censor file from specified revision'), _('REV')),
-        ('t', 'tombstone', '', _('replacement tombstone data'), _('TEXT')),
+        (
+            b'r',
+            b'rev',
+            b'',
+            _(b'censor file from specified revision'),
+            _(b'REV'),
+        ),
+        (b't', b'tombstone', b'', _(b'replacement tombstone data'), _(b'TEXT')),
     ],
-    _('-r REV [-t TEXT] [FILE]'),
+    _(b'-r REV [-t TEXT] [FILE]'),
     helpcategory=command.CATEGORY_MAINTENANCE,
 )
-def censor(ui, repo, path, rev='', tombstone='', **opts):
+def censor(ui, repo, path, rev=b'', tombstone=b'', **opts):
     with repo.wlock(), repo.lock():
         return _docensor(ui, repo, path, rev, tombstone, **opts)
 
 
-def _docensor(ui, repo, path, rev='', tombstone='', **opts):
+def _docensor(ui, repo, path, rev=b'', tombstone=b'', **opts):
     if not path:
-        raise error.Abort(_('must specify file path to censor'))
+        raise error.Abort(_(b'must specify file path to censor'))
     if not rev:
-        raise error.Abort(_('must specify revision to censor'))
+        raise error.Abort(_(b'must specify revision to censor'))
 
     wctx = repo[None]
 
     m = scmutil.match(wctx, (path,))
     if m.anypats() or len(m.files()) != 1:
-        raise error.Abort(_('can only specify an explicit filename'))
+        raise error.Abort(_(b'can only specify an explicit filename'))
     path = m.files()[0]
     flog = repo.file(path)
     if not len(flog):
-        raise error.Abort(_('cannot censor file with no history'))
+        raise error.Abort(_(b'cannot censor file with no history'))
 
     rev = scmutil.revsingle(repo, rev, rev).rev()
     try:
         ctx = repo[rev]
     except KeyError:
-        raise error.Abort(_('invalid revision identifier %s') % rev)
+        raise error.Abort(_(b'invalid revision identifier %s') % rev)
 
     try:
         fctx = ctx.filectx(path)
     except error.LookupError:
-        raise error.Abort(_('file does not exist at revision %s') % rev)
+        raise error.Abort(_(b'file does not exist at revision %s') % rev)
 
     fnode = fctx.filenode()
     heads = []
@@ -93,17 +99,17 @@
         if path in hc and hc.filenode(path) == fnode:
             heads.append(hc)
     if heads:
-        headlist = ', '.join([short(c.node()) for c in heads])
+        headlist = b', '.join([short(c.node()) for c in heads])
         raise error.Abort(
-            _('cannot censor file in heads (%s)') % headlist,
-            hint=_('clean/delete and commit first'),
+            _(b'cannot censor file in heads (%s)') % headlist,
+            hint=_(b'clean/delete and commit first'),
         )
 
     wp = wctx.parents()
     if ctx.node() in [p.node() for p in wp]:
         raise error.Abort(
-            _('cannot censor working directory'),
-            hint=_('clean/delete/update first'),
+            _(b'cannot censor working directory'),
+            hint=_(b'clean/delete/update first'),
         )
 
     with repo.transaction(b'censor') as tr: