hgext/graphlog.py
author Matt Harbison <matt_harbison@yahoo.com>
Sat, 07 Apr 2018 22:22:20 -0400
changeset 37518 092eff6833a7
parent 35038 0c9ba2ac60a8
child 40293 c303d65d2e34
permissions -rw-r--r--
lfs: infer the blob store URL from paths.default If `lfs.url` is specified, it takes precedence. However, now that we support serving blobs via hgweb, we shouldn't *require* this setting. Less configuration is better (things will work out of the box once this is sorted out), and git has similar functionality. This is not a complete solution- it isn't able to infer the blob store from an explicitly supplied path, and it should consider `paths.default-push` for push. The pull solution for that is a bit hacky, and this alone is an improvement for the vast majority of cases. Even though there are only a handful of references to the saved remote store, the location of them makes things complicated. 1) downloading files on demand in the revlog flag processor 2) copying to readonlyvfs with bundlerepo 3) downloading in the file prefetch hook 4) the canupload()/skipdownload() checks 5) uploading blobs Since revlog doesn't have a repo or ui reference, we can't avoid creating a remote store when the extension is loaded. While the long term goal is to make sure the prefetch hook is invoked early for every command for efficiency, this handling in the flag processor is needed as a last ditch fetch. In order to support the clone command, the remote store needs to be created later than when the extension loads, since `paths.default` isn't set until just before the files are checked out. Therefore, this patch changes the prefetch hook to ignore the saved reference, and build a new one. The canupload()/skipdownload() checks simply check if the stored instance is a `_nullremote`. Since this can only be set via `lfs.url` (which is reflected in the saved reference), checking only the instance created when the extension loaded is fine. The blob uploading function is called from several places: 1) a prepush hook 2) when writing a new bundle 3) from infinitepush The prepush hook gets an exchange.pushop, so it has a path to where the push is going. The bundle writer and infinitepush don't. Further, bundle creation for things like strip and amend are causing blobs to be uploaded. This seems wrong, but I don't want to side track this sorting that out, so punt on trying to handle explicit push paths or `paths.default-push`. I also think that sending blobs to a remote store when pushing to a local repo is wrong. This functionality predates the usercache, so perhaps that's the reason for it. I've got some patches floating around to stop sending blobs remotely in this case, and instead write directly to the other repo's blob store. But the tests for corruption handling weren't happy with this change, and I don't have time to rewrite them. So exclude filesystem based paths from this for now. I don't think there's much of a chance to implement `paths.remote:lfsurl` style configs, given how early these are resolved vs how late the remote store is created. But git has it, so I threw a TODO in there, in case anyone has ideas. I have no idea why this is now doing http auth twice when it wasn't before. I don't think the original blobstore's url is ever being used in these cases.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4344
345ed833854d Add graphlog extension
Joel Rosdahl <joel@rosdahl.net>
parents:
diff changeset
     1
# ASCII graph log extension for Mercurial
345ed833854d Add graphlog extension
Joel Rosdahl <joel@rosdahl.net>
parents:
diff changeset
     2
#
345ed833854d Add graphlog extension
Joel Rosdahl <joel@rosdahl.net>
parents:
diff changeset
     3
# Copyright 2007 Joel Rosdahl <joel@rosdahl.net>
4516
96d8a56d4ef9 Removed trailing whitespace and tabs from python files
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4509
diff changeset
     4
#
8225
46293a0c7e9f updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents: 8210
diff changeset
     5
# This software may be used and distributed according to the terms of the
10263
25e572394f5c Update license to GPLv2+
Matt Mackall <mpm@selenic.com>
parents: 10097
diff changeset
     6
# GNU General Public License version 2 or any later version.
8228
eee2319c5895 add blank line after copyright notices and after header
Martin Geisler <mg@lazybytes.net>
parents: 8225
diff changeset
     7
20118
6ed9141151bf graphlog: mark as deprecated
Martin Geisler <martin@geisler.net>
parents: 18267
diff changeset
     8
