Show More
@@ -1,361 +1,361 b'' | |||
|
1 | 1 | # subrepo.py - sub-repository handling for Mercurial |
|
2 | 2 | # |
|
3 | 3 | # Copyright 2009-2010 Matt Mackall <mpm@selenic.com> |
|
4 | 4 | # |
|
5 | 5 | # This software may be used and distributed according to the terms of the |
|
6 | 6 | # GNU General Public License version 2 or any later version. |
|
7 | 7 | |
|
8 | 8 | import errno, os, re, xml.dom.minidom, shutil |
|
9 | 9 | from i18n import _ |
|
10 | 10 | import config, util, node, error |
|
11 | 11 | hg = None |
|
12 | 12 | |
|
13 | 13 | nullstate = ('', '', 'empty') |
|
14 | 14 | |
|
15 | 15 | def state(ctx): |
|
16 | 16 | p = config.config() |
|
17 | 17 | def read(f, sections=None, remap=None): |
|
18 | 18 | if f in ctx: |
|
19 | 19 | p.parse(f, ctx[f].data(), sections, remap, read) |
|
20 | 20 | else: |
|
21 | 21 | raise util.Abort(_("subrepo spec file %s not found") % f) |
|
22 | 22 | |
|
23 | 23 | if '.hgsub' in ctx: |
|
24 | 24 | read('.hgsub') |
|
25 | 25 | |
|
26 | 26 | rev = {} |
|
27 | 27 | if '.hgsubstate' in ctx: |
|
28 | 28 | try: |
|
29 | 29 | for l in ctx['.hgsubstate'].data().splitlines(): |
|
30 | 30 | revision, path = l.split(" ", 1) |
|
31 | 31 | rev[path] = revision |
|
32 | 32 | except IOError, err: |
|
33 | 33 | if err.errno != errno.ENOENT: |
|
34 | 34 | raise |
|
35 | 35 | |
|
36 | 36 | state = {} |
|
37 | 37 | for path, src in p[''].items(): |
|
38 | 38 | kind = 'hg' |
|
39 | 39 | if src.startswith('['): |
|
40 | 40 | if ']' not in src: |
|
41 | 41 | raise util.Abort(_('missing ] in subrepo source')) |
|
42 | 42 | kind, src = src.split(']', 1) |
|
43 | 43 | kind = kind[1:] |
|
44 | 44 | state[path] = (src.strip(), rev.get(path, ''), kind) |
|
45 | 45 | |
|
46 | 46 | return state |
|
47 | 47 | |
|
48 | 48 | def writestate(repo, state): |
|
49 | 49 | repo.wwrite('.hgsubstate', |
|
50 | 50 | ''.join(['%s %s\n' % (state[s][1], s) |
|
51 | 51 | for s in sorted(state)]), '') |
|
52 | 52 | |
|
53 | 53 | def submerge(repo, wctx, mctx, actx): |
|
54 | 54 | # working context, merging context, ancestor context |
|
55 | 55 | if mctx == actx: # backwards? |
|
56 | 56 | actx = wctx.p1() |
|
57 | 57 | s1 = wctx.substate |
|
58 | 58 | s2 = mctx.substate |
|
59 | 59 | sa = actx.substate |
|
60 | 60 | sm = {} |
|
61 | 61 | |
|
62 | 62 | repo.ui.debug("subrepo merge %s %s %s\n" % (wctx, mctx, actx)) |
|
63 | 63 | |
|
64 | 64 | def debug(s, msg, r=""): |
|
65 | 65 | if r: |
|
66 | 66 | r = "%s:%s:%s" % r |
|
67 | 67 | repo.ui.debug(" subrepo %s: %s %s\n" % (s, msg, r)) |
|
68 | 68 | |
|
69 | 69 | for s, l in s1.items(): |
|
70 | 70 | if wctx != actx and wctx.sub(s).dirty(): |
|
71 | 71 | l = (l[0], l[1] + "+") |
|
72 | 72 | a = sa.get(s, nullstate) |
|
73 | 73 | if s in s2: |
|
74 | 74 | r = s2[s] |
|
75 | 75 | if l == r or r == a: # no change or local is newer |
|
76 | 76 | sm[s] = l |
|
77 | 77 | continue |
|
78 | 78 | elif l == a: # other side changed |
|
79 | 79 | debug(s, "other changed, get", r) |
|
80 | 80 | wctx.sub(s).get(r) |
|
81 | 81 | sm[s] = r |
|
82 | 82 | elif l[0] != r[0]: # sources differ |
|
83 | 83 | if repo.ui.promptchoice( |
|
84 | 84 | _(' subrepository sources for %s differ\n' |
|
85 | 85 | 'use (l)ocal source (%s) or (r)emote source (%s)?') |
|
86 | 86 | % (s, l[0], r[0]), |
|
87 | 87 | (_('&Local'), _('&Remote')), 0): |
|
88 | 88 | debug(s, "prompt changed, get", r) |
|
89 | 89 | wctx.sub(s).get(r) |
|
90 | 90 | sm[s] = r |
|
91 | 91 | elif l[1] == a[1]: # local side is unchanged |
|
92 | 92 | debug(s, "other side changed, get", r) |
|
93 | 93 | wctx.sub(s).get(r) |
|
94 | 94 | sm[s] = r |
|
95 | 95 | else: |
|
96 | 96 | debug(s, "both sides changed, merge with", r) |
|
97 | 97 | wctx.sub(s).merge(r) |
|
98 | 98 | sm[s] = l |
|
99 | 99 | elif l == a: # remote removed, local unchanged |
|
100 | 100 | debug(s, "remote removed, remove") |
|
101 | 101 | wctx.sub(s).remove() |
|
102 | 102 | else: |
|
103 | 103 | if repo.ui.promptchoice( |
|
104 | 104 | _(' local changed subrepository %s which remote removed\n' |
|
105 | 105 | 'use (c)hanged version or (d)elete?') % s, |
|
106 | 106 | (_('&Changed'), _('&Delete')), 0): |
|
107 | 107 | debug(s, "prompt remove") |
|
108 | 108 | wctx.sub(s).remove() |
|
109 | 109 | |
|
110 | 110 | for s, r in s2.items(): |
|
111 | 111 | if s in s1: |
|
112 | 112 | continue |
|
113 | 113 | elif s not in sa: |
|
114 | 114 | debug(s, "remote added, get", r) |
|
115 | 115 | mctx.sub(s).get(r) |
|
116 | 116 | sm[s] = r |
|
117 | 117 | elif r != sa[s]: |
|
118 | 118 | if repo.ui.promptchoice( |
|
119 | 119 | _(' remote changed subrepository %s which local removed\n' |
|
120 | 120 | 'use (c)hanged version or (d)elete?') % s, |
|
121 | 121 | (_('&Changed'), _('&Delete')), 0) == 0: |
|
122 | 122 | debug(s, "prompt recreate", r) |
|
123 | 123 | wctx.sub(s).get(r) |
|
124 | 124 | sm[s] = r |
|
125 | 125 | |
|
126 | 126 | # record merged .hgsubstate |
|
127 | 127 | writestate(repo, sm) |
|
128 | 128 | |
|
129 | 129 | def _abssource(repo, push=False): |
|
130 | 130 | if hasattr(repo, '_subparent'): |
|
131 | 131 | source = repo._subsource |
|
132 | 132 | if source.startswith('/') or '://' in source: |
|
133 | 133 | return source |
|
134 | 134 | parent = _abssource(repo._subparent) |
|
135 | 135 | if '://' in parent: |
|
136 | 136 | if parent[-1] == '/': |
|
137 | 137 | parent = parent[:-1] |
|
138 | 138 | return parent + '/' + source |
|
139 | 139 | return os.path.join(parent, repo._subsource) |
|
140 | 140 | if push and repo.ui.config('paths', 'default-push'): |
|
141 | 141 | return repo.ui.config('paths', 'default-push', repo.root) |
|
142 | 142 | return repo.ui.config('paths', 'default', repo.root) |
|
143 | 143 | |
|
144 | 144 | def subrepo(ctx, path): |
|
145 | 145 | # subrepo inherently violates our import layering rules |
|
146 | 146 | # because it wants to make repo objects from deep inside the stack |
|
147 | 147 | # so we manually delay the circular imports to not break |
|
148 | 148 | # scripts that don't use our demand-loading |
|
149 | 149 | global hg |
|
150 | 150 | import hg as h |
|
151 | 151 | hg = h |
|
152 | 152 | |
|
153 | 153 | util.path_auditor(ctx._repo.root)(path) |
|
154 | 154 | state = ctx.substate.get(path, nullstate) |
|
155 | 155 | if state[2] not in types: |
|
156 | 156 | raise util.Abort(_('unknown subrepo type %s') % state[2]) |
|
157 | 157 | return types[state[2]](ctx, path, state[:2]) |
|
158 | 158 | |
|
159 | 159 | # subrepo classes need to implement the following methods: |
|
160 | 160 | # __init__(self, ctx, path, state) |
|
161 | 161 | # dirty(self): returns true if the dirstate of the subrepo |
|
162 | 162 | # does not match current stored state |
|
163 | 163 | # commit(self, text, user, date): commit the current changes |
|
164 | 164 | # to the subrepo with the given log message. Use given |
|
165 | 165 | # user and date if possible. Return the new state of the subrepo. |
|
166 | 166 | # remove(self): remove the subrepo (should verify the dirstate |
|
167 | 167 | # is not dirty first) |
|
168 | 168 | # get(self, state): run whatever commands are needed to put the |
|
169 | 169 | # subrepo into this state |
|
170 | 170 | # merge(self, state): merge currently-saved state with the new state. |
|
171 | 171 | # push(self, force): perform whatever action is analagous to 'hg push' |
|
172 | 172 | # This may be a no-op on some systems. |
|
173 | 173 | |
|
174 | 174 | class hgsubrepo(object): |
|
175 | 175 | def __init__(self, ctx, path, state): |
|
176 | 176 | self._path = path |
|
177 | 177 | self._state = state |
|
178 | 178 | r = ctx._repo |
|
179 | 179 | root = r.wjoin(path) |
|
180 | 180 | if os.path.exists(os.path.join(root, '.hg')): |
|
181 | 181 | self._repo = hg.repository(r.ui, root) |
|
182 | 182 | else: |
|
183 | 183 | util.makedirs(root) |
|
184 | 184 | self._repo = hg.repository(r.ui, root, create=True) |
|
185 | 185 | f = file(os.path.join(root, '.hg', 'hgrc'), 'w') |
|
186 | 186 | f.write('[paths]\ndefault = %s\n' % os.path.join( |
|
187 | 187 | _abssource(ctx._repo), path)) |
|
188 | 188 | f.close() |
|
189 | 189 | self._repo._subparent = r |
|
190 | 190 | self._repo._subsource = state[0] |
|
191 | 191 | |
|
192 | 192 | def dirty(self): |
|
193 | 193 | r = self._state[1] |
|
194 | 194 | if r == '': |
|
195 | 195 | return True |
|
196 | 196 | w = self._repo[None] |
|
197 | 197 | if w.p1() != self._repo[r]: # version checked out changed |
|
198 | 198 | return True |
|
199 | 199 | return w.dirty() # working directory changed |
|
200 | 200 | |
|
201 | 201 | def commit(self, text, user, date): |
|
202 | 202 | self._repo.ui.debug("committing subrepo %s\n" % self._path) |
|
203 | 203 | n = self._repo.commit(text, user, date) |
|
204 | 204 | if not n: |
|
205 | 205 | return self._repo['.'].hex() # different version checked out |
|
206 | 206 | return node.hex(n) |
|
207 | 207 | |
|
208 | 208 | def remove(self): |
|
209 | 209 | # we can't fully delete the repository as it may contain |
|
210 | 210 | # local-only history |
|
211 | 211 | self._repo.ui.note(_('removing subrepo %s\n') % self._path) |
|
212 | 212 | hg.clean(self._repo, node.nullid, False) |
|
213 | 213 | |
|
214 | 214 | def _get(self, state): |
|
215 | 215 | source, revision, kind = state |
|
216 | 216 | try: |
|
217 | 217 | self._repo.lookup(revision) |
|
218 | 218 | except error.RepoError: |
|
219 | 219 | self._repo._subsource = source |
|
220 | self._repo.ui.status(_('pulling subrepo %s\n') % self._path) | |
|
221 | 220 | srcurl = _abssource(self._repo) |
|
221 | self._repo.ui.status(_('pulling subrepo %s from %s\n') % (self._path, srcurl)) | |
|
222 | 222 | other = hg.repository(self._repo.ui, srcurl) |
|
223 | 223 | self._repo.pull(other) |
|
224 | 224 | |
|
225 | 225 | def get(self, state): |
|
226 | 226 | self._get(state) |
|
227 | 227 | source, revision, kind = state |
|
228 | 228 | self._repo.ui.debug("getting subrepo %s\n" % self._path) |
|
229 | 229 | hg.clean(self._repo, revision, False) |
|
230 | 230 | |
|
231 | 231 | def merge(self, state): |
|
232 | 232 | self._get(state) |
|
233 | 233 | cur = self._repo['.'] |
|
234 | 234 | dst = self._repo[state[1]] |
|
235 | 235 | anc = dst.ancestor(cur) |
|
236 | 236 | if anc == cur: |
|
237 | 237 | self._repo.ui.debug("updating subrepo %s\n" % self._path) |
|
238 | 238 | hg.update(self._repo, state[1]) |
|
239 | 239 | elif anc == dst: |
|
240 | 240 | self._repo.ui.debug("skipping subrepo %s\n" % self._path) |
|
241 | 241 | else: |
|
242 | 242 | self._repo.ui.debug("merging subrepo %s\n" % self._path) |
|
243 | 243 | hg.merge(self._repo, state[1], remind=False) |
|
244 | 244 | |
|
245 | 245 | def push(self, force): |
|
246 | 246 | # push subrepos depth-first for coherent ordering |
|
247 | 247 | c = self._repo[''] |
|
248 | 248 | subs = c.substate # only repos that are committed |
|
249 | 249 | for s in sorted(subs): |
|
250 | 250 | c.sub(s).push(force) |
|
251 | 251 | |
|
252 | 252 | self._repo.ui.status(_('pushing subrepo %s\n') % self._path) |
|
253 | 253 | dsturl = _abssource(self._repo, True) |
|
254 | 254 | other = hg.repository(self._repo.ui, dsturl) |
|
255 | 255 | self._repo.push(other, force) |
|
256 | 256 | |
|
257 | 257 | class svnsubrepo(object): |
|
258 | 258 | def __init__(self, ctx, path, state): |
|
259 | 259 | self._path = path |
|
260 | 260 | self._state = state |
|
261 | 261 | self._ctx = ctx |
|
262 | 262 | self._ui = ctx._repo.ui |
|
263 | 263 | |
|
264 | 264 | def _svncommand(self, commands): |
|
265 | 265 | cmd = ['svn'] + commands + [self._path] |
|
266 | 266 | cmd = [util.shellquote(arg) for arg in cmd] |
|
267 | 267 | cmd = util.quotecommand(' '.join(cmd)) |
|
268 | 268 | env = dict(os.environ) |
|
269 | 269 | # Avoid localized output, preserve current locale for everything else. |
|
270 | 270 | env['LC_MESSAGES'] = 'C' |
|
271 | 271 | write, read, err = util.popen3(cmd, env=env, newlines=True) |
|
272 | 272 | retdata = read.read() |
|
273 | 273 | err = err.read().strip() |
|
274 | 274 | if err: |
|
275 | 275 | raise util.Abort(err) |
|
276 | 276 | return retdata |
|
277 | 277 | |
|
278 | 278 | def _wcrev(self): |
|
279 | 279 | output = self._svncommand(['info', '--xml']) |
|
280 | 280 | doc = xml.dom.minidom.parseString(output) |
|
281 | 281 | entries = doc.getElementsByTagName('entry') |
|
282 | 282 | if not entries: |
|
283 | 283 | return 0 |
|
284 | 284 | return int(entries[0].getAttribute('revision') or 0) |
|
285 | 285 | |
|
286 | 286 | def _wcchanged(self): |
|
287 | 287 | """Return (changes, extchanges) where changes is True |
|
288 | 288 | if the working directory was changed, and extchanges is |
|
289 | 289 | True if any of these changes concern an external entry. |
|
290 | 290 | """ |
|
291 | 291 | output = self._svncommand(['status', '--xml']) |
|
292 | 292 | externals, changes = [], [] |
|
293 | 293 | doc = xml.dom.minidom.parseString(output) |
|
294 | 294 | for e in doc.getElementsByTagName('entry'): |
|
295 | 295 | s = e.getElementsByTagName('wc-status') |
|
296 | 296 | if not s: |
|
297 | 297 | continue |
|
298 | 298 | item = s[0].getAttribute('item') |
|
299 | 299 | props = s[0].getAttribute('props') |
|
300 | 300 | path = e.getAttribute('path') |
|
301 | 301 | if item == 'external': |
|
302 | 302 | externals.append(path) |
|
303 | 303 | if (item not in ('', 'normal', 'unversioned', 'external') |
|
304 | 304 | or props not in ('', 'none')): |
|
305 | 305 | changes.append(path) |
|
306 | 306 | for path in changes: |
|
307 | 307 | for ext in externals: |
|
308 | 308 | if path == ext or path.startswith(ext + os.sep): |
|
309 | 309 | return True, True |
|
310 | 310 | return bool(changes), False |
|
311 | 311 | |
|
312 | 312 | def dirty(self): |
|
313 | 313 | if self._wcrev() == self._state[1] and not self._wcchanged()[0]: |
|
314 | 314 | return False |
|
315 | 315 | return True |
|
316 | 316 | |
|
317 | 317 | def commit(self, text, user, date): |
|
318 | 318 | # user and date are out of our hands since svn is centralized |
|
319 | 319 | changed, extchanged = self._wcchanged() |
|
320 | 320 | if not changed: |
|
321 | 321 | return self._wcrev() |
|
322 | 322 | if extchanged: |
|
323 | 323 | # Do not try to commit externals |
|
324 | 324 | raise util.Abort(_('cannot commit svn externals')) |
|
325 | 325 | commitinfo = self._svncommand(['commit', '-m', text]) |
|
326 | 326 | self._ui.status(commitinfo) |
|
327 | 327 | newrev = re.search('Committed revision ([\d]+).', commitinfo) |
|
328 | 328 | if not newrev: |
|
329 | 329 | raise util.Abort(commitinfo.splitlines()[-1]) |
|
330 | 330 | newrev = newrev.groups()[0] |
|
331 | 331 | self._ui.status(self._svncommand(['update', '-r', newrev])) |
|
332 | 332 | return newrev |
|
333 | 333 | |
|
334 | 334 | def remove(self): |
|
335 | 335 | if self.dirty(): |
|
336 | 336 | self._ui.warn(_('not removing repo %s because ' |
|
337 | 337 | 'it has changes.\n' % self._path)) |
|
338 | 338 | return |
|
339 | 339 | self._ui.note(_('removing subrepo %s\n') % self._path) |
|
340 | 340 | shutil.rmtree(self._ctx.repo.join(self._path)) |
|
341 | 341 | |
|
342 | 342 | def get(self, state): |
|
343 | 343 | status = self._svncommand(['checkout', state[0], '--revision', state[1]]) |
|
344 | 344 | if not re.search('Checked out revision [\d]+.', status): |
|
345 | 345 | raise util.Abort(status.splitlines()[-1]) |
|
346 | 346 | self._ui.status(status) |
|
347 | 347 | |
|
348 | 348 | def merge(self, state): |
|
349 | 349 | old = int(self._state[1]) |
|
350 | 350 | new = int(state[1]) |
|
351 | 351 | if new > old: |
|
352 | 352 | self.get(state) |
|
353 | 353 | |
|
354 | 354 | def push(self, force): |
|
355 | 355 | # nothing for svn |
|
356 | 356 | pass |
|
357 | 357 | |
|
358 | 358 | types = { |
|
359 | 359 | 'hg': hgsubrepo, |
|
360 | 360 | 'svn': svnsubrepo, |
|
361 | 361 | } |
@@ -1,210 +1,211 b'' | |||
|
1 | 1 | #!/bin/sh |
|
2 | 2 | |
|
3 | 3 | rm -rf sub |
|
4 | 4 | mkdir sub |
|
5 | 5 | cd sub |
|
6 | 6 | hg init t |
|
7 | 7 | cd t |
|
8 | 8 | |
|
9 | 9 | echo % first revision, no sub |
|
10 | 10 | echo a > a |
|
11 | 11 | hg ci -Am0 |
|
12 | 12 | |
|
13 | 13 | echo % add first sub |
|
14 | 14 | echo s = s > .hgsub |
|
15 | 15 | hg add .hgsub |
|
16 | 16 | hg init s |
|
17 | 17 | echo a > s/a |
|
18 | 18 | hg -R s ci -Ams0 |
|
19 | 19 | hg ci -m1 |
|
20 | 20 | |
|
21 | 21 | echo % add sub sub |
|
22 | 22 | echo ss = ss > s/.hgsub |
|
23 | 23 | hg init s/ss |
|
24 | 24 | echo a > s/ss/a |
|
25 | 25 | hg -R s add s/.hgsub |
|
26 | 26 | hg -R s/ss add s/ss/a |
|
27 | 27 | hg ci -m2 |
|
28 | 28 | |
|
29 | 29 | echo % bump sub rev |
|
30 | 30 | echo b > s/a |
|
31 | 31 | hg -R s ci -ms1 |
|
32 | 32 | hg ci -m3 |
|
33 | 33 | |
|
34 | 34 | echo % leave sub dirty |
|
35 | 35 | echo c > s/a |
|
36 | 36 | hg ci -m4 |
|
37 | 37 | hg tip -R s |
|
38 | 38 | |
|
39 | 39 | echo % check caching |
|
40 | 40 | hg co 0 |
|
41 | 41 | hg debugsub |
|
42 | 42 | echo % restore |
|
43 | 43 | hg co |
|
44 | 44 | hg debugsub |
|
45 | 45 | |
|
46 | 46 | echo % new branch for merge tests |
|
47 | 47 | hg co 1 |
|
48 | 48 | echo t = t >> .hgsub |
|
49 | 49 | hg init t |
|
50 | 50 | echo t > t/t |
|
51 | 51 | hg -R t add t |
|
52 | 52 | echo % 5 |
|
53 | 53 | hg ci -m5 # add sub |
|
54 | 54 | echo t2 > t/t |
|
55 | 55 | echo % 6 |
|
56 | 56 | hg st -R s |
|
57 | 57 | hg ci -m6 # change sub |
|
58 | 58 | hg debugsub |
|
59 | 59 | echo t3 > t/t |
|
60 | 60 | echo % 7 |
|
61 | 61 | hg ci -m7 # change sub again for conflict test |
|
62 | 62 | hg rm .hgsub |
|
63 | 63 | echo % 8 |
|
64 | 64 | hg ci -m8 # remove sub |
|
65 | 65 | |
|
66 | 66 | echo % merge tests |
|
67 | 67 | hg co -C 3 |
|
68 | 68 | hg merge 5 # test adding |
|
69 | 69 | hg debugsub |
|
70 | 70 | hg ci -m9 |
|
71 | 71 | hg merge 6 --debug # test change |
|
72 | 72 | hg debugsub |
|
73 | 73 | echo conflict > t/t |
|
74 | 74 | hg ci -m10 |
|
75 | 75 | HGMERGE=internal:merge hg merge --debug 7 # test conflict |
|
76 | 76 | echo % should conflict |
|
77 | 77 | cat t/t |
|
78 | 78 | |
|
79 | 79 | echo % clone |
|
80 | 80 | cd .. |
|
81 | hg clone t tc | |
|
81 | hg clone t tc | sed 's|from .*/sub|from .../sub|g' | |
|
82 | 82 | cd tc |
|
83 | 83 | hg debugsub |
|
84 | 84 | |
|
85 | 85 | echo % push |
|
86 | 86 | echo bah > t/t |
|
87 | 87 | hg ci -m11 |
|
88 | 88 | hg push | sed 's/ .*sub/ ...sub/g' |
|
89 | 89 | |
|
90 | 90 | echo % push -f |
|
91 | 91 | echo bah > s/a |
|
92 | 92 | hg ci -m12 |
|
93 | 93 | hg push | sed 's/ .*sub/ ...sub/g' |
|
94 | 94 | hg push -f | sed 's/ .*sub/ ...sub/g' |
|
95 | 95 | |
|
96 | 96 | echo % update |
|
97 | 97 | cd ../t |
|
98 | 98 | hg up -C # discard our earlier merge |
|
99 | 99 | echo blah > t/t |
|
100 | 100 | hg ci -m13 |
|
101 | 101 | |
|
102 | 102 | echo % pull |
|
103 | 103 | cd ../tc |
|
104 | 104 | hg pull | sed 's/ .*sub/ ...sub/g' |
|
105 |
|
|
|
105 | # should pull t | |
|
106 | hg up | sed 's|from .*/sub|from .../sub|g' | |
|
106 | 107 | cat t/t |
|
107 | 108 | |
|
108 | 109 | echo % bogus subrepo path aborts |
|
109 | 110 | echo 'bogus=[boguspath' >> .hgsub |
|
110 | 111 | hg ci -m 'bogus subrepo path' |
|
111 | 112 | |
|
112 | 113 | echo % issue 1986 |
|
113 | 114 | cd .. |
|
114 | 115 | rm -rf sub |
|
115 | 116 | hg init main |
|
116 | 117 | cd main |
|
117 | 118 | |
|
118 | 119 | hg init s # subrepo layout |
|
119 | 120 | cd s # |
|
120 | 121 | echo a > a # o 5 br |
|
121 | 122 | hg ci -Am1 # /| |
|
122 | 123 | hg branch br # o | 4 default |
|
123 | 124 | echo a >> a # | | |
|
124 | 125 | hg ci -m1 # | o 3 br |
|
125 | 126 | hg up default # |/| |
|
126 | 127 | echo b > b # o | 2 default |
|
127 | 128 | hg ci -Am1 # | | |
|
128 | 129 | hg up br # | o 1 br |
|
129 | 130 | hg merge tip # |/ |
|
130 | 131 | hg ci -m1 # o 0 default |
|
131 | 132 | hg up 2 |
|
132 | 133 | echo c > c |
|
133 | 134 | hg ci -Am1 |
|
134 | 135 | hg up 3 |
|
135 | 136 | hg merge 4 |
|
136 | 137 | hg ci -m1 |
|
137 | 138 | |
|
138 | 139 | cd .. # main repo layout: |
|
139 | 140 | echo 's = s' > .hgsub # |
|
140 | 141 | hg -R s up 2 # * <-- try to merge default into br again |
|
141 | 142 | hg ci -Am1 # .`| |
|
142 | 143 | hg branch br # . o 5 br --> substate = 5 |
|
143 | 144 | echo b > b # . | |
|
144 | 145 | hg -R s up 3 # o | 4 default --> substate = 4 |
|
145 | 146 | hg ci -Am1 # | | |
|
146 | 147 | hg up default # | o 3 br --> substate = 2 |
|
147 | 148 | echo c > c # |/| |
|
148 | 149 | hg ci -Am1 # o | 2 default --> substate = 2 |
|
149 | 150 | hg up 1 # | | |
|
150 | 151 | hg merge 2 # | o 1 br --> substate = 3 |
|
151 | 152 | hg ci -m1 # |/ |
|
152 | 153 | hg up 2 # o 0 default --> substate = 2 |
|
153 | 154 | hg -R s up 4 |
|
154 | 155 | echo d > d |
|
155 | 156 | hg ci -Am1 |
|
156 | 157 | hg up 3 |
|
157 | 158 | hg -R s up 5 |
|
158 | 159 | echo e > e |
|
159 | 160 | hg ci -Am1 |
|
160 | 161 | |
|
161 | 162 | hg up 5 |
|
162 | 163 | hg merge 4 # try to merge default into br again |
|
163 | 164 | cd .. |
|
164 | 165 | |
|
165 | 166 | echo % test subrepo delete from .hgsubstate |
|
166 | 167 | hg init testdelete |
|
167 | 168 | mkdir testdelete/nested testdelete/nested2 |
|
168 | 169 | hg init testdelete/nested |
|
169 | 170 | hg init testdelete/nested2 |
|
170 | 171 | echo test > testdelete/nested/foo |
|
171 | 172 | echo test > testdelete/nested2/foo |
|
172 | 173 | hg -R testdelete/nested add |
|
173 | 174 | hg -R testdelete/nested2 add |
|
174 | 175 | hg -R testdelete/nested ci -m test |
|
175 | 176 | hg -R testdelete/nested2 ci -m test |
|
176 | 177 | echo nested = nested > testdelete/.hgsub |
|
177 | 178 | echo nested2 = nested2 >> testdelete/.hgsub |
|
178 | 179 | hg -R testdelete add |
|
179 | 180 | hg -R testdelete ci -m "nested 1 & 2 added" |
|
180 | 181 | echo nested = nested > testdelete/.hgsub |
|
181 | 182 | hg -R testdelete ci -m "nested 2 deleted" |
|
182 | 183 | cat testdelete/.hgsubstate | sed "s:.* ::" |
|
183 | 184 | hg -R testdelete remove testdelete/.hgsub |
|
184 | 185 | hg -R testdelete ci -m ".hgsub deleted" |
|
185 | 186 | cat testdelete/.hgsubstate |
|
186 | 187 | |
|
187 | 188 | echo % test repository cloning |
|
188 | 189 | mkdir mercurial mercurial2 |
|
189 | 190 | hg init nested_absolute |
|
190 | 191 | echo test > nested_absolute/foo |
|
191 | 192 | hg -R nested_absolute add |
|
192 | 193 | hg -R nested_absolute ci -mtest |
|
193 | 194 | cd mercurial |
|
194 | 195 | hg init nested_relative |
|
195 | 196 | echo test2 > nested_relative/foo2 |
|
196 | 197 | hg -R nested_relative add |
|
197 | 198 | hg -R nested_relative ci -mtest2 |
|
198 | 199 | hg init main |
|
199 | 200 | echo nested_relative = ../nested_relative > main/.hgsub |
|
200 | 201 | echo nested_absolute = `pwd`/nested_absolute >> main/.hgsub |
|
201 | 202 | hg -R main add |
|
202 | 203 | hg -R main ci -m "add subrepos" |
|
203 | 204 | cd .. |
|
204 | 205 | hg clone mercurial/main mercurial2/main |
|
205 | 206 | cat mercurial2/main/nested_absolute/.hg/hgrc \ |
|
206 | 207 | mercurial2/main/nested_relative/.hg/hgrc \ |
|
207 | 208 | | "$TESTDIR/filtertmp.py" |
|
208 | 209 | rm -rf mercurial mercurial2 |
|
209 | 210 | |
|
210 | 211 | exit 0 |
@@ -1,268 +1,268 b'' | |||
|
1 | 1 | % first revision, no sub |
|
2 | 2 | adding a |
|
3 | 3 | % add first sub |
|
4 | 4 | adding a |
|
5 | 5 | committing subrepository s |
|
6 | 6 | % add sub sub |
|
7 | 7 | committing subrepository s |
|
8 | 8 | committing subrepository ss |
|
9 | 9 | % bump sub rev |
|
10 | 10 | committing subrepository s |
|
11 | 11 | % leave sub dirty |
|
12 | 12 | committing subrepository s |
|
13 | 13 | changeset: 3:1c833a7a9e3a |
|
14 | 14 | tag: tip |
|
15 | 15 | user: test |
|
16 | 16 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
17 | 17 | summary: 4 |
|
18 | 18 | |
|
19 | 19 | % check caching |
|
20 | 20 | 0 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
21 | 21 | % restore |
|
22 | 22 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
23 | 23 | path s |
|
24 | 24 | source s |
|
25 | 25 | revision 1c833a7a9e3a4445c711aaf0f012379cd0d4034e |
|
26 | 26 | % new branch for merge tests |
|
27 | 27 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
28 | 28 | adding t/t |
|
29 | 29 | % 5 |
|
30 | 30 | committing subrepository t |
|
31 | 31 | created new head |
|
32 | 32 | % 6 |
|
33 | 33 | committing subrepository t |
|
34 | 34 | path s |
|
35 | 35 | source s |
|
36 | 36 | revision e4ece1bf43360ddc8f6a96432201a37b7cd27ae4 |
|
37 | 37 | path t |
|
38 | 38 | source t |
|
39 | 39 | revision 6747d179aa9a688023c4b0cad32e4c92bb7f34ad |
|
40 | 40 | % 7 |
|
41 | 41 | committing subrepository t |
|
42 | 42 | % 8 |
|
43 | 43 | % merge tests |
|
44 | 44 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
45 | 45 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
46 | 46 | (branch merge, don't forget to commit) |
|
47 | 47 | path s |
|
48 | 48 | source s |
|
49 | 49 | revision fc627a69481fcbe5f1135069e8a3881c023e4cf5 |
|
50 | 50 | path t |
|
51 | 51 | source t |
|
52 | 52 | revision 60ca1237c19474e7a3978b0dc1ca4e6f36d51382 |
|
53 | 53 | created new head |
|
54 | 54 | searching for copies back to rev 2 |
|
55 | 55 | resolving manifests |
|
56 | 56 | overwrite None partial False |
|
57 | 57 | ancestor 1f14a2e2d3ec local f0d2028bf86d+ remote 1831e14459c4 |
|
58 | 58 | .hgsubstate: versions differ -> m |
|
59 | 59 | update: .hgsubstate 1/1 files (100.00%) |
|
60 | 60 | subrepo merge f0d2028bf86d+ 1831e14459c4 1f14a2e2d3ec |
|
61 | 61 | subrepo t: other changed, get t:6747d179aa9a688023c4b0cad32e4c92bb7f34ad:hg |
|
62 | 62 | getting subrepo t |
|
63 | 63 | resolving manifests |
|
64 | 64 | overwrite True partial False |
|
65 | 65 | ancestor 60ca1237c194+ local 60ca1237c194+ remote 6747d179aa9a |
|
66 | 66 | t: remote is newer -> g |
|
67 | 67 | update: t 1/1 files (100.00%) |
|
68 | 68 | getting t |
|
69 | 69 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
70 | 70 | (branch merge, don't forget to commit) |
|
71 | 71 | path s |
|
72 | 72 | source s |
|
73 | 73 | revision fc627a69481fcbe5f1135069e8a3881c023e4cf5 |
|
74 | 74 | path t |
|
75 | 75 | source t |
|
76 | 76 | revision 6747d179aa9a688023c4b0cad32e4c92bb7f34ad |
|
77 | 77 | committing subrepository t |
|
78 | 78 | searching for copies back to rev 2 |
|
79 | 79 | resolving manifests |
|
80 | 80 | overwrite None partial False |
|
81 | 81 | ancestor 1831e14459c4 local e45c8b14af55+ remote f94576341bcf |
|
82 | 82 | .hgsubstate: versions differ -> m |
|
83 | 83 | update: .hgsubstate 1/1 files (100.00%) |
|
84 | 84 | subrepo merge e45c8b14af55+ f94576341bcf 1831e14459c4 |
|
85 | 85 | subrepo t: both sides changed, merge with t:7af322bc1198a32402fe903e0b7ebcfc5c9bf8f4:hg |
|
86 | 86 | merging subrepo t |
|
87 | 87 | searching for copies back to rev 2 |
|
88 | 88 | resolving manifests |
|
89 | 89 | overwrite None partial False |
|
90 | 90 | ancestor 6747d179aa9a local 20a0db6fbf6c+ remote 7af322bc1198 |
|
91 | 91 | t: versions differ -> m |
|
92 | 92 | preserving t for resolve of t |
|
93 | 93 | update: t 1/1 files (100.00%) |
|
94 | 94 | picked tool 'internal:merge' for t (binary False symlink False) |
|
95 | 95 | merging t |
|
96 | 96 | my t@20a0db6fbf6c+ other t@7af322bc1198 ancestor t@6747d179aa9a |
|
97 | 97 | warning: conflicts during merge. |
|
98 | 98 | merging t failed! |
|
99 | 99 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved |
|
100 | 100 | use 'hg resolve' to retry unresolved file merges or 'hg update -C' to abandon |
|
101 | 101 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
102 | 102 | (branch merge, don't forget to commit) |
|
103 | 103 | % should conflict |
|
104 | 104 | <<<<<<< local |
|
105 | 105 | conflict |
|
106 | 106 | ======= |
|
107 | 107 | t3 |
|
108 | 108 | >>>>>>> other |
|
109 | 109 | % clone |
|
110 | 110 | updating to branch default |
|
111 | pulling subrepo s | |
|
111 | pulling subrepo s from .../sub/t/s | |
|
112 | 112 | requesting all changes |
|
113 | 113 | adding changesets |
|
114 | 114 | adding manifests |
|
115 | 115 | adding file changes |
|
116 | 116 | added 4 changesets with 5 changes to 3 files |
|
117 | pulling subrepo ss | |
|
117 | pulling subrepo ss from .../sub/t/s/ss | |
|
118 | 118 | requesting all changes |
|
119 | 119 | adding changesets |
|
120 | 120 | adding manifests |
|
121 | 121 | adding file changes |
|
122 | 122 | added 1 changesets with 1 changes to 1 files |
|
123 | pulling subrepo t | |
|
123 | pulling subrepo t from .../sub/t/t | |
|
124 | 124 | requesting all changes |
|
125 | 125 | adding changesets |
|
126 | 126 | adding manifests |
|
127 | 127 | adding file changes |
|
128 | 128 | added 4 changesets with 4 changes to 1 files (+1 heads) |
|
129 | 129 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
130 | 130 | path s |
|
131 | 131 | source s |
|
132 | 132 | revision fc627a69481fcbe5f1135069e8a3881c023e4cf5 |
|
133 | 133 | path t |
|
134 | 134 | source t |
|
135 | 135 | revision 20a0db6fbf6c3d2836e6519a642ae929bfc67c0e |
|
136 | 136 | % push |
|
137 | 137 | committing subrepository t |
|
138 | 138 | pushing ...sub/t |
|
139 | 139 | pushing ...subrepo ss |
|
140 | 140 | searching for changes |
|
141 | 141 | no changes found |
|
142 | 142 | pushing ...subrepo s |
|
143 | 143 | searching for changes |
|
144 | 144 | no changes found |
|
145 | 145 | pushing ...subrepo t |
|
146 | 146 | searching for changes |
|
147 | 147 | adding changesets |
|
148 | 148 | adding manifests |
|
149 | 149 | adding file changes |
|
150 | 150 | added 1 changesets with 1 changes to 1 files |
|
151 | 151 | searching for changes |
|
152 | 152 | adding changesets |
|
153 | 153 | adding manifests |
|
154 | 154 | adding file changes |
|
155 | 155 | added 1 changesets with 1 changes to 1 files |
|
156 | 156 | % push -f |
|
157 | 157 | committing subrepository s |
|
158 | 158 | abort: push creates new remote heads on branch 'default'! |
|
159 | 159 | pushing ...sub/t |
|
160 | 160 | pushing ...subrepo ss |
|
161 | 161 | searching for changes |
|
162 | 162 | no changes found |
|
163 | 163 | pushing ...subrepo s |
|
164 | 164 | searching for changes |
|
165 | 165 | (did you forget to merge? use push -f to force) |
|
166 | 166 | pushing ...subrepo t |
|
167 | 167 | searching for changes |
|
168 | 168 | no changes found |
|
169 | 169 | searching for changes |
|
170 | 170 | adding changesets |
|
171 | 171 | adding manifests |
|
172 | 172 | adding file changes |
|
173 | 173 | added 1 changesets with 1 changes to 1 files |
|
174 | 174 | pushing ...sub/t |
|
175 | 175 | pushing ...subrepo ss |
|
176 | 176 | searching for changes |
|
177 | 177 | no changes found |
|
178 | 178 | pushing ...subrepo s |
|
179 | 179 | searching for changes |
|
180 | 180 | adding changesets |
|
181 | 181 | adding manifests |
|
182 | 182 | adding file changes |
|
183 | 183 | added 1 changesets with 1 changes to 1 files (+1 heads) |
|
184 | 184 | pushing ...subrepo t |
|
185 | 185 | searching for changes |
|
186 | 186 | no changes found |
|
187 | 187 | searching for changes |
|
188 | 188 | no changes found |
|
189 | 189 | % update |
|
190 | 190 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
191 | 191 | committing subrepository t |
|
192 | 192 | % pull |
|
193 | 193 | pulling ...sub/t |
|
194 | 194 | searching for changes |
|
195 | 195 | adding changesets |
|
196 | 196 | adding manifests |
|
197 | 197 | adding file changes |
|
198 | 198 | added 1 changesets with 1 changes to 1 files |
|
199 | 199 | (run 'hg update' to get a working copy) |
|
200 | pulling subrepo t | |
|
200 | pulling subrepo t from .../sub/t/t | |
|
201 | 201 | searching for changes |
|
202 | 202 | adding changesets |
|
203 | 203 | adding manifests |
|
204 | 204 | adding file changes |
|
205 | 205 | added 1 changesets with 1 changes to 1 files |
|
206 | 206 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
207 | 207 | blah |
|
208 | 208 | % bogus subrepo path aborts |
|
209 | 209 | abort: missing ] in subrepo source |
|
210 | 210 | % issue 1986 |
|
211 | 211 | adding a |
|
212 | 212 | marked working directory as branch br |
|
213 | 213 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
214 | 214 | adding b |
|
215 | 215 | created new head |
|
216 | 216 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
217 | 217 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
218 | 218 | (branch merge, don't forget to commit) |
|
219 | 219 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
220 | 220 | adding c |
|
221 | 221 | created new head |
|
222 | 222 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
223 | 223 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
224 | 224 | (branch merge, don't forget to commit) |
|
225 | 225 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
226 | 226 | adding .hgsub |
|
227 | 227 | committing subrepository s |
|
228 | 228 | marked working directory as branch br |
|
229 | 229 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
230 | 230 | adding b |
|
231 | 231 | committing subrepository s |
|
232 | 232 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
233 | 233 | adding c |
|
234 | 234 | created new head |
|
235 | 235 | 2 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
236 | 236 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
237 | 237 | (branch merge, don't forget to commit) |
|
238 | 238 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
239 | 239 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
240 | 240 | adding d |
|
241 | 241 | committing subrepository s |
|
242 | 242 | created new head |
|
243 | 243 | 2 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
244 | 244 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
245 | 245 | adding e |
|
246 | 246 | committing subrepository s |
|
247 | 247 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
248 | 248 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
249 | 249 | (branch merge, don't forget to commit) |
|
250 | 250 | % test subrepo delete from .hgsubstate |
|
251 | 251 | adding testdelete/nested/foo |
|
252 | 252 | adding testdelete/nested2/foo |
|
253 | 253 | adding testdelete/.hgsub |
|
254 | 254 | committing subrepository nested2 |
|
255 | 255 | committing subrepository nested |
|
256 | 256 | nested |
|
257 | 257 | % test repository cloning |
|
258 | 258 | adding nested_absolute/foo |
|
259 | 259 | adding nested_relative/foo2 |
|
260 | 260 | adding main/.hgsub |
|
261 | 261 | committing subrepository nested_relative |
|
262 | 262 | committing subrepository nested_absolute |
|
263 | 263 | updating to branch default |
|
264 | 264 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
265 | 265 | [paths] |
|
266 | 266 | default = $HGTMP/test-subrepo/sub/mercurial/main/nested_absolute |
|
267 | 267 | [paths] |
|
268 | 268 | default = $HGTMP/test-subrepo/sub/mercurial/main/nested_relative |
General Comments 0
You need to be logged in to leave comments.
Login now