How to track a file (in various versions) used by several projects

Marcin Kasperski Marcin.Kasperski at mekk.waw.pl
Thu Oct 19 09:55:45 UTC 2023


> So for example, the code for systemA and systemB might both include
> "driver.au3". I would have a repository for systemA, a repository for
> systemB etc. There might be 3 - 10 projects that make use of
> driver.au3. They each have their own copy. They are updated
> independently. (…)

driver.au3 side
------------------

Single *separate* repository. Then one of two approaches

a) (if changes diverge often and you need them to coexist frequently)

   Create separate branch for each system (`hg branch blahblah`).
   Develop where appropriate, then merge changes to default (treated as
   „moving main target”), then merge default to branches when you are
   ready to consume them. This sounds like a lot of merges but those
   will mostly be painless.

   Mercurial will happily keep track of what was merged where and what
   was not.

b) (if history is mostly linear, you just need to avoid premature
   upgrades)

   Develop on default, whenever you reach version you need somewhere,
   tag it (`hg tag 1.3.4` or so).

{ using a) also doesn't exclude tagging, it is usually a Good Thing }

systems side
------------------

Simply use appropriate version.

In a) case it can be as simple as checking out repository to appropriate
branch (branches are sticky so once you do it once, hg pull + hg update
won't leave this branch).

In b) case you need some way to declare which driver version you use
(so you declare somehow in the code „I need driver.au3 in version
1.7.11”, then your compilation process checks out such version. I
personally use such approach with custom tooling but  in simple
case
   https://repo.mercurial-scm.org/hg/help/subrepos
may do.


Initial setup
-----------------

To initialize whole thing you may consider exporting bare driver3.au
history using hg convert (this command is not only about converting
between different repo types, it can be used to export partial history
from some repo).
https://wiki.mercurial-scm.org/ConvertExtension#Converting_from_Mercurial


More information about the Mercurial mailing list