Show More
@@ -0,0 +1,64 b'' | |||||
|
1 | $ hg init | |||
|
2 | $ hg init sub | |||
|
3 | $ echo 'sub = sub' > .hgsub | |||
|
4 | $ hg add .hgsub | |||
|
5 | $ echo c1 > f1 | |||
|
6 | $ echo c2 > sub/f2 | |||
|
7 | $ hg add -S | |||
|
8 | adding f1 | |||
|
9 | adding sub/f2 | |||
|
10 | $ hg commit -m0 | |||
|
11 | committing subrepository sub | |||
|
12 | ||||
|
13 | Make .hgsubstate dirty: | |||
|
14 | ||||
|
15 | $ echo '0000000000000000000000000000000000000000 sub' > .hgsubstate | |||
|
16 | $ hg diff --nodates | |||
|
17 | diff -r 853ea21970bb .hgsubstate | |||
|
18 | --- a/.hgsubstate | |||
|
19 | +++ b/.hgsubstate | |||
|
20 | @@ -1,1 +1,1 @@ | |||
|
21 | -5bbc614a5b06ad7f3bf7c2463d74b005324f34c1 sub | |||
|
22 | +0000000000000000000000000000000000000000 sub | |||
|
23 | ||||
|
24 | trying to do an empty commit: | |||
|
25 | ||||
|
26 | $ hg commit -m1 | |||
|
27 | committing subrepository sub | |||
|
28 | nothing changed | |||
|
29 | [1] | |||
|
30 | ||||
|
31 | an okay update of .hgsubstate | |||
|
32 | $ cd sub | |||
|
33 | $ echo c3 > f2 | |||
|
34 | $ hg commit -m "Sub commit" | |||
|
35 | $ cd .. | |||
|
36 | $ hg commit -m "Updated sub" | |||
|
37 | committing subrepository sub | |||
|
38 | ||||
|
39 | deleting again: | |||
|
40 | $ echo '' > .hgsub | |||
|
41 | $ hg commit -m2 | |||
|
42 | $ cat .hgsub | |||
|
43 | ||||
|
44 | $ cat .hgsubstate | |||
|
45 | ||||
|
46 | an okay commit, but with a dirty .hgsubstate | |||
|
47 | $ echo 'sub = sub' > .hgsub | |||
|
48 | $ hg commit -m3 | |||
|
49 | committing subrepository sub | |||
|
50 | $ echo '0000000000000000000000000000000000000000 sub' > .hgsubstate | |||
|
51 | $ hg diff --nodates | |||
|
52 | diff -r 41e1dee3d5d9 .hgsubstate | |||
|
53 | --- a/.hgsubstate | |||
|
54 | +++ b/.hgsubstate | |||
|
55 | @@ -1,1 +1,1 @@ | |||
|
56 | -fe0229ee9a0a38b43163c756bb51b94228b118e7 sub | |||
|
57 | +0000000000000000000000000000000000000000 sub | |||
|
58 | $ echo c4 > f3 | |||
|
59 | $ hg add f3 | |||
|
60 | $ hg status | |||
|
61 | M .hgsubstate | |||
|
62 | A f3 | |||
|
63 | $ hg commit -m4 | |||
|
64 | committing subrepository sub |
@@ -949,6 +949,7 b' class localrepository(repo.repository):' | |||||
949 |
|
949 | |||
950 | # commit subs |
|
950 | # commit subs | |
951 | if subs or removedsubs: |
|
951 | if subs or removedsubs: | |
|
952 | pstate = subrepo.substate(self['.']) | |||
952 | state = wctx.substate.copy() |
|
953 | state = wctx.substate.copy() | |
953 | for s in sorted(subs): |
|
954 | for s in sorted(subs): | |
954 | sub = wctx.sub(s) |
|
955 | sub = wctx.sub(s) | |
@@ -956,7 +957,19 b' class localrepository(repo.repository):' | |||||
956 | subrepo.subrelpath(sub)) |
|
957 | subrepo.subrelpath(sub)) | |
957 | sr = sub.commit(cctx._text, user, date) |
|
958 | sr = sub.commit(cctx._text, user, date) | |
958 | state[s] = (state[s][0], sr) |
|
959 | state[s] = (state[s][0], sr) | |
959 | subrepo.writestate(self, state) |
|
960 | ||
|
961 | changed = False | |||
|
962 | if len(pstate) != len(state): | |||
|
963 | changed = True | |||
|
964 | if not changed: | |||
|
965 | for newstate in state: | |||
|
966 | if state[newstate][1] != pstate[newstate]: | |||
|
967 | changed = True | |||
|
968 | if changed: | |||
|
969 | subrepo.writestate(self, state) | |||
|
970 | elif (changes[0] == ['.hgsubstate'] and changes[1] == [] and | |||
|
971 | changes[2] == []): | |||
|
972 | return None | |||
960 |
|
973 | |||
961 | # Save commit message in case this transaction gets rolled back |
|
974 | # Save commit message in case this transaction gets rolled back | |
962 | # (e.g. by a pretxncommit hook). Leave the content alone on |
|
975 | # (e.g. by a pretxncommit hook). Leave the content alone on |
@@ -13,6 +13,19 b' hg = None' | |||||
13 |
|
13 | |||
14 | nullstate = ('', '', 'empty') |
|
14 | nullstate = ('', '', 'empty') | |
15 |
|
15 | |||
|
16 | ||||
|
17 | def substate(ctx): | |||
|
18 | rev = {} | |||
|
19 | if '.hgsubstate' in ctx: | |||
|
20 | try: | |||
|
21 | for l in ctx['.hgsubstate'].data().splitlines(): | |||
|
22 | revision, path = l.split(" ", 1) | |||
|
23 | rev[path] = revision | |||
|
24 | except IOError as err: | |||
|
25 | if err.errno != errno.ENOENT: | |||
|
26 | raise | |||
|
27 | return rev | |||
|
28 | ||||
16 | def state(ctx, ui): |
|
29 | def state(ctx, ui): | |
17 | """return a state dict, mapping subrepo paths configured in .hgsub |
|
30 | """return a state dict, mapping subrepo paths configured in .hgsub | |
18 | to tuple: (source from .hgsub, revision from .hgsubstate, kind |
|
31 | to tuple: (source from .hgsub, revision from .hgsubstate, kind | |
@@ -39,15 +52,7 b' def state(ctx, ui):' | |||||
39 | for path, src in ui.configitems('subpaths'): |
|
52 | for path, src in ui.configitems('subpaths'): | |
40 | p.set('subpaths', path, src, ui.configsource('subpaths', path)) |
|
53 | p.set('subpaths', path, src, ui.configsource('subpaths', path)) | |
41 |
|
54 | |||
42 | rev = {} |
|
55 | rev = substate(ctx) | |
43 | if '.hgsubstate' in ctx: |
|
|||
44 | try: |
|
|||
45 | for l in ctx['.hgsubstate'].data().splitlines(): |
|
|||
46 | revision, path = l.split(" ", 1) |
|
|||
47 | rev[path] = revision |
|
|||
48 | except IOError, err: |
|
|||
49 | if err.errno != errno.ENOENT: |
|
|||
50 | raise |
|
|||
51 |
|
56 | |||
52 | state = {} |
|
57 | state = {} | |
53 | for path, src in p[''].items(): |
|
58 | for path, src in p[''].items(): |
General Comments 0
You need to be logged in to leave comments.
Login now