Mercurial > public > mercurial-scm > hg
comparison mercurial/debugcommands.py @ 45149:87047efbc6a6
debugcommands: create new debugantivirusrunning command
This writes the EICAR test file to .hg/cache, in an attempt to trigger
an AV scanner's scanning engine. This should let us (in theory) detect
some cases when a user's slowness is a result of AV scanning.
Differential Revision: https://phab.mercurial-scm.org/D8353
author | Augie Fackler <augie@google.com> |
---|---|
date | Wed, 01 Apr 2020 08:42:00 -0500 |
parents | 4a28f5e8408e |
children | 91aa9bba3dc9 |
comparison
equal
deleted
inserted
replaced
45148:a37f290a7124 | 45149:87047efbc6a6 |
---|---|
125 raise error.Abort(_(b'either two or three arguments required')) | 125 raise error.Abort(_(b'either two or three arguments required')) |
126 a = r.ancestor(lookup(rev1), lookup(rev2)) | 126 a = r.ancestor(lookup(rev1), lookup(rev2)) |
127 ui.write(b'%d:%s\n' % (r.rev(a), hex(a))) | 127 ui.write(b'%d:%s\n' % (r.rev(a), hex(a))) |
128 | 128 |
129 | 129 |
130 @command(b'debugantivirusrunning', []) | |
131 def debugantivirusrunning(ui, repo): | |
132 """attempt to trigger an antivirus scanner to see if one is active""" | |
133 with repo.cachevfs.open('eicar-test-file.com', b'wb') as f: | |
134 f.write( | |
135 util.b85decode( | |
136 # This is a base85-armored version of the EICAR test file. See | |
137 # https://en.wikipedia.org/wiki/EICAR_test_file for details. | |
138 b'ST#=}P$fV?P+K%yP+C|uG$>GBDK|qyDK~v2MM*<JQY}+dK~6+LQba95P' | |
139 b'E<)&Nm5l)EmTEQR4qnHOhq9iNGnJx' | |
140 ) | |
141 ) | |
142 # Give an AV engine time to scan the file. | |
143 time.sleep(2) | |
144 util.unlink(repo.cachevfs.join('eicar-test-file.com')) | |
145 | |
146 | |
130 @command(b'debugapplystreamclonebundle', [], b'FILE') | 147 @command(b'debugapplystreamclonebundle', [], b'FILE') |
131 def debugapplystreamclonebundle(ui, repo, fname): | 148 def debugapplystreamclonebundle(ui, repo, fname): |
132 """apply a stream clone bundle file""" | 149 """apply a stream clone bundle file""" |
133 f = hg.openpath(ui, fname) | 150 f = hg.openpath(ui, fname) |
134 gen = exchange.readbundle(ui, f, fname) | 151 gen = exchange.readbundle(ui, f, fname) |