Mercurial > hg
annotate mercurial/subrepoutil.py @ 41630:3d094bfaf885
subrepo: adjust subrepo prefix before calling subrepo.diff() (API)
Differential Revision: https://phab.mercurial-scm.org/D5886
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 07 Feb 2019 09:52:36 -0800 |
parents | 876494fd967d |
children | f6540aba8e3e |
rev | line source |
---|---|
36009
55e8efa2451a
subrepo: split non-core functions to new module
Yuya Nishihara <yuya@tcha.org>
parents:
35925
diff
changeset
|
1 # subrepoutil.py - sub-repository operations and substate handling |
8812
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
2 # |
10324
55d134ef8ab7
subrepo: correct copyright
David Soria Parra <dsp@php.net>
parents:
10299
diff
changeset
|
3 # Copyright 2009-2010 Matt Mackall <mpm@selenic.com> |
8812
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
4 # |
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
10263 | 6 # GNU General Public License version 2 or any later version. |
8812
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
7 |
25980
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
8 from __future__ import absolute_import |
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
9 |
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
10 import errno |
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
11 import os |
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
12 import posixpath |
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
13 import re |
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
14 |
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
15 from .i18n import _ |
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
16 from . import ( |
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
17 config, |
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
18 error, |
30060
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
19 filemerge, |
25980
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
20 pathutil, |
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
21 phases, |
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
22 util, |
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
23 ) |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36690
diff
changeset
|
24 from .utils import ( |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36690
diff
changeset
|
25 stringutil, |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36690
diff
changeset
|
26 ) |
25980
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
27 |
10177
5ca0d220ae21
subrepo: add table-based dispatch for subrepo types
Augie Fackler <durin42@gmail.com>
parents:
10175
diff
changeset
|
28 nullstate = ('', '', 'empty') |
8812
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
29 |
11775
a8614c5a5e9a
subrepos: support remapping of .hgsub source paths
Martin Geisler <mg@lazybytes.net>
parents:
11572
diff
changeset
|
30 def state(ctx, ui): |
11571 | 31 """return a state dict, mapping subrepo paths configured in .hgsub |
32 to tuple: (source from .hgsub, revision from .hgsubstate, kind | |
33 (key in types dict)) | |
34 """ | |
8812
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
35 p = config.config() |
25768
7a9ef8608a1d
subrepo: prefetch ctx.repo() for efficiency and centralization
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
25660
diff
changeset
|
36 repo = ctx.repo() |
8812
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
37 def read(f, sections=None, remap=None): |
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
38 if f in ctx: |
13017
d0e21c5fde41
subrepo: handle missing subrepo spec file as removed
Patrick Mezard <pmezard@gmail.com>
parents:
13015
diff
changeset
|
39 try: |
d0e21c5fde41
subrepo: handle missing subrepo spec file as removed
Patrick Mezard <pmezard@gmail.com>
parents:
13015
diff
changeset
|
40 data = ctx[f].data() |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25658
diff
changeset
|
41 except IOError as err: |
13017
d0e21c5fde41
subrepo: handle missing subrepo spec file as removed
Patrick Mezard <pmezard@gmail.com>
parents:
13015
diff
changeset
|
42 if err.errno != errno.ENOENT: |
d0e21c5fde41
subrepo: handle missing subrepo spec file as removed
Patrick Mezard <pmezard@gmail.com>
parents:
13015
diff
changeset
|
43 raise |
d0e21c5fde41
subrepo: handle missing subrepo spec file as removed
Patrick Mezard <pmezard@gmail.com>
parents:
13015
diff
changeset
|
44 # handle missing subrepo spec files as removed |
24645
b39afa36006a
subrepo: precisely identify the missing subrepo spec file
Matt Harbison <matt_harbison@yahoo.com>
parents:
24471
diff
changeset
|
45 ui.warn(_("warning: subrepo spec file \'%s\' not found\n") % |
25769
2538b87660be
subrepo: use repo.pathto instead of util.pathto to simplify invocation
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
25768
diff
changeset
|
46 repo.pathto(f)) |
13017
d0e21c5fde41
subrepo: handle missing subrepo spec file as removed
Patrick Mezard <pmezard@gmail.com>
parents:
13015
diff
changeset
|
47 return |
d0e21c5fde41
subrepo: handle missing subrepo spec file as removed
Patrick Mezard <pmezard@gmail.com>
parents:
13015
diff
changeset
|
48 p.parse(f, data, sections, remap, read) |
10174
65b6dc44cdbf
subrepo: fix includes support in .hgsub
Matt Mackall <mpm@selenic.com>
parents:
10069
diff
changeset
|
49 else: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25980
diff
changeset
|
50 raise error.Abort(_("subrepo spec file \'%s\' not found") % |
25769
2538b87660be
subrepo: use repo.pathto instead of util.pathto to simplify invocation
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
25768
diff
changeset
|
51 repo.pathto(f)) |
10174
65b6dc44cdbf
subrepo: fix includes support in .hgsub
Matt Mackall <mpm@selenic.com>
parents:
10069
diff
changeset
|
52 if '.hgsub' in ctx: |
65b6dc44cdbf
subrepo: fix includes support in .hgsub
Matt Mackall <mpm@selenic.com>
parents:
10069
diff
changeset
|
53 read('.hgsub') |
8812
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
54 |
11775
a8614c5a5e9a
subrepos: support remapping of .hgsub source paths
Martin Geisler <mg@lazybytes.net>
parents:
11572
diff
changeset
|
55 for path, src in ui.configitems('subpaths'): |
a8614c5a5e9a
subrepos: support remapping of .hgsub source paths
Martin Geisler <mg@lazybytes.net>
parents:
11572
diff
changeset
|
56 p.set('subpaths', path, src, ui.configsource('subpaths', path)) |
a8614c5a5e9a
subrepos: support remapping of .hgsub source paths
Martin Geisler <mg@lazybytes.net>
parents:
11572
diff
changeset
|
57 |
8812
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
58 rev = {} |
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
59 if '.hgsubstate' in ctx: |
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
60 try: |
16596
95ca6c8b38da
subrepo: do not traceback on .hgsubstate parsing errors
Patrick Mezard <patrick@mezard.eu>
parents:
16595
diff
changeset
|
61 for i, l in enumerate(ctx['.hgsubstate'].data().splitlines()): |
16595
2de6ac4ac17c
subrepo: ignore blank lines in .hgsubstate (issue3424)
Patrick Mezard <patrick@mezard.eu>
parents:
16555
diff
changeset
|
62 l = l.lstrip() |
2de6ac4ac17c
subrepo: ignore blank lines in .hgsubstate (issue3424)
Patrick Mezard <patrick@mezard.eu>
parents:
16555
diff
changeset
|
63 if not l: |
2de6ac4ac17c
subrepo: ignore blank lines in .hgsubstate (issue3424)
Patrick Mezard <patrick@mezard.eu>
parents:
16555
diff
changeset
|
64 continue |
16596
95ca6c8b38da
subrepo: do not traceback on .hgsubstate parsing errors
Patrick Mezard <patrick@mezard.eu>
parents:
16595
diff
changeset
|
65 try: |
95ca6c8b38da
subrepo: do not traceback on .hgsubstate parsing errors
Patrick Mezard <patrick@mezard.eu>
parents:
16595
diff
changeset
|
66 revision, path = l.split(" ", 1) |
95ca6c8b38da
subrepo: do not traceback on .hgsubstate parsing errors
Patrick Mezard <patrick@mezard.eu>
parents:
16595
diff
changeset
|
67 except ValueError: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25980
diff
changeset
|
68 raise error.Abort(_("invalid subrepository revision " |
24645
b39afa36006a
subrepo: precisely identify the missing subrepo spec file
Matt Harbison <matt_harbison@yahoo.com>
parents:
24471
diff
changeset
|
69 "specifier in \'%s\' line %d") |
25769
2538b87660be
subrepo: use repo.pathto instead of util.pathto to simplify invocation
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
25768
diff
changeset
|
70 % (repo.pathto('.hgsubstate'), (i + 1))) |
8812
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
71 rev[path] = revision |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25658
diff
changeset
|
72 except IOError as err: |
8812
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
73 if err.errno != errno.ENOENT: |
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
74 raise |
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
75 |
15149
eaec9cf91aea
subrepo: refactor state function
Martin Geisler <mg@aragost.com>
parents:
15061
diff
changeset
|
76 def remap(src): |
11775
a8614c5a5e9a
subrepos: support remapping of .hgsub source paths
Martin Geisler <mg@lazybytes.net>
parents:
11572
diff
changeset
|
77 for pattern, repl in p.items('subpaths'): |
11961
f3075ffa6b30
subrepos: handle backslashes in subpaths
Martin Geisler <mg@lazybytes.net>
parents:
11775
diff
changeset
|
78 # Turn r'C:\foo\bar' into r'C:\\foo\\bar' since re.sub |
f3075ffa6b30
subrepos: handle backslashes in subpaths
Martin Geisler <mg@lazybytes.net>
parents:
11775
diff
changeset
|
79 # does a string decode. |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36690
diff
changeset
|
80 repl = stringutil.escapestr(repl) |
11961
f3075ffa6b30
subrepos: handle backslashes in subpaths
Martin Geisler <mg@lazybytes.net>
parents:
11775
diff
changeset
|
81 # However, we still want to allow back references to go |
f3075ffa6b30
subrepos: handle backslashes in subpaths
Martin Geisler <mg@lazybytes.net>
parents:
11775
diff
changeset
|
82 # through unharmed, so we turn r'\\1' into r'\1'. Again, |
f3075ffa6b30
subrepos: handle backslashes in subpaths
Martin Geisler <mg@lazybytes.net>
parents:
11775
diff
changeset
|
83 # extra escapes are needed because re.sub string decodes. |
34068
6d21737c35bf
py3: fix type of regex literals in subrepo.py
Yuya Nishihara <yuya@tcha.org>
parents:
34022
diff
changeset
|
84 repl = re.sub(br'\\\\([0-9]+)', br'\\\1', repl) |
11775
a8614c5a5e9a
subrepos: support remapping of .hgsub source paths
Martin Geisler <mg@lazybytes.net>
parents:
11572
diff
changeset
|
85 try: |
a8614c5a5e9a
subrepos: support remapping of .hgsub source paths
Martin Geisler <mg@lazybytes.net>
parents:
11572
diff
changeset
|
86 src = re.sub(pattern, repl, src, 1) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25658
diff
changeset
|
87 except re.error as e: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25980
diff
changeset
|
88 raise error.Abort(_("bad subrepository pattern in %s: %s") |
37585
df4fd29c0854
py3: use stringutil.forcebytestr() to convert error messages to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
37084
diff
changeset
|
89 % (p.source('subpaths', pattern), |
df4fd29c0854
py3: use stringutil.forcebytestr() to convert error messages to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
37084
diff
changeset
|
90 stringutil.forcebytestr(e))) |
15149
eaec9cf91aea
subrepo: refactor state function
Martin Geisler <mg@aragost.com>
parents:
15061
diff
changeset
|
91 return src |
11775
a8614c5a5e9a
subrepos: support remapping of .hgsub source paths
Martin Geisler <mg@lazybytes.net>
parents:
11572
diff
changeset
|
92 |
15149
eaec9cf91aea
subrepo: refactor state function
Martin Geisler <mg@aragost.com>
parents:
15061
diff
changeset
|
93 state = {} |
eaec9cf91aea
subrepo: refactor state function
Martin Geisler <mg@aragost.com>
parents:
15061
diff
changeset
|
94 for path, src in p[''].items(): |
eaec9cf91aea
subrepo: refactor state function
Martin Geisler <mg@aragost.com>
parents:
15061
diff
changeset
|
95 kind = 'hg' |
eaec9cf91aea
subrepo: refactor state function
Martin Geisler <mg@aragost.com>
parents:
15061
diff
changeset
|
96 if src.startswith('['): |
eaec9cf91aea
subrepo: refactor state function
Martin Geisler <mg@aragost.com>
parents:
15061
diff
changeset
|
97 if ']' not in src: |
33365
6d88468d435b
subrepo: make the output references to subrepositories consistent
Matt Harbison <matt_harbison@yahoo.com>
parents:
33364
diff
changeset
|
98 raise error.Abort(_('missing ] in subrepository source')) |
15149
eaec9cf91aea
subrepo: refactor state function
Martin Geisler <mg@aragost.com>
parents:
15061
diff
changeset
|
99 kind, src = src.split(']', 1) |
eaec9cf91aea
subrepo: refactor state function
Martin Geisler <mg@aragost.com>
parents:
15061
diff
changeset
|
100 kind = kind[1:] |
15150
91dc8878f888
subrepo: try remapping subpaths using the "final" path
Martin Geisler <mg@aragost.com>
parents:
15149
diff
changeset
|
101 src = src.lstrip() # strip any extra whitespace after ']' |
91dc8878f888
subrepo: try remapping subpaths using the "final" path
Martin Geisler <mg@aragost.com>
parents:
15149
diff
changeset
|
102 |
91dc8878f888
subrepo: try remapping subpaths using the "final" path
Martin Geisler <mg@aragost.com>
parents:
15149
diff
changeset
|
103 if not util.url(src).isabs(): |
25768
7a9ef8608a1d
subrepo: prefetch ctx.repo() for efficiency and centralization
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
25660
diff
changeset
|
104 parent = _abssource(repo, abort=False) |
15150
91dc8878f888
subrepo: try remapping subpaths using the "final" path
Martin Geisler <mg@aragost.com>
parents:
15149
diff
changeset
|
105 if parent: |
91dc8878f888
subrepo: try remapping subpaths using the "final" path
Martin Geisler <mg@aragost.com>
parents:
15149
diff
changeset
|
106 parent = util.url(parent) |
91dc8878f888
subrepo: try remapping subpaths using the "final" path
Martin Geisler <mg@aragost.com>
parents:
15149
diff
changeset
|
107 parent.path = posixpath.join(parent.path or '', src) |
91dc8878f888
subrepo: try remapping subpaths using the "final" path
Martin Geisler <mg@aragost.com>
parents:
15149
diff
changeset
|
108 parent.path = posixpath.normpath(parent.path) |
37586
b94fecf4cd8c
py3: use bytes() instead of str() on util.url()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
37585
diff
changeset
|
109 joined = bytes(parent) |
15150
91dc8878f888
subrepo: try remapping subpaths using the "final" path
Martin Geisler <mg@aragost.com>
parents:
15149
diff
changeset
|
110 # Remap the full joined path and use it if it changes, |
91dc8878f888
subrepo: try remapping subpaths using the "final" path
Martin Geisler <mg@aragost.com>
parents:
15149
diff
changeset
|
111 # else remap the original source. |
91dc8878f888
subrepo: try remapping subpaths using the "final" path
Martin Geisler <mg@aragost.com>
parents:
15149
diff
changeset
|
112 remapped = remap(joined) |
91dc8878f888
subrepo: try remapping subpaths using the "final" path
Martin Geisler <mg@aragost.com>
parents:
15149
diff
changeset
|
113 if remapped == joined: |
91dc8878f888
subrepo: try remapping subpaths using the "final" path
Martin Geisler <mg@aragost.com>
parents:
15149
diff
changeset
|
114 src = remap(src) |
91dc8878f888
subrepo: try remapping subpaths using the "final" path
Martin Geisler <mg@aragost.com>
parents:
15149
diff
changeset
|
115 else: |
91dc8878f888
subrepo: try remapping subpaths using the "final" path
Martin Geisler <mg@aragost.com>
parents:
15149
diff
changeset
|
116 src = remapped |
91dc8878f888
subrepo: try remapping subpaths using the "final" path
Martin Geisler <mg@aragost.com>
parents:
15149
diff
changeset
|
117 |
15149
eaec9cf91aea
subrepo: refactor state function
Martin Geisler <mg@aragost.com>
parents:
15061
diff
changeset
|
118 src = remap(src) |
15723
1581da01d5c4
windows: use normalized path as path to subrepo
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15531
diff
changeset
|
119 state[util.pconvert(path)] = (src.strip(), rev.get(path, ''), kind) |
8812
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
120 |
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
121 return state |
8813
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
122 |
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
123 def writestate(repo, state): |
11571 | 124 """rewrite .hgsubstate in (outer) repo with these subrepo states""" |
24858
a99931201d1b
subrepo: don't write .hgsubstate lines with empty subrepo state (issue4622)
Matt Harbison <matt_harbison@yahoo.com>
parents:
24786
diff
changeset
|
125 lines = ['%s %s\n' % (state[s][1], s) for s in sorted(state) |
a99931201d1b
subrepo: don't write .hgsubstate lines with empty subrepo state (issue4622)
Matt Harbison <matt_harbison@yahoo.com>
parents:
24786
diff
changeset
|
126 if state[s][1] != nullstate[1]] |
14443
6fe6defdc924
subrepo: refactor writestate for clarity
Martin Geisler <mg@aragost.com>
parents:
14440
diff
changeset
|
127 repo.wwrite('.hgsubstate', ''.join(lines), '') |
8813
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
128 |
30060
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
129 def submerge(repo, wctx, mctx, actx, overwrite, labels=None): |
11571 | 130 """delegated from merge.applyupdates: merging of .hgsubstate file |
131 in working context, merging context and ancestor context""" | |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
132 if mctx == actx: # backwards? |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
133 actx = wctx.p1() |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
134 s1 = wctx.substate |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
135 s2 = mctx.substate |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
136 sa = actx.substate |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
137 sm = {} |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
138 |
9782
c1c40511c276
subrepo: add more debugging output, lose _ markers
Matt Mackall <mpm@selenic.com>
parents:
9781
diff
changeset
|
139 repo.ui.debug("subrepo merge %s %s %s\n" % (wctx, mctx, actx)) |
c1c40511c276
subrepo: add more debugging output, lose _ markers
Matt Mackall <mpm@selenic.com>
parents:
9781
diff
changeset
|
140 |
9779
58a6f3f4d553
subrepo: add some debug output to submerge
Matt Mackall <mpm@selenic.com>
parents:
9752
diff
changeset
|
141 def debug(s, msg, r=""): |
58a6f3f4d553
subrepo: add some debug output to submerge
Matt Mackall <mpm@selenic.com>
parents:
9752
diff
changeset
|
142 if r: |
10177
5ca0d220ae21
subrepo: add table-based dispatch for subrepo types
Augie Fackler <durin42@gmail.com>
parents:
10175
diff
changeset
|
143 r = "%s:%s:%s" % r |
9782
c1c40511c276
subrepo: add more debugging output, lose _ markers
Matt Mackall <mpm@selenic.com>
parents:
9781
diff
changeset
|
144 repo.ui.debug(" subrepo %s: %s %s\n" % (s, msg, r)) |
9779
58a6f3f4d553
subrepo: add some debug output to submerge
Matt Mackall <mpm@selenic.com>
parents:
9752
diff
changeset
|
145 |
31516
2915cc1d3429
subrepo: move prompts out of the if (issue5505)
Simon Farnsworth <simonfar@fb.com>
parents:
30755
diff
changeset
|
146 promptssrc = filemerge.partextras(labels) |
18364
6252b4f1c4b4
subrepos: process subrepos in sorted order
Mads Kiilerich <mads@kiilerich.com>
parents:
18297
diff
changeset
|
147 for s, l in sorted(s1.iteritems()): |
11470
34e33d50c26b
subrepo: correctly handle update -C with modified subrepos (issue2022)
Matt Mackall <mpm@selenic.com>
parents:
11463
diff
changeset
|
148 a = sa.get(s, nullstate) |
11463
f0ea93557133
subrepo: fix recording of + in .hgsubstate (issue2217)
Matt Mackall <mpm@selenic.com>
parents:
11455
diff
changeset
|
149 ld = l # local state with possible dirty flag for compares |
11470
34e33d50c26b
subrepo: correctly handle update -C with modified subrepos (issue2022)
Matt Mackall <mpm@selenic.com>
parents:
11463
diff
changeset
|
150 if wctx.sub(s).dirty(): |
11463
f0ea93557133
subrepo: fix recording of + in .hgsubstate (issue2217)
Matt Mackall <mpm@selenic.com>
parents:
11455
diff
changeset
|
151 ld = (l[0], l[1] + "+") |
11470
34e33d50c26b
subrepo: correctly handle update -C with modified subrepos (issue2022)
Matt Mackall <mpm@selenic.com>
parents:
11463
diff
changeset
|
152 if wctx == actx: # overwrite |
34e33d50c26b
subrepo: correctly handle update -C with modified subrepos (issue2022)
Matt Mackall <mpm@selenic.com>
parents:
11463
diff
changeset
|
153 a = ld |
11463
f0ea93557133
subrepo: fix recording of + in .hgsubstate (issue2217)
Matt Mackall <mpm@selenic.com>
parents:
11455
diff
changeset
|
154 |
31516
2915cc1d3429
subrepo: move prompts out of the if (issue5505)
Simon Farnsworth <simonfar@fb.com>
parents:
30755
diff
changeset
|
155 prompts = promptssrc.copy() |
2915cc1d3429
subrepo: move prompts out of the if (issue5505)
Simon Farnsworth <simonfar@fb.com>
parents:
30755
diff
changeset
|
156 prompts['s'] = s |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
157 if s in s2: |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
158 r = s2[s] |
11463
f0ea93557133
subrepo: fix recording of + in .hgsubstate (issue2217)
Matt Mackall <mpm@selenic.com>
parents:
11455
diff
changeset
|
159 if ld == r or r == a: # no change or local is newer |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
160 sm[s] = l |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
161 continue |
11463
f0ea93557133
subrepo: fix recording of + in .hgsubstate (issue2217)
Matt Mackall <mpm@selenic.com>
parents:
11455
diff
changeset
|
162 elif ld == a: # other side changed |
9782
c1c40511c276
subrepo: add more debugging output, lose _ markers
Matt Mackall <mpm@selenic.com>
parents:
9781
diff
changeset
|
163 debug(s, "other changed, get", r) |
13322
c19b9282d3a7
subrepo: make update -C clean the working directory for svn subrepos
Erik Zielke <ez@aragost.com>
parents:
13287
diff
changeset
|
164 wctx.sub(s).get(r, overwrite) |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
165 sm[s] = r |
11463
f0ea93557133
subrepo: fix recording of + in .hgsubstate (issue2217)
Matt Mackall <mpm@selenic.com>
parents:
11455
diff
changeset
|
166 elif ld[0] != r[0]: # sources differ |
30060
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
167 prompts['lo'] = l[0] |
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
168 prompts['ro'] = r[0] |
9048
86b4a9b0ddda
ui: extract choice from prompt
Simon Heimberg <simohe@besonet.ch>
parents:
8997
diff
changeset
|
169 if repo.ui.promptchoice( |
30060
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
170 _(' subrepository sources for %(s)s differ\n' |
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
171 'use (l)ocal%(l)s source (%(lo)s)' |
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
172 ' or (r)emote%(o)s source (%(ro)s)?' |
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
173 '$$ &Local $$ &Remote') % prompts, 0): |
9782
c1c40511c276
subrepo: add more debugging output, lose _ markers
Matt Mackall <mpm@selenic.com>
parents:
9781
diff
changeset
|
174 debug(s, "prompt changed, get", r) |
13322
c19b9282d3a7
subrepo: make update -C clean the working directory for svn subrepos
Erik Zielke <ez@aragost.com>
parents:
13287
diff
changeset
|
175 wctx.sub(s).get(r, overwrite) |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
176 sm[s] = r |
11463
f0ea93557133
subrepo: fix recording of + in .hgsubstate (issue2217)
Matt Mackall <mpm@selenic.com>
parents:
11455
diff
changeset
|
177 elif ld[1] == a[1]: # local side is unchanged |
9782
c1c40511c276
subrepo: add more debugging output, lose _ markers
Matt Mackall <mpm@selenic.com>
parents:
9781
diff
changeset
|
178 debug(s, "other side changed, get", r) |
13322
c19b9282d3a7
subrepo: make update -C clean the working directory for svn subrepos
Erik Zielke <ez@aragost.com>
parents:
13287
diff
changeset
|
179 wctx.sub(s).get(r, overwrite) |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
180 sm[s] = r |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
181 else: |
19811
5e10d41e7b9c
merge: let the user choose to merge, keep local or keep remote subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19788
diff
changeset
|
182 debug(s, "both sides changed") |
21401
2c364f7801c8
subrepo: use subrepo shortid method to generate subrepo diverged promptchoice
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
21400
diff
changeset
|
183 srepo = wctx.sub(s) |
30060
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
184 prompts['sl'] = srepo.shortid(l[1]) |
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
185 prompts['sr'] = srepo.shortid(r[1]) |
19811
5e10d41e7b9c
merge: let the user choose to merge, keep local or keep remote subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19788
diff
changeset
|
186 option = repo.ui.promptchoice( |
30060
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
187 _(' subrepository %(s)s diverged (local revision: %(sl)s, ' |
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
188 'remote revision: %(sr)s)\n' |
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
189 '(M)erge, keep (l)ocal%(l)s or keep (r)emote%(o)s?' |
19811
5e10d41e7b9c
merge: let the user choose to merge, keep local or keep remote subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19788
diff
changeset
|
190 '$$ &Merge $$ &Local $$ &Remote') |
30060
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
191 % prompts, 0) |
19811
5e10d41e7b9c
merge: let the user choose to merge, keep local or keep remote subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19788
diff
changeset
|
192 if option == 0: |
5e10d41e7b9c
merge: let the user choose to merge, keep local or keep remote subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19788
diff
changeset
|
193 wctx.sub(s).merge(r) |
5e10d41e7b9c
merge: let the user choose to merge, keep local or keep remote subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19788
diff
changeset
|
194 sm[s] = l |
5e10d41e7b9c
merge: let the user choose to merge, keep local or keep remote subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19788
diff
changeset
|
195 debug(s, "merge with", r) |
5e10d41e7b9c
merge: let the user choose to merge, keep local or keep remote subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19788
diff
changeset
|
196 elif option == 1: |
5e10d41e7b9c
merge: let the user choose to merge, keep local or keep remote subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19788
diff
changeset
|
197 sm[s] = l |
5e10d41e7b9c
merge: let the user choose to merge, keep local or keep remote subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19788
diff
changeset
|
198 debug(s, "keep local subrepo revision", l) |
5e10d41e7b9c
merge: let the user choose to merge, keep local or keep remote subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19788
diff
changeset
|
199 else: |
5e10d41e7b9c
merge: let the user choose to merge, keep local or keep remote subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19788
diff
changeset
|
200 wctx.sub(s).get(r, overwrite) |
5e10d41e7b9c
merge: let the user choose to merge, keep local or keep remote subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19788
diff
changeset
|
201 sm[s] = r |
5e10d41e7b9c
merge: let the user choose to merge, keep local or keep remote subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19788
diff
changeset
|
202 debug(s, "get remote subrepo revision", r) |
11463
f0ea93557133
subrepo: fix recording of + in .hgsubstate (issue2217)
Matt Mackall <mpm@selenic.com>
parents:
11455
diff
changeset
|
203 elif ld == a: # remote removed, local unchanged |
9782
c1c40511c276
subrepo: add more debugging output, lose _ markers
Matt Mackall <mpm@selenic.com>
parents:
9781
diff
changeset
|
204 debug(s, "remote removed, remove") |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
205 wctx.sub(s).remove() |
14417
25137d99a5ed
subrepo: handle local added subrepo case correctly
Matt Mackall <mpm@selenic.com>
parents:
14316
diff
changeset
|
206 elif a == nullstate: # not present in remote or ancestor |
25137d99a5ed
subrepo: handle local added subrepo case correctly
Matt Mackall <mpm@selenic.com>
parents:
14316
diff
changeset
|
207 debug(s, "local added, keep") |
25137d99a5ed
subrepo: handle local added subrepo case correctly
Matt Mackall <mpm@selenic.com>
parents:
14316
diff
changeset
|
208 sm[s] = l |
25137d99a5ed
subrepo: handle local added subrepo case correctly
Matt Mackall <mpm@selenic.com>
parents:
14316
diff
changeset
|
209 continue |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
210 else: |
9048
86b4a9b0ddda
ui: extract choice from prompt
Simon Heimberg <simohe@besonet.ch>
parents:
8997
diff
changeset
|
211 if repo.ui.promptchoice( |
30060
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
212 _(' local%(l)s changed subrepository %(s)s' |
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
213 ' which remote%(o)s removed\n' |
19226
c58b6ab4c26f
ui: merge prompt text components into a singe string
Matt Mackall <mpm@selenic.com>
parents:
19156
diff
changeset
|
214 'use (c)hanged version or (d)elete?' |
30060
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
215 '$$ &Changed $$ &Delete') % prompts, 0): |
9782
c1c40511c276
subrepo: add more debugging output, lose _ markers
Matt Mackall <mpm@selenic.com>
parents:
9781
diff
changeset
|
216 debug(s, "prompt remove") |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
217 wctx.sub(s).remove() |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
218 |
13857
ba1f98f877ec
subrepo: process merge substate in sorted order in submerge()
Adrian Buehlmann <adrian@cadifra.com>
parents:
13771
diff
changeset
|
219 for s, r in sorted(s2.items()): |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
220 if s in s1: |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
221 continue |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
222 elif s not in sa: |
9782
c1c40511c276
subrepo: add more debugging output, lose _ markers
Matt Mackall <mpm@selenic.com>
parents:
9781
diff
changeset
|
223 debug(s, "remote added, get", r) |
10175
fc32b2fc468e
subrepo: load from a context where the subrepo exists
Augie Fackler <durin42@gmail.com>
parents:
10174
diff
changeset
|
224 mctx.sub(s).get(r) |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
225 sm[s] = r |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
226 elif r != sa[s]: |
31516
2915cc1d3429
subrepo: move prompts out of the if (issue5505)
Simon Farnsworth <simonfar@fb.com>
parents:
30755
diff
changeset
|
227 prompts = promptssrc.copy() |
2915cc1d3429
subrepo: move prompts out of the if (issue5505)
Simon Farnsworth <simonfar@fb.com>
parents:
30755
diff
changeset
|
228 prompts['s'] = s |
9048
86b4a9b0ddda
ui: extract choice from prompt
Simon Heimberg <simohe@besonet.ch>
parents:
8997
diff
changeset
|
229 if repo.ui.promptchoice( |
30060
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
230 _(' remote%(o)s changed subrepository %(s)s' |
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
231 ' which local%(l)s removed\n' |
19226
c58b6ab4c26f
ui: merge prompt text components into a singe string
Matt Mackall <mpm@selenic.com>
parents:
19156
diff
changeset
|
232 'use (c)hanged version or (d)elete?' |
30060
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
233 '$$ &Changed $$ &Delete') % prompts, 0) == 0: |
9782
c1c40511c276
subrepo: add more debugging output, lose _ markers
Matt Mackall <mpm@selenic.com>
parents:
9781
diff
changeset
|
234 debug(s, "prompt recreate", r) |
24110
756c5c8331b0
subrepo: add tests for change/remove conflicts
Martin von Zweigbergk <martinvonz@google.com>
parents:
23963
diff
changeset
|
235 mctx.sub(s).get(r) |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
236 sm[s] = r |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
237 |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
238 # record merged .hgsubstate |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
239 writestate(repo, sm) |
19637
cc338115d3b2
subrepo: make submerge() return the merged substate
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19226
diff
changeset
|
240 return sm |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
241 |
35025
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
242 def precommit(ui, wctx, status, match, force=False): |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
243 """Calculate .hgsubstate changes that should be applied before committing |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
244 |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
245 Returns (subs, commitsubs, newstate) where |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
246 - subs: changed subrepos (including dirty ones) |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
247 - commitsubs: dirty subrepos which the caller needs to commit recursively |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
248 - newstate: new state dict which the caller must write to .hgsubstate |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
249 |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
250 This also updates the given status argument. |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
251 """ |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
252 subs = [] |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
253 commitsubs = set() |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
254 newstate = wctx.substate.copy() |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
255 |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
256 # only manage subrepos and .hgsubstate if .hgsub is present |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
257 if '.hgsub' in wctx: |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
258 # we'll decide whether to track this ourselves, thanks |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
259 for c in status.modified, status.added, status.removed: |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
260 if '.hgsubstate' in c: |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
261 c.remove('.hgsubstate') |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
262 |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
263 # compare current state to last committed state |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
264 # build new substate based on last committed state |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
265 oldstate = wctx.p1().substate |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
266 for s in sorted(newstate.keys()): |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
267 if not match(s): |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
268 # ignore working copy, use old state if present |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
269 if s in oldstate: |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
270 newstate[s] = oldstate[s] |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
271 continue |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
272 if not force: |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
273 raise error.Abort( |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
274 _("commit with new subrepo %s excluded") % s) |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
275 dirtyreason = wctx.sub(s).dirtyreason(True) |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
276 if dirtyreason: |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
277 if not ui.configbool('ui', 'commitsubrepos'): |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
278 raise error.Abort(dirtyreason, |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
279 hint=_("use --subrepos for recursive commit")) |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
280 subs.append(s) |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
281 commitsubs.add(s) |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
282 else: |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
283 bs = wctx.sub(s).basestate() |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
284 newstate[s] = (newstate[s][0], bs, newstate[s][2]) |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
285 if oldstate.get(s, (None, None, None))[1] != bs: |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
286 subs.append(s) |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
287 |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
288 # check for removed subrepos |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
289 for p in wctx.parents(): |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
290 r = [s for s in p.substate if s not in newstate] |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
291 subs += [s for s in r if match(s)] |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
292 if subs: |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
293 if (not match('.hgsub') and |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
294 '.hgsub' in (wctx.modified() + wctx.added())): |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
295 raise error.Abort(_("can't commit subrepos without .hgsub")) |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
296 status.modified.insert(0, '.hgsubstate') |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
297 |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
298 elif '.hgsub' in status.removed: |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
299 # clean up .hgsubstate when .hgsub is removed |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
300 if ('.hgsubstate' in wctx and |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
301 '.hgsubstate' not in (status.modified + status.added + |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
302 status.removed)): |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
303 status.removed.insert(0, '.hgsubstate') |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
304 |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
305 return subs, commitsubs, newstate |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
306 |
24785
39f519be5e65
subrepo: backout 93b0e0db7929 to restore reporelpath()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24778
diff
changeset
|
307 def reporelpath(repo): |
39f519be5e65
subrepo: backout 93b0e0db7929 to restore reporelpath()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24778
diff
changeset
|
308 """return path to this (sub)repo as seen from outermost repo""" |
39f519be5e65
subrepo: backout 93b0e0db7929 to restore reporelpath()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24778
diff
changeset
|
309 parent = repo |
39f519be5e65
subrepo: backout 93b0e0db7929 to restore reporelpath()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24778
diff
changeset
|
310 while util.safehasattr(parent, '_subparent'): |
39f519be5e65
subrepo: backout 93b0e0db7929 to restore reporelpath()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24778
diff
changeset
|
311 parent = parent._subparent |
39f519be5e65
subrepo: backout 93b0e0db7929 to restore reporelpath()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24778
diff
changeset
|
312 return repo.root[len(pathutil.normasprefix(parent.root)):] |
39f519be5e65
subrepo: backout 93b0e0db7929 to restore reporelpath()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24778
diff
changeset
|
313 |
12752
18b5b6392fcf
subrepo: rename relpath to subrelpath and introduce reporelpath
Mads Kiilerich <mads@kiilerich.com>
parents:
12506
diff
changeset
|
314 def subrelpath(sub): |
11571 | 315 """return path to this subrepo as seen from outermost repo""" |
24673
105758d1b37b
subrepo: add _relpath field to centralize subrelpath logic
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24672
diff
changeset
|
316 return sub._relpath |
11112
4a9bee613737
subrepo: print paths relative to upper repo root for push/pull/commit
Edouard Gomez <ed.gomez@free.fr>
parents:
11111
diff
changeset
|
317 |
12753
ef5eaf53f4f7
subrepo: abort instead of pushing/pulling to the repo itself
Mads Kiilerich <mads@kiilerich.com>
parents:
12752
diff
changeset
|
318 def _abssource(repo, push=False, abort=True): |
ef5eaf53f4f7
subrepo: abort instead of pushing/pulling to the repo itself
Mads Kiilerich <mads@kiilerich.com>
parents:
12752
diff
changeset
|
319 """return pull/push path of repo - either based on parent repo .hgsub info |
ef5eaf53f4f7
subrepo: abort instead of pushing/pulling to the repo itself
Mads Kiilerich <mads@kiilerich.com>
parents:
12752
diff
changeset
|
320 or on the top repo config. Abort or return None if no source found.""" |
14963
c035f1c53e39
subrepo: use safehasattr instead of hasattr
Augie Fackler <durin42@gmail.com>
parents:
14898
diff
changeset
|
321 if util.safehasattr(repo, '_subparent'): |
14076
924c82157d46
url: move URL parsing functions into util to improve startup time
Brodie Rao <brodie@bitheap.org>
parents:
14052
diff
changeset
|
322 source = util.url(repo._subsource) |
14766
4f56b7530eab
subrepos: be smarter about what's an absolute path (issue2808)
Matt Mackall <mpm@selenic.com>
parents:
14664
diff
changeset
|
323 if source.isabs(): |
35613
991f0be9dc39
py3: use bytes instead of pycompat.bytestr
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35587
diff
changeset
|
324 return bytes(source) |
13771
ce6227306c9a
subrepos: use url.url when normalizing repo paths
Brodie Rao <brodie@bitheap.org>
parents:
13753
diff
changeset
|
325 source.path = posixpath.normpath(source.path) |
12753
ef5eaf53f4f7
subrepo: abort instead of pushing/pulling to the repo itself
Mads Kiilerich <mads@kiilerich.com>
parents:
12752
diff
changeset
|
326 parent = _abssource(repo._subparent, push, abort=False) |
ef5eaf53f4f7
subrepo: abort instead of pushing/pulling to the repo itself
Mads Kiilerich <mads@kiilerich.com>
parents:
12752
diff
changeset
|
327 if parent: |
15498
ac5a340b26de
subrepo: use correct paths for subrepos with ..-relative paths on windows
Mads Kiilerich <mads@kiilerich.com>
parents:
15287
diff
changeset
|
328 parent = util.url(util.pconvert(parent)) |
15055
d629f1e89021
subrepo: fix cloning of repos from urls without slash after host (issue2970)
Mads Kiilerich <mads@kiilerich.com>
parents:
14994
diff
changeset
|
329 parent.path = posixpath.join(parent.path or '', source.path) |
13771
ce6227306c9a
subrepos: use url.url when normalizing repo paths
Brodie Rao <brodie@bitheap.org>
parents:
13753
diff
changeset
|
330 parent.path = posixpath.normpath(parent.path) |
35613
991f0be9dc39
py3: use bytes instead of pycompat.bytestr
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35587
diff
changeset
|
331 return bytes(parent) |
12753
ef5eaf53f4f7
subrepo: abort instead of pushing/pulling to the repo itself
Mads Kiilerich <mads@kiilerich.com>
parents:
12752
diff
changeset
|
332 else: # recursion reached top repo |
35777
0c0689a7565e
subrepo: handle 'C:' style paths on the command line (issue5770)
Matt Harbison <matt_harbison@yahoo.com>
parents:
35676
diff
changeset
|
333 path = None |
14963
c035f1c53e39
subrepo: use safehasattr instead of hasattr
Augie Fackler <durin42@gmail.com>
parents:
14898
diff
changeset
|
334 if util.safehasattr(repo, '_subtoppath'): |
35777
0c0689a7565e
subrepo: handle 'C:' style paths on the command line (issue5770)
Matt Harbison <matt_harbison@yahoo.com>
parents:
35676
diff
changeset
|
335 path = repo._subtoppath |
0c0689a7565e
subrepo: handle 'C:' style paths on the command line (issue5770)
Matt Harbison <matt_harbison@yahoo.com>
parents:
35676
diff
changeset
|
336 elif push and repo.ui.config('paths', 'default-push'): |
0c0689a7565e
subrepo: handle 'C:' style paths on the command line (issue5770)
Matt Harbison <matt_harbison@yahoo.com>
parents:
35676
diff
changeset
|
337 path = repo.ui.config('paths', 'default-push') |
0c0689a7565e
subrepo: handle 'C:' style paths on the command line (issue5770)
Matt Harbison <matt_harbison@yahoo.com>
parents:
35676
diff
changeset
|
338 elif repo.ui.config('paths', 'default'): |
0c0689a7565e
subrepo: handle 'C:' style paths on the command line (issue5770)
Matt Harbison <matt_harbison@yahoo.com>
parents:
35676
diff
changeset
|
339 path = repo.ui.config('paths', 'default') |
0c0689a7565e
subrepo: handle 'C:' style paths on the command line (issue5770)
Matt Harbison <matt_harbison@yahoo.com>
parents:
35676
diff
changeset
|
340 elif repo.shared(): |
0c0689a7565e
subrepo: handle 'C:' style paths on the command line (issue5770)
Matt Harbison <matt_harbison@yahoo.com>
parents:
35676
diff
changeset
|
341 # chop off the .hg component to get the default path form. This has |
0c0689a7565e
subrepo: handle 'C:' style paths on the command line (issue5770)
Matt Harbison <matt_harbison@yahoo.com>
parents:
35676
diff
changeset
|
342 # already run through vfsmod.vfs(..., realpath=True), so it doesn't |
0c0689a7565e
subrepo: handle 'C:' style paths on the command line (issue5770)
Matt Harbison <matt_harbison@yahoo.com>
parents:
35676
diff
changeset
|
343 # have problems with 'C:' |
18510
f254ab6207ae
subrepo: use sharepath if available when locating the source repo
Matt Harbison <matt_harbison@yahoo.com>
parents:
18364
diff
changeset
|
344 return os.path.dirname(repo.sharedpath) |
35777
0c0689a7565e
subrepo: handle 'C:' style paths on the command line (issue5770)
Matt Harbison <matt_harbison@yahoo.com>
parents:
35676
diff
changeset
|
345 if path: |
0c0689a7565e
subrepo: handle 'C:' style paths on the command line (issue5770)
Matt Harbison <matt_harbison@yahoo.com>
parents:
35676
diff
changeset
|
346 # issue5770: 'C:\' and 'C:' are not equivalent paths. The former is |
0c0689a7565e
subrepo: handle 'C:' style paths on the command line (issue5770)
Matt Harbison <matt_harbison@yahoo.com>
parents:
35676
diff
changeset
|
347 # as expected: an absolute path to the root of the C: drive. The |
0c0689a7565e
subrepo: handle 'C:' style paths on the command line (issue5770)
Matt Harbison <matt_harbison@yahoo.com>
parents:
35676
diff
changeset
|
348 # latter is a relative path, and works like so: |
0c0689a7565e
subrepo: handle 'C:' style paths on the command line (issue5770)
Matt Harbison <matt_harbison@yahoo.com>
parents:
35676
diff
changeset
|
349 # |
0c0689a7565e
subrepo: handle 'C:' style paths on the command line (issue5770)
Matt Harbison <matt_harbison@yahoo.com>
parents:
35676
diff
changeset
|
350 # C:\>cd C:\some\path |
0c0689a7565e
subrepo: handle 'C:' style paths on the command line (issue5770)
Matt Harbison <matt_harbison@yahoo.com>
parents:
35676
diff
changeset
|
351 # C:\>D: |
0c0689a7565e
subrepo: handle 'C:' style paths on the command line (issue5770)
Matt Harbison <matt_harbison@yahoo.com>
parents:
35676
diff
changeset
|
352 # D:\>python -c "import os; print os.path.abspath('C:')" |
0c0689a7565e
subrepo: handle 'C:' style paths on the command line (issue5770)
Matt Harbison <matt_harbison@yahoo.com>
parents:
35676
diff
changeset
|
353 # C:\some\path |
0c0689a7565e
subrepo: handle 'C:' style paths on the command line (issue5770)
Matt Harbison <matt_harbison@yahoo.com>
parents:
35676
diff
changeset
|
354 # |
0c0689a7565e
subrepo: handle 'C:' style paths on the command line (issue5770)
Matt Harbison <matt_harbison@yahoo.com>
parents:
35676
diff
changeset
|
355 # D:\>python -c "import os; print os.path.abspath('C:relative')" |
0c0689a7565e
subrepo: handle 'C:' style paths on the command line (issue5770)
Matt Harbison <matt_harbison@yahoo.com>
parents:
35676
diff
changeset
|
356 # C:\some\path\relative |
0c0689a7565e
subrepo: handle 'C:' style paths on the command line (issue5770)
Matt Harbison <matt_harbison@yahoo.com>
parents:
35676
diff
changeset
|
357 if util.hasdriveletter(path): |
0c0689a7565e
subrepo: handle 'C:' style paths on the command line (issue5770)
Matt Harbison <matt_harbison@yahoo.com>
parents:
35676
diff
changeset
|
358 if len(path) == 2 or path[2:3] not in br'\/': |
0c0689a7565e
subrepo: handle 'C:' style paths on the command line (issue5770)
Matt Harbison <matt_harbison@yahoo.com>
parents:
35676
diff
changeset
|
359 path = os.path.abspath(path) |
0c0689a7565e
subrepo: handle 'C:' style paths on the command line (issue5770)
Matt Harbison <matt_harbison@yahoo.com>
parents:
35676
diff
changeset
|
360 return path |
0c0689a7565e
subrepo: handle 'C:' style paths on the command line (issue5770)
Matt Harbison <matt_harbison@yahoo.com>
parents:
35676
diff
changeset
|
361 |
12753
ef5eaf53f4f7
subrepo: abort instead of pushing/pulling to the repo itself
Mads Kiilerich <mads@kiilerich.com>
parents:
12752
diff
changeset
|
362 if abort: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25980
diff
changeset
|
363 raise error.Abort(_("default path for subrepository not found")) |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
364 |
20176
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
365 def newcommitphase(ui, ctx): |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
366 commitphase = phases.newcommitphase(ui) |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
367 substate = getattr(ctx, "substate", None) |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
368 if not substate: |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
369 return commitphase |
33499
0407a51b9d8c
codemod: register core configitems using a script
Jun Wu <quark@fb.com>
parents:
33365
diff
changeset
|
370 check = ui.config('phases', 'checksubrepos') |
20176
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
371 if check not in ('ignore', 'follow', 'abort'): |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25980
diff
changeset
|
372 raise error.Abort(_('invalid phases.checksubrepos configuration: %s') |
20176
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
373 % (check)) |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
374 if check == 'ignore': |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
375 return commitphase |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
376 maxphase = phases.public |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
377 maxsub = None |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
378 for s in sorted(substate): |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
379 sub = ctx.sub(s) |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
380 subphase = sub.phase(substate[s][1]) |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
381 if maxphase < subphase: |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
382 maxphase = subphase |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
383 maxsub = s |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
384 if commitphase < maxphase: |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
385 if check == 'abort': |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25980
diff
changeset
|
386 raise error.Abort(_("can't commit in %s phase" |
20176
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
387 " conflicting %s from subrepository %s") % |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
388 (phases.phasenames[commitphase], |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
389 phases.phasenames[maxphase], maxsub)) |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
390 ui.warn(_("warning: changes are committed in" |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
391 " %s phase from subrepository %s\n") % |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
392 (phases.phasenames[maxphase], maxsub)) |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
393 return maxphase |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
394 return commitphase |