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.
|
|
|
|
|
2008-02-04 04:29:05 +03:00
|
|
|
# filemerge.py - file-level merge handling for Mercurial
|
|
|
|
#
|
|
|
|
# Copyright 2006, 2007, 2008 Matt Mackall <mpm@selenic.com>
|
|
|
|
#
|
2009-04-26 03:08:54 +04:00
|
|
|
# This software may be used and distributed according to the terms of the
|
2010-01-20 07:20:08 +03:00
|
|
|
# GNU General Public License version 2 or any later version.
|
2008-02-04 04:29:05 +03:00
|
|
|
|
2015-08-09 05:15:09 +03:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
|
|
|
import os
|
|
|
|
import re
|
|
|
|
import tempfile
|
|
|
|
|
|
|
|
from . import (
|
2016-12-17 23:24:36 +03:00
|
|
|
encoding,
|
2015-08-09 05:15:09 +03:00
|
|
|
error,
|
2016-04-10 11:23:09 +03:00
|
|
|
formatter,
|
2015-08-09 05:15:09 +03:00
|
|
|
match,
|
2016-10-08 17:10:58 +03:00
|
|
|
pycompat,
|
2017-08-05 19:13:57 +03:00
|
|
|
registrar,
|
2016-01-02 14:02:57 +03:00
|
|
|
scmutil,
|
2015-08-09 05:15:09 +03:00
|
|
|
simplemerge,
|
2018-09-22 02:23:32 +03:00
|
|
|
templatefilters,
|
2015-08-09 05:15:09 +03:00
|
|
|
templatekw,
|
|
|
|
templater,
|
|
|
|
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 .i18n import _
|
|
|
|
from .node import nullid, short
|
|
|
|
|
2008-02-04 04:29:05 +03:00
|
|
|
|
2017-10-08 21:37:13 +03:00
|
|
|
def _toolstr(ui, tool, part, *args):
|
|
|
|
return ui.config("merge-tools", tool + "." + part, *args)
|
2008-02-04 04:29:05 +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
|
|
|
|
|
|
|
def _toolbool(ui, tool, part, *args):
|
2017-10-08 21:37:13 +03:00
|
|
|
return ui.configbool("merge-tools", tool + "." + part, *args)
|
2008-02-04 04:29:05 +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-10-08 21:37:13 +03:00
|
|
|
def _toollist(ui, tool, part):
|
|
|
|
return ui.configlist("merge-tools", tool + "." + part)
|
2010-05-10 20:04:56 +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-02-12 16:38:12 +04:00
|
|
|
internals = {}
|
2015-02-10 10:07:39 +03:00
|
|
|
# Merge tools to document.
|
|
|
|
internalsdoc = {}
|
2012-02-12 16:38:12 +04:00
|
|
|
|
2017-08-05 19:13:57 +03:00
|
|
|
internaltool = registrar.internalmerge()
|
|
|
|
|
2015-10-08 01:13:41 +03:00
|
|
|
# internal tool merge types
|
2017-08-05 19:13:57 +03:00
|
|
|
nomerge = internaltool.nomerge
|
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
|
|
|
mergeonly = internaltool.mergeonly # just the full merge, no premerge
|
|
|
|
fullmerge = internaltool.fullmerge # both premerge and merge
|
2015-10-08 01:13:41 +03:00
|
|
|
|
2017-05-19 13:47:43 +03:00
|
|
|
_localchangedotherdeletedmsg = _(
|
|
|
|
"local%(l)s changed %(fd)s which other%(o)s deleted\n"
|
|
|
|
"use (c)hanged version, (d)elete, or leave (u)nresolved?"
|
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
|
|
|
"$$ &Changed $$ &Delete $$ &Unresolved"
|
|
|
|
)
|
2017-05-19 13:47:43 +03:00
|
|
|
|
|
|
|
_otherchangedlocaldeletedmsg = _(
|
|
|
|
"other%(o)s changed %(fd)s which local%(l)s deleted\n"
|
2019-09-19 06:39:33 +03:00
|
|
|
"use (c)hanged version, leave (d)eleted, "
|
|
|
|
"leave (u)nresolved, or input (r)enamed path?"
|
|
|
|
"$$ &Changed $$ &Deleted $$ &Unresolved $$ &Renamed"
|
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-19 13:47:43 +03:00
|
|
|
|
2015-11-16 22:45:35 +03:00
|
|
|
class absentfilectx(object):
|
|
|
|
"""Represents a file that's ostensibly in a context but is actually not
|
|
|
|
present in it.
|
|
|
|
|
|
|
|
This is here because it's very specific to the filemerge code for now --
|
|
|
|
other code is likely going to break with the values this returns."""
|
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-16 22:45:35 +03:00
|
|
|
def __init__(self, ctx, f):
|
|
|
|
self._ctx = ctx
|
|
|
|
self._f = f
|
|
|
|
|
|
|
|
def path(self):
|
|
|
|
return self._f
|
|
|
|
|
|
|
|
def size(self):
|
|
|
|
return None
|
|
|
|
|
|
|
|
def data(self):
|
|
|
|
return None
|
|
|
|
|
|
|
|
def filenode(self):
|
|
|
|
return nullid
|
|
|
|
|
|
|
|
_customcmp = 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
|
|
|
|
2015-11-16 22:45:35 +03:00
|
|
|
def cmp(self, fctx):
|
|
|
|
"""compare with other file context
|
|
|
|
|
|
|
|
returns True if different from fctx.
|
|
|
|
"""
|
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 not (
|
|
|
|
fctx.isabsent() and fctx.ctx() == self.ctx() and fctx.path() == self.path()
|
|
|
|
)
|
2015-11-16 22:45:35 +03:00
|
|
|
|
|
|
|
def flags(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
|
|
|
return ""
|
2015-11-16 22:45:35 +03:00
|
|
|
|
|
|
|
def changectx(self):
|
|
|
|
return self._ctx
|
|
|
|
|
|
|
|
def isbinary(self):
|
|
|
|
return False
|
|
|
|
|
|
|
|
def isabsent(self):
|
|
|
|
return 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
|
|
|
|
2019-09-18 17:10:31 +03:00
|
|
|
def _findtool(ui, repo, tool):
|
2012-02-12 16:38:12 +04:00
|
|
|
if tool in internals:
|
2008-04-04 03:21:53 +04:00
|
|
|
return tool
|
2019-09-18 17:10:31 +03:00
|
|
|
return _findexternaltoolwithreporoot(ui, repo, tool)
|
2014-11-02 22:58:50 +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
|
|
|
|
2019-09-18 17:10:31 +03:00
|
|
|
def _findexternaltoolinternal(ui, tool):
|
2011-03-08 22:05:18 +03:00
|
|
|
for kn in ("regkey", "regkeyalt"):
|
|
|
|
k = _toolstr(ui, tool, kn)
|
|
|
|
if not k:
|
|
|
|
continue
|
2011-05-06 17:16:22 +04:00
|
|
|
p = util.lookupreg(k, _toolstr(ui, tool, "regname"))
|
2008-02-04 04:29:05 +03:00
|
|
|
if p:
|
2017-10-26 21:07:06 +03:00
|
|
|
p = util.findexe(p + _toolstr(ui, tool, "regappend", ""))
|
2008-02-04 04:29:05 +03:00
|
|
|
if p:
|
|
|
|
return p
|
2019-09-18 17:10:31 +03:00
|
|
|
return _toolstr(ui, tool, "executable", tool)
|
|
|
|
|
|
|
|
|
|
|
|
def findexternaltool(ui, tool):
|
|
|
|
return util.findexe(util.expandpath(_findexternaltoolinternal(ui, tool)))
|
|
|
|
|
|
|
|
|
|
|
|
def _findexternaltoolwithreporoot(ui, repo, tool):
|
|
|
|
"""Like findexternaltool, but try checking inside the repo for the tool
|
|
|
|
before looking in the path."""
|
|
|
|
exe = _findexternaltoolinternal(ui, tool)
|
|
|
|
if not os.path.isabs(exe):
|
|
|
|
path = repo.wvfs.join(exe)
|
|
|
|
if os.path.isfile(path) and util.isexec(path):
|
|
|
|
return path
|
2011-10-13 05:45:58 +04:00
|
|
|
return util.findexe(util.expandpath(exe))
|
2008-02-04 04:29:05 +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
|
|
|
|
2015-11-16 08:40:15 +03:00
|
|
|
def _picktool(repo, ui, path, binary, symlink, changedelete):
|
|
|
|
def supportscd(tool):
|
|
|
|
return tool in internals and internals[tool].mergetype == nomerge
|
|
|
|
|
|
|
|
def check(tool, pat, symlink, binary, changedelete):
|
2008-02-04 04:29:05 +03:00
|
|
|
tmsg = tool
|
|
|
|
if pat:
|
2017-05-12 21:28:36 +03:00
|
|
|
tmsg = _("%s (for pattern %s)") % (tool, pat)
|
2019-09-18 17:10:31 +03:00
|
|
|
if not _findtool(ui, repo, tool):
|
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 pat: # explicitly requested tool deserves a warning
|
2008-11-07 04:47:12 +03:00
|
|
|
ui.warn(_("couldn't find merge tool %s\n") % tmsg)
|
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: # configured but non-existing tools are more silent
|
2008-11-07 04:47:12 +03:00
|
|
|
ui.note(_("couldn't find merge tool %s\n") % tmsg)
|
2008-02-04 04:29:05 +03:00
|
|
|
elif symlink and not _toolbool(ui, tool, "symlink"):
|
|
|
|
ui.warn(_("tool %s can't handle symlinks\n") % tmsg)
|
|
|
|
elif binary and not _toolbool(ui, tool, "binary"):
|
|
|
|
ui.warn(_("tool %s can't handle binary\n") % tmsg)
|
2015-11-16 08:40:15 +03:00
|
|
|
elif changedelete and not supportscd(tool):
|
|
|
|
# the nomerge tools are the only tools that support change/delete
|
|
|
|
# conflicts
|
|
|
|
pass
|
2008-02-04 04:29:05 +03:00
|
|
|
elif not util.gui() and _toolbool(ui, tool, "gui"):
|
|
|
|
ui.warn(_("tool %s requires a GUI\n") % tmsg)
|
2008-02-04 04:29:05 +03:00
|
|
|
else:
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
2015-06-26 01:46:55 +03:00
|
|
|
# internal config: ui.forcemerge
|
2010-10-20 07:33:52 +04:00
|
|
|
# forcemerge comes from command line arguments, highest priority
|
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
|
|
|
force = ui.config("ui", "forcemerge")
|
2010-10-20 07:33:52 +04:00
|
|
|
if force:
|
2019-09-18 17:10:31 +03:00
|
|
|
toolpath = _findtool(ui, repo, force)
|
2015-11-16 08:40:15 +03:00
|
|
|
if changedelete and not supportscd(toolpath):
|
|
|
|
return ":prompt", None
|
2010-10-20 07:33:52 +04:00
|
|
|
else:
|
2015-11-16 08:40:15 +03:00
|
|
|
if toolpath:
|
|
|
|
return (force, util.shellquote(toolpath))
|
|
|
|
else:
|
|
|
|
# mimic HGMERGE if given tool not found
|
|
|
|
return (force, force)
|
2010-10-20 07:33:52 +04:00
|
|
|
|
|
|
|
# HGMERGE takes next precedence
|
2016-12-17 23:24:36 +03:00
|
|
|
hgmerge = encoding.environ.get("HGMERGE")
|
2008-02-05 04:38:34 +03:00
|
|
|
if hgmerge:
|
2015-11-16 08:40:15 +03:00
|
|
|
if changedelete and not supportscd(hgmerge):
|
|
|
|
return ":prompt", None
|
|
|
|
else:
|
|
|
|
return (hgmerge, hgmerge)
|
2008-02-04 04:29:05 +03:00
|
|
|
|
|
|
|
# then patterns
|
2008-02-04 18:56:01 +03:00
|
|
|
for pat, tool in ui.configitems("merge-patterns"):
|
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
|
|
|
mf = match.match(repo.root, "", [pat])
|
2015-11-16 08:40:15 +03:00
|
|
|
if mf(path) and check(tool, pat, symlink, False, changedelete):
|
2019-09-18 17:10:31 +03:00
|
|
|
toolpath = _findtool(ui, repo, tool)
|
2012-10-26 23:02:58 +04:00
|
|
|
return (tool, util.shellquote(toolpath))
|
2008-02-04 04:29:05 +03:00
|
|
|
|
|
|
|
# then merge tools
|
|
|
|
tools = {}
|
2015-10-14 19:57:33 +03:00
|
|
|
disabled = set()
|
2010-01-25 09:05:27 +03:00
|
|
|
for k, v in ui.configitems("merge-tools"):
|
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
|
|
|
t = k.split(".")[0]
|
2008-02-04 04:29:05 +03:00
|
|
|
if t not in tools:
|
2017-10-08 21:37:13 +03:00
|
|
|
tools[t] = int(_toolstr(ui, t, "priority"))
|
|
|
|
if _toolbool(ui, t, "disabled"):
|
2015-10-14 19:57:33 +03:00
|
|
|
disabled.add(t)
|
2008-02-07 05:44:25 +03:00
|
|
|
names = tools.keys()
|
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
|
|
|
tools = sorted([(-p, tool) for tool, p in tools.items() if tool not in disabled])
|
2008-02-07 05:44:25 +03:00
|
|
|
uimerge = ui.config("ui", "merge")
|
|
|
|
if uimerge:
|
2015-11-16 08:40:15 +03:00
|
|
|
# external tools defined in uimerge won't be able to handle
|
|
|
|
# change/delete conflicts
|
|
|
|
if uimerge not in names and not changedelete:
|
2008-02-07 05:44:25 +03:00
|
|
|
return (uimerge, uimerge)
|
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
|
|
|
tools.insert(0, (None, uimerge)) # highest priority
|
|
|
|
tools.append((None, "hgmerge")) # the old default, if found
|
2010-01-25 09:05:27 +03:00
|
|
|
for p, t in tools:
|
2015-11-16 08:40:15 +03:00
|
|
|
if check(t, None, symlink, binary, changedelete):
|
2019-09-18 17:10:31 +03:00
|
|
|
toolpath = _findtool(ui, repo, t)
|
2012-10-26 23:02:58 +04:00
|
|
|
return (t, util.shellquote(toolpath))
|
2012-03-14 00:12:26 +04:00
|
|
|
|
|
|
|
# internal merge or prompt as last resort
|
2015-11-16 08:40:15 +03:00
|
|
|
if symlink or binary or changedelete:
|
2017-05-12 21:28:36 +03:00
|
|
|
if not changedelete and len(tools):
|
|
|
|
# any tool is rejected by capability for symlink or binary
|
|
|
|
ui.warn(_("no tool found to merge %s\n") % path)
|
2014-09-28 19:15:28 +04:00
|
|
|
return ":prompt", None
|
|
|
|
return ":merge", None
|
2008-02-04 04:29:05 +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
|
|
|
|
2008-02-04 04:29:05 +03:00
|
|
|
def _eoltype(data):
|
|
|
|
"Guess the EOL type of a file"
|
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 "\0" in data: # binary
|
2008-02-04 04:29:05 +03:00
|
|
|
return 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
|
|
|
if "\r\n" in data: # Windows
|
|
|
|
return "\r\n"
|
|
|
|
if "\r" in data: # Old Mac
|
|
|
|
return "\r"
|
|
|
|
if "\n" in data: # UNIX
|
|
|
|
return "\n"
|
|
|
|
return None # unknown
|
|
|
|
|
2008-02-04 04:29:05 +03:00
|
|
|
|
2017-10-16 23:10:55 +03:00
|
|
|
def _matcheol(file, back):
|
2008-02-04 04:29:05 +03:00
|
|
|
"Convert EOL markers in a file to match origfile"
|
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
|
|
|
tostyle = _eoltype(back.data()) # No repo.wread filters?
|
2008-02-04 04:29:05 +03:00
|
|
|
if tostyle:
|
2011-05-02 12:11:18 +04:00
|
|
|
data = util.readfile(file)
|
2008-02-04 04:29:05 +03:00
|
|
|
style = _eoltype(data)
|
|
|
|
if style:
|
|
|
|
newdata = data.replace(style, tostyle)
|
|
|
|
if newdata != data:
|
2011-05-02 12:11:18 +04:00
|
|
|
util.writefile(file, newdata)
|
2008-02-04 04:29:05 +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
|
|
|
|
|
|
|
@internaltool("prompt", nomerge)
|
merge: use labels in prompts to the user
Now that we persist the labels, we can consistently use the labels in
prompts for the user without risk of confusion. This changes a huge amount
of command output:
This means that merge prompts like:
no tool found to merge a
keep (l)ocal, take (o)ther, or leave (u)nresolved? u
and
remote changed a which local deleted
use (c)hanged version, leave (d)eleted, or leave (u)nresolved? c
become:
no tool found to merge a
keep (l)ocal [working copy], take (o)ther [destination], or leave (u)nresolved? u
and
remote [source] changed a which local [dest] deleted
use (c)hanged version, leave (d)eleted, or leave (u)nresolved? c
where "working copy" and "destination" were supplied by the command that
requested the merge as labels for conflict markers, and thus should be
human-friendly.
2016-08-12 16:01:42 +03:00
|
|
|
def _iprompt(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
|
2016-03-17 03:36:01 +03:00
|
|
|
"""Asks the user which of the local `p1()` or the other `p2()` version to
|
|
|
|
keep as the merged version."""
|
2012-02-12 16:38:12 +04:00
|
|
|
ui = repo.ui
|
|
|
|
fd = fcd.path()
|
|
|
|
|
2017-12-01 11:07:23 +03:00
|
|
|
# Avoid prompting during an in-memory merge since it doesn't support merge
|
|
|
|
# conflicts.
|
|
|
|
if fcd.changectx().isinmemory():
|
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
|
|
|
raise error.InMemoryMergeConflictsError(
|
2018-07-02 21:24:57 +03:00
|
|
|
"in-memory merge does not support file conflicts",
|
|
|
|
type=error.InMemoryMergeConflictsError.TYPE_FILE_CONFLICTS,
|
|
|
|
paths=[fcd.path()],
|
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-12-01 11:07:23 +03:00
|
|
|
|
merge: use labels in prompts to the user
Now that we persist the labels, we can consistently use the labels in
prompts for the user without risk of confusion. This changes a huge amount
of command output:
This means that merge prompts like:
no tool found to merge a
keep (l)ocal, take (o)ther, or leave (u)nresolved? u
and
remote changed a which local deleted
use (c)hanged version, leave (d)eleted, or leave (u)nresolved? c
become:
no tool found to merge a
keep (l)ocal [working copy], take (o)ther [destination], or leave (u)nresolved? u
and
remote [source] changed a which local [dest] deleted
use (c)hanged version, leave (d)eleted, or leave (u)nresolved? c
where "working copy" and "destination" were supplied by the command that
requested the merge as labels for conflict markers, and thus should be
human-friendly.
2016-08-12 16:01:42 +03:00
|
|
|
prompts = partextras(labels)
|
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
|
|
|
prompts["fd"] = fd
|
2015-11-11 04:13:16 +03:00
|
|
|
try:
|
2015-11-14 10:52:26 +03:00
|
|
|
if fco.isabsent():
|
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
|
|
|
index = ui.promptchoice(_localchangedotherdeletedmsg % prompts, 2)
|
|
|
|
choice = ["local", "other", "unresolved"][index]
|
2015-11-14 10:52:26 +03:00
|
|
|
elif fcd.isabsent():
|
2019-09-19 06:39:33 +03:00
|
|
|
# Rebase example:
|
|
|
|
#
|
|
|
|
# D (mynode)
|
|
|
|
# |
|
|
|
|
# B C (fco) # B renames a file. C changes that file.
|
|
|
|
# |/ # run 'rebase -s C -d D' without copytracing
|
|
|
|
# A (fca) # fcd: absent (working copy)
|
|
|
|
#
|
|
|
|
# Prompt looks like:
|
|
|
|
#
|
|
|
|
# other [source] changed <file-path> which local [dest] deleted
|
|
|
|
# use (c)hanged version, leave (d)eleted, ...
|
|
|
|
#
|
|
|
|
# Here, 'other [source]' is a local draft commit, 'local [dest]'
|
|
|
|
# is the rebase destination, a public 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
|
|
|
index = ui.promptchoice(_otherchangedlocaldeletedmsg % prompts, 2)
|
2019-09-19 06:39:33 +03:00
|
|
|
choice = ["other", "local", "unresolved", "rename"][index]
|
2015-11-14 10:52:26 +03:00
|
|
|
else:
|
2015-11-30 22:17:18 +03:00
|
|
|
index = ui.promptchoice(
|
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
|
|
|
_(
|
|
|
|
"keep (l)ocal%(l)s, take (o)ther%(o)s, or leave (u)nresolved"
|
|
|
|
" for %(fd)s?"
|
|
|
|
"$$ &Local $$ &Other $$ &Unresolved"
|
|
|
|
)
|
|
|
|
% prompts,
|
|
|
|
2,
|
|
|
|
)
|
|
|
|
choice = ["local", "other", "unresolved"][index]
|
|
|
|
|
|
|
|
if choice == "other":
|
|
|
|
return _iother(repo, mynode, orig, fcd, fco, fca, toolconf, labels)
|
|
|
|
elif choice == "local":
|
|
|
|
return _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf, labels)
|
|
|
|
elif choice == "unresolved":
|
|
|
|
return _ifail(repo, mynode, orig, fcd, fco, fca, toolconf, labels)
|
2019-09-19 06:39:33 +03:00
|
|
|
elif choice == "rename":
|
|
|
|
destctx = fcd.changectx()
|
|
|
|
# fcd most likely a working copy that does not have a commit hash.
|
|
|
|
# therefore 'mynode' is used for 'destnode', not fcd.node()
|
|
|
|
destpath = ui.prompt(
|
|
|
|
_(
|
|
|
|
"path '%(fd)s' in commit %(srcnode)s was renamed to [what path] in commit %(destnode)s ?"
|
|
|
|
)
|
|
|
|
% {"fd": fd, "srcnode": short(fco.node()), "destnode": short(mynode)},
|
|
|
|
default="",
|
|
|
|
)
|
|
|
|
if not destpath or destpath not in destctx:
|
|
|
|
ui.warn(
|
|
|
|
_(
|
|
|
|
"path '%(fd)s' does not exist in commit %(destnode)s - leave unresolved\n"
|
|
|
|
)
|
|
|
|
% {"fd": destpath, "destnode": short(mynode)}
|
|
|
|
)
|
|
|
|
return _ifail(repo, mynode, orig, fcd, fco, fca, toolconf, labels)
|
|
|
|
else:
|
|
|
|
fcd = destctx[destpath]
|
|
|
|
raise error.RetryFileMerge(fcd=fcd)
|
2015-11-11 04:13:16 +03:00
|
|
|
except error.ResponseExpected:
|
|
|
|
ui.write("\n")
|
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 _ifail(repo, mynode, orig, fcd, fco, fca, toolconf, labels)
|
2012-02-12 16:38:12 +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
|
|
|
|
|
|
|
@internaltool("local", nomerge)
|
merge: use labels in prompts to the user
Now that we persist the labels, we can consistently use the labels in
prompts for the user without risk of confusion. This changes a huge amount
of command output:
This means that merge prompts like:
no tool found to merge a
keep (l)ocal, take (o)ther, or leave (u)nresolved? u
and
remote changed a which local deleted
use (c)hanged version, leave (d)eleted, or leave (u)nresolved? c
become:
no tool found to merge a
keep (l)ocal [working copy], take (o)ther [destination], or leave (u)nresolved? u
and
remote [source] changed a which local [dest] deleted
use (c)hanged version, leave (d)eleted, or leave (u)nresolved? c
where "working copy" and "destination" were supplied by the command that
requested the merge as labels for conflict markers, and thus should be
human-friendly.
2016-08-12 16:01:42 +03:00
|
|
|
def _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
|
2016-03-17 03:36:01 +03:00
|
|
|
"""Uses the local `p1()` version of files as the merged version."""
|
2015-11-19 02:40:28 +03:00
|
|
|
return 0, fcd.isabsent()
|
2012-02-12 16:38:12 +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
|
|
|
|
|
|
|
@internaltool("other", nomerge)
|
merge: use labels in prompts to the user
Now that we persist the labels, we can consistently use the labels in
prompts for the user without risk of confusion. This changes a huge amount
of command output:
This means that merge prompts like:
no tool found to merge a
keep (l)ocal, take (o)ther, or leave (u)nresolved? u
and
remote changed a which local deleted
use (c)hanged version, leave (d)eleted, or leave (u)nresolved? c
become:
no tool found to merge a
keep (l)ocal [working copy], take (o)ther [destination], or leave (u)nresolved? u
and
remote [source] changed a which local [dest] deleted
use (c)hanged version, leave (d)eleted, or leave (u)nresolved? c
where "working copy" and "destination" were supplied by the command that
requested the merge as labels for conflict markers, and thus should be
human-friendly.
2016-08-12 16:01:42 +03:00
|
|
|
def _iother(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
|
2016-03-17 03:36:01 +03:00
|
|
|
"""Uses the other `p2()` version of files as the merged version."""
|
2015-11-19 02:41:50 +03:00
|
|
|
if fco.isabsent():
|
|
|
|
# local changed, remote deleted -- 'deleted' picked
|
2017-06-27 08:52:15 +03:00
|
|
|
_underlyingfctxifabsent(fcd).remove()
|
2015-11-19 02:41:50 +03:00
|
|
|
deleted = True
|
|
|
|
else:
|
2017-06-27 08:52:15 +03:00
|
|
|
_underlyingfctxifabsent(fcd).write(fco.data(), fco.flags())
|
2015-11-19 02:41:50 +03:00
|
|
|
deleted = False
|
|
|
|
return 0, deleted
|
2012-02-12 16:38:12 +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
|
|
|
|
|
|
|
@internaltool("fail", nomerge)
|
merge: use labels in prompts to the user
Now that we persist the labels, we can consistently use the labels in
prompts for the user without risk of confusion. This changes a huge amount
of command output:
This means that merge prompts like:
no tool found to merge a
keep (l)ocal, take (o)ther, or leave (u)nresolved? u
and
remote changed a which local deleted
use (c)hanged version, leave (d)eleted, or leave (u)nresolved? c
become:
no tool found to merge a
keep (l)ocal [working copy], take (o)ther [destination], or leave (u)nresolved? u
and
remote [source] changed a which local [dest] deleted
use (c)hanged version, leave (d)eleted, or leave (u)nresolved? c
where "working copy" and "destination" were supplied by the command that
requested the merge as labels for conflict markers, and thus should be
human-friendly.
2016-08-12 16:01:42 +03:00
|
|
|
def _ifail(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
|
2012-02-17 01:58:51 +04:00
|
|
|
"""
|
2012-02-12 16:38:12 +04:00
|
|
|
Rather than attempting to merge files that were modified on both
|
|
|
|
branches, it marks them as unresolved. The resolve command must be
|
|
|
|
used to resolve these conflicts."""
|
2015-11-24 21:57:01 +03:00
|
|
|
# for change/delete conflicts write out the changed version, then fail
|
|
|
|
if fcd.isabsent():
|
2017-06-27 08:52:15 +03:00
|
|
|
_underlyingfctxifabsent(fcd).write(fco.data(), fco.flags())
|
2015-11-19 00:52:28 +03:00
|
|
|
return 1, False
|
2012-02-12 16:38:12 +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-06-27 08:52:15 +03:00
|
|
|
def _underlyingfctxifabsent(filectx):
|
|
|
|
"""Sometimes when resolving, our fcd is actually an absentfilectx, but
|
|
|
|
we want to write to it (to do the resolve). This helper returns the
|
|
|
|
underyling workingfilectx in that case.
|
|
|
|
"""
|
|
|
|
if filectx.isabsent():
|
|
|
|
return filectx.changectx()[filectx.path()]
|
|
|
|
else:
|
|
|
|
return filectx
|
|
|
|
|
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-14 10:56:00 +03:00
|
|
|
def _premerge(repo, fcd, fco, fca, toolconf, files, labels=None):
|
2012-02-12 16:38:12 +04:00
|
|
|
tool, toolpath, binary, symlink = toolconf
|
2015-11-14 10:56:00 +03:00
|
|
|
if symlink or fcd.isabsent() or fco.isabsent():
|
2013-01-08 07:15:46 +04:00
|
|
|
return 1
|
2017-08-31 21:28:59 +03:00
|
|
|
unused, unused, unused, back = files
|
2012-02-12 16:38:12 +04:00
|
|
|
|
|
|
|
ui = 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
|
|
|
validkeep = ["keep", "keep-merge3"]
|
2014-08-05 03:58:39 +04:00
|
|
|
|
2012-02-12 16:38:12 +04:00
|
|
|
# do we attempt to simplemerge first?
|
|
|
|
try:
|
2013-01-08 07:15:46 +04:00
|
|
|
premerge = _toolbool(ui, tool, "premerge", not binary)
|
2012-02-12 16:38:12 +04:00
|
|
|
except error.ConfigError:
|
2017-10-08 21:37:13 +03:00
|
|
|
premerge = _toolstr(ui, tool, "premerge", "").lower()
|
2014-08-05 03:58:39 +04:00
|
|
|
if premerge not in validkeep:
|
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
|
|
|
_valid = ", ".join(["'" + v + "'" for v in validkeep])
|
|
|
|
raise error.ConfigError(
|
|
|
|
_("%s.premerge not valid " "('%s' is neither boolean nor %s)")
|
|
|
|
% (tool, premerge, _valid)
|
|
|
|
)
|
2012-02-12 16:38:12 +04:00
|
|
|
|
|
|
|
if premerge:
|
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 premerge == "keep-merge3":
|
2014-08-05 03:32:41 +04:00
|
|
|
if not labels:
|
|
|
|
labels = _defaultconflictlabels
|
|
|
|
if len(labels) < 3:
|
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
|
|
|
labels.append("base")
|
2017-09-01 20:35:43 +03:00
|
|
|
r = simplemerge.simplemerge(ui, fcd, fca, fco, quiet=True, label=labels)
|
2012-02-12 16:38:12 +04:00
|
|
|
if not r:
|
|
|
|
ui.debug(" premerge successful\n")
|
|
|
|
return 0
|
2014-08-05 03:58:39 +04:00
|
|
|
if premerge not in validkeep:
|
2017-08-31 21:28:59 +03:00
|
|
|
# restore from backup and try again
|
2017-08-31 21:28:59 +03:00
|
|
|
_restorebackup(fcd, back)
|
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 1 # continue merging
|
|
|
|
|
2012-02-12 16:38:12 +04:00
|
|
|
|
2015-11-12 04:34:28 +03:00
|
|
|
def _mergecheck(repo, mynode, orig, fcd, fco, fca, toolconf):
|
2015-10-07 08:56:33 +03:00
|
|
|
tool, toolpath, binary, symlink = toolconf
|
|
|
|
if symlink:
|
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.warn(
|
|
|
|
_("warning: internal %s cannot merge symlinks " "for %s\n")
|
|
|
|
% (tool, fcd.path())
|
|
|
|
)
|
2015-10-07 08:56:33 +03:00
|
|
|
return False
|
2015-11-14 10:58:05 +03:00
|
|
|
if fcd.isabsent() or fco.isabsent():
|
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.warn(
|
|
|
|
_("warning: internal %s cannot merge change/delete " "conflict for %s\n")
|
|
|
|
% (tool, fcd.path())
|
|
|
|
)
|
2015-11-14 10:58:05 +03:00
|
|
|
return False
|
2015-10-07 08:56:33 +03:00
|
|
|
return 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
|
|
|
|
filemerge: print the potentially conflicting destination commits for each conflict
Summary:
One thing that makes dealing with merge conflicts difficult at Facebook is that it can be tough to know *why* you have merge conflicts.
Because rebase processes one commit at a time, it's clear which of *your* commits is the problem, but finding the "other" commit is surprisingly hard. Often we rebase onto `master`, and in a monorepo, `master` is often a random commit that has no relationship to your code at all.
This diff attempts to improve the situation a bit by listing all of the commits between the common ancestor and the destination commit that modified the file. The user can then identify which are likely culprits:
```
warning: 2 conflicts while merging b! (edit, then use 'hg resolve --mark')
3 commits might've introduced this conflict:
- [0942ca9aff3d] random commit 1
- [3ebd0a462491] foo bar biz
- [3e5843b4b236] blah blah blah
```
When the destination is public, this approach requires one loose file download (~0.5s?) per conflicted file (this pulls in the full filectx history DAG, so further downloads aren't needed), which is likely acceptable as it only runs on conflicts, and provides value to the user. But it's also configurable for users performing massive codemods.
I'll add metrics to gather the average number if matched commits and the time taken to generate.
This doesn't put this information into the conflict markers, so a lot of people (Nuclide users or the default `editmerge` users) won't see it. We need to think creatively about how to expose it to them.
The ideal solution would tell you which commits edited the actual conflicted section(s), not just those that touched the file.
This requires fast remotefilelog downloads (cc @[100000771202578:Arun] :)). Once we have those, we can construct a local `linelog` of the commits involved, and used this to identify precisely which commits edited the conflicted sections of the file.
Reviewed By: quark-zju
Differential Revision: D9816270
fbshipit-source-id: 04e08dea7a9429eaeab0d40310cd34355104bb74
2018-10-25 23:59:35 +03:00
|
|
|
def _findconflictingcommits(repo, fcd, fca, maxcommits=10):
|
|
|
|
"""Attempts to find all of the commits on the destination that might've
|
|
|
|
conflicted during the merge.
|
|
|
|
|
|
|
|
This is a first attempt that merely finds commits that touched the file
|
|
|
|
between the ancestor and destination commit.
|
|
|
|
|
|
|
|
In the future, a textual analysis using linelog, to filter that list
|
|
|
|
to changes that edited the conflicted area, would be better. This requires
|
|
|
|
fast remotefilelog fetches from the server so we can construct the linelog
|
|
|
|
relatively quickly -- today, SSH overhead makes this infeasible.
|
|
|
|
|
|
|
|
Returns changectx[], max_hit?
|
|
|
|
"""
|
|
|
|
# (In a remotefilelog repo this will trigger a loose file download -- max
|
|
|
|
# one per call to _find_conflicting_commits)
|
2018-12-07 06:36:41 +03:00
|
|
|
# fcd is often workingfilectx, but not always.
|
|
|
|
current = fcd.parents()[:1]
|
filemerge: print the potentially conflicting destination commits for each conflict
Summary:
One thing that makes dealing with merge conflicts difficult at Facebook is that it can be tough to know *why* you have merge conflicts.
Because rebase processes one commit at a time, it's clear which of *your* commits is the problem, but finding the "other" commit is surprisingly hard. Often we rebase onto `master`, and in a monorepo, `master` is often a random commit that has no relationship to your code at all.
This diff attempts to improve the situation a bit by listing all of the commits between the common ancestor and the destination commit that modified the file. The user can then identify which are likely culprits:
```
warning: 2 conflicts while merging b! (edit, then use 'hg resolve --mark')
3 commits might've introduced this conflict:
- [0942ca9aff3d] random commit 1
- [3ebd0a462491] foo bar biz
- [3e5843b4b236] blah blah blah
```
When the destination is public, this approach requires one loose file download (~0.5s?) per conflicted file (this pulls in the full filectx history DAG, so further downloads aren't needed), which is likely acceptable as it only runs on conflicts, and provides value to the user. But it's also configurable for users performing massive codemods.
I'll add metrics to gather the average number if matched commits and the time taken to generate.
This doesn't put this information into the conflict markers, so a lot of people (Nuclide users or the default `editmerge` users) won't see it. We need to think creatively about how to expose it to them.
The ideal solution would tell you which commits edited the actual conflicted section(s), not just those that touched the file.
This requires fast remotefilelog downloads (cc @[100000771202578:Arun] :)). Once we have those, we can construct a local `linelog` of the commits involved, and used this to identify precisely which commits edited the conflicted sections of the file.
Reviewed By: quark-zju
Differential Revision: D9816270
fbshipit-source-id: 04e08dea7a9429eaeab0d40310cd34355104bb74
2018-10-25 23:59:35 +03:00
|
|
|
candidates = []
|
2018-12-07 06:36:41 +03:00
|
|
|
while current:
|
|
|
|
ctx = current[0].changectx()
|
filemerge: print the potentially conflicting destination commits for each conflict
Summary:
One thing that makes dealing with merge conflicts difficult at Facebook is that it can be tough to know *why* you have merge conflicts.
Because rebase processes one commit at a time, it's clear which of *your* commits is the problem, but finding the "other" commit is surprisingly hard. Often we rebase onto `master`, and in a monorepo, `master` is often a random commit that has no relationship to your code at all.
This diff attempts to improve the situation a bit by listing all of the commits between the common ancestor and the destination commit that modified the file. The user can then identify which are likely culprits:
```
warning: 2 conflicts while merging b! (edit, then use 'hg resolve --mark')
3 commits might've introduced this conflict:
- [0942ca9aff3d] random commit 1
- [3ebd0a462491] foo bar biz
- [3e5843b4b236] blah blah blah
```
When the destination is public, this approach requires one loose file download (~0.5s?) per conflicted file (this pulls in the full filectx history DAG, so further downloads aren't needed), which is likely acceptable as it only runs on conflicts, and provides value to the user. But it's also configurable for users performing massive codemods.
I'll add metrics to gather the average number if matched commits and the time taken to generate.
This doesn't put this information into the conflict markers, so a lot of people (Nuclide users or the default `editmerge` users) won't see it. We need to think creatively about how to expose it to them.
The ideal solution would tell you which commits edited the actual conflicted section(s), not just those that touched the file.
This requires fast remotefilelog downloads (cc @[100000771202578:Arun] :)). Once we have those, we can construct a local `linelog` of the commits involved, and used this to identify precisely which commits edited the conflicted sections of the file.
Reviewed By: quark-zju
Differential Revision: D9816270
fbshipit-source-id: 04e08dea7a9429eaeab0d40310cd34355104bb74
2018-10-25 23:59:35 +03:00
|
|
|
|
|
|
|
# Stop once we go beyond the common ancestor.
|
|
|
|
if repo.changelog.isancestor(ctx.node(), fca.node()):
|
|
|
|
break
|
|
|
|
|
|
|
|
candidates.append(ctx)
|
|
|
|
if len(candidates) >= maxcommits:
|
|
|
|
break
|
|
|
|
|
|
|
|
# Ignoring p2 path for simplicity. Ideally, we also follow p2, and
|
|
|
|
# can draw the graph DAG to the user.
|
2018-12-07 06:36:41 +03:00
|
|
|
current = current[0].parents()[:1]
|
filemerge: print the potentially conflicting destination commits for each conflict
Summary:
One thing that makes dealing with merge conflicts difficult at Facebook is that it can be tough to know *why* you have merge conflicts.
Because rebase processes one commit at a time, it's clear which of *your* commits is the problem, but finding the "other" commit is surprisingly hard. Often we rebase onto `master`, and in a monorepo, `master` is often a random commit that has no relationship to your code at all.
This diff attempts to improve the situation a bit by listing all of the commits between the common ancestor and the destination commit that modified the file. The user can then identify which are likely culprits:
```
warning: 2 conflicts while merging b! (edit, then use 'hg resolve --mark')
3 commits might've introduced this conflict:
- [0942ca9aff3d] random commit 1
- [3ebd0a462491] foo bar biz
- [3e5843b4b236] blah blah blah
```
When the destination is public, this approach requires one loose file download (~0.5s?) per conflicted file (this pulls in the full filectx history DAG, so further downloads aren't needed), which is likely acceptable as it only runs on conflicts, and provides value to the user. But it's also configurable for users performing massive codemods.
I'll add metrics to gather the average number if matched commits and the time taken to generate.
This doesn't put this information into the conflict markers, so a lot of people (Nuclide users or the default `editmerge` users) won't see it. We need to think creatively about how to expose it to them.
The ideal solution would tell you which commits edited the actual conflicted section(s), not just those that touched the file.
This requires fast remotefilelog downloads (cc @[100000771202578:Arun] :)). Once we have those, we can construct a local `linelog` of the commits involved, and used this to identify precisely which commits edited the conflicted sections of the file.
Reviewed By: quark-zju
Differential Revision: D9816270
fbshipit-source-id: 04e08dea7a9429eaeab0d40310cd34355104bb74
2018-10-25 23:59:35 +03:00
|
|
|
|
|
|
|
return candidates, len(candidates) >= maxcommits
|
|
|
|
|
|
|
|
|
|
|
|
def _describefailure(r, repo, mynode, orig, fcd, fco, fca):
|
2018-09-22 02:23:32 +03:00
|
|
|
"""Describes a merge conflict, which is rendered as a warning to the user"""
|
filemerge: print the potentially conflicting destination commits for each conflict
Summary:
One thing that makes dealing with merge conflicts difficult at Facebook is that it can be tough to know *why* you have merge conflicts.
Because rebase processes one commit at a time, it's clear which of *your* commits is the problem, but finding the "other" commit is surprisingly hard. Often we rebase onto `master`, and in a monorepo, `master` is often a random commit that has no relationship to your code at all.
This diff attempts to improve the situation a bit by listing all of the commits between the common ancestor and the destination commit that modified the file. The user can then identify which are likely culprits:
```
warning: 2 conflicts while merging b! (edit, then use 'hg resolve --mark')
3 commits might've introduced this conflict:
- [0942ca9aff3d] random commit 1
- [3ebd0a462491] foo bar biz
- [3e5843b4b236] blah blah blah
```
When the destination is public, this approach requires one loose file download (~0.5s?) per conflicted file (this pulls in the full filectx history DAG, so further downloads aren't needed), which is likely acceptable as it only runs on conflicts, and provides value to the user. But it's also configurable for users performing massive codemods.
I'll add metrics to gather the average number if matched commits and the time taken to generate.
This doesn't put this information into the conflict markers, so a lot of people (Nuclide users or the default `editmerge` users) won't see it. We need to think creatively about how to expose it to them.
The ideal solution would tell you which commits edited the actual conflicted section(s), not just those that touched the file.
This requires fast remotefilelog downloads (cc @[100000771202578:Arun] :)). Once we have those, we can construct a local `linelog` of the commits involved, and used this to identify precisely which commits edited the conflicted sections of the file.
Reviewed By: quark-zju
Differential Revision: D9816270
fbshipit-source-id: 04e08dea7a9429eaeab0d40310cd34355104bb74
2018-10-25 23:59:35 +03:00
|
|
|
|
|
|
|
relpath = repo.pathto(fcd.path())
|
|
|
|
msg = _(
|
2018-10-22 22:45:46 +03:00
|
|
|
"warning: %d conflicts while merging %s! (edit, then use 'hg resolve --mark')\n"
|
filemerge: print the potentially conflicting destination commits for each conflict
Summary:
One thing that makes dealing with merge conflicts difficult at Facebook is that it can be tough to know *why* you have merge conflicts.
Because rebase processes one commit at a time, it's clear which of *your* commits is the problem, but finding the "other" commit is surprisingly hard. Often we rebase onto `master`, and in a monorepo, `master` is often a random commit that has no relationship to your code at all.
This diff attempts to improve the situation a bit by listing all of the commits between the common ancestor and the destination commit that modified the file. The user can then identify which are likely culprits:
```
warning: 2 conflicts while merging b! (edit, then use 'hg resolve --mark')
3 commits might've introduced this conflict:
- [0942ca9aff3d] random commit 1
- [3ebd0a462491] foo bar biz
- [3e5843b4b236] blah blah blah
```
When the destination is public, this approach requires one loose file download (~0.5s?) per conflicted file (this pulls in the full filectx history DAG, so further downloads aren't needed), which is likely acceptable as it only runs on conflicts, and provides value to the user. But it's also configurable for users performing massive codemods.
I'll add metrics to gather the average number if matched commits and the time taken to generate.
This doesn't put this information into the conflict markers, so a lot of people (Nuclide users or the default `editmerge` users) won't see it. We need to think creatively about how to expose it to them.
The ideal solution would tell you which commits edited the actual conflicted section(s), not just those that touched the file.
This requires fast remotefilelog downloads (cc @[100000771202578:Arun] :)). Once we have those, we can construct a local `linelog` of the commits involved, and used this to identify precisely which commits edited the conflicted sections of the file.
Reviewed By: quark-zju
Differential Revision: D9816270
fbshipit-source-id: 04e08dea7a9429eaeab0d40310cd34355104bb74
2018-10-25 23:59:35 +03:00
|
|
|
) % (r, relpath)
|
|
|
|
|
2019-03-09 06:52:55 +03:00
|
|
|
if repo.ui.configbool("merge", "printcandidatecommmits"):
|
filemerge: print the potentially conflicting destination commits for each conflict
Summary:
One thing that makes dealing with merge conflicts difficult at Facebook is that it can be tough to know *why* you have merge conflicts.
Because rebase processes one commit at a time, it's clear which of *your* commits is the problem, but finding the "other" commit is surprisingly hard. Often we rebase onto `master`, and in a monorepo, `master` is often a random commit that has no relationship to your code at all.
This diff attempts to improve the situation a bit by listing all of the commits between the common ancestor and the destination commit that modified the file. The user can then identify which are likely culprits:
```
warning: 2 conflicts while merging b! (edit, then use 'hg resolve --mark')
3 commits might've introduced this conflict:
- [0942ca9aff3d] random commit 1
- [3ebd0a462491] foo bar biz
- [3e5843b4b236] blah blah blah
```
When the destination is public, this approach requires one loose file download (~0.5s?) per conflicted file (this pulls in the full filectx history DAG, so further downloads aren't needed), which is likely acceptable as it only runs on conflicts, and provides value to the user. But it's also configurable for users performing massive codemods.
I'll add metrics to gather the average number if matched commits and the time taken to generate.
This doesn't put this information into the conflict markers, so a lot of people (Nuclide users or the default `editmerge` users) won't see it. We need to think creatively about how to expose it to them.
The ideal solution would tell you which commits edited the actual conflicted section(s), not just those that touched the file.
This requires fast remotefilelog downloads (cc @[100000771202578:Arun] :)). Once we have those, we can construct a local `linelog` of the commits involved, and used this to identify precisely which commits edited the conflicted sections of the file.
Reviewed By: quark-zju
Differential Revision: D9816270
fbshipit-source-id: 04e08dea7a9429eaeab0d40310cd34355104bb74
2018-10-25 23:59:35 +03:00
|
|
|
candidates, hit_max = _findconflictingcommits(repo, fcd, fca)
|
|
|
|
else:
|
|
|
|
candidates, hit_max = [], False
|
|
|
|
|
|
|
|
if len(candidates):
|
|
|
|
msg += _(" %d commits might have introduced this conflict:\n") % (
|
|
|
|
len(candidates),
|
|
|
|
)
|
|
|
|
for ctx in candidates:
|
|
|
|
# TODO(phillco): Make this a configurable template
|
|
|
|
firstline = templatefilters.firstline(ctx.description())
|
|
|
|
msg += " - [%s] %s\n" % (short(ctx.node()), firstline)
|
|
|
|
if hit_max:
|
|
|
|
msg += " - (possibly more)\n"
|
|
|
|
return msg
|
2018-09-22 02:23:32 +03:00
|
|
|
|
|
|
|
|
2015-08-16 01:24:29 +03:00
|
|
|
def _merge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels, mode):
|
2012-02-17 01:58:51 +04:00
|
|
|
"""
|
2012-02-12 16:38:12 +04:00
|
|
|
Uses the internal non-interactive simple merge algorithm for merging
|
|
|
|
files. It will fail if there are any conflicts and leave markers in
|
2014-08-06 02:09:54 +04:00
|
|
|
the partially merged file. Markers will have two sections, one for each side
|
2015-08-16 01:24:29 +03:00
|
|
|
of merge, unless mode equals 'union' which suppresses the markers."""
|
2015-10-09 00:16:19 +03:00
|
|
|
ui = repo.ui
|
2012-02-12 16:38:12 +04:00
|
|
|
|
2017-09-01 20:35:43 +03:00
|
|
|
r = simplemerge.simplemerge(ui, fcd, fca, fco, label=labels, mode=mode)
|
2015-11-19 00:55:31 +03:00
|
|
|
return True, r, False
|
2012-02-12 16:38:12 +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
|
|
|
|
filemerge: print the potentially conflicting destination commits for each conflict
Summary:
One thing that makes dealing with merge conflicts difficult at Facebook is that it can be tough to know *why* you have merge conflicts.
Because rebase processes one commit at a time, it's clear which of *your* commits is the problem, but finding the "other" commit is surprisingly hard. Often we rebase onto `master`, and in a monorepo, `master` is often a random commit that has no relationship to your code at all.
This diff attempts to improve the situation a bit by listing all of the commits between the common ancestor and the destination commit that modified the file. The user can then identify which are likely culprits:
```
warning: 2 conflicts while merging b! (edit, then use 'hg resolve --mark')
3 commits might've introduced this conflict:
- [0942ca9aff3d] random commit 1
- [3ebd0a462491] foo bar biz
- [3e5843b4b236] blah blah blah
```
When the destination is public, this approach requires one loose file download (~0.5s?) per conflicted file (this pulls in the full filectx history DAG, so further downloads aren't needed), which is likely acceptable as it only runs on conflicts, and provides value to the user. But it's also configurable for users performing massive codemods.
I'll add metrics to gather the average number if matched commits and the time taken to generate.
This doesn't put this information into the conflict markers, so a lot of people (Nuclide users or the default `editmerge` users) won't see it. We need to think creatively about how to expose it to them.
The ideal solution would tell you which commits edited the actual conflicted section(s), not just those that touched the file.
This requires fast remotefilelog downloads (cc @[100000771202578:Arun] :)). Once we have those, we can construct a local `linelog` of the commits involved, and used this to identify precisely which commits edited the conflicted sections of the file.
Reviewed By: quark-zju
Differential Revision: D9816270
fbshipit-source-id: 04e08dea7a9429eaeab0d40310cd34355104bb74
2018-10-25 23:59:35 +03:00
|
|
|
@internaltool("union", fullmerge, _describefailure, precheck=_mergecheck)
|
2015-08-16 11:19:00 +03:00
|
|
|
def _iunion(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
|
|
|
|
"""
|
|
|
|
Uses the internal non-interactive simple merge algorithm for merging
|
|
|
|
files. It will use both left and right sides for conflict regions.
|
|
|
|
No markers are inserted."""
|
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 _merge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels, "union")
|
|
|
|
|
2015-08-16 11:19:00 +03:00
|
|
|
|
filemerge: print the potentially conflicting destination commits for each conflict
Summary:
One thing that makes dealing with merge conflicts difficult at Facebook is that it can be tough to know *why* you have merge conflicts.
Because rebase processes one commit at a time, it's clear which of *your* commits is the problem, but finding the "other" commit is surprisingly hard. Often we rebase onto `master`, and in a monorepo, `master` is often a random commit that has no relationship to your code at all.
This diff attempts to improve the situation a bit by listing all of the commits between the common ancestor and the destination commit that modified the file. The user can then identify which are likely culprits:
```
warning: 2 conflicts while merging b! (edit, then use 'hg resolve --mark')
3 commits might've introduced this conflict:
- [0942ca9aff3d] random commit 1
- [3ebd0a462491] foo bar biz
- [3e5843b4b236] blah blah blah
```
When the destination is public, this approach requires one loose file download (~0.5s?) per conflicted file (this pulls in the full filectx history DAG, so further downloads aren't needed), which is likely acceptable as it only runs on conflicts, and provides value to the user. But it's also configurable for users performing massive codemods.
I'll add metrics to gather the average number if matched commits and the time taken to generate.
This doesn't put this information into the conflict markers, so a lot of people (Nuclide users or the default `editmerge` users) won't see it. We need to think creatively about how to expose it to them.
The ideal solution would tell you which commits edited the actual conflicted section(s), not just those that touched the file.
This requires fast remotefilelog downloads (cc @[100000771202578:Arun] :)). Once we have those, we can construct a local `linelog` of the commits involved, and used this to identify precisely which commits edited the conflicted sections of the file.
Reviewed By: quark-zju
Differential Revision: D9816270
fbshipit-source-id: 04e08dea7a9429eaeab0d40310cd34355104bb74
2018-10-25 23:59:35 +03:00
|
|
|
@internaltool("merge", fullmerge, _describefailure, precheck=_mergecheck)
|
2015-08-16 01:24:29 +03:00
|
|
|
def _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
|
|
|
|
"""
|
|
|
|
Uses the internal non-interactive simple merge algorithm for merging
|
|
|
|
files. It will fail if there are any conflicts and leave markers in
|
|
|
|
the partially merged file. Markers will have two sections, one for each side
|
|
|
|
of merge."""
|
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 _merge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels, "merge")
|
|
|
|
|
2015-08-16 01:24:29 +03:00
|
|
|
|
filemerge: print the potentially conflicting destination commits for each conflict
Summary:
One thing that makes dealing with merge conflicts difficult at Facebook is that it can be tough to know *why* you have merge conflicts.
Because rebase processes one commit at a time, it's clear which of *your* commits is the problem, but finding the "other" commit is surprisingly hard. Often we rebase onto `master`, and in a monorepo, `master` is often a random commit that has no relationship to your code at all.
This diff attempts to improve the situation a bit by listing all of the commits between the common ancestor and the destination commit that modified the file. The user can then identify which are likely culprits:
```
warning: 2 conflicts while merging b! (edit, then use 'hg resolve --mark')
3 commits might've introduced this conflict:
- [0942ca9aff3d] random commit 1
- [3ebd0a462491] foo bar biz
- [3e5843b4b236] blah blah blah
```
When the destination is public, this approach requires one loose file download (~0.5s?) per conflicted file (this pulls in the full filectx history DAG, so further downloads aren't needed), which is likely acceptable as it only runs on conflicts, and provides value to the user. But it's also configurable for users performing massive codemods.
I'll add metrics to gather the average number if matched commits and the time taken to generate.
This doesn't put this information into the conflict markers, so a lot of people (Nuclide users or the default `editmerge` users) won't see it. We need to think creatively about how to expose it to them.
The ideal solution would tell you which commits edited the actual conflicted section(s), not just those that touched the file.
This requires fast remotefilelog downloads (cc @[100000771202578:Arun] :)). Once we have those, we can construct a local `linelog` of the commits involved, and used this to identify precisely which commits edited the conflicted sections of the file.
Reviewed By: quark-zju
Differential Revision: D9816270
fbshipit-source-id: 04e08dea7a9429eaeab0d40310cd34355104bb74
2018-10-25 23:59:35 +03:00
|
|
|
@internaltool("merge3", fullmerge, _describefailure, precheck=_mergecheck)
|
2014-08-06 01:58:45 +04:00
|
|
|
def _imerge3(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
|
|
|
|
"""
|
|
|
|
Uses the internal non-interactive simple merge algorithm for merging
|
|
|
|
files. It will fail if there are any conflicts and leave markers in
|
|
|
|
the partially merged file. Marker will have three sections, one from each
|
|
|
|
side of the merge and one for the base content."""
|
|
|
|
if not labels:
|
|
|
|
labels = _defaultconflictlabels
|
|
|
|
if len(labels) < 3:
|
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
|
|
|
labels.append("base")
|
2014-08-06 01:58:45 +04:00
|
|
|
return _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels)
|
|
|
|
|
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 _imergeauto(
|
|
|
|
repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None, localorother=None
|
|
|
|
):
|
2015-09-10 16:41:11 +03:00
|
|
|
"""
|
|
|
|
Generic driver for _imergelocal and _imergeother
|
|
|
|
"""
|
|
|
|
assert localorother is not None
|
|
|
|
tool, toolpath, binary, symlink = toolconf
|
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 = simplemerge.simplemerge(
|
|
|
|
repo.ui, fcd, fca, fco, label=labels, localorother=localorother
|
|
|
|
)
|
2015-09-10 16:41:11 +03:00
|
|
|
return True, r
|
|
|
|
|
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
|
|
|
|
|
|
|
@internaltool("merge-local", mergeonly, precheck=_mergecheck)
|
2015-09-10 16:41:11 +03:00
|
|
|
def _imergelocal(*args, **kwargs):
|
|
|
|
"""
|
|
|
|
Like :merge, but resolve all conflicts non-interactively in favor
|
2016-03-17 03:36:01 +03:00
|
|
|
of the local `p1()` changes."""
|
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
|
|
|
success, status = _imergeauto(localorother="local", *args, **kwargs)
|
2015-11-19 00:55:31 +03:00
|
|
|
return success, status, False
|
2015-09-10 16:41:11 +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
|
|
|
|
|
|
|
@internaltool("merge-other", mergeonly, precheck=_mergecheck)
|
2015-09-10 16:41:11 +03:00
|
|
|
def _imergeother(*args, **kwargs):
|
|
|
|
"""
|
|
|
|
Like :merge, but resolve all conflicts non-interactively in favor
|
2016-03-17 03:36:01 +03:00
|
|
|
of the other `p2()` changes."""
|
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
|
|
|
success, status = _imergeauto(localorother="other", *args, **kwargs)
|
2015-11-19 00:55:31 +03:00
|
|
|
return success, status, False
|
2015-09-10 16:41:11 +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
|
|
|
|
|
|
|
@internaltool("dump", fullmerge)
|
2014-05-09 03:37:33 +04:00
|
|
|
def _idump(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
|
2012-02-17 01:58:51 +04:00
|
|
|
"""
|
2012-02-12 16:38:12 +04:00
|
|
|
Creates three versions of the files to merge, containing the
|
|
|
|
contents of local, other and base. These files can then be used to
|
|
|
|
perform a merge manually. If the file to be merged is named
|
|
|
|
``a.txt``, these files will accordingly be named ``a.txt.local``,
|
|
|
|
``a.txt.other`` and ``a.txt.base`` and they will be placed in the
|
filemerge: add internal merge tool to dump files forcibly
Internal merge tool :dump implies premerge. Therefore, files aren't
dumped, if premerge runs successfully.
This undocumented behavior might confuse users, if they want to always
dump files. But just making :dump omit premerge might cause backward
compatibility issue for existing automation.
This patch adds new internal merge tool :forcedump, which works as
same as :dump, but omits premerge always.
Internal tools annotated with "nomerge" should merge "change and
delete" correctly, but _forcedump() can't. Therefore, it is annotated
with "mergeonly" to always omit premerge, even though it doesn't merge
files actually.
This patch also adds explanation about premerge to :dump, to clarify
how :dump actually works.
BTW, this patch specifies internal tools with "internal:" prefix in
newly added test scenario in test-merge-tools.t, even though this
prefix is already deprecated. This is only for similarity to other
tests in test-merge-tools.t.
2017-05-12 21:31:42 +03:00
|
|
|
same directory as ``a.txt``.
|
|
|
|
|
2017-10-21 00:15:46 +03:00
|
|
|
This implies premerge. Therefore, files aren't dumped, if premerge
|
filemerge: add internal merge tool to dump files forcibly
Internal merge tool :dump implies premerge. Therefore, files aren't
dumped, if premerge runs successfully.
This undocumented behavior might confuse users, if they want to always
dump files. But just making :dump omit premerge might cause backward
compatibility issue for existing automation.
This patch adds new internal merge tool :forcedump, which works as
same as :dump, but omits premerge always.
Internal tools annotated with "nomerge" should merge "change and
delete" correctly, but _forcedump() can't. Therefore, it is annotated
with "mergeonly" to always omit premerge, even though it doesn't merge
files actually.
This patch also adds explanation about premerge to :dump, to clarify
how :dump actually works.
BTW, this patch specifies internal tools with "internal:" prefix in
newly added test scenario in test-merge-tools.t, even though this
prefix is already deprecated. This is only for similarity to other
tests in test-merge-tools.t.
2017-05-12 21:31:42 +03:00
|
|
|
runs successfully. Use :forcedump to forcibly write files out.
|
|
|
|
"""
|
2017-08-31 21:28:59 +03:00
|
|
|
a = _workingpath(repo, fcd)
|
2015-10-09 00:17:31 +03:00
|
|
|
fd = fcd.path()
|
2012-02-12 16:38:12 +04:00
|
|
|
|
2017-10-16 06:36:29 +03:00
|
|
|
from . import context
|
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-10-16 06:36:29 +03:00
|
|
|
if isinstance(fcd, context.overlayworkingfilectx):
|
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
|
|
|
raise error.InMemoryMergeConflictsError(
|
2018-07-02 21:24:57 +03:00
|
|
|
"in-memory merge does not support the :dump tool.",
|
|
|
|
type=error.InMemoryMergeConflictsError.TYPE_FILE_CONFLICTS,
|
|
|
|
paths=[fcd.path()],
|
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-10-16 06:36:29 +03:00
|
|
|
|
2017-09-05 22:04:02 +03:00
|
|
|
util.writefile(a + ".local", fcd.decodeddata())
|
2015-10-09 00:17:31 +03:00
|
|
|
repo.wwrite(fd + ".other", fco.data(), fco.flags())
|
|
|
|
repo.wwrite(fd + ".base", fca.data(), fca.flags())
|
2015-11-19 00:55:31 +03:00
|
|
|
return False, 1, False
|
2012-02-12 16:38:12 +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
|
|
|
|
|
|
|
@internaltool("forcedump", mergeonly)
|
|
|
|
def _forcedump(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
|
filemerge: add internal merge tool to dump files forcibly
Internal merge tool :dump implies premerge. Therefore, files aren't
dumped, if premerge runs successfully.
This undocumented behavior might confuse users, if they want to always
dump files. But just making :dump omit premerge might cause backward
compatibility issue for existing automation.
This patch adds new internal merge tool :forcedump, which works as
same as :dump, but omits premerge always.
Internal tools annotated with "nomerge" should merge "change and
delete" correctly, but _forcedump() can't. Therefore, it is annotated
with "mergeonly" to always omit premerge, even though it doesn't merge
files actually.
This patch also adds explanation about premerge to :dump, to clarify
how :dump actually works.
BTW, this patch specifies internal tools with "internal:" prefix in
newly added test scenario in test-merge-tools.t, even though this
prefix is already deprecated. This is only for similarity to other
tests in test-merge-tools.t.
2017-05-12 21:31:42 +03:00
|
|
|
"""
|
|
|
|
Creates three versions of the files as same as :dump, but omits premerge.
|
|
|
|
"""
|
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 _idump(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=labels)
|
|
|
|
|
filemerge: add internal merge tool to dump files forcibly
Internal merge tool :dump implies premerge. Therefore, files aren't
dumped, if premerge runs successfully.
This undocumented behavior might confuse users, if they want to always
dump files. But just making :dump omit premerge might cause backward
compatibility issue for existing automation.
This patch adds new internal merge tool :forcedump, which works as
same as :dump, but omits premerge always.
Internal tools annotated with "nomerge" should merge "change and
delete" correctly, but _forcedump() can't. Therefore, it is annotated
with "mergeonly" to always omit premerge, even though it doesn't merge
files actually.
This patch also adds explanation about premerge to :dump, to clarify
how :dump actually works.
BTW, this patch specifies internal tools with "internal:" prefix in
newly added test scenario in test-merge-tools.t, even though this
prefix is already deprecated. This is only for similarity to other
tests in test-merge-tools.t.
2017-05-12 21:31:42 +03:00
|
|
|
|
2018-01-03 16:35:56 +03:00
|
|
|
def _xmergeimm(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
|
|
|
|
# In-memory merge simply raises an exception on all external merge tools,
|
|
|
|
# for now.
|
|
|
|
#
|
|
|
|
# It would be possible to run most tools with temporary files, but this
|
|
|
|
# raises the question of what to do if the user only partially resolves the
|
|
|
|
# file -- we can't leave a merge state. (Copy to somewhere in the .hg/
|
|
|
|
# directory and tell the user how to get it is my best idea, but it's
|
|
|
|
# clunky.)
|
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
|
|
|
raise error.InMemoryMergeConflictsError(
|
2018-07-02 21:24:57 +03:00
|
|
|
"in-memory merge does not support external merge tools",
|
|
|
|
type=error.InMemoryMergeConflictsError.TYPE_FILE_CONFLICTS,
|
|
|
|
paths=[fcd.path()],
|
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
|
|
|
)
|
|
|
|
|
2018-01-03 16:35:56 +03:00
|
|
|
|
2014-05-09 03:37:33 +04:00
|
|
|
def _xmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
|
2015-10-09 00:18:43 +03:00
|
|
|
tool, toolpath, binary, symlink = toolconf
|
2015-11-14 10:57:43 +03:00
|
|
|
if fcd.isabsent() or fco.isabsent():
|
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.warn(
|
|
|
|
_("warning: %s cannot merge change/delete conflict " "for %s\n")
|
|
|
|
% (tool, fcd.path())
|
|
|
|
)
|
2015-11-14 10:57:43 +03:00
|
|
|
return False, 1, None
|
2017-08-31 21:28:59 +03:00
|
|
|
unused, unused, unused, back = files
|
2017-08-31 21:28:59 +03:00
|
|
|
a = _workingpath(repo, fcd)
|
2017-08-31 21:28:59 +03:00
|
|
|
b, c = _maketempfiles(repo, fco, fca)
|
|
|
|
try:
|
|
|
|
out = ""
|
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
|
|
|
env = {
|
|
|
|
"HG_FILE": fcd.path(),
|
|
|
|
"HG_MY_NODE": short(mynode),
|
|
|
|
"HG_OTHER_NODE": str(fco.changectx()),
|
|
|
|
"HG_BASE_NODE": str(fca.changectx()),
|
|
|
|
"HG_MY_ISLINK": "l" in fcd.flags(),
|
|
|
|
"HG_OTHER_ISLINK": "l" in fco.flags(),
|
|
|
|
"HG_BASE_ISLINK": "l" in fca.flags(),
|
|
|
|
}
|
2017-08-31 21:28:59 +03:00
|
|
|
ui = repo.ui
|
|
|
|
|
2017-10-08 21:37:13 +03:00
|
|
|
args = _toolstr(ui, tool, "args")
|
2017-08-31 21:28:59 +03:00
|
|
|
if "$output" in args:
|
2017-10-16 23:10:55 +03:00
|
|
|
# read input from backup, write to original
|
|
|
|
out = a
|
|
|
|
a = repo.wvfs.join(back.path())
|
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
|
|
|
replace = {"local": a, "base": b, "other": c, "output": out}
|
|
|
|
args = util.interpolate(
|
|
|
|
r"\$", replace, args, lambda s: util.shellquote(util.localpath(s))
|
|
|
|
)
|
|
|
|
cmd = toolpath + " " + args
|
2017-08-31 21:28:59 +03:00
|
|
|
if _toolbool(ui, tool, "gui"):
|
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.status(
|
|
|
|
_("running merge tool %s for file %s\n") % (tool, fcd.path())
|
|
|
|
)
|
|
|
|
repo.ui.debug("launching merge tool: %s\n" % cmd)
|
|
|
|
r = ui.system(cmd, cwd=repo.root, environ=env, blockedtag="mergetool")
|
|
|
|
repo.ui.debug("merge tool returned: %d\n" % r)
|
2017-08-31 21:28:59 +03:00
|
|
|
return True, r, False
|
|
|
|
finally:
|
|
|
|
util.unlink(b)
|
|
|
|
util.unlink(c)
|
2012-02-12 16:38:12 +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
|
|
|
|
2014-05-09 03:50:22 +04:00
|
|
|
def _formatconflictmarker(repo, ctx, template, label, pad):
|
|
|
|
"""Applies the given template to the ctx, prefixed by the label.
|
|
|
|
|
|
|
|
Pad is the minimum width of the label prefix, so that multiple markers
|
|
|
|
can have aligned templated parts.
|
|
|
|
"""
|
|
|
|
if ctx.node() is None:
|
|
|
|
ctx = ctx.p1()
|
|
|
|
|
|
|
|
props = templatekw.keywords.copy()
|
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
|
|
|
props["templ"] = template
|
|
|
|
props["ctx"] = ctx
|
|
|
|
props["repo"] = repo
|
2017-04-22 13:56:47 +03:00
|
|
|
templateresult = template.render(props)
|
2014-05-09 03:50:22 +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
|
|
|
label = ("%s:" % label).ljust(pad + 1)
|
|
|
|
mark = "%s %s" % (label, templateresult)
|
2014-05-09 03:50:22 +04:00
|
|
|
|
2014-07-05 21:56:41 +04:00
|
|
|
if mark:
|
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
|
|
|
mark = mark.splitlines()[0] # split for safety
|
2014-07-05 21:56:41 +04:00
|
|
|
|
2014-07-05 21:56:41 +04:00
|
|
|
# 8 for the prefix of conflict marker lines (e.g. '<<<<<<< ')
|
|
|
|
return util.ellipsis(mark, 80 - 8)
|
2014-05-09 03:50:22 +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
|
|
|
|
|
|
|
_defaultconflictlabels = ["local", "other"]
|
|
|
|
|
2014-05-09 03:54:23 +04:00
|
|
|
|
2014-08-06 02:17:38 +04:00
|
|
|
def _formatlabels(repo, fcd, fco, fca, labels):
|
2014-05-09 03:50:22 +04:00
|
|
|
"""Formats the given labels using the conflict marker template.
|
|
|
|
|
|
|
|
Returns a list of formatted labels.
|
|
|
|
"""
|
|
|
|
cd = fcd.changectx()
|
|
|
|
co = fco.changectx()
|
2014-08-06 02:17:38 +04:00
|
|
|
ca = fca.changectx()
|
2014-05-09 03:50:22 +04:00
|
|
|
|
|
|
|
ui = 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
|
|
|
template = ui.config("ui", "mergemarkertemplate")
|
2017-02-25 13:36:02 +03:00
|
|
|
template = templater.unquotestring(template)
|
2017-04-22 13:56:47 +03:00
|
|
|
tmpl = formatter.maketemplater(ui, template)
|
2014-05-09 03:50:22 +04:00
|
|
|
|
2014-08-06 02:17:38 +04:00
|
|
|
pad = max(len(l) for l in labels)
|
2014-05-09 03:50:22 +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
|
|
|
newlabels = [
|
|
|
|
_formatconflictmarker(repo, cd, tmpl, labels[0], pad),
|
|
|
|
_formatconflictmarker(repo, co, tmpl, labels[1], pad),
|
|
|
|
]
|
2014-08-06 02:17:38 +04:00
|
|
|
if len(labels) > 2:
|
|
|
|
newlabels.append(_formatconflictmarker(repo, ca, tmpl, labels[2], pad))
|
|
|
|
return newlabels
|
2014-05-09 03:50:22 +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
|
|
|
|
merge: use labels in prompts to the user
Now that we persist the labels, we can consistently use the labels in
prompts for the user without risk of confusion. This changes a huge amount
of command output:
This means that merge prompts like:
no tool found to merge a
keep (l)ocal, take (o)ther, or leave (u)nresolved? u
and
remote changed a which local deleted
use (c)hanged version, leave (d)eleted, or leave (u)nresolved? c
become:
no tool found to merge a
keep (l)ocal [working copy], take (o)ther [destination], or leave (u)nresolved? u
and
remote [source] changed a which local [dest] deleted
use (c)hanged version, leave (d)eleted, or leave (u)nresolved? c
where "working copy" and "destination" were supplied by the command that
requested the merge as labels for conflict markers, and thus should be
human-friendly.
2016-08-12 16:01:42 +03:00
|
|
|
def partextras(labels):
|
|
|
|
"""Return a dictionary of extra labels for use in prompts to the user
|
|
|
|
|
|
|
|
Intended use is in strings of the form "(l)ocal%(l)s".
|
|
|
|
"""
|
|
|
|
if labels is 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
|
|
|
return {"l": "", "o": ""}
|
|
|
|
|
|
|
|
return {"l": " [%s]" % labels[0], "o": " [%s]" % labels[1]}
|
merge: use labels in prompts to the user
Now that we persist the labels, we can consistently use the labels in
prompts for the user without risk of confusion. This changes a huge amount
of command output:
This means that merge prompts like:
no tool found to merge a
keep (l)ocal, take (o)ther, or leave (u)nresolved? u
and
remote changed a which local deleted
use (c)hanged version, leave (d)eleted, or leave (u)nresolved? c
become:
no tool found to merge a
keep (l)ocal [working copy], take (o)ther [destination], or leave (u)nresolved? u
and
remote [source] changed a which local [dest] deleted
use (c)hanged version, leave (d)eleted, or leave (u)nresolved? c
where "working copy" and "destination" were supplied by the command that
requested the merge as labels for conflict markers, and thus should be
human-friendly.
2016-08-12 16:01:42 +03:00
|
|
|
|
|
|
|
|
2017-08-31 21:28:59 +03:00
|
|
|
def _restorebackup(fcd, back):
|
|
|
|
# TODO: Add a workingfilectx.write(otherfilectx) path so we can use
|
|
|
|
# util.copy here instead.
|
2017-10-16 23:10:55 +03:00
|
|
|
fcd.write(back.data(), fcd.flags())
|
2017-08-31 21:28:59 +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-10-16 23:10:55 +03:00
|
|
|
def _makebackup(repo, ui, wctx, fcd, premerge):
|
|
|
|
"""Makes and returns a filectx-like object for ``fcd``'s backup file.
|
2008-02-04 04:29:05 +03:00
|
|
|
|
2017-08-31 21:05:19 +03:00
|
|
|
In addition to preserving the user's pre-existing modifications to `fcd`
|
|
|
|
(if any), the backup is used to undo certain premerges, confirm whether a
|
|
|
|
merge changed anything, and determine what line endings the new file should
|
|
|
|
have.
|
2018-01-17 04:23:40 +03:00
|
|
|
|
|
|
|
Backups only need to be written once (right before the premerge) since their
|
|
|
|
content doesn't change afterwards.
|
2017-08-31 21:05:19 +03:00
|
|
|
"""
|
|
|
|
if fcd.isabsent():
|
|
|
|
return None
|
2017-10-16 23:10:55 +03:00
|
|
|
# TODO: Break this import cycle somehow. (filectx -> ctx -> fileset ->
|
|
|
|
# merge -> filemerge). (I suspect the fileset import is the weakest link)
|
|
|
|
from . import context
|
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-31 21:28:59 +03:00
|
|
|
a = _workingpath(repo, fcd)
|
2017-08-31 21:05:19 +03:00
|
|
|
back = scmutil.origpath(ui, repo, a)
|
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
|
|
|
inworkingdir = back.startswith(repo.wvfs.base) and not back.startswith(
|
2018-09-28 17:08:51 +03:00
|
|
|
repo.localvfs.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
|
|
|
)
|
2017-10-13 22:34:22 +03:00
|
|
|
if isinstance(fcd, context.overlayworkingfilectx) and inworkingdir:
|
|
|
|
# If the backup file is to be in the working directory, and we're
|
|
|
|
# merging in-memory, we must redirect the backup to the memory context
|
|
|
|
# so we don't disturb the working directory.
|
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
|
|
|
relpath = back[len(repo.wvfs.base) + 1 :]
|
2018-01-09 17:29:25 +03:00
|
|
|
if premerge:
|
|
|
|
wctx[relpath].write(fcd.data(), fcd.flags())
|
2017-10-13 22:34:22 +03:00
|
|
|
return wctx[relpath]
|
|
|
|
else:
|
2018-01-17 04:23:40 +03:00
|
|
|
if premerge:
|
|
|
|
# Otherwise, write to wherever path the user specified the backups
|
|
|
|
# should go. We still need to switch based on whether the source is
|
|
|
|
# in-memory so we can use the fast path of ``util.copy`` if both are
|
|
|
|
# on disk.
|
|
|
|
if isinstance(fcd, context.overlayworkingfilectx):
|
|
|
|
util.writefile(back, fcd.data())
|
|
|
|
else:
|
|
|
|
util.copyfile(a, back)
|
2017-10-13 22:34:22 +03:00
|
|
|
# A arbitraryfilectx is returned, so we can run the same functions on
|
|
|
|
# the backup context regardless of where it lives.
|
|
|
|
return context.arbitraryfilectx(back, repo=repo)
|
2017-08-31 21:05:19 +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-31 21:28:59 +03:00
|
|
|
def _maketempfiles(repo, fco, fca):
|
2017-08-31 21:05:19 +03:00
|
|
|
"""Writes out `fco` and `fca` as temporary files, so an external merge
|
|
|
|
tool may use them.
|
|
|
|
"""
|
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-10-08 10:19:20 +03:00
|
|
|
def temp(prefix, ctx):
|
2016-11-24 01:47:38 +03:00
|
|
|
fullbase, ext = os.path.splitext(ctx.path())
|
|
|
|
pre = "%s~%s." % (os.path.basename(fullbase), prefix)
|
|
|
|
(fd, name) = tempfile.mkstemp(prefix=pre, suffix=ext)
|
2015-10-08 10:19:20 +03:00
|
|
|
data = repo.wwritedata(ctx.path(), ctx.data())
|
2019-06-27 23:06:05 +03:00
|
|
|
f = util.fdopen(fd, pycompat.sysstr("wb"))
|
2015-10-08 10:19:20 +03:00
|
|
|
f.write(data)
|
|
|
|
f.close()
|
|
|
|
return name
|
|
|
|
|
2017-08-31 21:05:19 +03:00
|
|
|
b = temp("base", fca)
|
|
|
|
c = temp("other", fco)
|
|
|
|
|
2017-08-31 21:28:59 +03:00
|
|
|
return b, c
|
2017-08-31 21:05:19 +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-11 23:03:27 +03:00
|
|
|
def _filemerge(premerge, repo, wctx, mynode, orig, fcd, fco, fca, labels=None):
|
2017-08-31 21:05:19 +03:00
|
|
|
"""perform a 3-way merge in the working directory
|
|
|
|
|
|
|
|
premerge = whether this is a premerge
|
|
|
|
mynode = parent node before merge
|
|
|
|
orig = original local filename before merge
|
|
|
|
fco = other file context
|
|
|
|
fca = ancestor file context
|
|
|
|
fcd = local file context for current/destination file
|
|
|
|
|
|
|
|
Returns whether the merge is complete, the return value of the merge, and
|
|
|
|
a boolean indicating whether the file was deleted from disk."""
|
|
|
|
|
2018-09-22 02:23:32 +03:00
|
|
|
if not fco.cmp(fcd): # files ide gtical?
|
2015-11-19 01:22:52 +03:00
|
|
|
return True, None, False
|
2008-02-04 04:29:05 +03:00
|
|
|
|
2015-10-08 10:19:20 +03:00
|
|
|
ui = repo.ui
|
|
|
|
fd = fcd.path()
|
2018-02-23 18:20:37 +03:00
|
|
|
relorig = repo.pathto(orig)
|
|
|
|
relfo = repo.pathto(fco.path())
|
|
|
|
relfd = repo.pathto(fd)
|
|
|
|
|
2015-10-08 10:19:20 +03:00
|
|
|
binary = fcd.isbinary() or fco.isbinary() or fca.isbinary()
|
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
|
|
|
symlink = "l" in fcd.flags() + fco.flags()
|
2015-11-16 08:40:15 +03:00
|
|
|
changedelete = fcd.isabsent() or fco.isabsent()
|
|
|
|
tool, toolpath = _picktool(repo, ui, fd, binary, symlink, changedelete)
|
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 tool in internals and tool.startswith("internal:"):
|
2015-10-08 10:19:20 +03:00
|
|
|
# normalize to new-style names (':merge' etc)
|
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
|
|
|
tool = tool[len("internal") :]
|
|
|
|
ui.debug(
|
|
|
|
"picked tool '%s' for %s (binary %s symlink %s changedelete %s)\n"
|
|
|
|
% (
|
|
|
|
tool,
|
|
|
|
fd,
|
|
|
|
pycompat.bytestr(binary),
|
|
|
|
pycompat.bytestr(symlink),
|
|
|
|
pycompat.bytestr(changedelete),
|
|
|
|
)
|
|
|
|
)
|
2012-02-12 16:38:12 +04:00
|
|
|
|
2015-10-08 10:19:20 +03:00
|
|
|
if tool in internals:
|
|
|
|
func = internals[tool]
|
|
|
|
mergetype = func.mergetype
|
|
|
|
onfailure = func.onfailure
|
|
|
|
precheck = func.precheck
|
|
|
|
else:
|
2018-01-03 16:35:56 +03:00
|
|
|
if wctx.isinmemory():
|
|
|
|
func = _xmergeimm
|
|
|
|
else:
|
|
|
|
func = _xmerge
|
2015-10-08 10:19:20 +03:00
|
|
|
mergetype = fullmerge
|
|
|
|
onfailure = _("merging %s failed!\n")
|
|
|
|
precheck = None
|
2012-02-12 16:38:12 +04:00
|
|
|
|
2015-10-08 10:19:20 +03:00
|
|
|
toolconf = tool, toolpath, binary, symlink
|
|
|
|
|
|
|
|
if mergetype == nomerge:
|
merge: use labels in prompts to the user
Now that we persist the labels, we can consistently use the labels in
prompts for the user without risk of confusion. This changes a huge amount
of command output:
This means that merge prompts like:
no tool found to merge a
keep (l)ocal, take (o)ther, or leave (u)nresolved? u
and
remote changed a which local deleted
use (c)hanged version, leave (d)eleted, or leave (u)nresolved? c
become:
no tool found to merge a
keep (l)ocal [working copy], take (o)ther [destination], or leave (u)nresolved? u
and
remote [source] changed a which local [dest] deleted
use (c)hanged version, leave (d)eleted, or leave (u)nresolved? c
where "working copy" and "destination" were supplied by the command that
requested the merge as labels for conflict markers, and thus should be
human-friendly.
2016-08-12 16:01:42 +03:00
|
|
|
r, deleted = func(repo, mynode, orig, fcd, fco, fca, toolconf, labels)
|
2015-11-19 01:22:52 +03:00
|
|
|
return True, r, deleted
|
2015-10-08 10:19:20 +03:00
|
|
|
|
2015-10-12 06:02:53 +03:00
|
|
|
if premerge:
|
|
|
|
if orig != fco.path():
|
2018-02-23 18:20:37 +03:00
|
|
|
ui.status(_("merging %s and %s to %s\n") % (relorig, relfo, relfd))
|
2015-10-12 06:02:53 +03:00
|
|
|
else:
|
2018-02-23 18:20:37 +03:00
|
|
|
ui.status(_("merging %s\n") % relfd)
|
2015-10-08 10:19:20 +03:00
|
|
|
|
|
|
|
ui.debug("my %s other %s ancestor %s\n" % (fcd, fco, fca))
|
|
|
|
|
2018-09-22 02:23:32 +03:00
|
|
|
def getfailuremsg(on_failure, num_conflicts):
|
|
|
|
# on_failure can be a string or a function which we'll call.
|
|
|
|
if callable(on_failure):
|
|
|
|
return on_failure(num_conflicts, repo, mynode, orig, fcd, fco, fca)
|
|
|
|
else:
|
|
|
|
return on_failure % relfd
|
|
|
|
|
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 precheck and not precheck(repo, mynode, orig, fcd, fco, fca, toolconf):
|
2015-10-08 10:19:20 +03:00
|
|
|
if onfailure:
|
2017-12-01 11:07:23 +03:00
|
|
|
if wctx.isinmemory():
|
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
|
|
|
raise error.InMemoryMergeConflictsError(
|
2018-07-02 21:24:57 +03:00
|
|
|
"in-memory merge does not support merge conflicts",
|
|
|
|
type=error.InMemoryMergeConflictsError.TYPE_FILE_CONFLICTS,
|
|
|
|
paths=[fcd.path()],
|
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
|
|
|
)
|
2018-09-22 02:23:32 +03:00
|
|
|
ui.warn(getfailuremsg(onfailure, 1))
|
2015-11-19 01:22:52 +03:00
|
|
|
return True, 1, False
|
2015-10-08 10:19:20 +03:00
|
|
|
|
2017-10-16 23:10:55 +03:00
|
|
|
back = _makebackup(repo, ui, wctx, fcd, premerge)
|
2017-08-31 21:28:59 +03:00
|
|
|
files = (None, None, None, back)
|
2015-10-08 07:51:24 +03:00
|
|
|
r = 1
|
|
|
|
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
|
|
|
markerstyle = ui.config("ui", "mergemarkers")
|
2015-10-08 07:28:43 +03:00
|
|
|
if not labels:
|
|
|
|
labels = _defaultconflictlabels
|
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 markerstyle != "basic":
|
2015-10-08 07:28:43 +03:00
|
|
|
labels = _formatlabels(repo, fcd, fco, fca, labels)
|
2015-10-07 08:55:21 +03:00
|
|
|
|
2015-10-12 06:47:04 +03:00
|
|
|
if premerge and mergetype == fullmerge:
|
2015-11-14 10:56:00 +03:00
|
|
|
r = _premerge(repo, fcd, fco, fca, toolconf, files, labels=labels)
|
2015-10-12 06:47:14 +03:00
|
|
|
# complete if premerge successful (r is 0)
|
2015-11-19 01:22:52 +03:00
|
|
|
return not r, r, False
|
2015-10-08 07:22:16 +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
|
|
|
needcheck, r, deleted = func(
|
|
|
|
repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=labels
|
|
|
|
)
|
2015-11-19 00:55:31 +03:00
|
|
|
|
2015-10-08 09:35:30 +03:00
|
|
|
if needcheck:
|
2017-08-31 21:28:59 +03:00
|
|
|
r = _check(repo, r, ui, tool, fcd, files)
|
2014-05-09 03:50:22 +04:00
|
|
|
|
2012-02-12 16:38:12 +04:00
|
|
|
if r:
|
|
|
|
if onfailure:
|
2017-12-01 11:07:23 +03:00
|
|
|
if wctx.isinmemory():
|
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
|
|
|
raise error.InMemoryMergeConflictsError(
|
2018-07-02 21:24:57 +03:00
|
|
|
"in-memory merge does not support merge conflicts",
|
|
|
|
type=error.InMemoryMergeConflictsError.TYPE_FILE_CONFLICTS,
|
|
|
|
paths=[fcd.path()],
|
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
|
|
|
)
|
2018-09-22 02:23:32 +03:00
|
|
|
ui.warn(getfailuremsg(onfailure, r))
|
2017-10-06 16:48:43 +03:00
|
|
|
_onfilemergefailure(ui)
|
2008-02-04 04:29:05 +03:00
|
|
|
|
2015-11-19 01:22:52 +03:00
|
|
|
return True, r, deleted
|
2015-10-08 07:51:24 +03:00
|
|
|
finally:
|
2015-11-14 11:00:46 +03:00
|
|
|
if not r and back is not None:
|
2017-10-16 23:10:55 +03:00
|
|
|
back.remove()
|
2008-02-04 04:29:05 +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-10-06 16:48:43 +03:00
|
|
|
def _haltmerge():
|
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 = _("merge halted after failed merge (see hg resolve)")
|
2017-10-06 16:48:43 +03:00
|
|
|
raise error.InterventionRequired(msg)
|
|
|
|
|
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-10-06 16:48:43 +03:00
|
|
|
def _onfilemergefailure(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
|
|
|
action = ui.config("merge", "on-failure")
|
|
|
|
if action == "prompt":
|
2018-09-03 13:02:00 +03:00
|
|
|
msg = _(
|
|
|
|
"continue merge operation [(y)es/(n)o/(a)lways]?"
|
|
|
|
"$$ &Yes $$ &No $$ &Always"
|
|
|
|
)
|
|
|
|
choice = ui.promptchoice(msg, 0)
|
|
|
|
if choice == 1: # "no"
|
2017-10-06 16:48:43 +03:00
|
|
|
_haltmerge()
|
2018-09-03 13:02:00 +03:00
|
|
|
elif choice == 2: # "always"
|
|
|
|
ui.setconfig("merge", "on-failure", "continue", "user-prompt")
|
|
|
|
elif action == "halt":
|
2017-10-06 16:48:43 +03:00
|
|
|
_haltmerge()
|
|
|
|
# default action is 'continue', in which case we neither prompt nor halt
|
|
|
|
|
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-31 21:28:59 +03:00
|
|
|
def _check(repo, r, ui, tool, fcd, files):
|
2015-10-08 09:35:30 +03:00
|
|
|
fd = fcd.path()
|
2017-08-31 21:28:59 +03:00
|
|
|
unused, unused, unused, back = files
|
2015-10-08 09:35:30 +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
|
|
|
if not r and (
|
|
|
|
_toolbool(ui, tool, "checkconflicts")
|
|
|
|
or "conflicts" in _toollist(ui, tool, "check")
|
|
|
|
):
|
|
|
|
if re.search("^(<<<<<<< .*|=======|>>>>>>> .*)$", fcd.data(), re.MULTILINE):
|
2015-10-08 09:35:30 +03:00
|
|
|
r = 1
|
|
|
|
|
|
|
|
checked = 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
|
|
|
if "prompt" in _toollist(ui, tool, "check"):
|
2015-10-08 09:35:30 +03:00
|
|
|
checked = 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
|
|
|
if ui.promptchoice(
|
|
|
|
_("was merge of '%s' successful (yn)?" "$$ &Yes $$ &No") % fd, 1
|
|
|
|
):
|
2015-10-08 09:35:30 +03:00
|
|
|
r = 1
|
|
|
|
|
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 r
|
|
|
|
and not checked
|
|
|
|
and (
|
|
|
|
_toolbool(ui, tool, "checkchanged")
|
|
|
|
or "changed" in _toollist(ui, tool, "check")
|
|
|
|
)
|
|
|
|
):
|
2017-10-16 23:10:55 +03:00
|
|
|
if back is not None and not fcd.cmp(back):
|
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 ui.promptchoice(
|
|
|
|
_(
|
|
|
|
" output file %s appears unchanged\n"
|
|
|
|
"was merge successful (yn)?"
|
|
|
|
"$$ &Yes $$ &No"
|
|
|
|
)
|
|
|
|
% fd,
|
|
|
|
1,
|
|
|
|
):
|
2015-10-08 09:35:30 +03:00
|
|
|
r = 1
|
|
|
|
|
2015-11-14 11:00:46 +03:00
|
|
|
if back is not None and _toolbool(ui, tool, "fixeol"):
|
2017-08-31 21:28:59 +03:00
|
|
|
_matcheol(_workingpath(repo, fcd), back)
|
2015-10-08 09:35:30 +03:00
|
|
|
|
|
|
|
return r
|
|
|
|
|
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-31 21:28:59 +03:00
|
|
|
def _workingpath(repo, ctx):
|
|
|
|
return repo.wjoin(ctx.path())
|
|
|
|
|
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-11 23:03:27 +03:00
|
|
|
def premerge(repo, wctx, mynode, orig, fcd, fco, fca, labels=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
|
|
|
return _filemerge(True, repo, wctx, mynode, orig, fcd, fco, fca, labels=labels)
|
|
|
|
|
2015-10-12 06:47:04 +03:00
|
|
|
|
2017-09-11 23:03:27 +03:00
|
|
|
def filemerge(repo, wctx, mynode, orig, fcd, fco, fca, labels=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
|
|
|
return _filemerge(False, repo, wctx, mynode, orig, fcd, fco, fca, labels=labels)
|
|
|
|
|
2015-10-11 22:31:08 +03:00
|
|
|
|
2017-08-05 19:13:57 +03:00
|
|
|
def loadinternalmerge(ui, extname, registrarobj):
|
|
|
|
"""Load internal merge tool from specified registrarobj
|
|
|
|
"""
|
|
|
|
for name, func in registrarobj._table.iteritems():
|
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
|
|
|
fullname = ":" + name
|
2017-08-05 19:13:57 +03:00
|
|
|
internals[fullname] = func
|
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
|
|
|
internals["internal:" + name] = func
|
2017-08-05 19:13:57 +03:00
|
|
|
internalsdoc[fullname] = func
|
|
|
|
|
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-05 19:13:57 +03:00
|
|
|
# load built-in merge tools explicitly to setup internalsdoc
|
|
|
|
loadinternalmerge(None, None, internaltool)
|
|
|
|
|
2012-02-12 16:38:12 +04:00
|
|
|
# tell hggettext to extract docstrings from these functions:
|
|
|
|
i18nfunctions = internals.values()
|