Commit Graph

15 Commits

Author SHA1 Message Date
Jun Wu
2682422a3e uncommit: fix "restoring deletion" case for treestate
Summary:
The uncommit command does some low-level changes to dirstate - it changes the
parents without updating the tree. Then it uses traditional dirstate APIs to
update the tree.

Treestate and traditional dirstate differ on the "remove" API - treestate would
make it a no-op-ish if the file is not already tracked. Traditional dirstate
would create such an entry blindly and then mark it as "removed".

Treestate cannot simply create the entry because it needs "EXIST_P1" or
"EXIST_P2" information, which is outside the "remove" API itself.

To fix this, teach "uncommit" to write a treestate entry in this case.

The longer term fix would probably be removing the low-level "setparents"
calls.

Reviewed By: DurhamG

Differential Revision: D9282452

fbshipit-source-id: 9a0f0ac2f1bc2a4296c10f95819457f4f9585a82
2018-08-13 08:35:43 -07:00
Jun Wu
584656dff3 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-25 22:17:29 -07:00
Jun Wu
25d57c4aa8 unamend: backout the core version
We need hash-preserving unamend. Therefore remove the core version.
(grafted from 86e055fbb0c974e041dbd72cd95df6e3b37a0f6b)
(grafted from 129f15c3acd81d4390212430ea6b500412bc74ab)
(grafted from fbb42eb996d5bcddac4ba4e86a915a3bc62b3e16)
2018-01-03 05:35:56 -08:00
Martin von Zweigbergk
0c2857a328 unamend: allow unamending if allowunstable is set
I don't see why unamend should be disallowed when allowunstable is
set. By switching to rewriteutil.precheck() we fix that and get more
consistent error messages (and some additional ones).

Differential Revision: https://phab.mercurial-scm.org/D1682
2017-12-13 17:03:39 -08:00
Martin von Zweigbergk
14dfe2a25c memfilectx: make changectx argument mandatory in constructor (API)
committablefilectx has three subclasses: workingfilectx, memfilectx,
and overlayfilectx. committablefilectx takes an optional (change) ctx
instance to its constructor. If it's provided, it's set on the
instance as self._changectx. If not, that property is supposed to be
defined by the class. However, only workingfilectx does that. The
other two will have the property undefined if it's not passed in the
constructor. That seems bad to me. This patch makes the changectx
argument to the memfilectx constructor mandatory because that fixes
the failure I ran into. It seems like we should also fix the
overlayfilectx case.

Differential Revision: https://phab.mercurial-scm.org/D1658
2017-12-11 09:27:40 -08:00
Pulkit Goyal
a0250b29d4 rewriteutil: use precheck() in uncommit and amend commands
Differential Revision: https://phab.mercurial-scm.org/D1526
2017-11-28 05:50:45 +05:30
Pulkit Goyal
0456ca2613 unamend: drop unused vars, query after taking lock, use ctx.hex() for extras
This is the followup of review on D821.

Differential Revision: https://phab.mercurial-scm.org/D1579
2017-12-03 00:29:51 +05:30
Pulkit Goyal
c4428f695a uncommit: unify functions _uncommitdirstate and _unamenddirstate to one
The _unamenddirstate() function was inspired by _uncommitdirstate() function as
the logic was same but we were unable to use the latter function directly. So
previous patch introduced the _unamenddirstate() function and now this patch
unifies both the function and we have a _fixdirstate() function.

Adding function in previous patch and unifying in a later patch makes the
reasoning easier and also leaves the last patch dedicated to what it is meant to
be.

Differential Revision: https://phab.mercurial-scm.org/D971
2017-10-06 04:17:36 +05:30
Pulkit Goyal
9e302c97ba unamend: move fb extension unamend to core
unamend extension adds an unamend command which undoes the effect of the amend
command. This patch moves the unamend command from that extension to uncommit
extension and this one does not completely undoes the effect of amend command as
it creates a new commit, rather than reviving the old one back.

This also adds tests for the same.

.. feature::

   A new unamend command in uncommit extension which undoes the effect of the
   amend command by creating a new changeset which was there before amend and
   moving the changes that were amended to the working directory.

Differential Revision: https://phab.mercurial-scm.org/D821
2017-09-24 00:56:52 +05:30
Pulkit Goyal
5fe15c38d8 py3: handle keyword arguments in hgext/uncommit.py
Differential Revision: https://phab.mercurial-scm.org/D1323
2017-10-23 00:06:23 +05:30
Boris Feld
25a39ffc75 configitems: register the 'experimental.uncommitondirtywdir' config 2017-10-12 00:38:18 +02:00
Pulkit Goyal
00565cf47d uncommit: add an experimental.uncommitondirtywdir config
There are people who wants to do `hg uncommit` on dirty working directory, so
this patch adds a config which can be used to the achieve that.

Adds tests for the same.

Differential Revision: https://phab.mercurial-scm.org/D735
2017-09-20 02:40:25 +05:30
Pulkit Goyal
060e15ae30 uncommit: don't allow bare uncommit on dirty working directory
As per IRC discussion and suggestion by Augie, we should not allow bare `hg
uncommit` on dirty working directory.

Differential Revision: https://phab.mercurial-scm.org/D734
2017-09-20 02:18:01 +05:30
Pulkit Goyal
cbd5fda657 uncommit: rename the flag 'empty' to 'keep' which retains empty changeset
This patch renames the flag 'empty' which retains the empty changeset if all
the files are uncommitted to 'keep'.

Differential Revision: https://phab.mercurial-scm.org/D726
2017-09-16 02:34:13 +05:30
Pulkit Goyal
64bd8ed9ad uncommit: move fb-extension to core which uncommits a changeset
uncommit extension in fb-hgext adds a uncommit command which by default
uncommits a changeset and move all the changes to the working directory. If
file names are passed, uncommit moves the changes from those files to the
working directory and left the changeset with remaining committed files.

The uncommit extension in fb-hgext does not creates an empty commit like the one
in evolve extension unless user has specified ui.alllowemptycommit to True.

The test file added is a combination of tests from test-uncommit.t,
test-uncommit-merge.t and test-uncommit-bookmark.t from fb-hgext.

.. feature::

   A new uncommit extension which provides `hg uncommit` using which one can
   uncommit part or all of the changeset. This command undoes the effect of a
   local commit, returning the affected files to their uncommitted state.

Differential Revision: https://phab.mercurial-scm.org/D529
2017-08-24 22:55:56 +05:30