This patch adds a new flag --no-commit in graft command. This feature
grafts the changes but do not create commits for those changes, grafted
changes will be added in the working directory. Also added tests to reflect
the expected behavior.
Details
- Reviewers
pulkit - Group Reviewers
hg-reviewers - Commits
- rHG622f79e3a1cb: graft: add no-commit mode (issue5631)
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
Event Timeline
Can you test about the --no-commit flag being respected when we do --continue in case of conflicts? That part is not handled by this patch yet.
To elaborate:
$ hg graft --no-commit warning: conflicts while merging ... $ resolve the conflicts $ hg graft --continue ^^ this should respect --no-commit by not creating a commit
tests/test-graft.t | ||
---|---|---|
1390 | We don't want this message while using hg graft --no-commit. |
Hello Pulkit,
After spending some time with graft implementation, I hope now I have a good understanding of how graft is working.
Let me tell you what I have understood and how I want to implement --no-commit mode. So when we hit a merge conflict what we do is save the current state in graftstate by storing
rev for rev in revs[current_pos: ] And after marking resolved, IIUC when we run $ hg graft --continue we only left with graftstate and we have no idea what are the previous flags passed to graft.
My solution for --no-commit mode:
As in case of continue, we are only left with graftstate, So I am thinking to make a no_commit_flag file similarly as we create graftstate file and when we get --no-commit flag we can create this file and after completion of the command we can unlink this no_commit_flag file.
Please let me know if I am on the right path or not?
Thanks!
Sorry for getting a bit late for reviewing this. I was mostly traveling for last few days.
We can store that information in graftstate and we are done, no need to have an extra file. If you look at rebasestate and histeditstate, they do the same thing. About the format in which the new flag should be stored in graft state, I am going to send a series which will ease writing data to state files.
What I did to store --no-commit flag in graftstate is:
Add a flag True/False in 1st line of graftstate and keep it updated from previous value in graftstate for every iteration in revs.
mercurial/commands.py | ||
---|---|---|
2391 | To be honest I am not fan of storing data in such format, but that's how we store data right now. I have finally a series in review where we can use cbor to serialize data while writing to state files. Look at D2591. I think if that goes in, we should use that format to store about no-commit flag. | |
2399 | What about if we do --continue and --no-commit? Also, a lot of existing flags should error out while using with --no-commit. That's also missing. |
I have added tests to show the behavior of --no-commit with other flags.
mercurial/commands.py | ||
---|---|---|
2391 | okay, when your series will be pushed in, I will use cbor to write in statefile. |
I am sorry but I will like this to wait before we land the new state format thing. I don't want to put more information in old state files which don't have good format. But yes, if someone else feels we can go with this, I am fine with that too.
Not yet. I have started reiterating over the series and hopefully we will be in a state to take this patch in few weeks or maybe a month.
mercurial/commands.py | ||
---|---|---|
2260 | Here we are reading data from graftstate, this is run when --continue is passed, we read the graftstate and then continue the graft. | |
2387 | Why can't we do this outside of the for-loop above? Also there is no need to store the value if it's False. We can use statedata.get('no_commit') which will return None if the value is not present. | |
2396 | This reading of statefile should happen above where we are reading other values too. Also logic can be simplified if we read the value from statefile and store it in opts['no_commit'], similar to how we are reading date and user and storing them in opts. |
Please add tests where we are grafting multiple revisions using the --no-commit flag.
mercurial/commands.py | ||
---|---|---|
2207 | the error messages should be cannot specify --no-commit and --edit together. This applies to rest two also. | |
tests/test-graft.t | ||
1541 | We are already in a repository here. cd back before creating a new repo. | |
1550 | add a hg log call here, it will be helpful in understanding what's happening. | |
1553 | maybe test with couple of other flags too. | |
1561 | replace this with hg log | |
1579 | add a hg log call after that | |
1599 | replace this one also with hg log | |
1609 | I am not sure we need this behavior. Let's have this test so that others can chime in if we don't want to have this behavior. |
The patch mostly looks good to me. Added some minor nits. It will be great if you can add test where we graft multiple revs with --no-commit flag.
tests/test-graft.t | ||
---|---|---|
1551 | We should print a graphical version of log so that test can be understand better. Maybe replace this with hg log -GT "{rev}:{node|short} {desc}\n". Comment applies to other instances of hg log in test too. | |
1677 | hg log will serve the purpose better here. |
the error messages should be cannot specify --no-commit and --edit together. This applies to rest two also.