'''command to view revision graphs from a shell (DEPRECATED)
6ed9141151bf graphlog: mark as deprecated
Martin Geisler <martin@geisler.net>
parents: 18267
diff changeset
     9
6ed9141151bf graphlog: mark as deprecated
Martin Geisler <martin@geisler.net>
parents: 18267
diff changeset
    10
The functionality of this extension has been include in core Mercurial
27715
f93e7540db8c graphlog: update help with replacement
timeless <timeless@mozdev.org>
parents: 27149
diff changeset
    11
since version 2.3. Please use :hg:`log -G ...` instead.
7426
df0962f6c54e Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents: 7383
diff changeset
    12
df0962f6c54e Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents: 7383
diff changeset
    13
This extension adds a --graph option to the incoming, outgoing and log
9259
19a4b8fd5c48 graphlog: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents: 9198
diff changeset
    14
commands. When this options is given, an ASCII representation of the
19a4b8fd5c48 graphlog: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents: 9198
diff changeset
    15
revision graph is also shown.
7426
df0962f6c54e Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents: 7383
diff changeset
    16
'''
4344
345ed833854d Add graphlog extension
Joel Rosdahl <joel@rosdahl.net>
parents:
diff changeset
    17
29123
0e6b5a5aca22 py3: make hgext/graphlog.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 27715
diff changeset
    18
from __future__ import absolute_import
0e6b5a5aca22 py3: make hgext/graphlog.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 27715
diff changeset
    19
4344
345ed833854d Add graphlog extension
Joel Rosdahl <joel@rosdahl.net>
parents:
diff changeset
    20
from mercurial.i18n import _
29123
0e6b5a5aca22 py3: make hgext/graphlog.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 27715
diff changeset
    21
from mercurial import (
32414
04baab18d60a commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents: 32376
diff changeset
    22
    cmdutil,
29123
0e6b5a5aca22 py3: make hgext/graphlog.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 27715
diff changeset
    23
    commands,
32376
46ba2cdda476 registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents: 29852
diff changeset
    24
    registrar,
29123
0e6b5a5aca22 py3: make hgext/graphlog.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 27715
diff changeset
    25
)
5938
9ed100559851 graphlog: add filelog revision grapher
Steve Borho <steve@borho.org>
parents: 4735
diff changeset
    26
14311
9bbac962f4dd graphlog: use cmdutil.command decorator
Adrian Buehlmann <adrian@cadifra.com>
parents: 14139
diff changeset
    27
cmdtable = {}
32376
46ba2cdda476 registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents: 29852
diff changeset
    28
command = registrar.command(cmdtable)
29852
d5883fd055c6 extensions: change magic "shipped with hg" string
Augie Fackler <augie@google.com>
parents: 29123
diff changeset
    29
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
25186
80c5b2666a96 extensions: document that `testedwith = 'internal'` is special
Augie Fackler <augie@google.com>
parents: 24200
diff changeset
    30
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
80c5b2666a96 extensions: document that `testedwith = 'internal'` is special
Augie Fackler <augie@google.com>
parents: 24200
diff changeset
    31
# be specifying the version(s) of Mercurial they are tested with, or
80c5b2666a96 extensions: document that `testedwith = 'internal'` is special
Augie Fackler <augie@google.com>
parents: 24200
diff changeset
    32
# leave the attribute unspecified.
29852
d5883fd055c6 extensions: change magic "shipped with hg" string
Augie Fackler <augie@google.com>
parents: 29123
diff changeset
    33
testedwith = 'ships-with-hg-core'
14311
9bbac962f4dd graphlog: use cmdutil.command decorator
Adrian Buehlmann <adrian@cadifra.com>
parents: 14139
diff changeset
    34
9bbac962f4dd graphlog: use cmdutil.command decorator
Adrian Buehlmann <adrian@cadifra.com>
parents: 14139
diff changeset
    35
