Mercurial Stacked Diffs

Published
Length
3 min read

Luis Felipe Dias

All posts

You build mercurial stacked diffs by creating a chain of small, dependent commits. Each new commit sits on top of the last one for separate review. Teams use this setup to keep code reviews short and easy to read. Still, broad repo permissions let users push whole stacks without proper checks. A single bad commit or wide role can break the main branch fast. How mercurial stacked diffs work in daily workflows In a standard version control setup, engineers often bundle features into one giant c

Stacked Diffs: the complete guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free white paper. No spam. Unsubscribe anytime.

You build mercurial stacked diffs by creating a chain of small, dependent commits. Each new commit sits on top of the last one for separate review. Teams use this setup to keep code reviews short and easy to read. Still, broad repo permissions let users push whole stacks without proper checks. A single bad commit or wide role can break the main branch fast.

How mercurial stacked diffs work in daily workflows

In a standard version control setup, engineers often bundle features into one giant change. Reviewers must read hundreds of lines of code at once. This slows down the whole team and hides bugs inside huge files. Stacking solves this problem by splitting one big feature into small steps. You write the base change first and send it for review.

Next, you start the second change right on top of that base commit. You do not wait for the first review to finish before writing more code. Mercurial tracks the parent and child links between each local commit in the stack. When a reviewer asks for fixes on the first commit, you update that commit. Then you rebase the upper commits so the whole chain stays in sync.

Each commit in the stack gets its own review page in your review tool. Teammates can check the database change first and the app logic second. Once the bottom commit passes review and tests, it merges into the main branch. The remaining commits in the stack move down and wait for their turn.

What native version control solves and what it misses

Mercurial handles local history and commit graphs with great care. It keeps track of which draft commits belong to your current stack. Your source control host also checks who can log in and view the repo. You can set branch rules so that commits need approvals before they merge.

Still, source control permissions only govern who can push or merge code files. They do not control what happens when developers test those stacked changes against live systems. While building a stack, engineers often run local scripts against shared databases or servers. A repo role decides who can read code, not what live commands do in flight.

Stacked Diffs: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Also, automated pipelines often run tests for every single diff in a five-part stack. These test runners usually hold wide keys to cloud accounts or staging databases. If a commit contains a bad query or exposes a phone number, repo rules miss it. Native version control checks the static text file, not the runtime database session.

Managing permissions across local and shared test runs

When engineers work on a long stack of diffs, they switch contexts often. One commit might alter a table schema while the next updates an internal service. Developers need to test each layer of the stack against real data to be sure. Giving every developer full database passwords for local testing creates a huge risk.

Teams need a way to check every command and query as it runs. Instead of sharing raw keys for test servers, teams should check actions in real time. Masking rules can rewrite emails or card numbers in query results during local testing. This keeps test runs safe while engineers build and rebase their commit stacks.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

What happens when the bottom diff in a stack needs changes?

You check out the bottom commit, make your edits, and amend that change. Then you restack the upper commits so they sit on the updated base.

How many commits should I put in a single stack?

Most teams keep stacks between two and five commits for easy reading. Very tall stacks take more work to rebase when the base change shifts.

Can I merge a middle diff before the bottom diff lands?

No, because the middle diff depends on the code inside the bottom diff. You must merge the stack in order from the bottom to the top.

Save the open-source gateway.

hoop is MIT-licensed infrastructure for controlling how AI agents reach production data. Star hoophq/hoop so you can inspect it, deploy it, or share it when your team starts governing agent access.