2017-05-23 16:54:26 +03:00
|
|
|
# Copyright 2017-present Facebook. All Rights Reserved.
|
|
|
|
#
|
|
|
|
# faster copytrace implementation
|
|
|
|
#
|
|
|
|
# This software may be used and distributed according to the terms of the
|
|
|
|
# GNU General Public License version 2 or any later version.
|
|
|
|
|
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
|
|
|
"""extension that does copytracing fast
|
2017-06-01 14:39:27 +03:00
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
[copytrace]
|
|
|
|
# whether to enable fast copytracing or not
|
|
|
|
fastcopytrace = False
|
|
|
|
|
|
|
|
# limits the number of commits in the source "branch" i. e. "branch".
|
|
|
|
# that is rebased or merged. These are the commits from base up to csrc
|
|
|
|
# (see _mergecopies docblock below).
|
|
|
|
# copytracing can be too slow if there are too
|
|
|
|
# many commits in this "branch".
|
|
|
|
sourcecommitlimit = 100
|
|
|
|
|
|
|
|
# limits the number of heuristically found move candidates to check
|
|
|
|
maxmovescandidatestocheck = 5
|
2017-07-18 10:52:20 +03:00
|
|
|
|
2017-08-29 18:57:54 +03:00
|
|
|
# whether to enable fast copytracing during amends (requires fastcopytrace
|
|
|
|
# to be enabled.)
|
2017-07-18 10:52:20 +03:00
|
|
|
enableamendcopytrace = True
|
|
|
|
|
|
|
|
# how many previous commits to search through when looking for amend
|
|
|
|
# copytrace data.
|
|
|
|
amendcopytracecommitlimit = 100
|
|
|
|
|
2017-08-29 18:57:54 +03:00
|
|
|
# whether to enable full copytracing on small draft branches.
|
|
|
|
# Disabled by default
|
|
|
|
draftusefullcopytrace = False
|
|
|
|
|
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-01 14:39:27 +03:00
|
|
|
|
2017-11-03 03:00:12 +03:00
|
|
|
import anydbm
|
|
|
|
import collections
|
|
|
|
import json
|
|
|
|
import os
|
|
|
|
import time
|
|
|
|
|
2017-06-01 14:39:27 +03:00
|
|
|
from mercurial import (
|
2017-07-18 10:52:20 +03:00
|
|
|
cmdutil,
|
2017-06-01 14:39:27 +03:00
|
|
|
commands,
|
|
|
|
copies as copiesmod,
|
|
|
|
dispatch,
|
|
|
|
extensions,
|
|
|
|
filemerge,
|
2017-06-12 12:49:20 +03:00
|
|
|
node,
|
2017-07-18 10:52:20 +03:00
|
|
|
phases,
|
2017-11-03 03:00:12 +03:00
|
|
|
registrar,
|
2017-09-08 20:00:09 +03:00
|
|
|
scmutil,
|
2017-06-01 14:39:27 +03:00
|
|
|
util,
|
|
|
|
)
|
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
|
|
|
from mercurial.i18n import _
|
|
|
|
|
2017-05-23 16:54:26 +03:00
|
|
|
|
2017-11-03 03:00:12 +03:00
|
|
|
configtable = {}
|
|
|
|
configitem = registrar.configitem(configtable)
|
|
|
|
|
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
|
|
|
configitem("copytrace", "maxmovescandidatestocheck", default=5)
|
|
|
|
configitem("copytrace", "sourcecommitlimit", default=100)
|
|
|
|
configitem("copytrace", "fastcopytrace", default=False)
|
|
|
|
configitem("copytrace", "enableamendcopytrace", default=True)
|
|
|
|
configitem("copytrace", "amendcopytracecommitlimit", default=100)
|
2017-11-03 03:00:12 +03:00
|
|
|
|
2017-11-03 03:00:12 +03:00
|
|
|
defaultdict = collections.defaultdict
|
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
|
|
|
_copytracinghint = (
|
|
|
|
"hint: if this message is due to a moved file, you can "
|
|
|
|
+ "ask mercurial to attempt to automatically resolve this "
|
|
|
|
+ "change by re-running with the --tracecopies flag, but "
|
|
|
|
+ "this will significantly slow down the operation, so you "
|
|
|
|
+ "will need to be patient.\n"
|
|
|
|
+ "Source control team is working on fixing this problem.\n"
|
|
|
|
)
|
|
|
|
|
2017-05-23 16:54:26 +03:00
|
|
|
|
|
|
|
def uisetup(ui):
|
|
|
|
extensions.wrapfunction(dispatch, "runcommand", _runcommand)
|
|
|
|
|
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-23 16:54:26 +03:00
|
|
|
def extsetup(ui):
|
|
|
|
commands.globalopts.append(
|
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
|
|
|
("", "tracecopies", None, _("enable copytracing. Warning: can be very slow!"))
|
|
|
|
)
|
2017-08-29 18:57:54 +03:00
|
|
|
commands.globalopts.append(
|
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
|
|
|
("", "drafttrace", None, _("enable copytracing for draft branches."))
|
|
|
|
)
|
2017-05-23 16:54:26 +03:00
|
|
|
|
2017-09-09 04:46:24 +03:00
|
|
|
# With experimental.copytrace=off there can be cryptic merge errors.
|
2017-05-23 16:54:26 +03:00
|
|
|
# Let"s change error message to suggest re-running the command with
|
|
|
|
# enabled copytracing
|
|
|
|
filemerge._localchangedotherdeletedmsg = _(
|
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
|
|
|
"local%(l)s changed %(fd)s which other%(o)s deleted\n"
|
|
|
|
+ _copytracinghint
|
|
|
|
+ "use (c)hanged version, (d)elete, or leave (u)nresolved?"
|
|
|
|
"$$ &Changed $$ &Delete $$ &Unresolved"
|
|
|
|
)
|
2017-05-23 16:54:26 +03:00
|
|
|
|
|
|
|
filemerge._otherchangedlocaldeletedmsg = _(
|
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
|
|
|
"other%(o)s changed %(fd)s which local%(l)s deleted\n"
|
|
|
|
+ _copytracinghint
|
|
|
|
+ "use (c)hanged version, leave (d)eleted, or leave (u)nresolved?"
|
|
|
|
"$$ &Changed $$ &Deleted $$ &Unresolved"
|
|
|
|
)
|
|
|
|
|
|
|
|
extensions.wrapfunction(filemerge, "_filemerge", _filemerge)
|
|
|
|
extensions.wrapfunction(copiesmod, "mergecopies", _mergecopies)
|
|
|
|
extensions.wrapfunction(cmdutil, "amend", _amend)
|
|
|
|
|
|
|
|
|
|
|
|
def _filemerge(
|
|
|
|
origfunc,
|
|
|
|
premerge,
|
|
|
|
repo,
|
|
|
|
wctx,
|
|
|
|
mynode,
|
|
|
|
orig,
|
|
|
|
fcd,
|
|
|
|
fco,
|
|
|
|
fca,
|
|
|
|
labels=None,
|
|
|
|
*args,
|
|
|
|
**kwargs
|
|
|
|
):
|
2017-06-05 12:17:54 +03:00
|
|
|
if premerge:
|
2017-06-13 11:57:07 +03:00
|
|
|
# copytracing worked if files to merge have different file names
|
|
|
|
# and filelog contents are different (fco.cmp(fcd) returns True if
|
|
|
|
# they are different). If filelog contents are the same then the file
|
|
|
|
# was moved in the rebase/graft/merge source, but wasn't changed in the
|
|
|
|
# rebase/graft/merge destination. This case mercurial would've handled
|
|
|
|
# even with disabled copytracing, so we don't want to log it.
|
|
|
|
if orig != fco.path() and fco.cmp(fcd):
|
2017-06-05 12:17:54 +03:00
|
|
|
# copytracing was in action, let's record 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 repo.ui.config("experimental", "copytrace") == "on":
|
|
|
|
msg = "success (fastcopytracing)"
|
2017-06-05 12:17:54 +03:00
|
|
|
else:
|
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 = "success"
|
2017-06-12 12:49:20 +03:00
|
|
|
|
|
|
|
try:
|
|
|
|
destctx = _getctxfromfctx(fcd)
|
|
|
|
srcctx = _getctxfromfctx(fco)
|
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
|
|
|
hexes = "%s, %s" % (_gethex(destctx), _gethex(srcctx))
|
|
|
|
paths = "%s, %s" % (orig, fco.path())
|
2017-06-12 12:49:20 +03:00
|
|
|
msg = "%s (%s; %s)" % (msg, hexes, paths)
|
|
|
|
except Exception as e:
|
|
|
|
# we don't expect any exceptions to happen, but to be 100%
|
|
|
|
# sure we don't break hg let's catch everything and log 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
|
|
|
msg = "failed to log: %s" % (e,)
|
|
|
|
repo.ui.log("copytrace", msg=msg, reponame=_getreponame(repo, repo.ui))
|
|
|
|
|
|
|
|
return origfunc(
|
|
|
|
premerge, repo, wctx, mynode, orig, fcd, fco, fca, labels, *args, **kwargs
|
|
|
|
)
|
2017-06-12 12:49:20 +03:00
|
|
|
|
2017-06-05 12:17:54 +03:00
|
|
|
|
2017-05-23 16:54:26 +03:00
|
|
|
def _runcommand(orig, lui, repo, cmd, fullargs, ui, *args, **kwargs):
|
|
|
|
if "--tracecopies" in fullargs:
|
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
|
|
|
ui.setconfig("experimental", "copytrace", "on", "--tracecopies")
|
2017-05-23 16:54:26 +03:00
|
|
|
return orig(lui, repo, cmd, fullargs, ui, *args, **kwargs)
|
2017-05-23 16:54:52 +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-09-08 20:07:41 +03:00
|
|
|
def _amend(orig, ui, repo, old, extra, pats, opts):
|
2017-07-18 10:52:20 +03:00
|
|
|
"""Wraps amend to collect copytrace data on amend
|
|
|
|
|
|
|
|
If a file is created in one commit, modified in a subsequent commit, and
|
|
|
|
then renamed or copied by amending the original commit, restacking the
|
|
|
|
commits that modify the file will fail:
|
|
|
|
|
|
|
|
file modified here B B' restack of B to B' will fail
|
|
|
|
| :
|
|
|
|
file created here A --> A' file renamed in amended commit
|
|
|
|
| /
|
|
|
|
o --
|
|
|
|
|
|
|
|
This function collects information about copies and renames from amend
|
|
|
|
commits, and saves it for use during rebases onto the amend commit. This
|
|
|
|
lets rebases onto files that been renamed or copied in an amend commit
|
|
|
|
work without conflicts.
|
|
|
|
|
2017-09-08 20:00:09 +03:00
|
|
|
This function collects the copytrace information from the working copy and
|
|
|
|
stores it against the amended commit in a separate dbm file. Later,
|
2017-07-18 10:52:20 +03:00
|
|
|
in _domergecopies, this information will be merged with the rebase
|
|
|
|
copytrace data to incorporate renames and copies made during the amend.
|
|
|
|
"""
|
|
|
|
|
|
|
|
# Check if amend copytracing has been disabled.
|
2017-11-03 03:00:12 +03:00
|
|
|
if not ui.configbool("copytrace", "enableamendcopytrace"):
|
2017-09-08 20:07:41 +03:00
|
|
|
return orig(ui, repo, old, extra, pats, opts)
|
2017-09-08 20:00:09 +03:00
|
|
|
|
|
|
|
# Need to get the amend-copies before calling the command because files from
|
|
|
|
# the working copy will be used during the amend.
|
|
|
|
wctx = repo[None]
|
2017-07-18 10:52:20 +03:00
|
|
|
|
2017-09-08 20:00:09 +03:00
|
|
|
# Find the amend-copies.
|
|
|
|
matcher = scmutil.match(wctx, pats, opts)
|
|
|
|
amend_copies = copiesmod.pathcopies(old, wctx, matcher)
|
|
|
|
|
|
|
|
# Finally, invoke the command.
|
2017-09-08 20:07:41 +03:00
|
|
|
node = orig(ui, repo, old, extra, pats, opts)
|
2017-07-18 10:52:20 +03:00
|
|
|
amended_ctx = repo[node]
|
2017-09-08 20:00:09 +03:00
|
|
|
|
|
|
|
# Store the amend-copies against the amended context.
|
2017-07-18 10:52:20 +03:00
|
|
|
if amend_copies:
|
2018-09-28 17:08:56 +03:00
|
|
|
path = repo.localvfs.join("amendcopytrace")
|
2017-07-18 10:52:20 +03:00
|
|
|
try:
|
|
|
|
# Open the database, creating it if it doesn't already exist.
|
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
|
|
|
db = anydbm.open(path, "c")
|
2017-07-18 10:52:20 +03:00
|
|
|
except anydbm.error as e:
|
|
|
|
# Database locked, can't record these amend-copies.
|
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
|
|
|
ui.log("copytrace", "Failed to open amendcopytrace db: %s" % e)
|
2017-07-18 10:52:20 +03:00
|
|
|
return node
|
|
|
|
|
|
|
|
# Merge in any existing amend copies from any previous amends.
|
|
|
|
try:
|
2018-02-08 02:18:33 +03:00
|
|
|
orig_data = db[old.node()]
|
|
|
|
except KeyError:
|
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
|
|
|
orig_data = "{}"
|
2017-07-18 10:52:20 +03:00
|
|
|
except anydbm.error as e:
|
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
|
|
|
ui.log(
|
|
|
|
"copytrace",
|
|
|
|
"Failed to read key %s from amendcopytrace db: %s" % (old.hex(), e),
|
|
|
|
)
|
2017-07-18 10:52:20 +03:00
|
|
|
return node
|
2017-09-08 20:00:09 +03:00
|
|
|
|
2017-07-18 10:52:20 +03:00
|
|
|
orig_encoded = json.loads(orig_data)
|
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
|
|
|
orig_amend_copies = dict(
|
|
|
|
(k.decode("base64"), v.decode("base64"))
|
|
|
|
for (k, v) in orig_encoded.iteritems()
|
|
|
|
)
|
2017-07-18 10:52:20 +03:00
|
|
|
|
|
|
|
# Copytrace information is not valid if it refers to a file that
|
|
|
|
# doesn't exist in a commit. We need to update or remove entries
|
|
|
|
# that refer to files that might have only existed in the previous
|
|
|
|
# amend commit.
|
|
|
|
#
|
|
|
|
# Find chained copies and renames (a -> b -> c) and collapse them to
|
|
|
|
# (a -> c). Delete the entry for b if this was a rename.
|
|
|
|
for dst, src in amend_copies.iteritems():
|
|
|
|
if src in orig_amend_copies:
|
|
|
|
amend_copies[dst] = orig_amend_copies[src]
|
|
|
|
if src not in amended_ctx:
|
|
|
|
del orig_amend_copies[src]
|
|
|
|
|
|
|
|
# Copy any left over copies from the previous context.
|
|
|
|
for dst, src in orig_amend_copies.iteritems():
|
|
|
|
if dst not in amend_copies:
|
|
|
|
amend_copies[dst] = src
|
|
|
|
|
|
|
|
# Write out the entry for the new amend commit.
|
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
|
|
|
encoded = dict(
|
|
|
|
(k.encode("base64"), v.encode("base64"))
|
|
|
|
for (k, v) in amend_copies.iteritems()
|
|
|
|
)
|
2017-07-18 10:52:20 +03:00
|
|
|
db[node] = json.dumps(encoded)
|
|
|
|
try:
|
|
|
|
db.close()
|
|
|
|
except Exception as e:
|
|
|
|
# Database corruption. Not much we can do, so just log.
|
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
|
|
|
ui.log("copytrace", "Failed to close amendcopytrace db: %s" % e)
|
2017-07-18 10:52:20 +03:00
|
|
|
|
|
|
|
return node
|
|
|
|
|
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-07-18 10:52:20 +03:00
|
|
|
def _getamendcopies(repo, dest, ancestor):
|
2018-09-28 17:08:56 +03:00
|
|
|
path = repo.localvfs.join("amendcopytrace")
|
2017-07-18 10:52:20 +03:00
|
|
|
try:
|
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
|
|
|
db = anydbm.open(path, "r")
|
2017-07-18 10:52:20 +03:00
|
|
|
except anydbm.error:
|
|
|
|
return {}
|
|
|
|
try:
|
|
|
|
ctx = dest
|
|
|
|
count = 0
|
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
|
|
|
limit = repo.ui.configint("copytrace", "amendcopytracecommitlimit")
|
2017-07-18 10:52:20 +03:00
|
|
|
|
|
|
|
# Search for the ancestor commit that has amend copytrace data. This
|
|
|
|
# will be the most recent amend commit if we are rebasing onto an
|
|
|
|
# amend commit. If we reach the common ancestor or a public commit,
|
|
|
|
# then there is no amend copytrace data to be found.
|
|
|
|
while ctx.node() not in db:
|
|
|
|
ctx = ctx.p1()
|
|
|
|
count += 1
|
|
|
|
if ctx == ancestor or count > limit or ctx.phase() == phases.public:
|
|
|
|
return {}
|
|
|
|
|
|
|
|
# Load the amend copytrace data from this commit.
|
|
|
|
encoded = json.loads(db[ctx.node()])
|
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
|
|
|
return dict(
|
|
|
|
(k.decode("base64"), v.decode("base64")) for (k, v) in encoded.iteritems()
|
|
|
|
)
|
2017-07-18 10:52:20 +03:00
|
|
|
except Exception:
|
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
|
|
|
repo.ui.log("copytrace", "Failed to load amend copytrace for %s" % dest.hex())
|
2017-07-18 10:52:20 +03:00
|
|
|
return {}
|
|
|
|
finally:
|
|
|
|
try:
|
|
|
|
db.close()
|
|
|
|
except anydbm.error:
|
|
|
|
pass
|
|
|
|
|
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-01 14:39:27 +03:00
|
|
|
def _mergecopies(orig, repo, cdst, csrc, base):
|
|
|
|
start = time.time()
|
|
|
|
try:
|
|
|
|
return _domergecopies(orig, repo, cdst, csrc, base)
|
|
|
|
except Exception as e:
|
|
|
|
# make sure we don't break clients
|
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
|
|
|
repo.ui.log(
|
|
|
|
"copytrace",
|
|
|
|
"Copytrace failed: %s" % e,
|
|
|
|
reponame=_getreponame(repo, repo.ui),
|
|
|
|
)
|
2017-06-01 14:39:27 +03:00
|
|
|
return {}, {}, {}, {}, {}
|
|
|
|
finally:
|
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
|
|
|
repo.ui.log(
|
|
|
|
"copytracingduration",
|
|
|
|
"",
|
|
|
|
copytracingduration=time.time() - start,
|
|
|
|
fastcopytraceenabled=_fastcopytraceenabled(repo.ui),
|
|
|
|
)
|
|
|
|
|
2017-06-01 14:39:27 +03:00
|
|
|
|
|
|
|
def _domergecopies(orig, repo, cdst, csrc, base):
|
|
|
|
""" Fast copytracing using filename heuristics
|
|
|
|
|
2017-06-02 11:27:13 +03:00
|
|
|
Handle one case where we assume there are no merge commits in
|
2017-06-01 14:39:27 +03:00
|
|
|
"source branch". Source branch is commits from base up to csrc not
|
|
|
|
including base.
|
|
|
|
If these assumptions don't hold then we fallback to the
|
|
|
|
upstream mergecopies
|
|
|
|
|
|
|
|
p
|
|
|
|
|
|
|
|
|
p <- cdst - rebase or merge destination, can be draft
|
|
|
|
.
|
|
|
|
.
|
|
|
|
. d <- csrc - commit to be rebased or merged.
|
|
|
|
| |
|
|
|
|
p d <- base
|
|
|
|
| /
|
|
|
|
p <- common ancestor
|
|
|
|
|
|
|
|
To find copies we are looking for files with similar filenames.
|
|
|
|
See description of the heuristics below.
|
|
|
|
|
|
|
|
Upstream copytracing function returns five dicts:
|
|
|
|
"copy", "movewithdir", "diverge", "renamedelete" and "dirmove". See below
|
|
|
|
for a more detailed description (mostly copied from upstream).
|
|
|
|
This extension returns "copy" dict only, everything else is empty.
|
|
|
|
|
|
|
|
"copy" is a mapping from destination name -> source name,
|
|
|
|
where source is in csrc and destination is in cdst or vice-versa.
|
|
|
|
|
|
|
|
"movewithdir" is a mapping from source name -> destination name,
|
|
|
|
where the file at source present in one context but not the other
|
|
|
|
needs to be moved to destination by the merge process, because the
|
|
|
|
other context moved the directory it is in.
|
|
|
|
|
|
|
|
"diverge" is a mapping of source name -> list of destination names
|
|
|
|
for divergent renames. On the time of writing this extension it was used
|
|
|
|
only to print warning.
|
|
|
|
|
|
|
|
"renamedelete" is a mapping of source name -> list of destination
|
|
|
|
names for files deleted in c1 that were renamed in c2 or vice-versa.
|
|
|
|
On the time of writing this extension it was used only to print warning.
|
|
|
|
|
|
|
|
"dirmove" is a mapping of detected source dir -> destination dir renames.
|
|
|
|
This is needed for handling changes to new files previously grafted into
|
|
|
|
renamed directories.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
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 repo.ui.config("experimental", "copytrace") == "on":
|
2017-06-01 14:39:27 +03:00
|
|
|
# user explicitly enabled copytracing - use it
|
|
|
|
return orig(repo, cdst, csrc, base)
|
|
|
|
|
|
|
|
if not _fastcopytraceenabled(repo.ui):
|
|
|
|
return orig(repo, cdst, csrc, base)
|
|
|
|
|
2017-08-29 18:57:54 +03:00
|
|
|
# If base, source and destination are all draft branches, let's use full
|
|
|
|
# copytrace for increased capabilities since it will work fast enough
|
|
|
|
if _isfullcopytraceable(repo.ui, cdst, base):
|
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
|
|
|
configoverrides = {("experimental", "copytrace"): "on"}
|
|
|
|
with repo.ui.configoverride(configoverrides, "mergecopies"):
|
2017-08-29 18:57:54 +03:00
|
|
|
result = orig(repo, cdst, csrc, base)
|
2017-11-03 03:00:12 +03:00
|
|
|
if repo.ui.configbool("copytrace", "enableamendcopytrace"):
|
2017-08-29 18:57:54 +03:00
|
|
|
# Look for additional amend-copies
|
|
|
|
amend_copies = _getamendcopies(repo, cdst, base.p1())
|
|
|
|
# update result[0] dict w/ amend_copies
|
|
|
|
result[0].update(amend_copies)
|
|
|
|
|
|
|
|
return result
|
2017-06-01 14:39:27 +03:00
|
|
|
|
|
|
|
# avoid silly behavior for parent -> working dir
|
|
|
|
if csrc.node() is None and cdst.node() == repo.dirstate.p1():
|
|
|
|
return repo.dirstate.copies(), {}, {}, {}, {}
|
|
|
|
|
|
|
|
if cdst.rev() is None:
|
|
|
|
cdst = cdst.p1()
|
|
|
|
if csrc.rev() is None:
|
|
|
|
csrc = csrc.p1()
|
|
|
|
|
|
|
|
copies = {}
|
|
|
|
|
|
|
|
ctx = csrc
|
|
|
|
changedfiles = set()
|
|
|
|
sourcecommitnum = 0
|
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
|
|
|
sourcecommitlimit = repo.ui.configint("copytrace", "sourcecommitlimit")
|
2017-06-02 11:27:13 +03:00
|
|
|
mdst = cdst.manifest()
|
2017-06-01 14:39:27 +03:00
|
|
|
while ctx != base:
|
|
|
|
if len(ctx.parents()) == 2:
|
|
|
|
# To keep things simple let's not handle merges
|
|
|
|
return orig(repo, cdst, csrc, base)
|
|
|
|
changedfiles.update(ctx.files())
|
|
|
|
ctx = ctx.p1()
|
|
|
|
sourcecommitnum += 1
|
|
|
|
if sourcecommitnum > sourcecommitlimit:
|
|
|
|
return orig(repo, cdst, csrc, base)
|
|
|
|
|
2017-06-02 11:27:13 +03:00
|
|
|
cp = copiesmod._forwardcopies(base, csrc)
|
|
|
|
for dst, src in cp.iteritems():
|
|
|
|
if src in mdst:
|
|
|
|
copies[dst] = src
|
|
|
|
|
2017-06-07 13:40:54 +03:00
|
|
|
# file is missing if it isn't present in the destination, but is present in
|
|
|
|
# the base and present in the source.
|
|
|
|
# Presence in the base is important to exclude added files, presence in the
|
|
|
|
# source is important to exclude removed files.
|
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
|
|
|
missingfiles = filter(
|
|
|
|
lambda f: f not in mdst and f in base and f in csrc, changedfiles
|
|
|
|
)
|
2017-06-01 14:39:27 +03:00
|
|
|
if missingfiles:
|
|
|
|
# Use the following file name heuristic to find moves: moves are
|
|
|
|
# usually either directory moves or renames of the files in the
|
|
|
|
# same directory. That means that we can look for the files in dstc
|
|
|
|
# with either the same basename or the same dirname.
|
|
|
|
basenametofilename = defaultdict(list)
|
|
|
|
dirnametofilename = defaultdict(list)
|
2017-06-02 11:27:13 +03:00
|
|
|
for f in mdst.filesnotin(base.manifest()):
|
2017-06-01 14:39:27 +03:00
|
|
|
basename = os.path.basename(f)
|
|
|
|
dirname = os.path.dirname(f)
|
|
|
|
basenametofilename[basename].append(f)
|
|
|
|
dirnametofilename[dirname].append(f)
|
|
|
|
|
|
|
|
maxmovecandidatestocheck = repo.ui.configint(
|
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
|
|
|
"copytrace", "maxmovescandidatestocheck"
|
|
|
|
)
|
2017-06-01 14:39:27 +03:00
|
|
|
# in case of a rebase/graft, base may not be a common ancestor
|
|
|
|
anc = cdst.ancestor(csrc)
|
|
|
|
for f in missingfiles:
|
|
|
|
basename = os.path.basename(f)
|
|
|
|
dirname = os.path.dirname(f)
|
|
|
|
samebasename = basenametofilename[basename]
|
|
|
|
samedirname = dirnametofilename[dirname]
|
|
|
|
movecandidates = samebasename + samedirname
|
2017-06-07 13:40:54 +03:00
|
|
|
# f is guaranteed to be present in csrc, that's why
|
|
|
|
# csrc.filectx(f) won't fail
|
|
|
|
f2 = csrc.filectx(f)
|
|
|
|
for candidate in movecandidates[:maxmovecandidatestocheck]:
|
|
|
|
f1 = cdst.filectx(candidate)
|
|
|
|
if copiesmod._related(f1, f2, anc.rev()):
|
|
|
|
# if there are a few related copies then we'll merge
|
|
|
|
# changes into all of them. This matches the behaviour
|
|
|
|
# of upstream copytracing
|
|
|
|
copies[candidate] = f
|
|
|
|
if len(movecandidates) > maxmovecandidatestocheck:
|
|
|
|
msg = "too many moves candidates: %d" % len(movecandidates)
|
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
|
|
|
repo.ui.log("copytrace", msg=msg, reponame=_getreponame(repo, repo.ui))
|
2017-06-01 14:39:27 +03:00
|
|
|
|
2017-11-03 03:00:12 +03:00
|
|
|
if repo.ui.configbool("copytrace", "enableamendcopytrace"):
|
2017-07-18 10:52:20 +03:00
|
|
|
# Look for additional amend-copies.
|
|
|
|
amend_copies = _getamendcopies(repo, cdst, base.p1())
|
|
|
|
if amend_copies:
|
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
|
|
|
repo.ui.debug("Loaded amend copytrace for %s" % cdst)
|
2017-07-18 10:52:20 +03:00
|
|
|
for dst, src in amend_copies.iteritems():
|
|
|
|
if dst not in copies:
|
|
|
|
copies[dst] = src
|
|
|
|
|
2017-06-01 14:39:27 +03:00
|
|
|
return copies, {}, {}, {}, {}
|
|
|
|
|
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-01 14:39:27 +03:00
|
|
|
def _fastcopytraceenabled(ui):
|
2017-11-03 03:00:12 +03:00
|
|
|
return ui.configbool("copytrace", "fastcopytrace")
|
2017-06-01 14:39:27 +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-01 14:39:27 +03:00
|
|
|
def _getreponame(repo, ui):
|
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
|
|
|
reporoot = repo.origroot if util.safehasattr(repo, "origroot") else ""
|
|
|
|
reponame = ui.config("paths", "default") or reporoot
|
2017-06-01 14:39:27 +03:00
|
|
|
if reponame:
|
|
|
|
reponame = os.path.basename(reponame)
|
|
|
|
return reponame
|
2017-06-12 12:49:20 +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-12 12:49:20 +03:00
|
|
|
def _getctxfromfctx(fctx):
|
|
|
|
if fctx.isabsent():
|
|
|
|
return fctx._ctx
|
|
|
|
else:
|
|
|
|
return fctx._changectx
|
|
|
|
|
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-12 12:49:20 +03:00
|
|
|
def _gethex(ctx):
|
|
|
|
# for workingctx return p1 hex
|
2017-06-15 14:08:49 +03:00
|
|
|
return ctx.hex() if ctx.hex() != node.wdirhex else ctx.p1().hex()
|
2017-08-29 18:57:54 +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-08-29 18:57:54 +03:00
|
|
|
def _isfullcopytraceable(ui, cdst, base):
|
|
|
|
if not ui.configbool("copytrace", "draftusefullcopytrace", False):
|
|
|
|
return False
|
|
|
|
if cdst.phase() == phases.draft and base.phase() == phases.draft:
|
|
|
|
# draft branch: Use traditional copytracing if < 100 commits
|
|
|
|
ctx = cdst
|
|
|
|
commits = 0
|
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
|
|
|
sourcecommitlimit = ui.configint("copytrace", "sourcecommitlimit")
|
2017-08-29 18:57:54 +03:00
|
|
|
while ctx != base and commits != sourcecommitlimit:
|
|
|
|
ctx = ctx.p1()
|
|
|
|
commits += 1
|
|
|
|
return commits < sourcecommitlimit
|