Commit Graph

337 Commits

Author SHA1 Message Date
timeless
538843243e histedit: improve missing rule suggestion
include actual suggested text
2015-12-02 07:41:35 +00:00
Mateusz Kwapich
0016ccb3cd histedit: get rid of state.rules
Now we are using state.actions instead of state.rules everywhere.
2015-12-02 12:19:01 -08:00
Mateusz Kwapich
eb6e47fe5e histedit: change state.rules uses to state.actions
This change is replacing most of state.rules uses with state.actions
uses. The next change will change histeditstate class to actually
uses state actions.
2015-12-02 12:19:01 -08:00
Mateusz Kwapich
45bd81cd16 histedit: add tostate method to histedit action
the format of rules that we store in state file format is different from the rule
format that we present to users. We need a way of dumping action to state file.
2015-12-02 12:19:01 -08:00
Mateusz Kwapich
5cf03a9c5a histedit: remove makedesc
It's a dead code now.
2015-12-02 12:19:01 -08:00
Mateusz Kwapich
574ed39bd6 histedit: use torule instead of makedesc in ruleeditor 2015-12-02 12:19:01 -08:00
Mateusz Kwapich
644cc338bd histedit: add torule method to histedit action objects
To make histedit action objects responsible for understanding
the format of their action lines we are adding a torule method
which for a histedit action will return a string which can be
saved in histedit state or shown in text editor when editing the
plan.
2015-12-02 12:19:01 -08:00
Mateusz Kwapich
278e9a38b4 histedit: add verify() to histeditaction
This commits splits the parsing of the histedit rule from its semantic analysis.
It's necessary because sometimes we want to do first without doing the former (reading the
histedit state).
2015-12-02 12:19:01 -08:00
Mateusz Kwapich
29346eb944 histedit: add addhisteditaction decorator
This decorator will is allowing us to move the registering the action
in actiontable closer to the action code. Also it is storing the
verb inside histedit action so the action is aware of the verb
needed to trigger it.
2015-12-02 12:19:01 -08:00
Mateusz Kwapich
122e188cce histedit: add actions property to histedit state
I want to refactor histedit to use action objects instead of (verb, rest)
pairs whenever possible. At the end of this series I want the rules to
be translated into action objects when reading state and translated back
when writing state. All histedit internals should use action objects instead
of state rules.

To migrate histedti internals sequentially I'm introducing the state.actions
property to translate rules on the fly so we can use both state.actions and
state.rules until refactoring is done.
2015-12-02 12:19:01 -08:00
timeless
787afdd271 histedit: mention histedit-last-edit.txt on abort
Users may spend a lot of effort writing histedit rules,
getting an abort without being told they can recover their work
is very frustrating.

Avoid that by telling them where to find their work.
2015-12-02 08:07:36 +00:00
timeless
40357ef4f4 histedit: add missing raise keyword to statement 2015-12-02 07:40:42 +00:00
timeless
139b830297 histedit: improve grammar for _histedit comment 2015-12-02 07:39:49 +00:00
Mykola Nikishov
0ee9a8cf79 histedit: edit with custom filename
For instance, Emacs allows to open file with special features enabled
(AKA mode) based on the path/name of the file [1]. For such cases, use
'hg-histedit-XXX.txt' as filename pattern.

[1] https://www.gnu.org/software/emacs/manual/html_node/emacs/Choosing-Modes.html
2015-11-21 17:40:26 +02:00
Mathias De Maré
bbe157b7e0 histedit: add examples 2015-11-25 18:26:48 +01:00
Augie Fackler
18e5d950ee histedit: constant-ify the constraints list
Used a class as a namespace, and then wired up a classmethod to return
all known constraints. I'm mostly happy with this, even though it's
kind of weird for hg.
2015-11-23 10:13:05 -05:00
Mateusz Kwapich
60093bd539 histedit: add an experimental base action
This is a first (very simple) version of the histedit base action.
It works well in common usecases like rebasing the whole stack and
spliting the stack.

