Commit Graph

48 Commits

Author SHA1 Message Date
Durham Goode
f260c80298 configs: register more of our configs
Upstream has added devel warnings that require us to register all the configs
and remove the defaults that are specified at read time. This doesn't fix all
the cases, but is the start.

Differential Revision: https://phab.mercurial-scm.org/D1206
2017-10-23 20:02:57 -07:00
Jun Wu
415f5074b3 undo: do not run undolog for every command
Previously, undolog runs for every command, which sometimes adds unwanted
noticeable overhead like `hg status` with a large obsstore. This patch makes
undo smarter to only log commands that actually write things.

This is done by making undolog only run for transactions, updates (legacy
code that does not require a transaction). Tests are changed to reflect
`hg status` does not trigger undolog, and the new code seems to work better
with chg.

Differential Revision: https://phab.mercurial-scm.org/D739
2017-09-21 14:38:43 -07:00
Felix Merk
c2634fb76a undo: work better with chg
chg runs a mercurial command, we want to see which actual commands are run and
don't want to wrap at the chg level.

Differential Revision: https://phab.mercurial-scm.org/D504
2017-08-24 13:17:02 -07:00
Felix Merk
48ec146530 undo: better error messaging and hiding hg serve commands
In interactive mode, disables out of bounds <-,-> notifying the user with text
and a '\a' sound.  Friendlier ui messages for when the user selects the current
state with the arrow keys or when trying to undo to a state before we recorded
anything.  Hg serve commands generally aren't user executed and simply should be
skipped across when undoing (like unfinished states).  The user can always use
--absolute to see them in preview and to undo to them.

Differential Revision: https://phab.mercurial-scm.org/D502
2017-08-24 12:29:40 -07:00
Jun Wu
0dcbdce81e undo: explicitly disable pager on viewframe
`cmdutil.graphlog` may start pager. Explicitly disable it during
`viewframe.__init__` so the output won't get messed up.
2017-08-24 01:17:41 -07:00
Jun Wu
a2c1b1b707 undo: abort earlier if -i is specified
Check unfinished state and dirty working copy first so people won't get an
abort after selecting a state in the interactive interface.
2017-08-24 01:17:41 -07:00
Jun Wu
6363c9a947 undo: import interactiveui directly
This allows `undo -i` to always work.
2017-08-24 01:17:41 -07:00
Felix Merk
f9fd057193 undo: include ancestor in preview 2017-08-23 18:50:25 -07:00
Felix Merk
9df57fe0d2 undo: preview change - just show delta
Change preview to just show the delta and connected commits.  This means we need
to calculate oldworkingcopyparent and bookmarks diffs.  This output will be
cleaner especially for people with a lot of commits in their repo.

Differential Revision: https://phab.mercurial-scm.org/D467
2017-08-22 10:18:03 -07:00
Felix Merk
fcd302bf7b undo: draft obsolete commits
Visible obsolete commits are slightly tricky.  For example, an amend in the
middle of a stack will leave behind a visible obsoleted commit.  This diff
removes visible obsolete commits from 'olddraft()'.  This removes the need for
some special casing and allows for a more powerful preview.

Differential Revision: https://phab.mercurial-scm.org/D463
2017-08-21 13:28:50 -07:00
Felix Merk
cfbbbdf2c6 undo: preview perf improvements
Based on Adam Simpkin's ideas, faster code for the template functions.

Differential Revision: https://phab.mercurial-scm.org/D462
2017-08-21 13:28:50 -07:00
Felix Merk
e45f912211 undo: preview shows command and time output
Makes hg undo -i and hg undo -p output show an "undo to time, before command"
message and adds directions (left, right, return, q).  Also adds pager check as
pager break interactiveui.

Testing: run hg undo -p and hg undo -i and see output

Differential Revision: https://phab.mercurial-scm.org/D448
2017-08-21 11:25:36 -07:00
Felix Merk
721459469f undo: draft obsolete handling
Obsoleted commits may be visible.  To make sure that they are un-obsoleted after
undo when appropriate, we add "draft() & obsolete()" recording.  The most common
case where this matters is undoing a mid stack amend.

Differential Revision: https://phab.mercurial-scm.org/D438
2017-08-18 11:40:18 -07:00
Felix Merk
2d555e35dd undo: informative output
Instead of the _showstats output from hg.py, we now output the args and time of
the mercurial command we are undoing.

