Mercurial subppos at current revision of a specific branch

I am completely new to mercurial, I read a lot of topics on this topic, but I still can’t understand if I can achieve what I am trying to do.

In principle, it would be interesting for me to clone the current revision of the branch from the main repository and its sub-position in one command (acting on the main repo). I will try to explain this in a minute.

Let's say that I split my code into modules (only one module in the example below). I would like to have each module in my own repository and master repo (the one that has .hgsub) as glue to keep all the back-ups in place. The master repo simply contains .hgsub and a script, which are (1) hg archiveeach sub-directory in a predefined directory, and (2) performs non-root code building. All development, commits, push, pull, merge are performed in a separate subposition.

# create a module (subrepo of the master)
hg init subrepo
cd subrepo/
echo "a file" > aFile.c
echo "another file" > anotherFile.txt
hg add
hg ci -m "initial rev of subrepo"

# create the main (master) repo & add the reference to subrepo
cd ../
hg init main
cd main
hg clone ../subrepo subrepo
echo subrepo = ../subrepo > .hgsub
echo hg archive and out-of-source build > build.script
hg add
hg ci -m "initial rev of main repo"

So far so good. If I hg clone main, I get the current revision of the default subrepo branch, as expected.

BUT, imagine that I am ready to send my code to release: 1.0.0. I would do the following.

# create the branch 1.0 to manage the bug fixes to 1.0.0 and furthers
cd ../subrepo/
hg branch 1.0
hg ci -m "creating the branch 1.0"

# backstep to the main line to carry on the development of new features
hg up default 
echo "working in the main line" > aNewFeature.c
hg add
hg ci -m "carrying on the development in the main line (a new feature)"
hg glog 
@  changeset:   2:c499329c2729
|  tag:         tip
|  parent:      0:50d4522a99ea
|  user:        XXXX
|  date:        Tue Dec 07 16:13:28 2010 +0100
|  summary:     carrying on the development in the main line (a new feature)
|
| o  changeset:   1:0a81043e6e8a
|/   branch:      1.0
|    user:        XXXX
|    date:        Tue Dec 07 16:12:02 2010 +0100
|    summary:     creating the branch 1.0
|
o  changeset:   0:50d4522a99ea
   user:        XXXX
   date:        Tue Dec 07 15:52:57 2010 +0100
   summary:     initial rev of subrepo

, . master-, , , subrepo 1.0, hg clone?

, .

# replicate the branch structure also in the main repo
cd ../main/
hg branch 1.0
echo subrepo = ../subrepo -r 1.0 > .hgsub
hg ci -m "adding -r 1.0 to .hgsub"
hg up default 
echo subrepo = ../subrepo -r default > .hgsub
hg ci -m "adding -r default to .hgsub"
hg glog 
@  changeset:   2:f97c90a31a21
|  tag:         tip
|  parent:      0:1fd6b5d528b4
|  user:        XXXX
|  date:        Tue Dec 07 16:22:05 2010 +0100
|  summary:     adding -r default to .hgsub
|
| o  changeset:   1:3d9ed2f8b026
|/   branch:      1.0
|    user:        XXXX
|    date:        Tue Dec 07 16:21:32 2010 +0100
|    summary:     adding -r 1.0 to .hgsub
|
o  changeset:   0:1fd6b5d528b4
   user:        XXXX
   date:        Tue Dec 07 15:55:53 2010 +0100
   summary:     initial rev of main repo

hg clone ,

cd /a/directory
hg clone /path/to/main -r 1.0 main
requesting all changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 3 changes to 2 files
updating to branch 1.0
pulling subrepo subrepo
abort: HTTP Error 404: Not Found

, ?

.

: , , , .

http://[user[:pass]@]host[:port]/[path][#revision]

#branchname #revision. , , ( 1.0):

echo subrepo = ../subrepo#1.0 > .hgsub

hg clone , :

pulling subrepo subrepo
abort: unsupported URL component: "1.0"
Exception AttributeError: "'httprepository' object has no attribute 'urlopener'" in <bound method httprepository.__del__ of <mercurial.httprepo.httprepository object at 0x871332c>> ignored

Ubuntu 10.04, mercurial 1.4.3-1. ?

-

+3
1

:

echo subrepo = ../subrepo -r default > .hgsub

.hgsub.

echo subrepo = ../subrepo#1.0 > .hgsub

.hgsub :

subrepo-mount-point = subrepo-source-URL

. Mercurial subrepo-source-URL, subrepo subrepo-mount-point .

, Subrepo Mercurial : , .hgsubstate.

subrepo-revision-ID subrepo-mount-point

subrepo-revision-ID Mercurial subrepos. ,

 cd main/subrepo
 hg update 1.0
 cd ..
 hg commit -m 'Updated subrepo in main'

, , .hgsubstate . : hg update , .hgsubstate , Mercurial subppos.

, , . Mercurial: , , , subrepos , .

onsub, , :

hg onsub hg update
# run test!
hg commit -m 'Updated all subrepos to their tip'

- , , . , Mercurial .hgsubstate.

+5

Source: https://habr.com/ru/post/1778989/


All Articles