Commit Graph

11 Commits

Author SHA1 Message Date
Jordi Gutiérrez Hermoso
8eb132f5ea style: kill ersatz if-else ternary operators
Although Python supports `X = Y if COND else Z`, this was only
introduced in Python 2.5. Since we have to support Python 2.4, it was
a very common thing to write instead `X = COND and Y or Z`, which is a
bit obscure at a glance. It requires some intricate knowledge of
Python to understand how to parse these one-liners.

We change instead all of these one-liners to 4-liners. This was
executed with the following perlism:

    find -name "*.py" -exec perl -pi -e 's,(\s*)([\.\w]+) = \(?(\S+)\s+and\s+(\S*)\)?\s+or\s+(\S*)$,$1if $3:\n$1    $2 = $4\n$1else:\n$1    $2 = $5,' {} \;

I tweaked the following cases from the automatic Perl output:

    prev = (parents and parents[0]) or nullid
    port = (use_ssl and 443 or 80)
    cwd = (pats and repo.getcwd()) or ''
    rename = fctx and webutil.renamelink(fctx) or []
    ctx = fctx and fctx or ctx
    self.base = (mapfile and os.path.dirname(mapfile)) or ''

I also added some newlines wherever they seemd appropriate for readability

There are probably a few ersatz ternary operators still in the code
somewhere, lurking away from the power of a simple regex.
2015-03-13 17:00:06 -04:00
Mike Edgar
3ac3b11add dagutil: fix id/ix typos in docstrings 2014-10-24 16:26:44 -04:00
Mads Kiilerich
f3e152462b dagutils: fix docstrings for singleton internalize/externalize 2014-08-15 19:43:32 +02:00
Pierre-Yves David
5cf610755f discovery: enforce filtering into revlogbaseddag._internalizeall
One more step toward discovery running on filtered repo.
2013-11-15 23:27:39 -05:00
Pierre-Yves David
6ebc9feba5 discovery: make revlogdag work on filtered repo
The revlogdag class is a core part of discovery. We need its initialisation to
exclude revision filtered out.
2013-11-15 23:27:15 -05:00
Brodie Rao
92158e04de cleanup: "raise SomeException()" -> "raise SomeException" 2012-05-12 16:00:58 +02:00
Peter Arrenbrecht
bc696e8298 dagutil: fix off-by-one in inverserevlogdag buildup 2011-08-25 17:20:00 +02:00
Wagner Bruna
acc5952bf3 dagutil: fix missing import of i18n._ 2011-06-15 17:04:06 -03:00
Sune Foldager
354fe2aa7b revlogdag: add linearize function
See the docstring for a detailed explanation. The linearizer was originally
written by Benoit Boissinot.
2011-05-18 23:11:34 +02:00
Steven Brown
411d547af4 setdiscovery: limit lines to 80 characters 2011-05-05 23:21:37 +08:00
Peter Arrenbrecht
75fa0e5ea9 discovery: add new set-based discovery
Adds a new discovery method based on repeatedly sampling the still
undecided subset of the local node graph to determine the set of nodes
common to both the client and the server.

For small differences between client and server, it uses about the same
or slightly fewer roundtrips than the old tree-based discovery. For
larger differences, it typically reduces the number of roundtrips
drastically (from 150 to 4, for instance).

The old discovery code now lives in treediscovery.py, the new code is
in setdiscovery.py.

Still missing is a hook for extensions to contribute nodes to the
initial sample. For instance, Augie's remotebranches could contribute
the last known state of the server's heads.

Credits for the actual sampler and computing common heads instead of
bases go to Benoit Boissinot.
2011-05-02 19:21:30 +02:00