I don't see any obvious edge cases - but probably there is more than one.
That's why I want to keep it behind experimental.histeditng config knob
for now. I think on knob for all new histedit behaviors is better because
we will test all of them together and testers will need to turn it on only
once to get all new nice things.
2015-11-17 15:04:31 -08:00
Mateusz Kwapich
0e2838b3e0 histedit: add abortdirty function
Small helper function for aborting histedit when left with dirty working
directory.
2015-11-17 17:53:52 -08:00
Mateusz Kwapich
0cd6ba356d histedit: add forceother constraint
For the future 'base' action in histedit we need a verification
constraint which will not allow using this action with changes
that are currently edited.
2015-11-12 16:40:33 -08:00
Mateusz Kwapich
45af8348f7 histedit: make verification configurable
Before we can add a 'base' action to histedit need to change verification
so that action can specify which steps of verification should run for it.

Also it's everything we need for the exec and stop actions implementation.

I thought about baking verification into each histedit action (so each
of them is responsible for verifying its constraints) but it felt wrong
because:
 - every action would need to know its context (eg. the list of all other
   actions)
 - a lot of duplicated work will be added - each action will iterate through
   all others
 - the steps of the verification would need to be extracted and named anyway
   in order to be reused

The verifyrules function grows too big now. I plan to refator it in one of
the next series.
2015-11-17 16:37:26 -08:00
Laurent Charignon
8ace80e21d histedit: make use of bookmarks.recordchange instead of bookmarks.write
Before this patch we were using the old api bookmarks.write, this patches
replaces its usage by bookmarks.recordchange, the new api to record bookmark
changes.
2015-11-20 13:23:47 -08:00
liscju
8a47b8ef21 histedit: extracts _isdirtywc function
Checking if working copy is dirty was done in few places, this
patch extracts it in _isdirtywc procedure.
2015-11-12 12:44:15 +01:00
Pierre-Yves David
eaea148fdb histedit: properly apply bundle2 backups
If the histedit fails, we restore a backup. We make sure this backup bundle can
be in bundle2 format as general delta will require.
2015-10-20 03:07:23 +02:00
Durham Goode
6c10065cf4 histedit: make histedit prune when obsolete is enabled
Back in June we made histedit use obsolete markers to cleanup when possible.
This was rolled back as part of bb3db0db4037 (which should have only rolled back
the --abort stuff, but rolled back everything). This caused a nasty bug when
used in conjuction with the inhibit+directaccess extensions where histedit would
leave old nodes around even after they had been squashed away.

The root of the problem is that we first clean up old nodes, and then we clean
up temp nodes. In the first pass, when we obsoleted old nodes, some would become
unobsolete because they had temp nodes on top of them, thus making them stick
around even after the histedit finished.

The fix is to A) move the temp node cleanup to be before the old node cleanup
(since they are topological on top of the old nodes), and B) use obsolete
markers instead of stripping.
2015-10-17 12:32:23 -07:00
Augie Fackler
f53d137cd7 histedit: use cg?unpacker.apply() instead of changegroup.addchangegroup() 2015-10-13 17:14:21 -04:00
Pierre-Yves David
30913031d4 error: get Abort from 'error' instead of 'util'
The home of 'Abort' is 'error' not 'util' however, a lot of code seems to be
confused about that and gives all the credit to 'util' instead of the
hardworking 'error'. In a spirit of equity, we break the cycle of injustice and
give back to 'error' the respect it deserves. And screw that 'util' poser.

For great justice.
2015-10-08 12:55:45 -07:00
Christian Delahousse
7472064a6f histedit: delete histedit statefile on any exception during abort
When an user aborts a histedit, many things could go wrong. At a minimum, after
a histedit abort failure, their repository should be out of that state. We've
found situations where the user could not exit the histedit state without
manually deleting the histedit state file. This patch ensures that if any
exception happens during an abort, the histedit statefile will be deleted so
that users are out of the histedit state and can at least manually get the repo
back to a workable condition.
2015-10-05 16:44:45 -07:00
Christian Delahousse
77b3596e11 histedit: check presence of statefile before deleting it
When the histeditstate class instance has it's clear() method called, there is
nothing to check to see if the state file exists before deleting it. It may not
exist, which would create an exception. This patch allows clear to be called at
any time.

