When --date flag specified with hg amend and working copy is clean,
hg amend amends, which is generally undesirable behavior.
But it is commonly used to change date on each amend.
I added experimental.amend.dateonly config option to not amend
if only thing that changed is date.
I also added tests for this.
Details
- Reviewers
pulkit durin42 - Group Reviewers
hg-reviewers
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
Event Timeline
This looks good to me but since I helped Zharas in preparing the patch, I won't queue it.
I'm not sure how I feel about this. I think we talked within the team at Google about always passing a -D now and decided not to do it because of the issue you're fixing here (I may be confusing the discussion with one about using hg metaedit). Still, I feel like this patch is a workaround for the real problem. I assume that the real problem is that there the date is not normally updated when you amend a commit (i.e. you want to always pass -D now, not a specific other timestamp). If that's the problem we're trying address, should we instead introduce a config called something like amend.updatetimestamp that makes it update the timestamp to the current time? That would naturally not update the timestamp if the timestamp was the only thing that changed (just like this patch does it). The natural generalization of amend.updatetimestamp is something like rewrite.updatetimestamp that would be respected by amend, histedit, rebase, etc.
What do you think? Is that the use case you're trying to address with this patch?
mercurial/configitems.py | ||
---|---|---|
440–442 | "amend.dateonly" sounds like it only updates the date. Maybe "amend.skipdateonly" or "amend.nodateonly"? It doesn't matter much because we'll need to update it anyway later if we drop the "experimental" label. | |
tests/test-amend.t | ||
372–386 | You only care about the date here, right? You can probably do something like hg log -T '{date|isodate}\n' to make the test clearer. |
(Replying because I adviced Zharas to take up this issue and he is a new mercurial user and have less context on the problem)
I agree that the real problem is amend not updating the timestamp. People have aliased amend to amend -D now or just like you said, they always pass -D now. In such cases, even if the working directory is not changed, we end up creating a new commit with just date change. This patch tries to solve the problem of creating a new commit when only date has changed for people who do amend -D now always by preventing that if the config option is turned on.
I like your idea of having a config option which is respected by all the commands.
That said, will you like to see a v2 of this patch with inline comments addressed or we abandon this idea in favour of proposed config option to change the date.
mercurial/configitems.py | ||
---|---|---|
440–442 | "amend.skipdateonly" sounds good. |
I should be easy to introduce such an option and make amend respect it (similar amount of code as this patch), so I'd just like to hear if others think it's a good idea first. If others agree with it, then it seems better to introduce the generic option right away. I can't/won't access IRC right now, but feel free to check there what others think and update this review when you have.
I should be easy to introduce such an option and make amend respect it (similar amount of code as this patch), so I'd just like to hear if others think it's a good idea first. If others agree with it, then it seems better to introduce the generic option right away. I can't/won't access IRC right now, but feel free to check there what others think and update this review when you have.
SGTM.
Perhaps, ui.history-editing-backup can be moved under the same config group.
"amend.dateonly" sounds like it only updates the date. Maybe "amend.skipdateonly" or "amend.nodateonly"? It doesn't matter much because we'll need to update it anyway later if we drop the "experimental" label.