Diagnosing and Fixing Common Mercurial Bookmark Issues
A practical guide to spotting missing, conflicting, or orphaned bookmarks in Mercurial, with ordered checks, fixes, and escalation steps.
25 Aug 2025, 16:49 UTC

Problem Overview
Bookmarks in Mercurial let you mark a specific changeset with a friendly name, similar to Git tags but mutable. When a bookmark behaves unexpectedly—disappears after a push, conflicts after a rebase, or lingers as an orphan—your workflow can stall. This guide gives you a concise, ordered diagnostic path to identify the root cause, apply the appropriate fix, and know when to involve your team.
Recognizable Conditions
Below are three conditions that most Mercurial users encounter with bookmarks. Each condition is paired with a likely cause and a quick test.
| Condition | Typical Cause | Quick Check |
|---|---|---|
Bookmark missing after hg push | Remote repository lacks bookmark support or push omitted --bookmark | Run hg bookmarks locally and on the remote clone. |
Bookmark conflict after hg rebase | Two changesets share the same bookmark name. | Inspect hg log --template={bookmark} for duplicate names. |
Orphaned bookmark entry in .hg/bookmarks | Interrupted edit or manual file modification left a stale reference. | Open .hg/bookmarks and look for lines that no longer map to a changeset. |
Ordered Diagnostic Checks
- Verify Bookmark Presence on All Clones
Run
hg bookmarksin each clone. If a bookmark appears locally but not remotely, skip to step 3. - Confirm Remote Bookmark Support
Remote Mercurial servers (e.g.,
hg serve, Bitbucket, GitHub) must support bookmarks. Check the server'shg help configor documentation forallowbookmarks. If absent, bookmarks aren't stored. - Check Push Flags
Push bookmarks with
hg push --bookmarkorhg push -B. Without the flag, bookmarks are not transmitted. Example:hg push -B featurepushes only thefeaturebookmark. - Inspect Bookmark History for Duplicates
Run
hg log --template=\"{rev}:{node|short} {bookmark}\\n\". If the same bookmark name appears on two different revisions, a conflict exists. - Search for Orphaned Entries
Open
.hg/bookmarksand verify each line maps to a valid changeset hash. Remove any line that doesn't. - Validate Working Directory State
After cleaning
.hg/bookmarks, runhg updateto ensure the working directory reflects the correct bookmark head.
Fixes Tied to Findings
1. Missing Bookmark After Push
Fix: Push with the bookmark flag and enable bookmark support on the server.
# Push a single bookmark
hg push -B feature
# Or push all bookmarks
hg push --bookmark
Risk: If the remote is read-only or bookmarks are disabled, the push will fail. Verify allowbookmarks=true in the remote's hgrc or ask the admin.
2. Bookmark Conflict After Rebase
Fix: Rename one of the conflicting bookmarks or collapse the changesets.
# Rename conflicting bookmark
hg bookmark -r 12345 new-feature
# Collapse bookmarks if they point to the same head
hg bookmark -f -r 12345 new-feature
Risk: Renaming changes the history visible to collaborators. Communicate changes before pushing.
3. Orphaned Bookmark Entry
Fix: Edit .hg/bookmarks to delete stale lines, then run hg update to sync.
# Edit .hg/bookmarks
# Remove lines that reference missing changesets
# After editing
hg update
Risk: Manual editing may corrupt the file if syntax is incorrect. Always back up .hg/bookmarks before editing.
Escalation Criteria
Use the following thresholds to decide when to involve teammates or a repository admin:
- Bookmark missing on multiple clones – Verify remote support; if missing, contact the server admin.
- Bookmark conflict after rebase that affects public history – Coordinate with collaborators; rebase may rewrite history.
- Persistent orphaned bookmarks after cleanup – Check for repository corruption or permission issues; consider cloning a fresh copy.
Verification Steps
To confirm the fix worked:
- Create a fresh clone:
hg clone https://example.com/repo newclone. - Add a bookmark:
hg bookmark feature, commit, and push with--bookmark. - Pull in another clone:
hg pullandhg update. - Run
hg bookmarks– thefeaturebookmark should appear.
For rebase tests, after rebasing on a bookmark, hg bookmarks should show the updated head. If the bookmark name changes, verify the rename was intentional.
Limitations and Practical Checks
Bookmark support varies by server version. Mercurial 4.0+ includes out-of-the-box support, but older servers may require manual configuration. Always check hg help config on the remote. Additionally, bookmark operations are not atomic; if a push fails midway, you may end up with half-applied bookmarks. Use hg status and hg log to confirm consistency.
Conclusion
By following the ordered checks and applying the targeted fixes above, most bookmark-related hiccups in Mercurial can be resolved quickly. Remember to keep backups, coordinate with collaborators on history-rewriting operations, and verify remote support before pushing bookmarks.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.