@command('glog',
16432
365bb0fa73a4 graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents: 16431
diff changeset
    36
    [('f', 'follow', None,
365bb0fa73a4 graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents: 16431
diff changeset
    37
     _('follow changeset history, or file history across copies and renames')),
365bb0fa73a4 graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents: 16431
diff changeset
    38
    ('', 'follow-first', None,
365bb0fa73a4 graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents: 16431
diff changeset
    39
     _('only follow the first parent of merge changesets (DEPRECATED)')),
365bb0fa73a4 graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents: 16431
diff changeset
    40
    ('d', 'date', '', _('show revisions matching date spec'), _('DATE')),
365bb0fa73a4 graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents: 16431
diff changeset
    41
    ('C', 'copies', None, _('show copied files')),
365bb0fa73a4 graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents: 16431
diff changeset
    42
    ('k', 'keyword', [],
365bb0fa73a4 graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents: 16431
diff changeset
    43
     _('do case-insensitive search for a given text'), _('TEXT')),
23091
8d43c6bb38c0 doc: change 'revision or range' to 'revision or revset'
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 21782
diff changeset
    44
    ('r', 'rev', [], _('show the specified revision or revset'), _('REV')),
16432
365bb0fa73a4 graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents: 16431
diff changeset
    45
    ('', 'removed', None, _('include revisions where files were removed')),
365bb0fa73a4 graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents: 16431
diff changeset
    46
    ('m', 'only-merges', None, _('show only merges (DEPRECATED)')),
365bb0fa73a4 graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents: 16431
diff changeset
    47
    ('u', 'user', [], _('revisions committed by user'), _('USER')),
365bb0fa73a4 graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents: 16431
diff changeset
    48
    ('', 'only-branch', [],
365bb0fa73a4 graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents: 16431
diff changeset
    49
     _('show only changesets within the given named branch (DEPRECATED)'),
365bb0fa73a4 graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents: 16431
diff changeset
    50
     _('BRANCH')),
365bb0fa73a4 graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents: 16431
diff changeset
    51
    ('b', 'branch', [],
365bb0fa73a4 graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents: 16431
diff changeset
    52
     _('show changesets within the given named branch'), _('BRANCH')),
365bb0fa73a4 graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents: 16431
diff changeset
    53
    ('P', 'prune', [],
365bb0fa73a4 graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents: 16431
diff changeset
    54
     _('do not display revision or any of its ancestors'), _('REV')),
32414
04baab18d60a commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents: 32376
diff changeset
    55
    ] + cmdutil.logopts + cmdutil.walkopts,
21782
404eca1ce4f9 graphlog: define inferrepo in command decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents: 20118
diff changeset
    56
    _('[OPTION]... [FILE]'),
404eca1ce4f9 graphlog: define inferrepo in command decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents: 20118
diff changeset
    57
    inferrepo=True)
27149
2f804a38351e graphlog: rename glog function
timeless <timeless@mozdev.org>
parents: 25186
diff changeset
    58
def glog(ui, repo, *pats, **opts):
7325
f9985108d4e4 graphlog: split the actual DAG grapher out into a separate method
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 7324
diff changeset
    59
    """show revision history alongside an ASCII revision graph
f9985108d4e4 graphlog: split the actual DAG grapher out into a separate method
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 7324
diff changeset
    60
9259
19a4b8fd5c48 graphlog: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents: 9198
diff changeset
    61
    Print a revision history alongside a revision graph drawn with
19a4b8fd5c48 graphlog: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents: 9198
diff changeset
    62
    ASCII characters.
7325
f9985108d4e4 graphlog: split the actual DAG grapher out into a separate method
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 7324
diff changeset
    63
9259
19a4b8fd5c48 graphlog: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents: 9198
diff changeset
    64
    Nodes printed as an @ character are parents of the working
19a4b8fd5c48 graphlog: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents: 9198
diff changeset
    65
    directory.
27715
f93e7540db8c graphlog: update help with replacement
timeless <timeless@mozdev.org>
parents: 27149
diff changeset
    66
f93e7540db8c graphlog: update help with replacement
timeless <timeless@mozdev.org>
parents: 27149
diff changeset
    67
    This is an alias to :hg:`log -G`.
7325
f9985108d4e4 graphlog: split the actual DAG grapher out into a separate method
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 7324
diff changeset
    68
    """
35038
0c9ba2ac60a8 py3: handle keyword arguments in hgext/graphlog.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 32414
diff changeset
    69
    opts[r'graph'] = True
24200
8e1f1673aa9a graphlog: do not bypass commands.log so that -fr works
Yuya Nishihara <yuya@tcha.org>
parents: 23091
diff changeset
    70
    return commands.log(ui, repo, *pats, **opts)