Differential Revision: https://phab.mercurial-scm.org/D412
2017-08-18 11:37:45 -07:00
Felix Merk
aa2547d949 undo: unfinished command handling
hg rebase, histedit, unshelve and other commands may stop in an unfinished state
because of merge conflicts or other reasons.  The user then has the ability to
continue or abort.  Undoing in this case is slightly tricky as for example
aborting a rebase will perform real strips and so undo will fail with an error.
This change still records these states, but flags them as unfinished and skips
over them when undoing and redoing.  Hg undo --absolute does not ignore these
states in the really unlikely situation you want to go to one of them.

Differential Revision: https://phab.mercurial-scm.org/D410
2017-08-18 11:37:45 -07:00
Ryan McElroy
674d828aad undo: allprecursors -> allpredecessors
Summary: Per upstream name changes. Eliminated develwarns.

Reviewers: #fbhgext, simonfar

Reviewed By: #fbhgext, simonfar

Differential Revision: https://phab.mercurial-scm.org/D432
2017-08-18 03:11:29 -07:00
Ryan McElroy
7770cdf605 undo: precnode -> prednode
Summary: Names be a'changin.

Reviewers: #fbhgext, simonfar

Reviewed By: #fbhgext, simonfar

Differential Revision: https://phab.mercurial-scm.org/D427
2017-08-18 03:11:29 -07:00
Felix Merk
3f41f783a1 undo: performance improvement attempt
Undo -p is really slow on certain large repos.  This caches 'olddraft()' by
using the revlog nodes.  Since revlogs are immutable this should be really safe
and could hopefully dramatically improve not only hg undo -p performance, but
performance of all undo commands.

Differential Revision: https://phab.mercurial-scm.org/D439
2017-08-17 16:45:37 -07:00
Felix Merk
00870d6060 undo: don't break when undo isn't first argument
Undo commands where undo wasn't first, for example `hg --pager=off undo` break
multiple things, including hg redo.  This change fixes this.

Differential Revision: https://phab.mercurial-scm.org/D396
2017-08-15 16:56:25 -07:00
Felix Merk
8a98220afc undo: invalidate false cache
Mercurial sometimes leaves bad caches.  Easiest example is when updating to a
hidden commit, where hg undo will fail, but can be reproduced with many commands
(such as fold which is used for testing here).

Test Plan:
unit tests

Differential Revision: https://phab.mercurial-scm.org/D395
2017-08-15 16:56:25 -07:00
Felix Merk
1ab935a4dc undo: add Scuba logging
Adds scuba logging to dev command timers so we can see how often some seemingly
unlikely edge (error) cases happen.  Once we are confident that hg undo is
stable we can get rid of these logs.  This is specifically for things that
don't loudly fail (since the user shouldn't care about them) but we still would
like to know about.  Note that
[sampling]
key.undo=perfpipe_dev_command_timers
is needed in an hgrc file for this to work.

Test: deleted gap file, ran undo and confirmed error was noted in dev command
timers

Differential Revision: https://phab.mercurial-scm.org/D357
2017-08-15 16:50:40 -07:00
Felix Merk
db3ca9f593 undo: improved --branch handling
Adds --branch handling to the no argument redo.  Also adds better branch testing
and takes a more sensible approach to an undo after an undo --branch.

Redo now restores undoredo.i's --branch field.  Undo after a undo --branch is
now an absolute undo.  See test cases.

Test Plan:
unit

Differential Revision: https://phab.mercurial-scm.org/D324
2017-08-11 18:05:03 -07:00
Felix Merk
5cd0a8ae43 undo: better docs
Strips docs of unnescerary info and sticks complex things behind --verbose flag.
In most cases hg undo and redo or hg undo --preview should be enough for the
user.  Also changes --index to --step, which seems clearer.

Differential Revision: https://phab.mercurial-scm.org/D287
2017-08-11 18:05:03 -07:00
Felix Merk
1041cbca21 undo: no argument redo
Changes redo to straight up undo the previous undo.  This is a bit trickier than
it may seem.  The previous redo capabilities are still covered in hg undo as
--index accepts negative numbers allowing you to step both forward and
backwards one step at a time.  The new redo reads the linear undo log to find
out where to undo to while updating the undo/redo index allowing you to continue
from where you left off.

