This is an archive of the discontinued Mercurial Phabricator instance.

undo: prevent nested calls of log
ClosedPublic

Authored by felixmerk on Jul 31 2017, 2:00 PM.
Tags
None
Subscribers

Details

Reviewers
stash
Group Reviewers
Restricted Project
Commits
rFBHGX135217f25bd7: undo: prevent nested calls of log
Summary

Certain extensions (specifically infinite push) call full fledge mercurial
commands. Since all proper mercurial commands might change the repo state,
these are tracked and changes are recorded, which at best causes confusing repo
states for the user and at worst prevents the user from undo-ing due to
precieved gaps in the log. By using an env flag we can avoid this.

This change was tested in a repo with infinite push enabled with unit tests.

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

felixmerk created this revision.Jul 31 2017, 2:00 PM
Herald added a reviewer: Restricted Project. · View Herald TranscriptJul 31 2017, 2:00 PM
stash added a subscriber: stash.Aug 1 2017, 9:57 AM

Certain extensions (specifically infinite push) call full fledge mercurial commands.

I know only about hg update which calls hg pull and hg pullbackup which also calls hg pull. Anything else that I'm missing?

hgext3rd/undo.py
61–72

Can you use just one if statement?

if  ...:
        changes = safelog(repo, [""])
        if changes:
            _recordnewgap(repo)
        ...
        rootlog = True
else:
        rootlog = False
67

I don't think you need to use os.environ. It doesn't give any benefits because infinitepush doesn't create a separate process. A global variable is enough.

stash requested changes to this revision.Aug 1 2017, 9:57 AM
This revision now requires changes to proceed.Aug 1 2017, 9:57 AM
stash accepted this revision.Aug 1 2017, 10:25 AM
stash added inline comments.
hgext3rd/undo.py
67

Oh, I think I understand now. This is because of the hook the runs hg pushbackup command.

This revision is now accepted and ready to land.Aug 1 2017, 10:25 AM
felixmerk added inline comments.Aug 1 2017, 1:15 PM
hgext3rd/undo.py
67

Yes, pushbackup was the culprit when I ran into the issue

felixmerk added inline comments.Aug 1 2017, 3:22 PM
hgext3rd/undo.py
61–72

One if statement is doable, but increases likelihood of issues with simultaneous commands run. There are some edge cases (with two mercurial commands) that cause weird behavior in terms of what data is stored. Longer term, some fancy wrapping of the lock command will reduce this.

This revision was automatically updated to reflect the committed changes.