Patchwork ui: restrict length of autogenerated blocked tags

login
register
mail settings
Submitter Simon Farnsworth
Date March 20, 2017, 12:11 p.m.
Message ID <4e7a3cc6b4e4253aeb17.1490011917@devvm022.lla2.facebook.com>
Download mbox | patch
Permalink /patch/19474/
State Accepted
Headers show

Comments

Simon Farnsworth - March 20, 2017, 12:11 p.m.
# HG changeset patch
# User Simon Farnsworth <simonfar@fb.com>
# Date 1490011701 25200
#      Mon Mar 20 05:08:21 2017 -0700
# Node ID 4e7a3cc6b4e4253aeb1754f0a8b3b080bccf3196
# Parent  291951ad070b3fa39dd1d83503aa1011a20d9a21
ui: restrict length of autogenerated blocked tags

Long autogenerated blocked tags tend to be because the command has an absolute
path; at Facebook, we've had a few where the tag is thousands of characters
long (in association with the mergedriver).

Change the default to use a suffix of a command as the default tag, limiting us
to 85 characters (for a 100 character tag). This is long enough to overflow a
standard terminal (thus be obviously autogenerated), but short enough to be
readable.
Yuya Nishihara - March 21, 2017, 2:03 p.m.
On Mon, 20 Mar 2017 05:11:57 -0700, Simon Farnsworth wrote:
> # HG changeset patch
> # User Simon Farnsworth <simonfar@fb.com>
> # Date 1490011701 25200
> #      Mon Mar 20 05:08:21 2017 -0700
> # Node ID 4e7a3cc6b4e4253aeb1754f0a8b3b080bccf3196
> # Parent  291951ad070b3fa39dd1d83503aa1011a20d9a21
> ui: restrict length of autogenerated blocked tags

Seems fine. Queued, thanks.

Patch

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -1234,7 +1234,10 @@ 
         object as exception.
         '''
         if blockedtag is None:
-            blockedtag = 'unknown_system_' + cmd.translate(None, _keepalnum)
+            # Long cmds tend to be because of an absolute path on cmd. Keep
+            # the tail end instead
+            cmdsuffix = cmd.translate(None, _keepalnum)[-85:]
+            blockedtag = 'unknown_system_' + cmdsuffix
         out = self.fout
         if any(s[1] for s in self._bufferstates):
             out = self