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

  • SEARCH
  • Home
  • 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 8035819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:25:29+00:00 2026-06-05T02:25:29+00:00

I have a repository with two branches, A and B . They are meant

  • 0

I have a repository with two branches, A and B.

They are meant to be the same code, but aimed at different versions of the libraries they depend on.

So A/file1.js might have a snippet in it like so:

this.actor.bar();

whilst B/file1.js might have:

// `bar` had its name changed to `foo` in version X.Y of library Z
this.actor.foo();

Then I go along into A say and make a whole bunch of changes that are compatible with both versions of library Z and want to merge them into B.

Is there any way I can tell mercurial, “do a merge but ignore the lines where *.bar() becomes *.foo()“?

Basically there are a few blocks of code that differ between branches A and B because of the version of library they depend upon, but I’ve written the code such that asides from those lines, the rest of the code is identical.

I just don’t want to have to deal with these blocks of code every time I merge, because otherwise I’m more prone to fudge up the merge and switch some of these blocks around.

The only thing I can conceive is somehow making a different diff preset for each file that calls diff --ignore-matching-lines [impressively_long_argument] that is custom to each file – this seems like the wrong way to do it!

(Can I do this in git? This is a feature I’d switch versioning systems for, although I have no idea how one would implement it. Or perhaps the solution lies in finding a sophisticated diff tool).

  • 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-06-05T02:25:30+00:00Added an answer on June 5, 2026 at 2:25 am

    Git and Mercurial both handle this more easily that you’re imagining (and easier than, say, svn or CVS do). That’s because git and Mercurial merge changes not differences.

    If you have two branches, A and B, and you’ve changed bar to foo in branch A when you do this:

    hg update B
    hg merge A
    

    it will merge in all the changesets currently in A that haven’t yet been merged into B. That will include your bar to foo change and you’ll have to manually exclude that specific change but only that one time.

    The next time you do:

    hg update B
    hg merge A
    

    it will again merge in all the changesets currently in A that haven’t been merged to A, but since the changeset that does bar to foo has already been merged in it doesn’t matter at all that A has foos and and B has barss because that difference wasn’t created in the changesets now being merged, that change won’t be applied to B and you don’t have to manually reject it again.

    This is one of the key advantages that a CVS with a full graph history brings. You’re not merging two snapshots, you’re applying the differences that are new in branch A to branch B, so if a difference isn’t new you don’t have to re-reject it — the system remembers, “oh, I remember, you didn’t want that”.

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

Sidebar

Related Questions

I have two projects in the same Subversion repository. They both use some standard
I have a repository with two branches: live and stage. The repository holds code
I have a git repository with two branches; one for code that's used for
I have a git repository (at github.com) with two branches: master and gh-pages. I
I have two branches in my Git repository: master seotweaks (created originally from master
I have a Git repository with two branches: master and redesign . The redesign
I have merged two branches in a local Git repository, with a bunch of
I have a git repository and two branches master and st (branched from master
I have a remote bare repository with two branches 'master' and 'testing', where HEAD
I have two branches in my repository(SAMPLE) master .. under Master ---> AA (folder)-->

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.