This will be needed for the following patch.
2015-10-06 15:09:28 -07:00
Christian Delahousse
6f2b3a468a histedit: add inprogress method to state class
If a histedit is progress, the 'histedit-state' file should exist. The patch
implements a convenience function to do check if a histedit is in progress.

This method will be use in next patch in the series.
2015-10-05 16:34:17 -07:00
Pierre-Yves David
374e65cff5 histedit: remove a mutable default argument
Mutable default arguments are know to the state of California to cause bugs.
2015-09-24 00:38:34 -07:00
Augie Fackler
57b1966770 histedit: use one editor when multiple folds happen in a row (issue3524) (BC)
This was the first ever feature request for histedit, originally filed
back on April 4, 2009. Finally fixed.

In the future we'll probably want to make it possible for other
preprocessing steps to be added to the list, but for now we're
skipping that because it's unclear what the API should look like
without a proposed consumer.
2015-08-27 14:46:26 -04:00
timeless@mozdev.org
c07651e722 histedit: fix grammar in cleanupnode comment 2015-09-08 20:30:01 -04:00
timeless@mozdev.org
0ceae1ee9a histedit: fix English (en-US) 2015-08-28 13:52:49 -04:00
timeless@mozdev.org
e88cb37448 histedit: improve discoverability of edit commit message 2015-08-28 15:50:36 -04:00
timeless@mozdev.org
52eae47139 spelling: behaviour -> behavior 2015-08-28 10:53:55 -04:00
timeless@mozdev.org
b8d4ab1619 histedit: fix grammar for help for safety aborts 2015-08-28 11:31:44 -04:00
Augie Fackler
25ce37007c histedit: correct spelling etc in more comments
Spotted during review of another patch.
2015-08-17 22:56:12 -04:00
Pierre-Yves David
d1822462df histedit: add a missing "s" in a comment 2015-07-31 12:54:16 -07:00
Pierre-Yves David
d7dbab10fd histedit: do not stay on a cleaned nodes on abort
There is case where nodes are neither in tmpnodes nor leaf but still get
removed. For example, if you used the "edit" action, made a commit and run
--abort. The commit you made is not tracked by histedit, yet it will likely be
cleaned up with its parent. The commit may not tracked because no replacements
computations are done in the --abort case.
2015-08-03 06:13:05 -07:00
Pierre-Yves David
d31b5ec741 histedit: also update away from tmpnodes
The working copy may be on a tmpnodes, we need to update away before it is
stripped from the repository.
2015-08-03 06:11:45 -07:00
Pierre-Yves David
8eb6cf86e6 histedit: use revset to check if we need to update during abort
The for loop is already quite more complicated than necessary and we are about
to add some logic. Instead, we use a simple revset. Revset laziness should
provide us with similar performance.
2015-08-03 06:08:37 -07:00
Pierre-Yves David
063bf1acfb histedit: remove useless 'else' clause
This 'else: pass' clause have no effect. We drop it for clarity.
2015-08-03 05:57:45 -07:00
Pierre-Yves David
138cd324a8 histedit: make cleanupnode more robust
The goal of this function is to strip content out of the repository. We do not
really care if this content is visible or cleanup node not and we should proceed
anyway. None of the internal actions are subject to this, however, a third party
extension running arbitrary commands during histedit is affected by this.
2015-07-31 15:46:49 -07:00
Pierre-Yves David
a2cfbc8b70 histedit: extract a simpler function to process replacement on abort
The process replacement is building a full mapping to allow moving bookmarks and
creating obsolescence marker. We do not need the full logic for abort so we
extract it. It will be useful as abort is missing some data about the
replacement and can crash when third party extensions push it a bit too far.
2015-08-03 14:16:51 -07:00
Pierre-Yves David
6b2961e47a histedit: backout 3e883e7ec57b
The faulty changeset use obsolescence marker to roll the repository back on
--abort. This is a problematic approach because --abort should be as close as an
actually transaction rollback as possible stripping all created data from the
repository (cf `hg rebase --abort` stripping all created changesets). Instead
3e883e7ec57b made all content created during the aborted histedit still
available in the repository adding obsolescence marker to make them hidden. This
will cause trouble to evolution user as a re-run of the same histedit (with
success) will likely result in the very same node to be "recreated" while
obsolescence marker would be in place for them. And canceling an obsoletion is
still a fairly complicated process.

