2019-11-01 22:33:28 +03:00
|
|
|
# Portions Copyright (c) Facebook, Inc. and its affiliates.
|
|
|
|
#
|
|
|
|
# This software may be used and distributed according to the terms of the
|
|
|
|
# GNU General Public License version 2.
|
|
|
|
|
2010-06-09 19:27:47 +04:00
|
|
|
# discovery.py - protocol changeset discovery functions
|
2010-06-07 20:35:54 +04:00
|
|
|
#
|
2010-06-09 19:27:47 +04:00
|
|
|
# Copyright 2010 Matt Mackall <mpm@selenic.com>
|
2010-06-07 20:35:54 +04:00
|
|
|
#
|
|
|
|
# This software may be used and distributed according to the terms of the
|
|
|
|
# GNU General Public License version 2 or any later version.
|
|
|
|
|
2015-08-09 05:07:11 +03:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
checkheads: upgrade the obsolescence postprocessing logic (issue4354)
The previous logic had many shortcoming (eg: looking at the head only, not
handling prune, etc...), the new logic use a more robust approach:
For each head, we check if after the push all changesets exclusive to this heads
will be obsolete. If they are, the branch considered be "replaced".
To check if a changeset will be obsolete, we simply checks:
* the changeset phase
* the existence of a marker relevant to the "pushed set" that affects the
changesets..
This fixes two major issues of the previous algorithm:
* branch partially rewritten (eg: head but not root) are no longer detected as
replaced,
* Prune are now properly handled.
(This implementation was introduction in the evolve extension, version 6.0.0.)
This new algorithm has an extended number of tests, a basic one is provided
in this patch. The others will be introduced in their own changeset for clarity.
In addition, we stop trying to process heads unknown locally, we do not have
enough data to take an informed decision so we should stop pretending we do.
This reflect a test that is now update.
2017-04-15 03:55:18 +03:00
|
|
|
import functools
|
|
|
|
|
2019-02-27 17:20:46 +03:00
|
|
|
from . import bookmarks, branchmap, phases, setdiscovery, treediscovery, util
|
|
|
|
from .node import hex, nullid
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2010-06-07 20:35:54 +04:00
|
|
|
|
2019-06-04 01:09:21 +03:00
|
|
|
def findcommonincoming(
|
|
|
|
repo, remote, heads=None, force=False, ancestorsof=None, needlargestcommonset=True
|
|
|
|
):
|
2011-04-30 19:21:37 +04:00
|
|
|
"""Return a tuple (common, anyincoming, heads) used to identify the common
|
|
|
|
subset of nodes between repo and remote.
|
|
|
|
|
|
|
|
"common" is a list of (at least) the heads of the common subset.
|
|
|
|
"anyincoming" is testable as a boolean indicating if any nodes are missing
|
|
|
|
locally. If remote does not support getbundle, this actually is a list of
|
|
|
|
roots of the nodes that would be incoming, to be supplied to
|
|
|
|
changegroupsubset. No code except for pull should be relying on this fact
|
|
|
|
any longer.
|
|
|
|
"heads" is either the supplied heads, or else the remote's heads.
|
2017-12-07 01:33:01 +03:00
|
|
|
"ancestorsof" if not None, restrict the discovery to a subset defined by
|
|
|
|
these nodes. Changeset outside of this set won't be considered (and
|
|
|
|
won't appears in "common")
|
2019-06-04 01:09:21 +03:00
|
|
|
"needlargestcommonset" if set to True then it will return the largest set of common nodes.
|
|
|
|
Otherwise heuristics can be used to speed up discovery but return a smaller
|
|
|
|
common set.
|
2010-06-07 20:35:54 +04:00
|
|
|
|
2012-08-16 00:38:42 +04:00
|
|
|
If you pass heads and they are all known locally, the response lists just
|
2011-05-02 21:21:30 +04:00
|
|
|
these heads in "common" and in "heads".
|
2011-05-06 16:44:18 +04:00
|
|
|
|
|
|
|
Please use findcommonoutgoing to compute the set of outgoing nodes to give
|
|
|
|
extensions a good hook into outgoing.
|
2011-05-02 21:21:30 +04:00
|
|
|
"""
|
2010-06-07 20:35:54 +04:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if not remote.capable("getbundle"):
|
2011-05-02 21:21:30 +04:00
|
|
|
return treediscovery.findcommonincoming(repo, remote, heads, force)
|
2010-06-07 20:35:54 +04:00
|
|
|
|
2011-05-02 21:21:30 +04:00
|
|
|
if heads:
|
|
|
|
allknown = True
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
knownnode = repo.changelog.hasnode # no nodemap until it is filtered
|
2011-05-02 21:21:30 +04:00
|
|
|
for h in heads:
|
2013-11-16 08:28:43 +04:00
|
|
|
if not knownnode(h):
|
2011-05-02 21:21:30 +04:00
|
|
|
allknown = False
|
|
|
|
break
|
|
|
|
if allknown:
|
|
|
|
return (heads, False, heads)
|
2010-06-07 20:35:54 +04:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
res = setdiscovery.findcommonheads(
|
2019-06-04 01:09:21 +03:00
|
|
|
repo.ui,
|
|
|
|
repo,
|
|
|
|
remote,
|
|
|
|
abortwhenunrelated=not force,
|
|
|
|
ancestorsof=ancestorsof,
|
|
|
|
needlargestcommonset=needlargestcommonset,
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
)
|
2011-05-02 21:21:30 +04:00
|
|
|
common, anyinc, srvheads = res
|
|
|
|
return (list(common), anyinc, heads or list(srvheads))
|
2010-06-07 20:35:54 +04:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2012-01-09 06:47:16 +04:00
|
|
|
class outgoing(object):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
"""Represents the set of nodes present in a local repo but not in a
|
2012-01-09 06:47:16 +04:00
|
|
|
(possibly) remote one.
|
|
|
|
|
|
|
|
Members:
|
|
|
|
|
|
|
|
missing is a list of all nodes present in local but not in remote.
|
|
|
|
common is a list of all nodes shared between the two repos.
|
2012-01-11 03:27:46 +04:00
|
|
|
excluded is the list of missing changeset that shouldn't be sent remotely.
|
2012-01-09 06:47:16 +04:00
|
|
|
missingheads is the list of heads of missing.
|
|
|
|
commonheads is the list of heads of common.
|
|
|
|
|
|
|
|
The sets are computed on demand from the heads, unless provided upfront
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
by discovery."""
|
2012-01-09 06:47:16 +04:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
def __init__(self, repo, commonheads=None, missingheads=None, missingroots=None):
|
2016-08-09 23:31:38 +03:00
|
|
|
# at least one of them must not be set
|
|
|
|
assert None in (commonheads, missingroots)
|
2016-08-09 16:55:44 +03:00
|
|
|
cl = repo.changelog
|
2016-09-06 19:43:25 +03:00
|
|
|
if missingheads is None:
|
2019-11-07 21:50:10 +03:00
|
|
|
missingheads = repo.heads()
|
2016-08-09 23:31:38 +03:00
|
|
|
if missingroots:
|
|
|
|
discbases = []
|
|
|
|
for n in missingroots:
|
|
|
|
discbases.extend([p for p in cl.parents(n) if p != nullid])
|
|
|
|
# TODO remove call to nodesbetween.
|
|
|
|
# TODO populate attributes on outgoing instance instead of setting
|
|
|
|
# discbases.
|
|
|
|
csets, roots, heads = cl.nodesbetween(missingroots, missingheads)
|
|
|
|
included = set(csets)
|
|
|
|
missingheads = heads
|
|
|
|
commonheads = [n for n in discbases if n not in included]
|
|
|
|
elif not commonheads:
|
2016-08-09 16:55:44 +03:00
|
|
|
commonheads = [nullid]
|
2012-01-09 06:47:16 +04:00
|
|
|
self.commonheads = commonheads
|
|
|
|
self.missingheads = missingheads
|
2016-08-09 16:55:44 +03:00
|
|
|
self._revlog = cl
|
2012-01-09 06:47:16 +04:00
|
|
|
self._common = None
|
|
|
|
self._missing = None
|
2012-01-11 03:27:46 +04:00
|
|
|
self.excluded = []
|
2012-01-09 06:47:16 +04:00
|
|
|
|
|
|
|
def _computecommonmissing(self):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
sets = self._revlog.findcommonmissing(self.commonheads, self.missingheads)
|
2012-01-09 06:47:16 +04:00
|
|
|
self._common, self._missing = sets
|
|
|
|
|
|
|
|
@util.propertycache
|
|
|
|
def common(self):
|
|
|
|
if self._common is None:
|
|
|
|
self._computecommonmissing()
|
|
|
|
return self._common
|
|
|
|
|
|
|
|
@util.propertycache
|
|
|
|
def missing(self):
|
|
|
|
if self._missing is None:
|
|
|
|
self._computecommonmissing()
|
|
|
|
return self._missing
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
|
|
|
def findcommonoutgoing(
|
|
|
|
repo, other, onlyheads=None, force=False, commoninc=None, portable=False
|
|
|
|
):
|
|
|
|
"""Return an outgoing instance to identify the nodes present in repo but
|
2012-01-09 06:47:16 +04:00
|
|
|
not in other.
|
2011-05-06 16:44:18 +04:00
|
|
|
|
2012-05-12 17:54:54 +04:00
|
|
|
If onlyheads is given, only nodes ancestral to nodes in onlyheads
|
|
|
|
(inclusive) are included. If you already know the local repo's heads,
|
|
|
|
passing them in onlyheads is faster than letting them be recomputed here.
|
2011-05-06 16:44:18 +04:00
|
|
|
|
2012-07-26 04:54:13 +04:00
|
|
|
If commoninc is given, it must be the result of a prior call to
|
2012-05-12 21:38:20 +04:00
|
|
|
findcommonincoming(repo, other, force) to avoid recomputing it here.
|
|
|
|
|
|
|
|
If portable is given, compute more conservative common and missingheads,
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
to make bundles created from the instance more portable."""
|
2012-01-11 03:27:46 +04:00
|
|
|
# declare an empty outgoing object to be filled later
|
2016-08-09 16:26:53 +03:00
|
|
|
og = outgoing(repo, None, None)
|
2012-01-11 03:27:46 +04:00
|
|
|
|
|
|
|
# get common set if not provided
|
|
|
|
if commoninc is None:
|
2019-06-04 01:09:21 +03:00
|
|
|
commoninc = findcommonincoming(
|
|
|
|
repo, other, force=force, ancestorsof=onlyheads, needlargestcommonset=True
|
|
|
|
)
|
2012-01-11 03:27:46 +04:00
|
|
|
og.commonheads, _any, _hds = commoninc
|
|
|
|
|
|
|
|
# compute outgoing
|
2019-09-24 03:08:35 +03:00
|
|
|
if repo.ui.configbool("experimental", "narrow-heads"):
|
|
|
|
mayexclude = None
|
|
|
|
else:
|
|
|
|
mayexclude = repo._phasecache.phaseroots[phases.secret] or repo.obsstore
|
2012-07-13 16:38:49 +04:00
|
|
|
if not mayexclude:
|
2012-01-11 03:27:46 +04:00
|
|
|
og.missingheads = onlyheads or repo.heads()
|
|
|
|
elif onlyheads is None:
|
|
|
|
# use visible heads as it should be cached
|
2013-01-13 11:39:16 +04:00
|
|
|
og.missingheads = repo.filtered("served").heads()
|
2018-11-06 14:12:52 +03:00
|
|
|
og.excluded = [ctx.node() for ctx in repo.set("secret()")]
|
2012-01-11 03:27:46 +04:00
|
|
|
else:
|
|
|
|
# compute common, missing and exclude secret stuff
|
|
|
|
sets = repo.changelog.findcommonmissing(og.commonheads, onlyheads)
|
|
|
|
og._common, allmissing = sets
|
|
|
|
og._missing = missing = []
|
2012-01-20 03:27:11 +04:00
|
|
|
og.excluded = excluded = []
|
2012-01-11 03:27:46 +04:00
|
|
|
for node in allmissing:
|
2012-07-13 16:38:49 +04:00
|
|
|
ctx = repo[node]
|
2018-11-06 14:12:52 +03:00
|
|
|
if ctx.phase() >= phases.secret:
|
2012-07-25 21:34:31 +04:00
|
|
|
excluded.append(node)
|
|
|
|
else:
|
|
|
|
missing.append(node)
|
2012-07-13 16:38:49 +04:00
|
|
|
if len(missing) == len(allmissing):
|
2012-01-11 03:27:46 +04:00
|
|
|
missingheads = onlyheads
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
else: # update missing heads
|
2012-07-13 16:38:49 +04:00
|
|
|
missingheads = phases.newheads(repo, onlyheads, excluded)
|
2012-01-11 03:27:46 +04:00
|
|
|
og.missingheads = missingheads
|
2012-05-12 21:38:20 +04:00
|
|
|
if portable:
|
|
|
|
# recompute common and missingheads as if -r<rev> had been given for
|
|
|
|
# each head of missing, and --base <rev> for each head of the proper
|
|
|
|
# ancestors of missing
|
|
|
|
og._computecommonmissing()
|
|
|
|
cl = repo.changelog
|
|
|
|
missingrevs = set(cl.rev(n) for n in og._missing)
|
2012-06-01 23:37:18 +04:00
|
|
|
og._common = set(cl.ancestors(missingrevs)) - missingrevs
|
2012-05-12 21:38:20 +04:00
|
|
|
commonheads = set(og.commonheads)
|
|
|
|
og.missingheads = [h for h in og.missingheads if h not in commonheads]
|
|
|
|
|
2012-01-11 03:27:46 +04:00
|
|
|
return og
|
2011-05-06 16:44:18 +04:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2017-05-29 11:56:00 +03:00
|
|
|
def _headssummary(pushop):
|
2012-07-17 20:21:49 +04:00
|
|
|
"""compute a summary of branch and heads status before and after push
|
|
|
|
|
2017-05-29 06:52:13 +03:00
|
|
|
return {'branch': ([remoteheads], [newheads],
|
|
|
|
[unsyncedheads], [discardedheads])} mapping
|
2012-07-17 18:30:42 +04:00
|
|
|
|
2017-05-29 06:52:13 +03:00
|
|
|
- branch: the branch name,
|
2012-07-17 18:30:42 +04:00
|
|
|
- remoteheads: the list of remote heads known locally
|
2017-05-29 06:52:13 +03:00
|
|
|
None if the branch is new,
|
|
|
|
- newheads: the new remote heads (known locally) with outgoing pushed,
|
|
|
|
- unsyncedheads: the list of remote heads unknown locally,
|
|
|
|
- discardedheads: the list of heads made obsolete by the push.
|
2012-07-17 20:21:49 +04:00
|
|
|
"""
|
2017-05-29 11:56:00 +03:00
|
|
|
repo = pushop.repo.unfiltered()
|
|
|
|
remote = pushop.remote
|
|
|
|
outgoing = pushop.outgoing
|
2012-07-17 20:21:49 +04:00
|
|
|
cl = repo.changelog
|
2012-07-17 18:30:42 +04:00
|
|
|
headssum = {}
|
2012-07-17 20:21:49 +04:00
|
|
|
# A. Create set of branches involved in the push.
|
|
|
|
branches = set(repo[n].branch() for n in outgoing.missing)
|
|
|
|
remotemap = remote.branchmap()
|
|
|
|
newbranches = branches - set(remotemap)
|
|
|
|
branches.difference_update(newbranches)
|
|
|
|
|
2012-07-17 18:30:42 +04:00
|
|
|
# A. register remote heads
|
|
|
|
remotebranches = set()
|
|
|
|
for branch, heads in remote.branchmap().iteritems():
|
|
|
|
remotebranches.add(branch)
|
|
|
|
known = []
|
|
|
|
unsynced = []
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
knownnode = cl.hasnode # do not use nodemap until it is filtered
|
2012-07-17 18:30:42 +04:00
|
|
|
for h in heads:
|
2013-11-16 08:28:43 +04:00
|
|
|
if knownnode(h):
|
2012-07-17 18:30:42 +04:00
|
|
|
known.append(h)
|
|
|
|
else:
|
|
|
|
unsynced.append(h)
|
|
|
|
headssum[branch] = (known, list(known), unsynced)
|
|
|
|
# B. add new branch data
|
|
|
|
missingctx = list(repo[n] for n in outgoing.missing)
|
|
|
|
touchedbranches = set()
|
|
|
|
for ctx in missingctx:
|
|
|
|
branch = ctx.branch()
|
|
|
|
touchedbranches.add(branch)
|
|
|
|
if branch not in headssum:
|
|
|
|
headssum[branch] = (None, [], [])
|
|
|
|
|
|
|
|
# C drop data about untouched branches:
|
|
|
|
for branch in remotebranches - touchedbranches:
|
|
|
|
del headssum[branch]
|
|
|
|
|
|
|
|
# D. Update newmap with outgoing changes.
|
2012-07-17 20:21:49 +04:00
|
|
|
# This will possibly add new heads and remove existing ones.
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
newmap = branchmap.branchcache(
|
|
|
|
(branch, heads[1])
|
|
|
|
for branch, heads in headssum.iteritems()
|
|
|
|
if heads[0] is not None
|
|
|
|
)
|
2013-01-08 04:28:39 +04:00
|
|
|
newmap.update(repo, (ctx.rev() for ctx in missingctx))
|
2012-07-17 18:30:42 +04:00
|
|
|
for branch, newheads in newmap.iteritems():
|
|
|
|
headssum[branch][1][:] = newheads
|
2017-05-29 06:33:59 +03:00
|
|
|
for branch, items in headssum.iteritems():
|
|
|
|
for l in items:
|
|
|
|
if l is not None:
|
|
|
|
l.sort()
|
2017-05-29 06:52:13 +03:00
|
|
|
headssum[branch] = items + ([],)
|
|
|
|
|
2017-05-29 06:47:27 +03:00
|
|
|
# If there are no obsstore, no post processing are needed.
|
|
|
|
if repo.obsstore:
|
2017-06-05 15:37:04 +03:00
|
|
|
torev = repo.changelog.rev
|
2017-06-05 15:44:15 +03:00
|
|
|
futureheads = set(torev(h) for h in outgoing.missingheads)
|
|
|
|
futureheads |= set(torev(h) for h in outgoing.commonheads)
|
|
|
|
allfuturecommon = repo.changelog.ancestors(futureheads, inclusive=True)
|
2017-05-29 06:47:27 +03:00
|
|
|
for branch, heads in sorted(headssum.iteritems()):
|
2017-05-29 06:52:13 +03:00
|
|
|
remoteheads, newheads, unsyncedheads, placeholder = heads
|
2017-05-29 06:47:27 +03:00
|
|
|
result = _postprocessobsolete(pushop, allfuturecommon, newheads)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
headssum[branch] = (
|
|
|
|
remoteheads,
|
|
|
|
sorted(result[0]),
|
|
|
|
unsyncedheads,
|
|
|
|
sorted(result[1]),
|
|
|
|
)
|
2012-07-17 18:30:42 +04:00
|
|
|
return headssum
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2012-07-17 18:30:42 +04:00
|
|
|
def _oldheadssummary(repo, remoteheads, outgoing, inc=False):
|
2012-07-17 20:21:49 +04:00
|
|
|
"""Compute branchmapsummary for repo without branchmap support"""
|
|
|
|
|
|
|
|
# 1-4b. old servers: Check for new topological heads.
|
|
|
|
# Construct {old,new}map with branch = None (topological branch).
|
2012-12-19 17:49:06 +04:00
|
|
|
# (code based on update)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
knownnode = repo.changelog.hasnode # no nodemap until it is filtered
|
2017-05-29 06:33:59 +03:00
|
|
|
oldheads = sorted(h for h in remoteheads if knownnode(h))
|
2012-07-17 20:21:49 +04:00
|
|
|
# all nodes in outgoing.missing are children of either:
|
|
|
|
# - an element of oldheads
|
|
|
|
# - another element of outgoing.missing
|
|
|
|
# - nullrev
|
|
|
|
# This explains why the new head are very simple to compute.
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
r = repo.set("heads(%ln + %ln)", oldheads, outgoing.missing)
|
2017-05-29 06:33:59 +03:00
|
|
|
newheads = sorted(c.node() for c in r)
|
2014-08-15 03:26:41 +04:00
|
|
|
# set some unsynced head to issue the "unsynced changes" warning
|
2015-03-14 00:00:06 +03:00
|
|
|
if inc:
|
2017-05-29 06:37:19 +03:00
|
|
|
unsynced = [None]
|
2015-03-14 00:00:06 +03:00
|
|
|
else:
|
2017-05-29 06:37:19 +03:00
|
|
|
unsynced = []
|
2017-05-29 06:52:13 +03:00
|
|
|
return {None: (oldheads, newheads, unsynced, [])}
|
2012-07-17 20:21:49 +04:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2015-11-10 22:16:25 +03:00
|
|
|
def _nowarnheads(pushop):
|
2015-11-06 20:48:24 +03:00
|
|
|
# Compute newly pushed bookmarks. We don't warn about bookmarked heads.
|
2015-11-10 22:16:25 +03:00
|
|
|
repo = pushop.repo.unfiltered()
|
|
|
|
remote = pushop.remote
|
2015-11-06 20:48:24 +03:00
|
|
|
localbookmarks = repo._bookmarks
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
remotebookmarks = remote.listkeys("bookmarks")
|
2015-11-06 20:48:24 +03:00
|
|
|
bookmarkedheads = set()
|
2016-05-25 00:36:27 +03:00
|
|
|
|
|
|
|
# internal config: bookmarks.pushing
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
newbookmarks = [
|
|
|
|
localbookmarks.expandname(b)
|
|
|
|
for b in pushop.ui.configlist("bookmarks", "pushing")
|
|
|
|
]
|
2016-05-25 00:36:27 +03:00
|
|
|
|
2015-11-06 20:48:24 +03:00
|
|
|
for bm in localbookmarks:
|
|
|
|
rnode = remotebookmarks.get(bm)
|
|
|
|
if rnode and rnode in repo:
|
|
|
|
lctx, rctx = repo[bm], repo[rnode]
|
|
|
|
if bookmarks.validdest(repo, rctx, lctx):
|
|
|
|
bookmarkedheads.add(lctx.node())
|
|
|
|
else:
|
|
|
|
if bm in newbookmarks and bm not in remotebookmarks:
|
|
|
|
bookmarkedheads.add(repo[bm].node())
|
|
|
|
|
|
|
|
return bookmarkedheads
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2017-03-22 01:30:13 +03:00
|
|
|
def _postprocessobsolete(pushop, futurecommon, candidate_newhs):
|
|
|
|
"""post process the list of new heads with obsolescence information
|
|
|
|
|
checkheads: upgrade the obsolescence postprocessing logic (issue4354)
The previous logic had many shortcoming (eg: looking at the head only, not
handling prune, etc...), the new logic use a more robust approach:
For each head, we check if after the push all changesets exclusive to this heads
will be obsolete. If they are, the branch considered be "replaced".
To check if a changeset will be obsolete, we simply checks:
* the changeset phase
* the existence of a marker relevant to the "pushed set" that affects the
changesets..
This fixes two major issues of the previous algorithm:
* branch partially rewritten (eg: head but not root) are no longer detected as
replaced,
* Prune are now properly handled.
(This implementation was introduction in the evolve extension, version 6.0.0.)
This new algorithm has an extended number of tests, a basic one is provided
in this patch. The others will be introduced in their own changeset for clarity.
In addition, we stop trying to process heads unknown locally, we do not have
enough data to take an informed decision so we should stop pretending we do.
This reflect a test that is now update.
2017-04-15 03:55:18 +03:00
|
|
|
Exists as a sub-function to contain the complexity and allow extensions to
|
2017-03-22 01:30:13 +03:00
|
|
|
experiment with smarter logic.
|
checkheads: upgrade the obsolescence postprocessing logic (issue4354)
The previous logic had many shortcoming (eg: looking at the head only, not
handling prune, etc...), the new logic use a more robust approach:
For each head, we check if after the push all changesets exclusive to this heads
will be obsolete. If they are, the branch considered be "replaced".
To check if a changeset will be obsolete, we simply checks:
* the changeset phase
* the existence of a marker relevant to the "pushed set" that affects the
changesets..
This fixes two major issues of the previous algorithm:
* branch partially rewritten (eg: head but not root) are no longer detected as
replaced,
* Prune are now properly handled.
(This implementation was introduction in the evolve extension, version 6.0.0.)
This new algorithm has an extended number of tests, a basic one is provided
in this patch. The others will be introduced in their own changeset for clarity.
In addition, we stop trying to process heads unknown locally, we do not have
enough data to take an informed decision so we should stop pretending we do.
This reflect a test that is now update.
2017-04-15 03:55:18 +03:00
|
|
|
|
2017-03-22 01:30:13 +03:00
|
|
|
Returns (newheads, discarded_heads) tuple
|
|
|
|
"""
|
checkheads: upgrade the obsolescence postprocessing logic (issue4354)
The previous logic had many shortcoming (eg: looking at the head only, not
handling prune, etc...), the new logic use a more robust approach:
For each head, we check if after the push all changesets exclusive to this heads
will be obsolete. If they are, the branch considered be "replaced".
To check if a changeset will be obsolete, we simply checks:
* the changeset phase
* the existence of a marker relevant to the "pushed set" that affects the
changesets..
This fixes two major issues of the previous algorithm:
* branch partially rewritten (eg: head but not root) are no longer detected as
replaced,
* Prune are now properly handled.
(This implementation was introduction in the evolve extension, version 6.0.0.)
This new algorithm has an extended number of tests, a basic one is provided
in this patch. The others will be introduced in their own changeset for clarity.
In addition, we stop trying to process heads unknown locally, we do not have
enough data to take an informed decision so we should stop pretending we do.
This reflect a test that is now update.
2017-04-15 03:55:18 +03:00
|
|
|
# known issue
|
2017-03-22 01:30:13 +03:00
|
|
|
#
|
checkheads: upgrade the obsolescence postprocessing logic (issue4354)
The previous logic had many shortcoming (eg: looking at the head only, not
handling prune, etc...), the new logic use a more robust approach:
For each head, we check if after the push all changesets exclusive to this heads
will be obsolete. If they are, the branch considered be "replaced".
To check if a changeset will be obsolete, we simply checks:
* the changeset phase
* the existence of a marker relevant to the "pushed set" that affects the
changesets..
This fixes two major issues of the previous algorithm:
* branch partially rewritten (eg: head but not root) are no longer detected as
replaced,
* Prune are now properly handled.
(This implementation was introduction in the evolve extension, version 6.0.0.)
This new algorithm has an extended number of tests, a basic one is provided
in this patch. The others will be introduced in their own changeset for clarity.
In addition, we stop trying to process heads unknown locally, we do not have
enough data to take an informed decision so we should stop pretending we do.
This reflect a test that is now update.
2017-04-15 03:55:18 +03:00
|
|
|
# * We "silently" skip processing on all changeset unknown locally
|
2017-03-22 01:30:13 +03:00
|
|
|
#
|
checkheads: upgrade the obsolescence postprocessing logic (issue4354)
The previous logic had many shortcoming (eg: looking at the head only, not
handling prune, etc...), the new logic use a more robust approach:
For each head, we check if after the push all changesets exclusive to this heads
will be obsolete. If they are, the branch considered be "replaced".
To check if a changeset will be obsolete, we simply checks:
* the changeset phase
* the existence of a marker relevant to the "pushed set" that affects the
changesets..
This fixes two major issues of the previous algorithm:
* branch partially rewritten (eg: head but not root) are no longer detected as
replaced,
* Prune are now properly handled.
(This implementation was introduction in the evolve extension, version 6.0.0.)
This new algorithm has an extended number of tests, a basic one is provided
in this patch. The others will be introduced in their own changeset for clarity.
In addition, we stop trying to process heads unknown locally, we do not have
enough data to take an informed decision so we should stop pretending we do.
This reflect a test that is now update.
2017-04-15 03:55:18 +03:00
|
|
|
# * if <nh> is public on the remote, it won't be affected by obsolete
|
|
|
|
# marker and a new is created
|
|
|
|
|
|
|
|
# define various utilities and containers
|
2017-03-22 01:30:13 +03:00
|
|
|
repo = pushop.repo
|
checkheads: upgrade the obsolescence postprocessing logic (issue4354)
The previous logic had many shortcoming (eg: looking at the head only, not
handling prune, etc...), the new logic use a more robust approach:
For each head, we check if after the push all changesets exclusive to this heads
will be obsolete. If they are, the branch considered be "replaced".
To check if a changeset will be obsolete, we simply checks:
* the changeset phase
* the existence of a marker relevant to the "pushed set" that affects the
changesets..
This fixes two major issues of the previous algorithm:
* branch partially rewritten (eg: head but not root) are no longer detected as
replaced,
* Prune are now properly handled.
(This implementation was introduction in the evolve extension, version 6.0.0.)
This new algorithm has an extended number of tests, a basic one is provided
in this patch. The others will be introduced in their own changeset for clarity.
In addition, we stop trying to process heads unknown locally, we do not have
enough data to take an informed decision so we should stop pretending we do.
This reflect a test that is now update.
2017-04-15 03:55:18 +03:00
|
|
|
unfi = repo.unfiltered()
|
|
|
|
tonode = unfi.changelog.node
|
2017-06-05 17:20:20 +03:00
|
|
|
torev = unfi.changelog.nodemap.get
|
checkheads: upgrade the obsolescence postprocessing logic (issue4354)
The previous logic had many shortcoming (eg: looking at the head only, not
handling prune, etc...), the new logic use a more robust approach:
For each head, we check if after the push all changesets exclusive to this heads
will be obsolete. If they are, the branch considered be "replaced".
To check if a changeset will be obsolete, we simply checks:
* the changeset phase
* the existence of a marker relevant to the "pushed set" that affects the
changesets..
This fixes two major issues of the previous algorithm:
* branch partially rewritten (eg: head but not root) are no longer detected as
replaced,
* Prune are now properly handled.
(This implementation was introduction in the evolve extension, version 6.0.0.)
This new algorithm has an extended number of tests, a basic one is provided
in this patch. The others will be introduced in their own changeset for clarity.
In addition, we stop trying to process heads unknown locally, we do not have
enough data to take an informed decision so we should stop pretending we do.
This reflect a test that is now update.
2017-04-15 03:55:18 +03:00
|
|
|
public = phases.public
|
|
|
|
getphase = unfi._phasecache.phase
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
ispublic = lambda r: getphase(unfi, r) == public
|
|
|
|
ispushed = lambda n: torev(n) in futurecommon
|
2017-06-05 17:17:47 +03:00
|
|
|
hasoutmarker = functools.partial(pushingmarkerfor, unfi.obsstore, ispushed)
|
checkheads: upgrade the obsolescence postprocessing logic (issue4354)
The previous logic had many shortcoming (eg: looking at the head only, not
handling prune, etc...), the new logic use a more robust approach:
For each head, we check if after the push all changesets exclusive to this heads
will be obsolete. If they are, the branch considered be "replaced".
To check if a changeset will be obsolete, we simply checks:
* the changeset phase
* the existence of a marker relevant to the "pushed set" that affects the
changesets..
This fixes two major issues of the previous algorithm:
* branch partially rewritten (eg: head but not root) are no longer detected as
replaced,
* Prune are now properly handled.
(This implementation was introduction in the evolve extension, version 6.0.0.)
This new algorithm has an extended number of tests, a basic one is provided
in this patch. The others will be introduced in their own changeset for clarity.
In addition, we stop trying to process heads unknown locally, we do not have
enough data to take an informed decision so we should stop pretending we do.
This reflect a test that is now update.
2017-04-15 03:55:18 +03:00
|
|
|
successorsmarkers = unfi.obsstore.successors
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
newhs = set() # final set of new heads
|
|
|
|
discarded = set() # new head of fully replaced branch
|
checkheads: upgrade the obsolescence postprocessing logic (issue4354)
The previous logic had many shortcoming (eg: looking at the head only, not
handling prune, etc...), the new logic use a more robust approach:
For each head, we check if after the push all changesets exclusive to this heads
will be obsolete. If they are, the branch considered be "replaced".
To check if a changeset will be obsolete, we simply checks:
* the changeset phase
* the existence of a marker relevant to the "pushed set" that affects the
changesets..
This fixes two major issues of the previous algorithm:
* branch partially rewritten (eg: head but not root) are no longer detected as
replaced,
* Prune are now properly handled.
(This implementation was introduction in the evolve extension, version 6.0.0.)
This new algorithm has an extended number of tests, a basic one is provided
in this patch. The others will be introduced in their own changeset for clarity.
In addition, we stop trying to process heads unknown locally, we do not have
enough data to take an informed decision so we should stop pretending we do.
This reflect a test that is now update.
2017-04-15 03:55:18 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
localcandidate = set() # candidate heads known locally
|
|
|
|
unknownheads = set() # candidate heads unknown locally
|
checkheads: upgrade the obsolescence postprocessing logic (issue4354)
The previous logic had many shortcoming (eg: looking at the head only, not
handling prune, etc...), the new logic use a more robust approach:
For each head, we check if after the push all changesets exclusive to this heads
will be obsolete. If they are, the branch considered be "replaced".
To check if a changeset will be obsolete, we simply checks:
* the changeset phase
* the existence of a marker relevant to the "pushed set" that affects the
changesets..
This fixes two major issues of the previous algorithm:
* branch partially rewritten (eg: head but not root) are no longer detected as
replaced,
* Prune are now properly handled.
(This implementation was introduction in the evolve extension, version 6.0.0.)
This new algorithm has an extended number of tests, a basic one is provided
in this patch. The others will be introduced in their own changeset for clarity.
In addition, we stop trying to process heads unknown locally, we do not have
enough data to take an informed decision so we should stop pretending we do.
This reflect a test that is now update.
2017-04-15 03:55:18 +03:00
|
|
|
for h in candidate_newhs:
|
|
|
|
if h in unfi:
|
|
|
|
localcandidate.add(h)
|
|
|
|
else:
|
|
|
|
if successorsmarkers.get(h) is not None:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
msg = (
|
|
|
|
"checkheads: remote head unknown locally has" " local marker: %s\n"
|
|
|
|
)
|
checkheads: upgrade the obsolescence postprocessing logic (issue4354)
The previous logic had many shortcoming (eg: looking at the head only, not
handling prune, etc...), the new logic use a more robust approach:
For each head, we check if after the push all changesets exclusive to this heads
will be obsolete. If they are, the branch considered be "replaced".
To check if a changeset will be obsolete, we simply checks:
* the changeset phase
* the existence of a marker relevant to the "pushed set" that affects the
changesets..
This fixes two major issues of the previous algorithm:
* branch partially rewritten (eg: head but not root) are no longer detected as
replaced,
* Prune are now properly handled.
(This implementation was introduction in the evolve extension, version 6.0.0.)
This new algorithm has an extended number of tests, a basic one is provided
in this patch. The others will be introduced in their own changeset for clarity.
In addition, we stop trying to process heads unknown locally, we do not have
enough data to take an informed decision so we should stop pretending we do.
This reflect a test that is now update.
2017-04-15 03:55:18 +03:00
|
|
|
repo.ui.debug(msg % hex(h))
|
|
|
|
unknownheads.add(h)
|
|
|
|
|
|
|
|
# fast path the simple case
|
|
|
|
if len(localcandidate) == 1:
|
|
|
|
return unknownheads | set(candidate_newhs), set()
|
|
|
|
|
|
|
|
# actually process branch replacement
|
|
|
|
while localcandidate:
|
|
|
|
nh = localcandidate.pop()
|
|
|
|
# run this check early to skip the evaluation of the whole branch
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if torev(nh) in futurecommon or ispublic(torev(nh)):
|
checkheads: upgrade the obsolescence postprocessing logic (issue4354)
The previous logic had many shortcoming (eg: looking at the head only, not
handling prune, etc...), the new logic use a more robust approach:
For each head, we check if after the push all changesets exclusive to this heads
will be obsolete. If they are, the branch considered be "replaced".
To check if a changeset will be obsolete, we simply checks:
* the changeset phase
* the existence of a marker relevant to the "pushed set" that affects the
changesets..
This fixes two major issues of the previous algorithm:
* branch partially rewritten (eg: head but not root) are no longer detected as
replaced,
* Prune are now properly handled.
(This implementation was introduction in the evolve extension, version 6.0.0.)
This new algorithm has an extended number of tests, a basic one is provided
in this patch. The others will be introduced in their own changeset for clarity.
In addition, we stop trying to process heads unknown locally, we do not have
enough data to take an informed decision so we should stop pretending we do.
This reflect a test that is now update.
2017-04-15 03:55:18 +03:00
|
|
|
newhs.add(nh)
|
|
|
|
continue
|
|
|
|
|
|
|
|
# Get all revs/nodes on the branch exclusive to this head
|
|
|
|
# (already filtered heads are "ignored"))
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
branchrevs = unfi.revs("only(%n, (%ln+%ln))", nh, localcandidate, newhs)
|
checkheads: upgrade the obsolescence postprocessing logic (issue4354)
The previous logic had many shortcoming (eg: looking at the head only, not
handling prune, etc...), the new logic use a more robust approach:
For each head, we check if after the push all changesets exclusive to this heads
will be obsolete. If they are, the branch considered be "replaced".
To check if a changeset will be obsolete, we simply checks:
* the changeset phase
* the existence of a marker relevant to the "pushed set" that affects the
changesets..
This fixes two major issues of the previous algorithm:
* branch partially rewritten (eg: head but not root) are no longer detected as
replaced,
* Prune are now properly handled.
(This implementation was introduction in the evolve extension, version 6.0.0.)
This new algorithm has an extended number of tests, a basic one is provided
in this patch. The others will be introduced in their own changeset for clarity.
In addition, we stop trying to process heads unknown locally, we do not have
enough data to take an informed decision so we should stop pretending we do.
This reflect a test that is now update.
2017-04-15 03:55:18 +03:00
|
|
|
branchnodes = [tonode(r) for r in branchrevs]
|
|
|
|
|
|
|
|
# The branch won't be hidden on the remote if
|
|
|
|
# * any part of it is public,
|
|
|
|
# * any part of it is considered part of the result by previous logic,
|
|
|
|
# * if we have no markers to push to obsolete it.
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if (
|
|
|
|
any(ispublic(r) for r in branchrevs)
|
|
|
|
or any(torev(n) in futurecommon for n in branchnodes)
|
|
|
|
or any(not hasoutmarker(n) for n in branchnodes)
|
|
|
|
):
|
2017-03-22 01:30:13 +03:00
|
|
|
newhs.add(nh)
|
|
|
|
else:
|
checkheads: upgrade the obsolescence postprocessing logic (issue4354)
The previous logic had many shortcoming (eg: looking at the head only, not
handling prune, etc...), the new logic use a more robust approach:
For each head, we check if after the push all changesets exclusive to this heads
will be obsolete. If they are, the branch considered be "replaced".
To check if a changeset will be obsolete, we simply checks:
* the changeset phase
* the existence of a marker relevant to the "pushed set" that affects the
changesets..
This fixes two major issues of the previous algorithm:
* branch partially rewritten (eg: head but not root) are no longer detected as
replaced,
* Prune are now properly handled.
(This implementation was introduction in the evolve extension, version 6.0.0.)
This new algorithm has an extended number of tests, a basic one is provided
in this patch. The others will be introduced in their own changeset for clarity.
In addition, we stop trying to process heads unknown locally, we do not have
enough data to take an informed decision so we should stop pretending we do.
This reflect a test that is now update.
2017-04-15 03:55:18 +03:00
|
|
|
# note: there is a corner case if there is a merge in the branch.
|
|
|
|
# we might end up with -more- heads. However, these heads are not
|
|
|
|
# "added" by the push, but more by the "removal" on the remote so I
|
|
|
|
# think is a okay to ignore them,
|
|
|
|
discarded.add(nh)
|
|
|
|
newhs |= unknownheads
|
2017-03-22 01:30:13 +03:00
|
|
|
return newhs, discarded
|
checkheads: upgrade the obsolescence postprocessing logic (issue4354)
The previous logic had many shortcoming (eg: looking at the head only, not
handling prune, etc...), the new logic use a more robust approach:
For each head, we check if after the push all changesets exclusive to this heads
will be obsolete. If they are, the branch considered be "replaced".
To check if a changeset will be obsolete, we simply checks:
* the changeset phase
* the existence of a marker relevant to the "pushed set" that affects the
changesets..
This fixes two major issues of the previous algorithm:
* branch partially rewritten (eg: head but not root) are no longer detected as
replaced,
* Prune are now properly handled.
(This implementation was introduction in the evolve extension, version 6.0.0.)
This new algorithm has an extended number of tests, a basic one is provided
in this patch. The others will be introduced in their own changeset for clarity.
In addition, we stop trying to process heads unknown locally, we do not have
enough data to take an informed decision so we should stop pretending we do.
This reflect a test that is now update.
2017-04-15 03:55:18 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2017-06-05 17:17:47 +03:00
|
|
|
def pushingmarkerfor(obsstore, ispushed, node):
|
checkheads: upgrade the obsolescence postprocessing logic (issue4354)
The previous logic had many shortcoming (eg: looking at the head only, not
handling prune, etc...), the new logic use a more robust approach:
For each head, we check if after the push all changesets exclusive to this heads
will be obsolete. If they are, the branch considered be "replaced".
To check if a changeset will be obsolete, we simply checks:
* the changeset phase
* the existence of a marker relevant to the "pushed set" that affects the
changesets..
This fixes two major issues of the previous algorithm:
* branch partially rewritten (eg: head but not root) are no longer detected as
replaced,
* Prune are now properly handled.
(This implementation was introduction in the evolve extension, version 6.0.0.)
This new algorithm has an extended number of tests, a basic one is provided
in this patch. The others will be introduced in their own changeset for clarity.
In addition, we stop trying to process heads unknown locally, we do not have
enough data to take an informed decision so we should stop pretending we do.
This reflect a test that is now update.
2017-04-15 03:55:18 +03:00
|
|
|
"""true if some markers are to be pushed for node
|
|
|
|
|
|
|
|
We cannot just look in to the pushed obsmarkers from the pushop because
|
|
|
|
discovery might have filtered relevant markers. In addition listing all
|
|
|
|
markers relevant to all changesets in the pushed set would be too expensive
|
|
|
|
(O(len(repo)))
|
|
|
|
|
|
|
|
(note: There are cache opportunity in this function. but it would requires
|
|
|
|
a two dimensional stack.)
|
|
|
|
"""
|
|
|
|
successorsmarkers = obsstore.successors
|
|
|
|
stack = [node]
|
|
|
|
seen = set(stack)
|
|
|
|
while stack:
|
|
|
|
current = stack.pop()
|
2017-06-05 17:17:47 +03:00
|
|
|
if ispushed(current):
|
checkheads: upgrade the obsolescence postprocessing logic (issue4354)
The previous logic had many shortcoming (eg: looking at the head only, not
handling prune, etc...), the new logic use a more robust approach:
For each head, we check if after the push all changesets exclusive to this heads
will be obsolete. If they are, the branch considered be "replaced".
To check if a changeset will be obsolete, we simply checks:
* the changeset phase
* the existence of a marker relevant to the "pushed set" that affects the
changesets..
This fixes two major issues of the previous algorithm:
* branch partially rewritten (eg: head but not root) are no longer detected as
replaced,
* Prune are now properly handled.
(This implementation was introduction in the evolve extension, version 6.0.0.)
This new algorithm has an extended number of tests, a basic one is provided
in this patch. The others will be introduced in their own changeset for clarity.
In addition, we stop trying to process heads unknown locally, we do not have
enough data to take an informed decision so we should stop pretending we do.
This reflect a test that is now update.
2017-04-15 03:55:18 +03:00
|
|
|
return True
|
|
|
|
markers = successorsmarkers.get(current, ())
|
|
|
|
# markers fields = ('prec', 'succs', 'flag', 'meta', 'date', 'parents')
|
|
|
|
for m in markers:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
nexts = m[1] # successors
|
|
|
|
if not nexts: # this is a prune marker
|
|
|
|
nexts = m[5] or () # parents
|
checkheads: upgrade the obsolescence postprocessing logic (issue4354)
The previous logic had many shortcoming (eg: looking at the head only, not
handling prune, etc...), the new logic use a more robust approach:
For each head, we check if after the push all changesets exclusive to this heads
will be obsolete. If they are, the branch considered be "replaced".
To check if a changeset will be obsolete, we simply checks:
* the changeset phase
* the existence of a marker relevant to the "pushed set" that affects the
changesets..
This fixes two major issues of the previous algorithm:
* branch partially rewritten (eg: head but not root) are no longer detected as
replaced,
* Prune are now properly handled.
(This implementation was introduction in the evolve extension, version 6.0.0.)
This new algorithm has an extended number of tests, a basic one is provided
in this patch. The others will be introduced in their own changeset for clarity.
In addition, we stop trying to process heads unknown locally, we do not have
enough data to take an informed decision so we should stop pretending we do.
This reflect a test that is now update.
2017-04-15 03:55:18 +03:00
|
|
|
for n in nexts:
|
|
|
|
if n not in seen:
|
|
|
|
seen.add(n)
|
|
|
|
stack.append(n)
|
|
|
|
return False
|