Differential Revision: https://phab.mercurial-scm.org/D286
2017-08-11 18:05:03 -07:00
Felix Merk
a0591aa926 undo: preview interactive ui
Provide interactive preview.  undo -p now provides support of using arrow keys
and return to select state.  The interactive ui is set up to be generic so
potentially could be used for other commands.

Test Plan:
1. Running a bash script that sets up an interesting repo
2. hitting hg undo -p and trying every key combination
    Specifically: control-C still works, q quits, left goes forward,
    right goes backwards, return brings you to a state
3. running redo after preview and return
4. running undo a few times and then using undo -p to go back forward
5. going out of bounds both up and down
6. hitting other random keys during hg undo -p
7. running hg undo -p with other flags

Differential Revision: https://phab.mercurial-scm.org/D263
2017-08-11 18:05:03 -07:00
Felix Merk
223355effd undo: add --index and redo support to preview
Adds --index handling for --preview.  With the added handling, preview also
works for redo.  In order to bypass template logic, we simply change the
"undoredo.i" file and reset it afterwards.

Differential Revision: https://phab.mercurial-scm.org/D207
2017-08-11 18:05:03 -07:00
Felix Merk
070ee13318 undo: basic --preview
Allows for hg undo --preview to see smartlog like preview of what undo will do.
This will be neccesery before a general roll-out so users can see what undo will
do.  This first iteration only shows what "hg undo" will do, not redo and not
--index.

Differential Revision: https://phab.mercurial-scm.org/D206
2017-08-11 18:05:03 -07:00
Kostia Balytskyi
c979f86f0a lint: fix undo-related warnings
Summary: Before this `test-check-code-hg.t` failed on `undo`-related things.

Test Plan: - rt

Reviewers: felixmerk, #fbhgext

Differential Revision: https://phab.mercurial-scm.org/D226
2017-08-04 06:08:23 -07:00
Felix Merk
582f47c3b4 undo: clean up bin/hex
Standardizes some bin/hex in hg undo.  hg stores node data in hex form to make
it easier to read its files and because it seems to resolve some parsing issues.
While converting everything to binary seems prudent, it proved non-trivial and
isn't a pressing concern.  If we want to make this change, we should do it
before hg undo is rolled out generally.  As no other extension should directly
access the data it doesn't seem that important.  Interesting information should
be available with the revsets already.

Differential Revision: https://phab.mercurial-scm.org/D188
2017-08-03 15:17:21 -07:00
Felix Merk
2e993a8456 undo: localbrach fancy indexes
Adds smart indexing to localbranch undoes. This eliminates the mental burden of
the user of keeping track in what order and when changes where made.  Drawback
is that it raises the computational complexity from the number of draft
commits to draft commits times how many repo states you are undoing.  Common use
case should be to undo a small number of changes, so this is acceptable.

hg undo -b changectx finds the closest pertinent change and undoes that.  -b
with -n is not supported.  The reason it is not supported is that local branch
level undoes are delta specific and not state specific, which in essence means
that running hg undo -b # twice is not guaranteed to give you the same resault
as running hg undo -b # -n 2.  We could run -b multiple times for a -n, but the
cost of a -b increases with a larger -n (which isn't the case for a standard
undo), and abort handling would be more complicated (I'm not sure how well we
can roll back a tree of obs markers?).  In essence -n with -b is not that
usefull a feature (bc perf limits) and would potentially require a decently large
amount of time to implement correctly.

Also adds redo -b since this command now makes a lot more sense when we use the
smarter indexing.  Adds logic to seperate undoes and redoes in different
branches.  You can perform relative undoes and redoes within the latest scope,
while undoes and redoes within a new scope will start at the present (absolute)
state.

Differential Revision: https://phab.mercurial-scm.org/D186
2017-08-03 15:17:21 -07:00
Felix Merk
c280eb12b5 undo: basic single repo undo
Add the ability to undo changes within one 'localbranch'.  In the future, this
will probably become default behavior.  Undo -b changecontext will undo changes
belonging to the local branch identified by the changecontext (see revset
localbranch).  Based on obs markers we can identify connected commits that we
in turn reveal or hide outside of this localbranch.  This undo allows users to
work on multiple branches independantly.

Currently, indexing for undoes is still on the repo level.  This isn't good
from a ux experience.  Next up would be localbranch level indexing logic and
redo logic.

