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 8114403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:08:05+00:00 2026-06-06T03:08:05+00:00

I have a mercurial repository myProject : myProject |- file1.js |- file2.css |- useful.js

  • 0

I have a mercurial repository myProject:

myProject
|- file1.js
|- file2.css
|- useful.js

Now useful.js is a file with a few useful classes in it. I use it in multiple projects and as such it has its own repository:

useful
|- useful.js
|- example.js
|- README

The idea is that other people can check out useful, have alook at the file and the example and readme, and if they like it, they copy useful.js into their own project and make use of it.

Since useful.js is used in a few of my projects, what is the recommended way to keep it in sync? There is a restriction that useful.js must live in the top-level folder myProject, i.e. can’t be nested. This makes it tricky to use subrepositories (and in any case, then I’d get the other files like example.js and README).

The other thing to note is that the useful repo has a few branches: default, version1, and version2. My projects that use useful.js also have branches default, version1 and version2. I’d like to make sure that whenever I switch between branches in myProject, my useful.js switches branches too. If not for that I could probably live with a symbolic link.

This situation doesn’t seem particularly uncommon; how do others handle it? Just write a hook on update to check if I’m switching branches and switch accordingly? Plus hooks on commit, push, pull ? (basically replicate subrepo behaviour for the single file)?

cheers.

  • 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-06T03:08:06+00:00Added an answer on June 6, 2026 at 3:08 am

    It is impossible to add only a part of a repository as a subrepository with Mercurial. Thus you can’t add only a single file from a repository.

    Even if your other repository contained only one file, you could’nt add it at the root level either.

    You will have to find another way to include your useful.js file. You’re mentionning hooks to do that, but I can’t see a way to do it honestly without some kind of manual work. Personnally, I’ll go with “simplicity” and do everything “by hand”.

    Concerning the branch switch, there’s no builtin mechanism in Mercurial, but as you said you should be able to do that with a hook on update.

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

Sidebar

Related Questions

I have imported our SVN repository into Mercurial and now we have entries for
I have a mercurial repository setup with a few named branches. I want to
I have a central Mercurial repository, which configured to use HTTPS and requires authentication
I have a mercurial repository which has several projects (from an IntelliJ IDEA sense)
I have a mercurial repository, and inside it a file that ends with '>>'.
I have mercurial repository. There is .hgignore file: λ ~/workspace/kompgrafika/nurbs/ cat .hgignore syntax: regexp
I have a Mercurial repository set up on a Linux server, and some (but
I have a Mercurial repository that I can see just fine if I navigate
I have an existing Mercurial repository for a C++ application in a small corporate
I have a NetBeans project and the Mercurial repository is in the project root.

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.