Newer
Older
$ hg -q -R repo2 pull -u
$ echo 1 > repo2/s/a
$ hg -R repo2/s ci -m2
$ hg -q -R repo2/s push
$ hg -R repo2/s up -C 0
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ echo 2 > repo2/s/b
$ hg -R repo2/s ci -m3 -A
adding b
created new head
$ hg -R repo2 ci -m3
$ hg -q -R repo2 push

Martin von Zweigbergk
committed
abort: push creates new remote head cc505f09a8b2 (in subrepository "s")
(merge or see 'hg help push' for details about pushing new heads)
$ hg -R repo update
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
test if untracked file is not overwritten
(this tests also has a change to update .hgsubstate and merge it within the
same second. It should mark is are modified , even if none of mode, size and
timestamp of it isn't changed on the filesystem (see also issue4583))
$ echo issue3276_ok > repo/s/b
$ hg -R repo2 push -f -q
$ hg -R repo update
b: untracked file differs
abort: untracked files in working directory differ from files in requested revision (in subrepository "s")
[255]
$ cat repo/s/b
issue3276_ok
$ rm repo/s/b
$ hg -R repo revert --all
reverting repo/.hgsubstate
reverting subrepo s
$ hg -R repo update
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cat repo/s/b
2
Issue1852 subrepos with relative paths always push/pull relative to default
Prepare a repo with subrepo
$ hg init issue1852a
$ cd issue1852a
$ hg init sub/repo
$ echo test > sub/repo/foo
$ hg -R sub/repo add sub/repo/foo
$ echo sub/repo = sub/repo > .hgsub
$ hg add .hgsub
$ hg ci -mtest
committing subrepository sub/repo
$ echo test >> sub/repo/foo
$ hg ci -mtest
committing subrepository sub/repo
$ hg cat sub/repo/foo
test
test
$ hg cat sub/repo/foo -Tjson | sed 's|\\\\|/|g'

Yuya Nishihara
committed
"path": "foo"
non-exact match:

Yuya Nishihara
committed
$ hg cat -T '{path|relpath}\n' 'glob:**'
.hgsub
.hgsubstate
sub/repo/foo

Yuya Nishihara
committed
$ hg cat -T '{path|relpath}\n' 're:^sub'
sub/repo/foo
missing subrepos in working directory:
$ mkdir -p tmp/sub/repo
$ hg cat -r 0 --output tmp/%p_p sub/repo/foo
$ cat tmp/sub/repo/foo_p
test
$ mv sub/repo sub_
$ hg cat sub/repo/baz
skipping missing subrepository: sub/repo
[1]
$ rm -rf sub/repo
$ mv sub_ sub/repo
$ cd ..
Create repo without default path, pull top repo, and see what happens on update
$ hg init issue1852b
$ hg -R issue1852b pull issue1852a
pulling from issue1852a
requesting all changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 3 changes to 2 files
Denis Laxalde
committed
new changesets 19487b456929:be5eb94e7215
(run 'hg update' to get a working copy)
$ hg -R issue1852b update
abort: default path for subrepository not found (in subrepository "sub/repo")
Matt Harbison
committed
Ensure a full traceback, not just the SubrepoAbort part
$ hg -R issue1852b update --traceback 2>&1 | grep 'raise error\.Abort'
raise error.Abort(_(b"default path for subrepository not found"))
Matt Harbison
committed
Pull -u now doesn't help
$ hg -R issue1852b pull -u issue1852a
pulling from issue1852a
searching for changes
no changes found
Try the same, but with pull -u
$ hg init issue1852c
$ hg -R issue1852c pull -r0 -u issue1852a
pulling from issue1852a
adding changesets
adding manifests
adding file changes
added 1 changesets with 2 changes to 2 files
Denis Laxalde
committed
new changesets 19487b456929
cloning subrepo sub/repo from issue1852a/sub/repo
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
Try to push from the other side
$ hg -R issue1852a push `pwd`/issue1852c
pushing to $TESTTMP/issue1852c
pushing subrepo sub/repo to $TESTTMP/issue1852c/sub/repo
searching for changes
no changes found
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
Incoming and outgoing should not use the default path:
$ hg clone -q issue1852a issue1852d
$ hg -R issue1852d outgoing --subrepos issue1852c
comparing with issue1852c
searching for changes
no changes found
comparing with issue1852c/sub/repo
searching for changes
no changes found
[1]
$ hg -R issue1852d incoming --subrepos issue1852c
comparing with issue1852c
searching for changes
no changes found
comparing with issue1852c/sub/repo
searching for changes
no changes found
[1]
Check that merge of a new subrepo doesn't write the uncommitted state to
.hgsubstate (issue4622)
$ hg init issue1852a/addedsub
$ echo zzz > issue1852a/addedsub/zz.txt
$ hg -R issue1852a/addedsub ci -Aqm "initial ZZ"
$ hg clone issue1852a/addedsub issue1852d/addedsub
updating to branch default
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ echo def > issue1852a/sub/repo/foo
$ hg -R issue1852a ci -SAm 'tweaked subrepo'
adding tmp/sub/repo/foo_p
committing subrepository sub/repo
$ echo 'addedsub = addedsub' >> issue1852d/.hgsub
$ echo xyz > issue1852d/sub/repo/foo
$ hg -R issue1852d pull -u
pulling from $TESTTMP/issue1852a
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 2 changes to 2 files
Denis Laxalde
committed
new changesets c82b79fdcc5b
subrepository sub/repo diverged (local revision: f42d5c7504a8, remote revision: 46cd4aac504c)
you can (m)erge, keep (l)ocal [working copy] or keep (r)emote [destination].
what do you want to do? m
pulling subrepo sub/repo from $TESTTMP/issue1852a/sub/repo
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
Denis Laxalde
committed
new changesets 46cd4aac504c
subrepository sources for sub/repo differ
you can use (l)ocal source (f42d5c7504a8) or (r)emote source (46cd4aac504c).
what do you want to do? l
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cat issue1852d/.hgsubstate
f42d5c7504a811dda50f5cf3e5e16c3330b87172 sub/repo
Check status of files when none of them belong to the first
subrepository:
$ hg init subrepo-status
$ cd subrepo-status
$ hg init subrepo-1
$ hg init subrepo-2
$ cd subrepo-2
$ touch file
$ hg add file
$ cd ..
$ echo subrepo-1 = subrepo-1 > .hgsub
$ echo subrepo-2 = subrepo-2 >> .hgsub
$ hg add .hgsub
$ hg ci -m 'Added subrepos'
committing subrepository subrepo-2
$ hg st subrepo-2/file
Check that share works with subrepo
$ hg --config extensions.share= share . ../shared
updating working directory
Matt Harbison
committed
sharing subrepo subrepo-1 from $TESTTMP/subrepo-status/subrepo-1
sharing subrepo subrepo-2 from $TESTTMP/subrepo-status/subrepo-2
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
Matt Harbison
committed
$ find ../shared/* | sort
../shared/subrepo-1
../shared/subrepo-1/.hg
../shared/subrepo-1/.hg/cache
../shared/subrepo-1/.hg/cache/storehash
../shared/subrepo-1/.hg/cache/storehash/* (glob)
../shared/subrepo-1/.hg/hgrc
../shared/subrepo-1/.hg/requires
../shared/subrepo-1/.hg/sharedpath
../shared/subrepo-1/.hg/wcache
Matt Harbison
committed
../shared/subrepo-2
../shared/subrepo-2/.hg
../shared/subrepo-2/.hg/branch
../shared/subrepo-2/.hg/cache
../shared/subrepo-2/.hg/cache/storehash
../shared/subrepo-2/.hg/cache/storehash/* (glob)
../shared/subrepo-2/.hg/dirstate
../shared/subrepo-2/.hg/hgrc
../shared/subrepo-2/.hg/requires
../shared/subrepo-2/.hg/sharedpath
../shared/subrepo-2/.hg/wcache
../shared/subrepo-2/.hg/wcache/checkisexec (execbit !)
../shared/subrepo-2/.hg/wcache/checklink (symlink no-rust !)
../shared/subrepo-2/.hg/wcache/checklink-target (symlink no-rust !)
../shared/subrepo-2/.hg/wcache/manifestfulltextcache
Matt Harbison
committed
../shared/subrepo-2/file
$ hg -R ../shared in

Martin von Zweigbergk
committed
abort: repository default not found
$ hg -R ../shared/subrepo-2 showconfig paths
paths.default=$TESTTMP/subrepo-status/subrepo-2
$ hg -R ../shared/subrepo-1 sum --remote
parent: -1:000000000000 tip (empty repository)
branch: default
commit: (clean)
update: (current)
remote: (synced)
Check hg update --clean
$ cd $TESTTMP/t
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
$ rm -r t/t.orig
$ hg status -S --all
C .hgsub
C .hgsubstate
C a
C s/.hgsub
C s/.hgsubstate
C s/a
C s/ss/a
C t/t
$ echo c1 > s/a
$ cd s
$ echo c1 > b
$ echo c1 > c
$ hg add b
$ cd ..
$ hg status -S
M s/a
A s/b
? s/c
$ hg update -C
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
updated to "925c17564ef8: 13"
2 other heads for branch "default"
$ hg status -S
? s/b
? s/c
Sticky subrepositories, no changes
$ cd $TESTTMP/t
$ hg id
925c17564ef8 tip
$ hg -R s id
12a213df6fa9 tip
$ hg -R t id
52c0adc0515a tip
$ hg update 11
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg id
365661e5936a
$ hg -R s id
fc627a69481f
$ hg -R t id
e95bcfa18a35
Sticky subrepositories, file changes
$ touch s/f1
$ touch t/f1
$ hg add -S s/f1
$ hg add -S t/f1
$ hg id
365661e5936a+
$ hg -R s id
fc627a69481f+
$ hg -R t id
e95bcfa18a35+
$ hg update tip
Angel Ezquerra
committed
subrepository s diverged (local revision: fc627a69481f, remote revision: 12a213df6fa9)
you can (m)erge, keep (l)ocal [working copy] or keep (r)emote [destination].
what do you want to do? m
subrepository sources for s differ
you can use (l)ocal source (fc627a69481f) or (r)emote source (12a213df6fa9).
what do you want to do? l
Angel Ezquerra
committed
subrepository t diverged (local revision: e95bcfa18a35, remote revision: 52c0adc0515a)
you can (m)erge, keep (l)ocal [working copy] or keep (r)emote [destination].
what do you want to do? m
subrepository sources for t differ
you can use (l)ocal source (e95bcfa18a35) or (r)emote source (52c0adc0515a).
what do you want to do? l
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg id
925c17564ef8+ tip
$ hg -R s id
fc627a69481f+
$ hg -R t id
e95bcfa18a35+
$ hg update --clean tip
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
Sticky subrepository, revision updates
$ hg id
925c17564ef8 tip
$ hg -R s id
12a213df6fa9 tip
$ hg -R t id
52c0adc0515a tip
$ cd s
$ hg update -r -2
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cd ../t
$ hg update -r 2
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cd ..
$ hg update 10
Angel Ezquerra
committed
subrepository s diverged (local revision: 12a213df6fa9, remote revision: fc627a69481f)
you can (m)erge, keep (l)ocal [working copy] or keep (r)emote [destination].
what do you want to do? m
Angel Ezquerra
committed
subrepository t diverged (local revision: 52c0adc0515a, remote revision: 20a0db6fbf6c)
you can (m)erge, keep (l)ocal [working copy] or keep (r)emote [destination].
what do you want to do? m
subrepository sources for t differ (in checked out version)
you can use (l)ocal source (7af322bc1198) or (r)emote source (20a0db6fbf6c).
what do you want to do? l
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg id
e45c8b14af55+
$ hg -R s id
02dcf1d70411
$ hg -R t id
7af322bc1198
Sticky subrepository, file changes and revision updates
$ touch s/f1
$ touch t/f1
$ hg add -S s/f1
$ hg add -S t/f1
$ hg id
e45c8b14af55+
$ hg -R s id
02dcf1d70411+
$ hg -R t id
7af322bc1198+
$ hg update tip
Angel Ezquerra
committed
subrepository s diverged (local revision: 12a213df6fa9, remote revision: 12a213df6fa9)
you can (m)erge, keep (l)ocal [working copy] or keep (r)emote [destination].
what do you want to do? m
subrepository sources for s differ
you can use (l)ocal source (02dcf1d70411) or (r)emote source (12a213df6fa9).
what do you want to do? l
Angel Ezquerra
committed
subrepository t diverged (local revision: 52c0adc0515a, remote revision: 52c0adc0515a)
you can (m)erge, keep (l)ocal [working copy] or keep (r)emote [destination].
what do you want to do? m
subrepository sources for t differ
you can use (l)ocal source (7af322bc1198) or (r)emote source (52c0adc0515a).
what do you want to do? l
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg id
925c17564ef8+ tip
02dcf1d70411+
$ hg -R t id
7af322bc1198+
Sticky repository, update --clean
$ hg update --clean tip
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg id
925c17564ef8 tip
$ hg -R s id
12a213df6fa9 tip
$ hg -R t id
52c0adc0515a tip
Test subrepo already at intended revision:
$ cd s
$ hg update fc627a69481f
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cd ..
$ hg update 11
Angel Ezquerra
committed
subrepository s diverged (local revision: 12a213df6fa9, remote revision: fc627a69481f)
you can (m)erge, keep (l)ocal [working copy] or keep (r)emote [destination].
what do you want to do? m
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg id -n
11+
$ hg -R s id
fc627a69481f
$ hg -R t id
Matt Mackall
committed
Test that removing .hgsubstate doesn't break anything:
$ hg rm -f .hgsubstate
$ hg ci -mrm
nothing changed
[1]
Matt Mackall
committed
$ hg log -vr tip
changeset: 13:925c17564ef8
Matt Mackall
committed
tag: tip
user: test
date: Thu Jan 01 00:00:00 1970 +0000
files: .hgsubstate
Matt Mackall
committed
description:
Matt Mackall
committed
Test that removing .hgsub removes .hgsubstate:
$ hg rm .hgsub
$ hg ci -mrm2
created new head
Matt Mackall
committed
$ hg log -vr tip
changeset: 14:2400bccd50af
Matt Mackall
committed
tag: tip
parent: 11:365661e5936a
Matt Mackall
committed
user: test
date: Thu Jan 01 00:00:00 1970 +0000
files: .hgsub .hgsubstate
description:
rm2
Test issue3153: diff -S with deleted subrepos
$ hg diff --nodates -S -c .
diff -r 365661e5936a -r 2400bccd50af .hgsub
--- a/.hgsub
+++ /dev/null
@@ -1,2 +0,0 @@
-s = s
-t = t
diff -r 365661e5936a -r 2400bccd50af .hgsubstate
--- a/.hgsubstate
+++ /dev/null
@@ -1,2 +0,0 @@
-fc627a69481fcbe5f1135069e8a3881c023e4cf5 s
-e95bcfa18a358dc4936da981ebf4147b4cad1362 t
Test behavior of add for explicit path in subrepo:
$ cd ..
$ hg init explicit
$ cd explicit
$ echo s = s > .hgsub
$ hg add .hgsub
$ hg init s
$ hg ci -m0
Adding with an explicit path in a subrepo adds the file
$ echo c1 > f1
$ echo c2 > s/f2
$ hg st -S
? f1
? s/f2
$ hg add s/f2
$ hg st -S
$ hg ci -Am1
adding f1
Adding with an explicit path in a subrepo with -S has the same behavior
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
$ echo c3 > f3
$ echo c4 > s/f4
$ hg st -S
? f3
? s/f4
$ hg add -S s/f4
$ hg st -S
A s/f4
? f3
$ hg ci -R s -m1
$ hg ci -Ama2
adding f3
Adding without a path or pattern silently ignores subrepos
$ echo c5 > f5
$ echo c6 > s/f6
$ echo c7 > s/f7
$ hg st -S
? f5
? s/f6
? s/f7
$ hg add
adding f5
$ hg st -S
A f5
? s/f6
? s/f7
$ hg ci -R s -Am2
adding f6
adding f7
$ hg ci -m3
Adding without a path or pattern with -S also adds files in subrepos
$ echo c8 > f8
$ echo c9 > s/f9
$ echo c10 > s/f10
$ hg st -S
? f8
? s/f10
? s/f9
$ hg add -S
adding f8
adding s/f10
adding s/f9
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
$ hg st -S
A f8
A s/f10
A s/f9
$ hg ci -R s -m3
$ hg ci -m4
Adding with a pattern silently ignores subrepos
$ echo c11 > fm11
$ echo c12 > fn12
$ echo c13 > s/fm13
$ echo c14 > s/fn14
$ hg st -S
? fm11
? fn12
? s/fm13
? s/fn14
$ hg add 'glob:**fm*'
adding fm11
$ hg st -S
A fm11
? fn12
? s/fm13
? s/fn14
$ hg ci -R s -Am4
adding fm13
adding fn14
$ hg ci -Am5
adding fn12
Adding with a pattern with -S also adds matches in subrepos
$ echo c15 > fm15
$ echo c16 > fn16
$ echo c17 > s/fm17
$ echo c18 > s/fn18
$ hg st -S
? fm15
? fn16
? s/fm17
? s/fn18
$ hg add -S 'glob:**fm*'
adding fm15
adding s/fm17
$ hg st -S
A fm15
A s/fm17
? fn16
? s/fn18
$ hg ci -R s -Am5
adding fn18
$ hg ci -Am6
adding fn16
Test behavior of forget for explicit path in subrepo:
Forgetting an explicit path in a subrepo untracks the file
$ echo c19 > s/f19
$ hg add s/f19
$ hg st -S
A s/f19
$ hg forget s/f19
$ hg st -S
? s/f19
$ rm s/f19
$ cd ..
Courtesy phases synchronisation to publishing server does not block the push
(issue3781)
$ cp -R main issue3781
$ cp -R main issue3781-dest
$ cd issue3781-dest/s
$ hg phase tip # show we have draft changeset
5: draft
$ chmod a-w .hg/store/phaseroots # prevent phase push
$ cd ../../issue3781
$ cat >> .hg/hgrc << EOF
> [paths]
> default=../issue3781-dest/
> EOF
$ hg push --config devel.legacy.exchange=bundle1
pushing to $TESTTMP/issue3781-dest
pushing subrepo s to $TESTTMP/issue3781-dest/s
searching for changes
no changes found
searching for changes
no changes found
[1]
# clean the push cache
$ rm s/.hg/cache/storehash/*
$ hg push # bundle2+
pushing to $TESTTMP/issue3781-dest
pushing subrepo s to $TESTTMP/issue3781-dest/s
searching for changes
no changes found
searching for changes
no changes found
[1]

Katsunori FUJIWARA
committed
$ cd ..

Katsunori FUJIWARA
committed
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
Test phase choice for newly created commit with "phases.subrepochecks"
configuration
$ cd t
$ hg update -q -r 12
$ cat >> s/ss/.hg/hgrc <<EOF
> [phases]
> new-commit = secret
> EOF
$ cat >> s/.hg/hgrc <<EOF
> [phases]
> new-commit = draft
> EOF
$ echo phasecheck1 >> s/ss/a
$ hg -R s commit -S --config phases.checksubrepos=abort -m phasecheck1
committing subrepository ss
transaction abort!
rollback completed
abort: can't commit in draft phase conflicting secret from subrepository ss
[255]
$ echo phasecheck2 >> s/ss/a
$ hg -R s commit -S --config phases.checksubrepos=ignore -m phasecheck2
committing subrepository ss
$ hg -R s/ss phase tip
3: secret
$ hg -R s phase tip
6: draft
$ echo phasecheck3 >> s/ss/a
$ hg -R s commit -S -m phasecheck3
committing subrepository ss
warning: changes are committed in secret phase from subrepository ss
$ hg -R s/ss phase tip
4: secret
$ hg -R s phase tip
7: secret
$ cat >> t/.hg/hgrc <<EOF
> [phases]
> new-commit = draft
> EOF
$ cat >> .hg/hgrc <<EOF
> [phases]
> new-commit = public
> EOF
$ echo phasecheck4 >> s/ss/a
$ echo phasecheck4 >> t/t
$ hg commit -S -m phasecheck4
committing subrepository s
committing subrepository s/ss

Katsunori FUJIWARA
committed
warning: changes are committed in secret phase from subrepository ss
committing subrepository t
warning: changes are committed in secret phase from subrepository s
created new head
$ hg -R s/ss phase tip
5: secret
$ hg -R s phase tip
8: secret
$ hg -R t phase tip
6: draft
$ hg phase tip
15: secret
$ cd ..
Test that commit --secret works on both repo and subrepo (issue4182)
$ cd main
$ echo secret >> b
$ echo secret >> s/b
$ hg commit --secret --subrepo -m "secret"
committing subrepository s
$ hg phase -r .
6: secret
$ cd s
$ hg phase -r .
6: secret
$ cd ../../

Katsunori FUJIWARA
committed
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
Test "subrepos" template keyword
$ cd t
$ hg update -q 15
$ cat > .hgsub <<EOF
> s = s
> EOF
$ hg commit -m "16"
warning: changes are committed in secret phase from subrepository s
(addition of ".hgsub" itself)
$ hg diff --nodates -c 1 .hgsubstate
diff -r f7b1eb17ad24 -r 7cf8cfea66e4 .hgsubstate
--- /dev/null
+++ b/.hgsubstate
@@ -0,0 +1,1 @@
+e4ece1bf43360ddc8f6a96432201a37b7cd27ae4 s
$ hg log -r 1 --template "{p1node|short} {p2node|short}\n{subrepos % '{subrepo}\n'}"
f7b1eb17ad24 000000000000
s
(modification of existing entry)
$ hg diff --nodates -c 2 .hgsubstate
diff -r 7cf8cfea66e4 -r df30734270ae .hgsubstate
--- a/.hgsubstate
+++ b/.hgsubstate
@@ -1,1 +1,1 @@
-e4ece1bf43360ddc8f6a96432201a37b7cd27ae4 s
+dc73e2e6d2675eb2e41e33c205f4bdab4ea5111d s
$ hg log -r 2 --template "{p1node|short} {p2node|short}\n{subrepos % '{subrepo}\n'}"
7cf8cfea66e4 000000000000
s
(addition of entry)
$ hg diff --nodates -c 5 .hgsubstate
diff -r 7cf8cfea66e4 -r 1f14a2e2d3ec .hgsubstate
--- a/.hgsubstate
+++ b/.hgsubstate
@@ -1,1 +1,2 @@
e4ece1bf43360ddc8f6a96432201a37b7cd27ae4 s
+60ca1237c19474e7a3978b0dc1ca4e6f36d51382 t
$ hg log -r 5 --template "{p1node|short} {p2node|short}\n{subrepos % '{subrepo}\n'}"
7cf8cfea66e4 000000000000
t
(removal of existing entry)
$ hg diff --nodates -c 16 .hgsubstate
diff -r 8bec38d2bd0b -r f2f70bc3d3c9 .hgsubstate
--- a/.hgsubstate
+++ b/.hgsubstate
@@ -1,2 +1,1 @@
0731af8ca9423976d3743119d0865097c07bdc1b s
-e202dc79b04c88a636ea8913d9182a1346d9b3dc t
$ hg log -r 16 --template "{p1node|short} {p2node|short}\n{subrepos % '{subrepo}\n'}"
8bec38d2bd0b 000000000000
t
(merging)
$ hg diff --nodates -c 9 .hgsubstate
diff -r f6affe3fbfaa -r f0d2028bf86d .hgsubstate
--- a/.hgsubstate
+++ b/.hgsubstate
@@ -1,1 +1,2 @@
fc627a69481fcbe5f1135069e8a3881c023e4cf5 s
+60ca1237c19474e7a3978b0dc1ca4e6f36d51382 t
$ hg log -r 9 --template "{p1node|short} {p2node|short}\n{subrepos % '{subrepo}\n'}"
f6affe3fbfaa 1f14a2e2d3ec
t
(removal of ".hgsub" itself)
$ hg diff --nodates -c 8 .hgsubstate
diff -r f94576341bcf -r 96615c1dad2d .hgsubstate
--- a/.hgsubstate
+++ /dev/null
@@ -1,2 +0,0 @@
-e4ece1bf43360ddc8f6a96432201a37b7cd27ae4 s
-7af322bc1198a32402fe903e0b7ebcfc5c9bf8f4 t
$ hg log -r 8 --template "{p1node|short} {p2node|short}\n{subrepos % '{subrepo}\n'}"
f94576341bcf 000000000000

Katsunori FUJIWARA
committed
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
Test that '[paths]' is configured correctly at subrepo creation
$ cd $TESTTMP/tc
$ cat > .hgsub <<EOF
> # to clear bogus subrepo path 'bogus=[boguspath'
> s = s
> t = t
> EOF
$ hg update -q --clean null
$ rm -rf s t
$ cat >> .hg/hgrc <<EOF
> [paths]
> default-push = /foo/bar
> EOF
$ hg update -q
$ cat s/.hg/hgrc
[paths]
default = $TESTTMP/t/s
default-push = /foo/bar/s
$ cat s/ss/.hg/hgrc
[paths]
default = $TESTTMP/t/s/ss
default-push = /foo/bar/s/ss
$ cat t/.hg/hgrc
[paths]
default = $TESTTMP/t/t
default-push = /foo/bar/t
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
$ cd $TESTTMP/t
$ hg up -qC 0
$ echo 'bar' > bar.txt
$ hg ci -Am 'branch before subrepo add'
adding bar.txt
created new head
$ hg merge -r "first(subrepo('s'))"
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$ hg status -S -X '.hgsub*'
A s/a
? s/b
? s/c
? s/f1
$ hg status -S --rev 'p2()'
A bar.txt
? s/b
? s/c
? s/f1
$ hg diff -S -X '.hgsub*' --nodates
diff -r 000000000000 s/a
--- /dev/null
+++ b/s/a
@@ -0,0 +1,1 @@
+a
$ hg diff -S --rev 'p2()' --nodates
diff -r 7cf8cfea66e4 bar.txt
--- /dev/null
+++ b/bar.txt
@@ -0,0 +1,1 @@
+bar
$ hg diff -X '.hgsub*' --nodates s
diff -r 000000000000 s/a
--- /dev/null
+++ b/s/a
@@ -0,0 +1,1 @@
+a
$ hg diff -X '.hgsub*' --nodates s/a
diff -r 000000000000 s/a
--- /dev/null
+++ b/s/a
@@ -0,0 +1,1 @@
+a

Katsunori FUJIWARA
committed
$ cd ..
test for ssh exploit 2017-07-25
$ cat >> $HGRCPATH << EOF
> [ui]
> ssh = sh -c "read l; read l; read l"
> EOF
$ hg init malicious-proxycommand
$ cd malicious-proxycommand
$ echo 's = [hg]ssh://-oProxyCommand=touch${IFS}owned/path' > .hgsub
$ hg init s
$ cd s
$ echo init > init
$ hg add
adding init
$ hg commit -m init
$ cd ..
$ hg add .hgsub
$ hg ci -m 'add subrepo'
$ cd ..
$ hg clone malicious-proxycommand malicious-proxycommand-clone
updating to branch default
Matt Harbison
committed
cloning subrepo s from ssh://-oProxyCommand%3Dtouch%24%7BIFS%7Downed/path
abort: potentially unsafe url: 'ssh://-oProxyCommand=touch${IFS}owned/path' (in subrepository "s")
[255]
also check that a percent encoded '-' (%2D) doesn't work
$ cd malicious-proxycommand
$ echo 's = [hg]ssh://%2DoProxyCommand=touch${IFS}owned/path' > .hgsub
$ hg ci -m 'change url to percent encoded'
$ cd ..
$ rm -r malicious-proxycommand-clone
$ hg clone malicious-proxycommand malicious-proxycommand-clone
updating to branch default
Matt Harbison
committed
cloning subrepo s from ssh://-oProxyCommand%3Dtouch%24%7BIFS%7Downed/path
abort: potentially unsafe url: 'ssh://-oProxyCommand=touch${IFS}owned/path' (in subrepository "s")
[255]
also check for a pipe
$ cd malicious-proxycommand
$ echo 's = [hg]ssh://fakehost|touch${IFS}owned/path' > .hgsub
$ hg ci -m 'change url to pipe'
$ cd ..
$ rm -r malicious-proxycommand-clone
$ hg clone malicious-proxycommand malicious-proxycommand-clone
updating to branch default
Matt Harbison
committed
cloning subrepo s from ssh://fakehost%7Ctouch%24%7BIFS%7Downed/path

Martin von Zweigbergk
committed
abort: no suitable response from remote hg
$ [ ! -f owned ] || echo 'you got owned'
also check that a percent encoded '|' (%7C) doesn't work
$ cd malicious-proxycommand
$ echo 's = [hg]ssh://fakehost%7Ctouch%20owned/path' > .hgsub
$ hg ci -m 'change url to percent encoded pipe'
$ cd ..
$ rm -r malicious-proxycommand-clone
$ hg clone malicious-proxycommand malicious-proxycommand-clone
updating to branch default
Matt Harbison
committed
cloning subrepo s from ssh://fakehost%7Ctouch%20owned/path

Martin von Zweigbergk
committed
abort: no suitable response from remote hg
$ [ ! -f owned ] || echo 'you got owned'
and bad usernames:
$ cd malicious-proxycommand
$ echo 's = [hg]ssh://-oProxyCommand=touch owned@example.com/path' > .hgsub
$ hg ci -m 'owned username'
$ cd ..
$ rm -r malicious-proxycommand-clone
$ hg clone malicious-proxycommand malicious-proxycommand-clone
updating to branch default
Matt Harbison
committed
cloning subrepo s from ssh://-oProxyCommand%3Dtouch%20owned@example.com/path
abort: potentially unsafe url: 'ssh://-oProxyCommand=touch owned@example.com/path' (in subrepository "s")
[255]

Yuya Nishihara
committed
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
Test convert subrepositories including merge (issue5526):
$ hg init tconv
$ hg convert --config extensions.convert= -q t/s tconv/s
$ hg convert --config extensions.convert= -q t/s/ss tconv/s/ss
$ hg convert --config extensions.convert= -q t/t tconv/t
convert shouldn't fail because of pseudo filenode:
$ hg convert --config extensions.convert= t tconv
scanning source...
sorting...
converting...
17 0
16 1
15 2
14 3
13 4
12 5
11 6
10 7
9 8
8 9