Differential Revision: https://phab.mercurial-scm.org/D160
2017-08-03 15:17:21 -07:00
Felix Merk
a10bb81e36 undo: localbranch revset
Adds localbranch revset to be used for localbranch undos.  A localbranch is a
set of draft commits that are connected via draft commits.  Any draft commit
within a branch, or a public commit at the base of the branch, can be passed as
an argument to localbranch().  This will be necessary for selecting the scope
for a localbranch undo.  Also fixes oldraft() output when used with other
revsets.  Previously olddraft() would ignore operators such as and because of a
missing the necessary handling.

Differential Revision: https://phab.mercurial-scm.org/D159
2017-08-03 15:17:21 -07:00
Felix Merk
9eb0bc6078 undo: prevent nested calls of log
Certain extensions (specifically infinite push) call full fledge mercurial
commands.  Since all proper mercurial commands might change the repo state,
these are tracked and changes are recorded, which at best causes confusing repo
states for the user and at worst prevents the user from undo-ing due to
precieved gaps in the log.  By using an env flag we can avoid this.

This change was tested in a repo with infinite push enabled with unit tests.

Differential Revision: https://phab.mercurial-scm.org/D198
2017-08-01 12:26:16 -07:00
Felix Merk
c63a96535a undo: cover lock error cases and add timeout
Lock error handling reduces likelyhood undo hangs or breaks other commands.
Fixes known bug of undo in read-only repo.  Undo is not neccesary for mercurial
to work and handles missing data (decently) well.  Failing silently (potentially
logging to scuba for timeouts) is acceptable, since if the issue is real we will
fail not silently when trying to undo.

Differential Revision: https://phab.mercurial-scm.org/D200
2017-08-01 12:24:44 -07:00
Felix Merk
782636d475 undo: file corruption handling
Basic file corruption handling: if file is corrupted, we nuke our history.
Downside is that we won't be able to undo furter back in case of a corruption,
but considering corruption this is expected.

Differential Revision: https://phab.mercurial-scm.org/D111
2017-07-19 17:49:21 -07:00
Felix Merk
82603807d7 undo: meaningful obs markers for undos
Makes obs markers for undos more meaningful.  When an undo performs a strict one
to one change, the written obs marker reflects that and the user even gets a
helpful ui message in smartlog.  One to many undos do not support such obs
markers (currently) because we can't tell splits and divergence apart easily.

Differential Revision: https://phab.mercurial-scm.org/D108
2017-07-19 17:49:21 -07:00
Felix Merk
0077b01e13 undo: add --keep to maintian working copy changes
Allow user to keep working copy changes after undo, mimicking unamend and
uncommit behavior.  As discussed at the team lunch, this allows undo to remain
ignorant of what command the user has run while conforming to user expectations.
In the future this could be done in a smarter way where we properly restore hg
status dynamically.

Differential Revision: https://phab.mercurial-scm.org/D55
2017-07-19 17:49:21 -07:00
Felix Merk
b86893cb84 undo: adds -f flag and gap edge case handling
Prevents users from accidentally crossing gaps in their history and adds an
overwride.  In most cases undoing across a gap isn't desired as the connection
between the pre and post states is unkown.  While undoing across a gap is not
destructive or inherently risky, it is inherently confusing to the user since
we don't know how many and what commands where run.  Furthermore, there is no
guarantee that the pre and post states of a gap are actually connected in any
sane way.

Differential Revision: https://phab.mercurial-scm.org/D53
2017-07-19 17:49:21 -07:00
Felix Merk
1fd69b2cab undo: implements relative undo, hg redo and tests
Implements, and makes default relative undos and adds redos.  A relative undo
behaves differently only if you haven't performend any repo changing operations
since your previous undo or redo, in which case you operate relative to that
undo/redo.  This means that a second undo will not undo the previous undo but
instead bring you furter back.

Differential Revision: https://phab.mercurial-scm.org/D52
2017-07-19 17:49:21 -07:00
Felix Merk
683f74bc3b undo: bare bones undo without tests
Adds undo command that changes working copy parent, bookmarks and
visible draft commits to a previous repo state.

