mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 15:27:13 +03:00
Turn off git diff by default in 'hg show'
Summary: Bryan O'Sullivan found that the copy detection in git diff was a significant contributor to the relative slowness of 'hg log -vpr .' compared to 'git show'. Automatically disable git-style diff by default for 'hg show', and allow you to re-enable it via command line option if you need it and can accept the slowdown. Depends on D2820421 Test Plan: Run the automated test and confirm no regression. ``` : /data/users/simonfar/fb-hgext (hg) [nocopydetectioninshow] : simonfar@devvm148 tests $ ../../hg/tests/run-tests.py -l test-show.t -i . # Ran 1 tests, 0 skipped, 0 warned, 0 failed. ``` Confirm that git diffs are the default in your hgrc: ``` : /data/users/simonfar/fb-hgext (hg) [nocopydetectioninshow] : simonfar@devvm148 tests $ hg --config alias.show=show --config extensions.show=../show.py showconfig | grep diff.git diff.git=True ``` Run the new 'hg show' manually, and confirm that you don't get a git diff despite your hgrc setting: ``` : /data/users/simonfar/fb-hgext (hg) [nocopydetectioninshow] : simonfar@devvm148 tests $ hg --config alias.show=show --config extensions.show=../show.py show changeset: 7d57a1e75587af73e252d69611aa12ebffc38e78 (@) bookmarks: nocopydetectioninshow user: Simon Farnsworth <simonfar@fb.com> date: Mon, 11 Jan 2016 16:28:15 -0800 Turn off git diff by default in 'hg show' diff -r 6dda76b19bf1 -r 7d57a1e75587 show.py --- a/show.py Mon Jan 11 15:30:19 2016 -0800 +++ b/show.py Mon Jan 11 16:28:15 2016 -0800 @@ -93,16 +93,27 @@ opts['patch'] = True opts['verbose'] = True - backup = ui.backupconfig('ui', 'verbose') - basebackup = repo.baseui.backupconfig('ui', 'verbose') + + verbosebackup = ui.backupconfig('ui', 'verbose') + verbosebasebackup = repo.baseui.backupconfig('ui', 'verbose') + # Copy tracking is slow when doing a git diff. Override hgrc, and rely on + # opts getting us a git diff if it's been requested. Ideally, we'd find and + # fix the slowness in copy tracking, but this works for now. + # See Bryan O'Sullivan's comments on task 9599994 for context + gitdiffbackup = ui.backupconfig('diff', 'git') + gitdiffbasebackup = ui.backupconfig('diff', 'git') try: ui.setconfig('ui', 'verbose', True) + ui.setconfig('diff', 'git', False) # Propagate to subrepos repo.baseui.setconfig('ui', 'verbose', True) + repo.baseui.setconfig('diff', 'git', False) newargs = [] commands.log(ui, repo, *newargs, **opts) finally: - ui.restoreconfig(backup) - repo.baseui.restoreconfig(basebackup) + ui.restoreconfig(gitdiffbackup) + repo.baseui.restoreconfig(gitdiffbasebackup) + ui.restoreconfig(verbosebackup) + repo.baseui.restoreconfig(verbosebasebackup) ``` Run the new 'hg show' manually with --git, and confirm that you get a git diff: ``` : /data/users/simonfar/fb-hgext (hg) [nocopydetectioninshow] : simonfar@devvm148 tests $ hg --config alias.show=show --config extensions.show=../show.py show --git changeset: 7d57a1e75587af73e252d69611aa12ebffc38e78 (@) bookmarks: nocopydetectioninshow user: Simon Farnsworth <simonfar@fb.com> date: Mon, 11 Jan 2016 16:28:15 -0800 Turn off git diff by default in 'hg show' diff --git a/show.py b/show.py --- a/show.py +++ b/show.py @@ -93,16 +93,27 @@ opts['patch'] = True opts['verbose'] = True - backup = ui.backupconfig('ui', 'verbose') - basebackup = repo.baseui.backupconfig('ui', 'verbose') + + verbosebackup = ui.backupconfig('ui', 'verbose') + verbosebasebackup = repo.baseui.backupconfig('ui', 'verbose') + # Copy tracking is slow when doing a git diff. Override hgrc, and rely on + # opts getting us a git diff if it's been requested. Ideally, we'd find and + # fix the slowness in copy tracking, but this works for now. + # See Bryan O'Sullivan's comments on task 9599994 for context + gitdiffbackup = ui.backupconfig('diff', 'git') + gitdiffbasebackup = ui.backupconfig('diff', 'git') try: ui.setconfig('ui', 'verbose', True) + ui.setconfig('diff', 'git', False) # Propagate to subrepos repo.baseui.setconfig('ui', 'verbose', True) + repo.baseui.setconfig('diff', 'git', False) newargs = [] commands.log(ui, repo, *newargs, **opts) finally: - ui.restoreconfig(backup) - repo.baseui.restoreconfig(basebackup) + ui.restoreconfig(gitdiffbackup) + repo.baseui.restoreconfig(gitdiffbasebackup) + ui.restoreconfig(verbosebackup) + repo.baseui.restoreconfig(verbosebasebackup) ``` Reviewers: #sourcecontrol, ttung, lcharignon Reviewed By: lcharignon Subscribers: rmcelroy, lcharignon, #sourcecontrol Differential Revision: https://phabricator.fb.com/D2822071 Tasks: 9599994 Signature: t1:2822071:1452586169:59011b5331cd6c76741cae348c8db4912ed6c9b7
This commit is contained in:
parent
86662e0f15
commit
a5b47065a2
12
show.py
12
show.py
@ -69,12 +69,20 @@ def show(ui, repo, *args, **opts):
|
||||
opts['patch'] = True
|
||||
opts['verbose'] = True
|
||||
|
||||
backup = ui.backupconfig('ui', 'verbose')
|
||||
verbosebackup = ui.backupconfig('ui', 'verbose')
|
||||
# Copy tracking is slow when doing a git diff. Override hgrc, and rely on
|
||||
# opts getting us a git diff if it's been requested. Ideally, we'd find and
|
||||
# fix the slowness in copy tracking, but this works for now.
|
||||
# On a commit with lots of possible copies, Bryan O'Sullivan found that this
|
||||
# reduces "time hg show" from 1.76 seconds to 0.81 seconds.
|
||||
gitdiffbackup = ui.backupconfig('diff', 'git')
|
||||
|
||||
try:
|
||||
ui.setconfig('ui', 'verbose', True)
|
||||
ui.setconfig('diff', 'git', False)
|
||||
newargs = []
|
||||
commands.log(ui, repo, *newargs, **opts)
|
||||
|
||||
finally:
|
||||
ui.restoreconfig(backup)
|
||||
ui.restoreconfig(gitdiffbackup)
|
||||
ui.restoreconfig(verbosebackup)
|
||||
|
Loading…
Reference in New Issue
Block a user