This also rollback using obsmarkers instead of strip to clean up temporary node
on successful histedit run because the two change were not split in separated
changeset. Rolling that part back does not have significant consequence a will
have to be resubmitted independently
2015-07-31 15:11:07 -07:00
Matt Mackall
f9425f2260 histedit: mark defaultrev option experimental 2015-06-25 17:37:35 -05:00
Laurent Charignon
e2ba5b2bbc histedit: mark temporary commits as obsolete when allowed to
Before this patch, we were stripping temporary commits at the end of a histedit
whether it was successful or not. If we can create obs markers, we should
create them instead of stripping because it is faster and safer.
2015-07-16 11:12:15 -07:00
Laurent Charignon
5d5716b606 histedit: minor refactoring of createmarkers check
We use a variable to store whether or not we can create obsolescence markers.
It makes the patch series more readable as we are going to reuse this
values in other places in the function.
2015-07-16 11:17:37 -07:00
Gregory Szorc
5380dea2a7 global: mass rewrite to use modern exception syntax
Python 2.6 introduced the "except type as instance" syntax, replacing
the "except type, instance" syntax that came before. Python 3 dropped
support for the latter syntax. Since we no longer support Python 2.4 or
2.5, we have no need to continue supporting the "except type, instance".

This patch mass rewrites the exception syntax to be Python 2.6+ and
Python 3 compatible.

This patch was produced by running `2to3 -f except -w -n .`.
2015-06-23 22:20:08 -07:00
Augie Fackler
7dfc9502d8 histedit: abort rather than edit a public changeset (issue4704)
This is suboptimal as the user still has to explicitly cancel the
histedit afterwards, but it prevents the immediate problem.

histedit should probably implicitly do 'hg histedit --abort' if a
util.Abort is raised internally.
2015-06-05 15:20:33 -04:00
Augie Fackler
a8bce1d268 histedit: copyedit docstring wording problem I noticed while here 2015-06-05 15:12:08 -04:00
Jordi Gutiérrez Hermoso
a6105df67a phases: add hg help phases hint to failures to edit public commits
There were a couple of locations that were missing this hint after an
edition of some kind failed due to the public phase.
2015-06-01 14:16:52 -04:00
Jordi Gutiérrez Hermoso
3ed01018a3 phases: rewrite "immutable changeset" to "public changeset"
The phrase "cannot edit immutable changeset" is kind of tautological.
Of course unchangeable things can't be changed. We instead mention
"public" and provide a hint so that we can point to the actual
problem. Even in cases where some operation other than edition cannot
be performed, "public" gives the root cause that results in the
"immutable" effect.

