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.
Details
- Reviewers
stash - Group Reviewers
Restricted Project - Commits
- rFBHGXac8013486e5a: undo: localbranch revset
Diff Detail
- Repository
- rFBHGX Facebook Mercurial Extensions
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
Event Timeline
hgext3rd/undo.py | ||
---|---|---|
389 | This is recomputed many times, I think it's a good idea to compute it only once | |
398–408 | Doc says that you are accepting changeset, but you are really accepting arbitrary revset. Something needs to be changed, I think doc | |
417–420 | I'm not really sure what you are trying to achieve. Are you trying to remove duplicates? In that case using set is faster and simpler to understand |
hgext3rd/undo.py | ||
---|---|---|
398–408 | The code does support either, but I wasn't sure how to accept both string arguments (such as 27cb) and a revset (such as draft()) while still using the revsetlang.get commands and so I restricted the input to what I needed and what I tested while allowing for future expansion of allowed inputs. Do we have some more powerful input handling commands? | |
417–420 | Good point! That's definitely cleaner. |
I don't want to block you so I'm going to accept the change. But before landing please do two things:
- Update the docstring of the revset describing the behavior of localbranch(PUBLIC)
- Add tests for localbranch(PUBLIC) and maybe localbranch(HASH1 + HASH2)
hgext3rd/undo.py | ||
---|---|---|
385–408 | Do I understand correctly it's a bug fix? | |
394 | This can also be cached | |
398–408 | No need to change the code, I'd just change the doc string from localbranch(changeset) to localbranch(revset) or something like that. | |
416 | This case is not actually covered with tests, please do. | |
tests/test-undo.t | ||
180–203 | Why did you add this change? Is it related to the fix in olddraft() revset? | |
444 | To verify your test I did arc patch and changed the test a bit: {P57679225} I think it's a bit clearer. Also please add tests with public commits. |
hgext3rd/undo.py | ||
---|---|---|
385–408 | It allows for logical operations such as "and" to work. I tried covering it in the commit message with "fixes oldraft() output when used with other revsets," but I can be more explicit about the nature of the bug. | |
tests/test-undo.t | ||
180–203 | Yes. olddraft() did not respond to "and" and some other revset operators. I hadn't realized that the revset itself had to cover that logic and I still don't know why "and" didn't work while "-" did work. I now use the same "subset &" logic that other revsets use. | |
444 | Line 504 I guess I should add a newline and comment before |
hgext3rd/undo.py | ||
---|---|---|
398–408 | Maybe I'm misunderstanding, but "tip()" for example is a revset but not a string and so will raise an error. If you look at a revset that takes both as arguments, such as branch in revset.py, there is a lot of logic that goes with it. |
hgext3rd/undo.py | ||
---|---|---|
398–408 | Ok, thanks for explanation |
hgext3rd/undo.py | ||
---|---|---|
416 | You can use revs = revset.getset(repo, fullreposet(repo), x) here so it works with arbitrary revset. | |
417–427 | Could you check if the revset is equivalent to the below one? querystring = revsetlang.formatspec('((::%ld) & draft())::', revs) return subset & smartset.baseset(repo.revs(querystring)) And that might still have issues with: $ hg update a-public-commit $ hg commit $ hg strip . $ hg undo # ?? But we can figure out it later. |
hgext3rd/undo.py | ||
---|---|---|
417–427 | I see the strip case was handled by the public() and %s test. It might be possible to handle it first, like, we can assume len(revs) == 1 and test repo[revs.first()].phase(), if it's phases.public, use an alternative revset: (children(%d) & draft()):: # executed on an filtered repo |
This is recomputed many times, I think it's a good idea to compute it only once