Commit Graph

178 Commits

Author SHA1 Message Date
Durham Goode
d8291a43e1 histedit: fix --edit-plan
--edit-plan was completely broken from the command line because it used an old
api that was not updated (it would crash with a stack trace). Let's update it
and add tests to catch this.
2015-04-22 15:53:03 -07:00
FUJIWARA Katsunori
cc87b5c26d histedit: fix reST syntax problem of example code in help document
To show example code correctly in online help, text block of it should
be preceded by "::" and indented.
2015-04-28 23:27:18 +09:00
Wagner Bruna
9e590e39d1 histedit: fix typo in abort message 2015-04-21 21:01:17 -03:00
Durham Goode
f289436208 histedit: fix rollup prompting for a commit message (issue4606)
Commit 960f8ca79ab1 broke histedit's rollup by causing it to open the editor.
Turns out I missed a spot where the rollup option was read.

This fixes that and adjusts the test to catch this case.
2015-04-20 18:44:57 -07:00
Durham Goode
71ec25235f histedit: change state format to allow non-hash lines
The existing state serialization format assumed the rule line consisted of an
action and a hash. In our external extension that adds 'exec' this is not the
case (there is no hash, just the shell command). So let's change the format to
be more generic with just an action and a remainder, and the various commands
can handle it as they wish.

Flagged for stable since we want to get this format tweak in before the new
format goes live in the release.
2015-04-17 09:46:43 -07:00
Durham Goode
7f3a86f2d3 histedit: delete all non-actionclass related code
Now that all actions have been migrated to the class format, we can delete all
the unnecessary code that supported the old function format.
2015-04-04 02:16:48 -07:00
Durham Goode
adafa999c2 histedit: improve roll action integration with fold
Previously the fold action would inspect it's class to figure out if it was a
rollup or not. This was hacky. Now that finishfold is inside the fold class,
let's modify it to check a function (which roll can override) to determine if it
should be prompting for a commit message.
2015-04-04 02:12:53 -07:00
Durham Goode
e4084f95da histedit: move finishfold into fold class
Let's move the finishfold function into the fold class so we can modify it from
the roll class more easily.
2015-04-04 02:12:24 -07:00
Durham Goode
cdb6754f26 histedit: convert fold/roll actions into a class
This converts the fold/roll actions into a histeditclass instance, as part of an
ongoing effort to refactor histedit for maintainability and robustness.

The tests changed for two reasons:

1) We get a new 'empty changeset' warning because we now warn more consistently
between normal histedit and --continue about commits disappearing.

2) Previously we were not putting the histedit-source extra field on the
temporary fold commit during normal runs, but we were on --continue runs. By
unifying these code paths we now consistently put histedit-source on the
temporary fold commit, which changes some of the hashes in the backup bundles.
2015-04-04 02:03:27 -07:00
Durham Goode
162b56f0ee histedit: convert edit action into a class
This converts the edit action into a histeditclass instance, as part of an
ongoing effort to refactor histedit for maintainability and robustness.
2015-04-04 01:00:51 -07:00
Durham Goode
3c8163667a histedit: convert message action into a class
This converts the message action into a histeditclass instance, as part of an
ongoing effort to refactor histedit for maintainability and robustness.
2015-04-04 00:42:32 -07:00
Durham Goode
9f8ec725b7 histedit: convert drop action into a class
This converts the drop action into a histeditclass instance, as part of an
ongoing effort to refactor histedit for maintainability and robustness.
2015-04-04 00:30:01 -07:00
Durham Goode
e59cce69af histedit: convert pick action into a class
This converts the pick action into a histeditclass instance, as part of an
ongoing effort to refactor histedit for maintainability and robustness.

The test output changed because previously pick would only report the commit
disappearing if there were no merge conflicts. Now that we've unified the normal
and the --continue flows, they act the same and we get the warning even after
--continue.
2015-04-04 11:39:08 -07:00
Durham Goode
0cfabb416a histedit: integrate action class into flow
This takes the newly added histeditaction class and integrates it into the
histedit run and bootstrapcontinue logic. No actions implement the class yet,
but they will be add in upcoming patches.
2015-04-04 11:37:08 -07:00
Durham Goode
2da5a94d9a histedit: add a new histeditaction class
This adds a new class called histeditaction. It represents a single action in a
histedit plan. Future patches will integrate it into the histedit flow, then
convert each existing action in to the class form one by one.

This is part of a larger refactor aimed at increasing histedit robustness,
maintainability, and extensibility.
2015-04-04 11:34:53 -07:00
Durham Goode
8cf27316ea histedit: allow histedit --continue when not on a descendant (BC)
Previously we would not allow --continue if the current working copy parent was
not a descendant of the commit produced by the previous histedit step. There's
nothing really blocking us from continuing the histedit in this situation, so
let's stop aborting in this case.

