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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:10:42+00:00 2026-06-01T13:10:42+00:00

We are working with severall people on the same project and are using Mercurial

  • 0

We are working with severall people on the same project and are using Mercurial as our DVCS. Our project does have severall subrepos.
We do need to send patches to each other by mail, because it is at this moment impossible to push and pull from the master repo.
The export command – if executed on the master will only create a patch for the master, and not for the subrepo’s. We could manually create pathes for those, but we would like to know if there is an easier way to do this?

  • 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-01T13:10:43+00:00Added an answer on June 1, 2026 at 1:10 pm

    As Martin suggested, i wrote my own extension. I will post the code here, in the hope someone will improve it or make it defaulf available in mercurial …

    Thanks Martin, i based it on your onsub extension, and yes i know there are a few problems with it, but for now, it serves its purpose. (problems with more than 10 subrepos and more than 1 level of nesting)

    """execute the Bundle command in a repository and each subrepository"""
    
    # bundlesb.py - execute the Bundle command in a repository and each subrepository
    #
    # Copyright 2012 Johan G.
    #
    # This software may be used and distributed according to the terms of
    # the GNU General Public License version 2 or any later version.
    
    import os
    import zipfile
    from mercurial.i18n import _
    from mercurial import extensions, subrepo, util
    
    def bundlesb(ui, repo, *args, **opts):
        """execute the Bundle command in a repository and each subrepository
    
        Creates a combined bundle (with hgs extention) for the current 
        repository. 
    
        Because the revision numbers of the root and the subrepos will differ,
        we cannot reliably choose a revision to start from. A date to start
        from should be nice, but i have not taken the time to implement this.
        Instead i choose to take the N (default=10) last changesets into account.
        This seems to work well in our environment. Instead of providing the
        number of changesets for the operation, you can also specify -a to
        include all changesets. 
    
        Use --verbose/-v to print information and the subrepo
        name for each subrepo. 
        """
        ui.status("Starting operation\n")
        zipname = os.path.splitext(' '.join(args))[0]
        if (zipname==''):
           zipname = os.path.join(repo.root, os.path.split(repo.root)[1])
           #raise ValueError("FILE cannot be empty")
        zipname= zipname + '.hgs'
        allchangesets=opts.get('all')
        changesets=opts.get('changesets')
        ui.debug(_("input filename=%s ; AllChangesets=%s ; Changesets=%s \n") % (zipname, allchangesets, changesets))
        files=[]
    
        #work on the root repository
        runcmd(ui, repo.root, files, "0Root", repo['.'].rev(), ".", changesets, allchangesets)
    
        #do the same for each subrepository
        foreach(ui, repo, files, changesets, allchangesets)
    
        # open the zip file for writing, and write stuff to it
        ui.status("creating file: " + zipname + "\n\n")
    
        file = zipfile.ZipFile(zipname, "w" )
        for name in files:
            file.write(name, os.path.basename(name), zipfile.ZIP_DEFLATED)
        file.close()
    
        # open the file again, to see what's in it
    
        file = zipfile.ZipFile(zipname, "r")
        for info in file.infolist():
            ui.debug(info.filename + " " + str(info.date_time) + " " + str(info.file_size) + " " + str(info.compress_size) +"\n")
            #delete all the compressed .hg files
        os.remove(os.path.join(repo.root, info.filename)) 
    
        ui.status("\nOperation complete\n")
    
    
    def foreach(ui, repo, files, changesets, allchangesets):
        ctx = repo['.']
        work = [(1, ctx.sub(subpath)) for subpath in sorted(ctx.substate)]
    
        while work:
            (depth, sub) = work.pop(0)
    
            if hasattr(subrepo, 'relpath'):
                relpath = subrepo.relpath(sub)
            else:
                relpath = subrepo.subrelpath(sub)
    
            rev=sub._repo[sub._state[1]].rev()
    
            ui.debug(str(rev) + " " + str(sub._repo[sub._state[1]].user()) + " " + str(sub._repo[sub._state[1]].date()) + "\n")
    
            if depth>1:
                raise Exception("No support for nested levels deeper than 1 yet.")
    
        runcmd(ui, repo.root, files, str(depth) + relpath, rev, relpath, changesets, allchangesets)
    
            if isinstance(sub, subrepo.hgsubrepo):
                rev = sub._state[1]
                ctx = sub._repo[rev]
                w = [(depth + 1, ctx.sub(subpath)) 
                     for subpath in sorted(ctx.substate)]
                work.extend(w)
    
    def runcmd(ui, root, files, name, revision, path, changesets, allchangesets):
        files.append(root + "/" + name + ".hg")
        if (revision<=changesets) or allchangesets:
           cmd="hg bundle -a " + root + "/" + name + ".hg"
        else:
           cmd="hg bundle --base " + str(revision-changesets)+ " "  + root + "/" + name + ".hg"
        ui.note(_("Working on '%s' in %s\n") % (path, root))
        ui.debug( "command line: "+ cmd +"\n")
        util.system(cmd, 
            cwd=os.path.join(root, path),
            onerr=util.Abort,
            errprefix=_('terminated bundlesub in %s') % path)
    
    
    cmdtable = {
        "bundlesb":
            (bundlesb,
             [('c', 'changesets', 10, _('the number of recent changesets to include in the bundle'), 'N'),
              ('a', 'all', None, _('include all changesets in the bundle')),],
             _('[-c|-a] FILE...'))
    
    }
    

    And the other way around:

     """execute the UnBundle command in a repository and each subrepository
               for a file created with BundleSb"""
    
    # unbundlesub.py - execute the UnBundle command in a repository and each subrepository
    #
    # Copyright 2012 Johan G.
    #
    # This software may be used and distributed according to the terms of
    # the GNU General Public License version 2 or any later version.
    
    import os
    import zipfile
    #import glob
    from mercurial.i18n import _
    from mercurial import extensions, subrepo, util
    
    def unbundlesb(ui, repo, *args, **opts):
        """execute the UnBundle command in a repository and each subrepository
            for a file created with BundleSb
    
        Updates the current repository from a combined bundle (with hgs extention). 
    
        Use --verbose/-v to print more detailed information during the operation. 
        """
        ui.status("Starting unbundle operation\n")
    
        update = opts.get('update')
        file = os.path.splitext(' '.join(args))[0] + '.hgs'
        if (file==''):
           raise ValueError("FILE cannot be empty")
    
        ui.debug("input filename=" + file + "\n")
        zfile = zipfile.ZipFile(file, "r" )
        for info in zfile.infolist():
            ui.debug(info.filename + " " + str(info.date_time) + " " + str(info.file_size) + " " + str(info.compress_size) +"\n")
        zfile.extract(info,repo.root)
            runcmd(ui, repo.root, info.filename, update)
            #delete all the compressed .hg files
        os.remove(os.path.join(repo.root, info.filename)) 
    
        zfile.close()
    
        ui.status("\nOperation complete\n")
    
    
    def runcmd(ui, root, name, update):
        level=name[0]
        rep=name[1:len(name)-3]
        ui.debug(_("Detected level=%s for repository %s \n") % (level, rep))
        cmd="hg unbundle "
        if (update): cmd= cmd + "-u "
        cmd= cmd + root + "\\" + name 
        ui.note(_("Working on '%s' in %s\n") % (rep, root))
        if (level == '1'):
            wd=os.path.join(root, rep)
        elif (level=='0'):
            wd=root
        else:
           raise Exception("Do not know what to do with a level >1")
    
        ui.debug(_("command line: %s in working directory %s\n") % (cmd, wd))
    
        util.system(cmd, 
                cwd=wd,
                onerr=util.Abort,
                errprefix=_('terminated unbundlesub in %s') % rep)
    
    
    cmdtable = {
        "unbundlesb":
            (unbundlesb,
             [('u', 'update', None,
               _('update to new branch head if changesets were unbundled'))],
             _('[-u] FILE...'))
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When working on a project with several other people it's common to have several
I have a GitHub project which does the same thing (a simple RogueLike game
We have several config files in a project that 3 people are working on.
I'm working on an old project written and then patched by several people over
I'm currently working on a C++ project that needs to have as few external
In a big application I am working, several people import same modules differently e.g.
Our group has several people, any number of which may be working on any
In our Organization we have 200 Android O.S mobiles for our customer support people.All
I have been working on a project which had been split over several servers
I'm working on a project where I need to make a Flex application that

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.