There is a precedent for saying "public" instead of "immutable", for
example, in `hg commit --amend`.
2015-06-01 18:05:38 +00:00
Matt Mackall
82ee6a7ddc merge with stable 2015-05-29 17:00:55 -05:00
Durham Goode
70caa9d8e9 histedit: fix keep during --continue
The --keep option was being serialized to the state file, but it wasn't actually
being used when running a histedit --continue. This fixes that.
2015-05-28 20:30:20 -07:00
Durham Goode
af1cd08e45 histedit: fix --continue when rules are finished
If histedit failed after all the rules were complete (for instance, if there was
an exception in the cleanup phase), you couldn't --continue because it was
unable to pop a rule. Let's just skip the rule execution phase of --continue if
there are no more rules.
2015-05-01 15:45:07 -07:00
Durham Goode
be15b493fa histedit: fix serializing of None backupfile
If the histedit backupfile was None (like if evolve is enabled) it would get
serialized as 'None' into the state file. Later if the histedit was aborted and
the top most commit was unreachable (ex: if it was obsolete or stripped),
histedit would try to unbundle the backupfile and try to read .hg/None.

This fixes it to not serialize None. Since it only happens with evolve, I'm not
sure how to add test coverage here.
2015-05-01 15:28:47 -07:00
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
Augie Fackler
f95a6caba1 extensions: document that testedwith = 'internal' is special
Extension authors (notably at companies using hg) have been
cargo-culting the `testedwith = 'internal'` bit from hg's own
extensions, which then defeats our "file bugs over here" logic in
dispatch. Let's be more aggressive about trying to give extension
authors a hint about what testedwith should say.
2015-04-28 16:44:37 -04:00
Augie Fackler
a5b17bd9d1 cleanup: use __builtins__.any instead of util.any
any() is available in all Python versions we support now.
2015-05-16 14:30:07 -04: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
Pierre-Yves David
256f11e0d3 histedit: stabilise the order nodes that are stripped
The `nodes` object is a set. We sort it to get stable order. This is going to
prevent revsets from getting confused when removing a `.set()` call in `roots`.
2014-10-10 13:31:00 -07:00
Augie Fackler
2ecee11b67 histedit: check mutability of contexts correctly
The right way to check if a context is mutable is to call .mutable(),
not to compare .phase() with public.
2014-08-19 14:33:01 -04:00
Durham Goode
a5a69f0001 dirstate: wrap setparent calls with begin/endparentchange (issue4353)
This wraps all the locations of dirstate.setparent with the appropriate
begin/endparentchange calls. This will prevent exceptions during those calls
from causing incoherent dirstates (issue4353).
2014-09-05 11:36:20 -07:00
Kevin Bullock
6cd9563e40 merge with stable 2014-09-07 11:46:11 -05:00
Siddharth Agarwal
ca3e00a8e3 histedit: abort gracefully on --continue/--abort with no state
Previously we'd print an ugly message saying that the histedit-state file
doesn't exist in the repo.
2014-09-03 20:42:51 +02:00
Mads Kiilerich
4dd236da3f convert: use None value for missing files instead of overloading IOError
The internal API used IOError to indicate that a file should be marked as
removed.

There is some correlation between IOError (especially with ENOENT) and files
that should be removed, but using IOErrors to represent file removal internally
required some hacks.

Instead, use the value None to indicate that the file not is present.