Differential Revision: https://phab.mercurial-scm.org/D51
2017-07-19 17:49:21 -07:00
Jun Wu
c1a9fbc79e undo: move undolog to vfs and mark as lock-safe
The upstream has added some warning around repo.svfs/vfs write operations
without taking locks. For undo, we don't want to take the repo lock (since
that means read-only operations like `hg log` will be blocked by another
`hg commit`). So undo has its own locking and own transaction (for lower
overhead). Therefore move all files we may write (including lock and
transaction files) to `.hg/undolog` and whitelist the directory at
`localrepository._wlockfreeprefix` to bypass the checks.

Differential Revision: https://phab.mercurial-scm.org/D112
2017-07-18 11:30:05 -07:00
Felix Merk
4fdf562a93 undo: improved performance and prep for hg undo
Implements lighttransaction(repo) which improves performance of hg undo and
prevents infinite loops caused by hooks that run true hg commands.  Also adds
_getrevlog and _invertindex commands, factoring out code that will be reused.
Changes output for gaps when typing hg debugundohistory -l for slightly
better ui and clearer testing. Lastly, changes lock from repo lock to new
undolog lock and tests this.  In the future, with some changes to undo.log,
we may be able to take the lock later, bypassing the need to take it for
read-only operations.

Differential Revision: https://phab.mercurial-scm.org/D50
2017-07-17 13:18:54 -07:00
Jun Wu
285b5a92e6 codemod: rewrite nested with
This is the result of running a codemod script:

  python ~/hg/contrib/codemod/codemod_nestedwith.py **/*.py

Plus a manual cleanup that removes the comment in `absorb/__init.py`.

See D76 for the codemod script.

Differential Revision: https://phab.mercurial-scm.org/D78
2017-07-17 12:02:08 -07:00
Felix Merk
5ddcdfffe8 undo: add olddraft revset to return previous drafts
Summary: Register `olddraft([index])` revset returning draft changesets using undo data.

Test Plan: unit tests

Reviewers: stash, #mercurial, quark

Reviewed By: quark

Subscribers: mitrandir, quark, medson, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5359322

Tasks: 19646287, 19261492

Signature: t1:5359322:1499122771:0a1e952a9bb4cd6b31d95a229ccb398cd6aafd1f
2017-07-03 19:01:09 -07:00
Felix Merk
ba1dce8f88 undo: deal with --hidden flag edge case
Summary:
Makes sure repo is filtered by the "visible" filter which hides hidden commits.
Otherwise --hidden flag can mass up "draftheads" storage.

Test Plan: Added a new test case.

Reviewers: #mercurial, quark

Reviewed By: quark

Subscribers: quark, medson, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5357222

Tasks: 19822306

Signature: t1:5357222:1499102417:ce78065d36841601fe0dfb1d615d7b3be28c5870
2017-07-03 19:01:09 -07:00
Felix Merk
955a9bfcce undo: allow user to list or see details about undoable commands run
Summary: add hg debugundohistory -l to view recent undoable transactions

Test Plan: unit test

Reviewers: #mercurial, stash, quark

Reviewed By: quark

Subscribers: quark, mitrandir, durham, stash, medson, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5325772

Tasks: 19646287

Signature: t1:5325772:1499122626:48dd25cee8ed8912c07a6c1dabb3d4286483a8b7
2017-07-03 19:01:09 -07:00
Felix Merk
1abcb63689 undo: amend transacts twice
Summary: amend performs two transactions, second without command which breaks our assertion, but possibly isn't an issue. This fixes the assertion.

Test Plan: unit tests

Reviewers: #mercurial, stash, quark

Reviewed By: quark

Subscribers: quark, stash, medson, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5326358

Tasks: 19261492

Signature: t1:5326358:1498684945:0fde1df243cdbac67ceb092d30599ebd56a731a5
2017-06-28 15:28:40 -07:00
Felix Merk
fbd87d6923 undo: store op history
Summary: Store basic operational history: bookmarks, commands, private heads, date and working copy parent

Test Plan: Unit tests

Reviewers: durham, #mercurial, mitrandir, quark

Reviewed By: quark

Subscribers: stash, mitrandir

Differential Revision: https://phabricator.intern.facebook.com/D5293596

Tasks: 19261492, 19563903, 19450726

Tags: Hg Undo

Signature: t1:5293596:1498245082:264e344054ee5061a439dec1c6071c2a60ffcf55
2017-06-23 12:19:09 -07:00