This is technically a BC change, but it is making things more forgiving so I
think it's ok.

In the future we will likely add an 'exec' action to histedit, which means the
user can do whatever they want during the middle of a histedit (like perhaps
calling 'hg update'), which means we'll need to support this case eventually
anyway.
2015-04-04 01:00:05 -07:00
Durham Goode
2d8e97020e histedit: store backup file before histedit
It's possible for the user to delete some of the commits they started with
during a histedit, and aborting the histedit doesn't bring them back. Let's
store a backup bundle so we can always recover the stack of commits from before
they began.
2015-04-04 02:37:43 -07:00
Durham Goode
ecf9be40a5 histedit: replace pickle with custom serialization
Pickle is undesirable, so let's serialize it ourselves. We keep the ability to
parse existing pickle blobs for now.
2015-04-13 08:23:57 -07:00
Durham Goode
04eb9da604 histedit: fix preventing strips during histedit
We were trying to prevent strips of important nodes during histedit,
but the check was actually comparing the short hashes in the rules to
the exact value the user typed in, so it only ever worked if the user
typed a 12 character hash.
2015-04-04 11:24:48 -07:00
Durham Goode
e49196de24 histedit: remove extra histedit constructor call
In a previous commit we removed the extra histedit object instance being
constructed in --continue and --abort. The new --edit-todo missed this fix
though (which means the state object it produces doesn't have the locks on it).
It's not breaking anything now, but let's go ahead and clean that up before we
forget.
2015-03-11 07:19:55 -07:00
Anton Shestakov
638673ec74 histedit: use better meta-variable names than VALUE in help text
Before this change hg help histedit would use the default variable label:

    --commands VALUE
...
 -r --rev VALUE [+]

With this change the text will be in the usual help text style and a bit more
explanatory:

    --commands FILE
...
 -r --rev REV [+]
2015-03-09 14:32:17 +08:00
Anton Shestakov
23b1ae0b86 histedit: tweak --commands help text
The rest of help messages for command arguments are simple phrases without any
ending punctuation, so having this text be a complete sentence didn't really
fit.
2015-03-09 14:10:42 +08:00
Mateusz Kwapich
0ddde4bfd1 histedit: add a config allowing changing histedit rule line length limit
Since many users are using terminals wider than 80 chars there should be an
option to have longer lines in histedit editor.

Even if the summary line is shorter than 80 chars after adding action line
prefixes (like "pick 7c2fd3b9020c") it doesn't fit there anymore. Setting
it to for example 110 would be a  nice option to have.
2015-01-21 14:45:24 -08:00
Matt Mackall
94d4298620 histedit: fix style of new error message
- lowercase
- no punctuation
- brief
- short node
2015-03-03 17:28:05 -06:00
Mateusz Kwapich
f867af76c9 histedit: add --edit-plan option to histedit
--edit-plan allows user to edit remaining histedit rules in the middle of
histedit process
2015-01-22 12:36:38 -08:00
Mateusz Kwapich
ddb3155c4d histedit: generalize makedesc
Allow makedesc to generate description for any action - not only pick.
(to be used in histedit --edit-plan)
2015-01-22 10:52:50 -08:00
Mateusz Kwapich
3735b62df2 histedit: extract method ruleeditor
Extract functionality of editing histedit rules to separate method so we can
reuse it in upcoming --edit-plan option.
2015-02-23 10:57:27 -08:00
Durham Goode
8504194a9f histedit: don't recreate state object
Previously, the histedit state object was being recreated during continue/abort.
This meant that the locks that were held on the original state object were not
available to actions, which meant actions could not release the lock on the
repository (like an 'exec' action would need to do).

This affected our internal extension that added the 'exec' action.
2015-02-17 19:59:26 -08:00
Mateusz Kwapich
d8c405977d histedit: switch state to store node instead of ctx
Currently, if the node no longer exists, the state object fails to load
and pukes with an exception. Changing the state object to only store the
node allows callers to handle these cases.  For instance, in
bootstrapcontinue we can now detect that the node doesn't exist and exit
gracefully.

The alternative is to have the state object store something like None
when the node doesn't exist, but then outside callers won't be able to
access the old node for recovery (unless we store both the node and the
ctx, but why bother).

More importantly it allows us to detect this case when doing hg histedit
--abort.  Currently this situation results in both --continue and
--abort being broken and the user has to rm .hg/histedit-state to unwedge
their repo.
(description by Durham Goode)
2015-02-05 13:10:07 -08:00
Mateusz Kwapich
aa07ec44a0 histedit: don't allow to strip nodes which are necessary to continue histedit
During histedit we don't want user to do any operation resulting in
stripping nodes needed to continue history editing. This patch
wraps the strip function to detect such situations.
2015-01-30 16:47:35 -08:00
Durham Goode
14bdd4051b histedit: allow configuring default behavior
Adds a configuration setting for allowing users to specify the default behavior
of 'hg histedit' without arguments. This saves users from having to manually
figure out the bottom commit or a complicated revset. My current revset of
choice is "only(.) & draft() - ::merge()"

The commits that histedit can work with is usually quite limited, so if this
feature ends up working well, we may want to consider making "only(.) & draft()
- ::merge()" the default behavior for everyone.
2015-02-02 16:19:35 -08:00
Mateusz Kwapich
4e97391ce2 histedit: store full node hash in rules
Previously histedit only stored the short version of the rule nodes in the
state. This meant that later we couldn't resolve a rule node to its full
form if the commit had been deleted from the repo.

Let's store the full form from the beginning.
2015-01-26 15:18:07 -08:00
Augie Fackler
fae3cac059 histedit: miscellaneous style cleanups
Fix some mis-wrapped lines, re-wrap some lines to be more compact,
remove superfluous parens.
2014-10-16 14:55:45 -04:00
Augie Fackler
7c83341fc3 histedit: update docstring on histeditstate.read()
The docstring showed the previous class-less heritage of read(). Now
that it's classy, update the docstring.
2014-10-16 14:51:15 -04:00
Augie Fackler
09cf4ee603 histedit: remove now-superfluous repo argument from processreplacement
Spotted by Olle on the mailing list during review.
2014-10-16 14:49:46 -04:00
David Soria Parra
c65ab5256c histedit: move locks into state
Allow action functions to control the locks. This is necessary for
an implementation of x/exec or similar.
2014-10-15 08:38:36 -07:00
David Soria Parra
682ab7e2b3 histedit: read state from histeditstate
Read the state in histeditstate. This allows us to correctly update
internal variables when necessary without having to recreate a new
state.  When we read a state in _histedit state while we will already
have state passed from histedit(), we can read the state in place
and don't have to merge two histeditstates.
2014-10-15 08:38:16 -07:00
David Soria Parra
11e6c07280 histedit: pass state to action functions 2014-10-15 08:18:26 -07:00
David Soria Parra
458406fb0a histedit: pass state to processreplacement 2014-10-16 10:06:49 -07:00
David Soria Parra
f49484c47e histedit: pass state to boostrapcontinue
Pass the state to boostrapcontinue and remove the unecessary passing
of repo.
2014-10-15 08:06:15 -07:00
David Soria Parra
e76bcb59ab histedit: let the state expose a context but serialize correctly to nodes
The histedit code often expects a context. However histedit hands
around the tuple for the serialization and therefore hand over a
parentctxnode. This leads to code having to return a context based
on the parentctxnode. We let the state only return a context but
correctly serialize and deserialze to a node.
2014-10-15 17:11:54 -07:00
David Soria Parra
98dfaf4629 histedit: add clear method to remove state
Encapsulate the unlinking histedit-state and use the vfs layer instead of
os.unlink.
2014-10-15 17:30:57 -07:00
David Soria Parra
db9d057e8e histedit: use state object where necessary
We are using the properties from the state object where necessary and
ensure that the state is set correctly.
2014-10-14 20:35:17 -07:00
David Soria Parra
80d1c27177 histedit: add histedit state class
Add an histeditstate class that is intended to hold the current
state.  This allows us encapsulate the state and avoids passing
around a tuple which is based on the serialization format. In
particular this will give actions more control over the state and
allow external sources to have more control of histedits behavior,
e.g. an external implementation of x/exec.
2014-10-15 17:17:12 -07:00
Durham Goode
faa1c33f8b obsolete: add allowunstable option
This option allows the creation of unstable commits. This allows things like
amending in the middle of a stack of commits, etc.
2014-10-14 13:25:13 -07:00
Durham Goode
18f3737f3a obsolete: add createmarkers option
The basic obsolete option is allowing the creation of obsolete markers. This
does not enable other features, such as allowing unstable commits or exchanging
obsolete markers.
2014-10-14 13:23:52 -07:00
Martin von Zweigbergk
c8176c1f40 histedit: access status fields by name rather than index 2014-10-04 21:19:44 -07:00
Matt Mackall
a61dbef490 histedit: use merge.graft 2014-10-13 17:12:47 -05:00
Matt Mackall
f663e5fc01 duplicatecopies: move from cmdutil to copies
This is in preparation for moving its primary caller into merge.py,
which would be a layering violation in the current location.
2014-10-13 14:33:13 -05:00
Matt Mackall
9286044a06 histedit: fix indent
The duplicatecopies call should be part of the rebase block.
2014-10-13 14:04:11 -05:00