Before, spurious IO errors could cause commits that silently removed files.
They will now be reported like all other IO errors so the root cause can be
fixed.
2014-08-26 22:03:32 +02:00
Mike Edgar
7d4f56ed60 histedit: use str.startswith to check for comments in action list 2014-08-22 16:40:34 -04:00
Mike Edgar
f32b610c93 histedit: drop duplicate line extracting keep option 2014-08-22 16:37:55 -04:00
Martin von Zweigbergk
69e9a354a2 histedit: preserve initial author on fold (issue4296)
When the authorship of the changeset folded in does not match that of
the base changeset, we currently use the configured ui.username
instead. This is especially surprising when the user is not the author
of either of the changesets. In such cases, the resulting authorship
(the user's) is clearly incorrect. Even when the user is folding in a
patch they authored themselves, it's not clear whether they should
take over the authorship. Let's instead keep it simple and always
preserve the base changeset's authorship. This is also how
"git rebase -i" handles folding/squashing.
2014-08-13 11:50:13 -07:00
Augie Fackler
73aafc176d histedit: respect revsetalias entries (issue4311)
We now expand user-provided revsets before using repo.revs() to locate
the root(s) of the user-specified set.
2014-07-28 19:20:13 -04:00
Matt Mackall
25d1182c5d merge with stable 2014-08-14 15:21:48 -05:00
Mike Edgar
fb41d0ff84 histedit: add "roll" command to fold commit data and drop message (issue4256)
This new histedit command (short for "rollup") is a variant of "fold" akin to
"hg amend" for working copy: it accumulates changes without interrupting
the user and asking for an updated commit message.
2014-08-06 16:51:41 -04:00
Matt Mackall
7cba48bf37 whitespace: nuke triple blank lines in **.py 2014-08-07 14:58:12 -05:00
FUJIWARA Katsunori
f3bc52a2ae histedit: pass 'editform' argument to 'cmdutil.getcommiteditor'
This patch passes 'editform' argument according to the format below:

  EXTENSION[.COMMAND][.ROUTE]

  - EXTENSION: name of extension
  - COMMAND: name of command, if there are two or more commands in EXTENSION
  - ROUTE: name of route, if there are two or more routes for COMMAND

In this patch:

  - 'edit', 'fold', 'mess' and 'pick' are used as COMMAND
  - ROUTE is omitted

'histedit.pick' case is very rare, but possible if:

  - target revision causes conflict at merging (= requires '--continue'), and
  - description of it is empty ('hg commit -m " "' can create such one)

In the code path for 'histedit --continue' (the last patch hunk),
'canonaction' doesn't contain the entry for 'fold', because 'fold'
action causes:

  - using temporary commit message forcibly, and
  - making 'editopt' False always (= omit editor invocation if commit
    message is specified)
2014-08-02 21:46:26 +09:00
FUJIWARA Katsunori
9aa5fab4ec histedit: use 'util.ellipsis' to trim description of each changesets
Before this patch, trimming description of each changesets in histedit
may split at intermediate multi-byte sequence.

This patch uses 'util.ellipsis' to trim description of each changesets
instead of directly slicing byte sequence.

Even though 'util.ellipsis' adds '...' as ellipsis when specified
string is trimmed (= this changes result of trimming), this patch uses
it, because:

  - it can be used without any additional 'import', and
  - ellipsis seems to be better than just trimming, for usability
2014-07-06 02:56:41 +09:00
Sean Farley
1002b6c612 memfilectx: call super.__init__ instead of duplicating code
This patch changes the calling signature of memfilectx's __init__ to fall in
line with the other file contexts.

Calling code and tests have been updated accordingly.
2013-08-15 16:49:27 -05:00
FUJIWARA Katsunori
876753dee7 histedit: use "getcommiteditor()" instead of explicit editor choice for "--continue"
This omits (redundant) adding "\n' to "message", because:

  - empty line is inserted by "commitforceeditor", if editor is invoked
  - tail white-spaces are stripped at storing into chaneglog, otherwise

This patch also enhances "test-histedit-edit.t", because "hg histedit"
hasn't been explicitly tested around editor invocation and
"--continue" option.
2014-05-11 00:49:35 +09:00
FUJIWARA Katsunori
768da96e03 histedit: use "getcommiteditor()" instead of explicit editor choice for "fold"
This patch doesn't change any tests like as preceding patches, because
editor invocation is already tested in "test-histedit-fold.t".
2014-05-11 00:49:35 +09:00
FUJIWARA Katsunori
1d4d1b5665 histedit: use the editor gotten by "getcommiteditor()" for "message"
Before this patch, "hg histedit" for "message" uses "ui.edit()" for
commit message editing.

It shows original commit message, but not detail about the target
revision: status of each modified/added/removed files, for example.

This patch uses the editor gotten by "getcommiteditor()" instead of
"ui.edit()" for "message"

In "test-histedit-edit.t", this patch omits "fixbundle" invocation,
because it prevents from confirming the "HG: added f" line in commit
message by filtering " added " lines.

Omiting "fixbundle" invocation causes that the exit code of "hg
histedit" appears as one of command line: in this case, "hg histedit"
is aborted by (expected) exception raising.
2014-05-11 00:49:35 +09:00
FUJIWARA Katsunori
741eb22d11 histedit: pass "editor" argument to "memctx.__init__()" for "collapse" command
The preceding patch causes that "memctx.__init__()" with "editor"
argument invokes editor and saves edited commit message into
".hg/last-message.txt".

This patch passes "editor" argument to "memctx.__init__()" instead of
explicit invocations of "commitforceeditor()" and
"savecommitmessage()" for "collapse" command.
2014-05-05 21:26:40 +09:00
FUJIWARA Katsunori
6e45a5e5e2 histedit: use "editor" argument of "commit()" instead of explicit "ui.edit()"
Before this patch, "message" action of "hg histedit" uses "ui.edit()"
explicitly to get commit message edited manually.

This requires explicit "localrepository.savecommitmessage()"
invocation to save edited commit message into ".hg/last-message.txt",
because unexpected exception raising may abort command execution
before saving it in "localrepository.commit()".

This patch uses "editor" argument of "localrepository.commit()"
instead of explicit "ui.edit()" invocation for "message" action of "hg
histedit"

"localrepository.commit()" will invoke "editor()" function newly added
in this patch, and save edited commit message into ".hg/last-message.txt"
automatically.
2014-05-05 21:26:40 +09:00
Wagner Bruna
7f9ce654b1 histedit, i18n: replace '+' with concatenation to make hggettext happy 2014-04-22 10:14:16 -03:00
Matt Mackall
6f3036019b merge with stable 2014-04-14 15:14:02 -04:00
FUJIWARA Katsunori
89625609bb histedit: save manually edited commit message into ".hg/last-message.txt"
Before this patch, manually edited commit message for "message"
command in histedit-ing is not saved into ".hg/last-message.txt" until
it is saved by "localrepository.savecommitmessage()" in
"localrepository.commit()".

This may lose such commit message, if unexpected exception is raised.

This patch saves manually edited commit message for "message" comand
in histedit-ing into ".hg/last-message.txt" just after user editing.

This is the simplest implementation to fix on stable. Editing and
saving commit message should be centralized into the framework of
"localrepository.commit()" with "editor" argument in the future.

This patch uses repository wrapping class for exception raising before
saving commit message in "localrepository.commit()" easily and
certainly, because such exception requires corner case condition.
2014-04-15 03:21:59 +09:00
FUJIWARA Katsunori
7ccf898121 histedit: save manually edited commit message into ".hg/last-message.txt"
Before this patch, manually edited commit message for "fold" command
in histedit-ing is never saved into ".hg/last-message.txt", because it
uses "localrepository.commitctx()" instead of
"localrepository.commit()": saving into ".hg/last-message.txt" is
executed only in the latter.

This patch saves manually edited commit message for "fold" command in
histedit-ing into ".hg/last-message.txt" just after user editing.

This is the simplest implementation to fix on stable. Editing and
saving commit message for memctx should be centralized into the
framework like "localrepository.commit()" with "editor" argument or so
in the future.
2014-03-19 01:07:41 +09:00
David Soria Parra
8c28662ef9 histedit: select the lowest rev when looking for a root in a revset (bc)
When we specify a revision or a revset we just get the last element from the
list. For revsets this can lead to unintended effects where you specify a
revset like only() but instead histedit selects the highest revision in the
set as root. Therefore we should always use the lowest revision number as
root.
2014-03-13 16:05:06 -07:00
Mads Kiilerich
2629efac4f config: set a 'source' in most cases where config don't come from file but code
Some extensions set configuration settings that showed up in 'hg showconfig
--debug' with 'none' as source. That was confusing.

Instead, they will now tell which extension they come from.

This change tries to be consistent and specify a source everywhere - also where
it perhaps is less relevant.
2014-03-19 02:45:14 +01:00
Matt Mackall
ea6ffc9a80 merge with stable 2014-03-18 14:25:28 -05:00
Olle Lundberg
572e5a90a5 histedit: move logic for finding child nodes to new function
This function will be used in later patches.
2014-03-06 01:24:03 +01:00
Olle Lundberg
eafad841b7 histedit: clean up lock imports
We are alread importing the release function from lock, no need
to actually import the module too.
2014-03-05 22:02:45 +01:00
Matt Mackall
b35d905ff6 histedit: shorten new fold message
Lots of people, like Mr. Check-Code, insist on using 80-column terminals.
2014-02-15 19:12:53 -06:00
Adrian Zgorzałek
4f40289598 histedit: clarify description of fold command
N and (N-1) didn't add any information to description of fold.
More useful is refering to the commit list as it is displayed in editor.
2014-02-13 18:05:35 -08:00
Siddharth Agarwal
def3d4797d histedit: hold wlock and lock while in progress
Currently, histedit acquires and releases lock and wlock several times during
its run. This isn't great because it allows other hg processes to come in and
change state. With this fix, lock and wlock are acquired and released exactly
once.

The change to test-histedit-drop.t is a minor implementation one -- the cache
is still correctly invalidated, but it just happens a little later and only
gets printed out because of the unrelated --debug flag.
2013-11-17 15:11:09 -08:00
FUJIWARA Katsunori
6371252cb7 histedit: add description about exit code 2013-10-27 00:24:25 +09:00
Matt Mackall
7b8a7d221c merge with stable 2013-10-01 17:00:03 -07:00
FUJIWARA Katsunori
da45f9c6a0 histedit: suggest "histedit --abort" for inconsistent histedit state
Mercurial earlier than 2.7 allows users to do anything other than
starting new histedit, even though current histedit is not finished or
aborted yet. So, unfinished (and maybe inconsistent now) histedit
states may be left and forgotten in repositories.

Before this patch, histedit extension shows the message below, when it
detects such inconsistent state:

   abort: REV is not an ancestor of working directory
   (update to REV or descendant and run "hg histedit --continue" again)

But this message is incorrect, unless old Mercurial is re-installed,
because Mercurial 2.7 or later disallows users to update the working
directory to another revision.

This patch changes the hint message to suggest "hg histedit --abort".
2013-10-01 00:35:07 +09:00
FUJIWARA Katsunori
0aaf5e6516 histedit: add more detailed help about "--outgoing" 2013-10-01 00:12:34 +09:00
FUJIWARA Katsunori
e27c19b1b7 histedit: abort if there are multiple roots in "--outgoing" revisions
Before this patch, if there are multiple roots in "--outgoing"
revisions, result of "histedit --outgoing" depends on the parent of
the working directory. It succeeds only when the parent of the working
directory is a descendant of the oldest root in "--outgoing"
revisions, and fails otherwise.

It seems to be ambiguous and difficult for users.

This patch makes "histedit --outgoing" abort if there are multiple
roots in "--outgoing" revisions always.
2013-10-01 00:12:34 +09:00
FUJIWARA Katsunori
e190bd65ec histedit: add more detailed help about "--outgoing" 2013-10-01 00:12:34 +09:00
FUJIWARA Katsunori
cd5b67960a histedit: abort if there are multiple roots in "--outgoing" revisions
Before this patch, if there are multiple roots in "--outgoing"
revisions, result of "histedit --outgoing" depends on the parent of
the working directory. It succeeds only when the parent of the working
directory is a descendant of the oldest root in "--outgoing"
revisions, and fails otherwise.

It seems to be ambiguous and difficult for users.

This patch makes "histedit --outgoing" abort if there are multiple
roots in "--outgoing" revisions always.
2013-10-01 00:12:34 +09:00
David Soria Parra
22083388ea histedit: remove unused parents() call 2013-09-26 14:47:19 +02:00