Page MenuHomePhabricator

When saving and restoring local state in Mercurial, also save and restore bookmarks
ClosedPublic

Authored by epriestley on Jul 8 2020, 9:37 PM.
Tags
None
Referenced Files
F14074895: D21396.id50929.diff
Thu, Nov 21, 9:10 AM
Unknown Object (File)
Fri, Nov 15, 1:11 PM
Unknown Object (File)
Wed, Oct 30, 1:54 PM
Unknown Object (File)
Thu, Oct 24, 3:13 AM
Unknown Object (File)
Thu, Oct 24, 3:11 AM
Unknown Object (File)
Thu, Oct 24, 3:10 AM
Unknown Object (File)
Thu, Oct 24, 3:07 AM
Unknown Object (File)
Sep 24 2024, 1:33 AM
Subscribers
None

Details

Summary

Ref PHI1808. In Mercurial, we must save and restore bookmark state explicitly.

  • Save and restore bookmarks.
  • Clean up concepts in "arc-ls-markers" slightly, so we don't need separate "isCurrent" and "isActive" flags, hopefully.

I believe the totality of Mercurial state is:

  • A (non-bare) working copy points at exactly one commit (which might be the empty/null commit, in an empty repository).
  • A working copy has exactly one active branch.
    • Each branch has zero or more heads.
    • Each head may be closed.
    • Each (non-null) commit belongs to exactly one branch.
    • Note that the active branch may have zero heads and zero commits which belong to it!
  • A working copy has zero or one active bookmark.

To capture this, we now emit:

  • A list of branch heads. If a branch head is a working copy commit, that head is flagged as active.
  • A list of bookmarks. If a bookmark is the current bookmark, that bookmark is flagged as active.
  • A single "branch-state" virtual marker. This covers the case where you have run "hg branch X" to create X, but no objects in the working copy actually correspond to X yet. It also covers the case where you are on a concrete branch, but not any head of that branch.
  • A single "commit-state" virtual marker. This always shows the current commit in the working copy.
Test Plan
  • Useful states to test are:
    • Empty repository (not all commands currently work here).
    • Normal repository, on a bookmark.
    • Normal repository, no bookmark.
    • "hg up 123" to update to somewhere in history.
    • "hg branch X", to start a new branch with no commits.
  • Ran "arc branches" and "arc bookmarks" in various states. Saw generally sensible output.
  • Ran "arc land --hold ..." in various states against a failing remote. Saw generally sensible output, and saw working properly restored to the original state.

Diff Detail

Repository
rARC Arcanist
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This revision was not accepted when it landed; it landed in state Needs Review.Jul 8 2020, 10:30 PM
This revision was automatically updated to reflect the committed changes.