Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3338824
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:25:17+00:00 2026-05-18T00:25:17+00:00

This is a best practice question, and I expect the answer to be it

  • 0

This is a best practice question, and I expect the answer to be “it depends”. I just hope to learn more real world scenarios and workflows.

First of all, I’m talking about different changes for the same project, so no subrepo please.

Let’s say you have your code base in an hg repository. You start to work on a complicated new feature A, then a complicated bug B is reported by your trusted tester (you have testers, right?).

It’s trivial if (the fix for) B depends on A. You simlply ci A then ci B.

My question is what to do when they are independent (or at least it seems now).

I can think of the following ways:

  1. Use a separate clone for B.
  2. Use anonymous or named branches, or bookmarks, in the same repository.
  3. Use MQ (with B patch on top of A).
  4. Use branched MQ (I’ll explain later).
  5. Use multiple MQ (since 1.6)

1 and 2 are covered by an excellent blog by @Steve Losh linked from a slightly related question.

The one huge advantage of 1 over the other choices is that it doesn’t require any rebuild when you switch from working on one thing to the other, because the files are physically separated and independent. So it’s really the only choice if, for example, A and/or B touches a header file that defines a tri-state boolean and is included by thousands of C files (don’t tell me you haven’t seen such a legacy code base).

3 is probably the easiest (in terms of setup and overhead), and you can flip the order of A and B if B is a small and/or urgent fix. However it can get tricky if A and B touches the same file(s). It’s easy to fix patch hunks that failed to apply if A and B changes are orthogonal within the same file(s), but conceptually it’s still a bit risky.

4 can make you dizzy but it’s the most powerful and flexible and scalable way. I default hg qinit with -c since I want to mark work-in-progress patches and push/pull them, but it does take a conceptual leap to realize that you can branch in MQ repo too. Here are the steps (mq = hg –mq):

  1. hg qnew bugA; make changes for A; hg qref
  2. mq branch branchA; hg qci
  3. hg qpop; mq up -rtip^
  4. hg qnew bugB; make changes for B; hg qref
  5. mq branch branchB; hg qci
  6. To work on A again: hg qpop; mq up branchA; hg qpush

It seems crazy to take so many steps, and whenever you need to switch work you must hg qci; hg qpop; mq up <branch>; hg qpush. But consider this: you have several named release branches in the same repository, and you need to work on several projects and bug fixes at the same time for all of them (you’d better get guaranteed bonus for this kind of work). You’d get lost very soon with the other approaches.

Now my fellow hg lovers, are there other/better alternatives?


(UPDATE) qqueue almost makes #4 obsolete. See Steve Losh’s elegant description here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T00:25:17+00:00Added an answer on May 18, 2026 at 12:25 am

    It seems like there’s no more or better choices than the ones I listed in the question. So here they are again.

    1. Use one clone per project.
      • Pros: total separation, thus no rebuild when switching projects.
      • Cons: toolchain needs to switch between two clones.
    2. Use anonymous or named branches, or bookmarks, in the same repository.
      • Pros: standard hg (or any DVCS) practice; clean and clear.
      • Cons: must commit before switching and rebuild after.
    3. Use MQ with one patch (or multiple consecutive patches) per project.
      • Pros: simple and easy.
      • Cons: must qrefresh before switching and rebuild after; tricky and risky if projects are not orthogonal.
    4. Use one MQ branch (or qqueue in 1.6+) per project.
      • Pros: ultra flexible and scalable (for the number of concurrent projects)
      • Cons: must qrefresh and qcommit before switching and rebuild after; feels complicated.

    Like always, there’s no silver bullet, so pick and choose the one right for the job.


    (UPDATE) For anyone who’s in love with MQ, using MQ on top of regular branches (#2 + #3) is probably the most common and preferable practice.

    If you have two concurrent projects with baseline on two branches (for example next release and current release), it’s trivial to hop between them like this:

    hg qnew; {coding}; hg qrefresh; {repeat}
    hg qfinish -a
    hg update -r <branch/bookmark/rev>
    hg qimport -r <rev>; {repeat}
    

    For the last step, qimport should add a -a option to import a line of changesets at once. I hope Meister Geisler notices this 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a comment on this answer of another question , the commenter says: don’t
This question is an attempt to find a practical solution for this question .
Inspired by this question where there are differing views on SET NOCOUNT... Should we
I am aware that this could be seen as subjective but this is definitely
I will use a simple example to illustrate my question. In Java, C, or
In another SO question, I've seen several people recommend me to always use TryGetValue.
I writing a dynamic HTML parsers functionality. I will want to modify existing parsers
I'm looking for an Objective-C way of sorting characters in a string, as per
I suspect that all non-trivial software is likely to experience situations where it hits
I know the basic principles about memory management (retain count, autorelease pools etc) in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.