Mercurial > hg
annotate mercurial/subrepo.py @ 12011:f38b0a3308b6
deltaparent(): don't return nullrev for a revision containing a full snapshot
this allows us to simplify manifest.readdelta and revlog.revdiff
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Sat, 21 Aug 2010 19:30:42 +0200 |
parents | f3075ffa6b30 |
children | 63eab3b74ba6 |
rev | line source |
---|---|
8812
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1 # subrepo.py - sub-repository handling for Mercurial |
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 |
11109
a2bc2f2d77a9
subrepo: normalize path part of URLs so that pulling subrepos from webdir works
Edouard Gomez <ed.gomez@free.fr>
parents:
11078
diff
changeset
|
8 import errno, os, re, xml.dom.minidom, shutil, urlparse, posixpath |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
9 from i18n import _ |
8813
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
10 import config, util, node, error |
9092
9aebeea7ac00
subrepo: use hg.repository instead of creating localrepo directly
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
9049
diff
changeset
|
11 hg = None |
8813
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
12 |
10177
5ca0d220ae21
subrepo: add table-based dispatch for subrepo types
Augie Fackler <durin42@gmail.com>
parents:
10175
diff
changeset
|
13 nullstate = ('', '', 'empty') |
8812
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
14 |
11775
a8614c5a5e9a
subrepos: support remapping of .hgsub source paths
Martin Geisler <mg@lazybytes.net>
parents:
11572
diff
changeset
|
15 def state(ctx, ui): |
11571 | 16 """return a state dict, mapping subrepo paths configured in .hgsub |
17 to tuple: (source from .hgsub, revision from .hgsubstate, kind | |
18 (key in types dict)) | |
19 """ | |
8812
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
20 p = config.config() |
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
21 def read(f, sections=None, remap=None): |
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
22 if f in ctx: |
10174
65b6dc44cdbf
subrepo: fix includes support in .hgsub
Matt Mackall <mpm@selenic.com>
parents:
10069
diff
changeset
|
23 p.parse(f, ctx[f].data(), sections, remap, read) |
65b6dc44cdbf
subrepo: fix includes support in .hgsub
Matt Mackall <mpm@selenic.com>
parents:
10069
diff
changeset
|
24 else: |
65b6dc44cdbf
subrepo: fix includes support in .hgsub
Matt Mackall <mpm@selenic.com>
parents:
10069
diff
changeset
|
25 raise util.Abort(_("subrepo spec file %s not found") % f) |
65b6dc44cdbf
subrepo: fix includes support in .hgsub
Matt Mackall <mpm@selenic.com>
parents:
10069
diff
changeset
|
26 |
65b6dc44cdbf
subrepo: fix includes support in .hgsub
Matt Mackall <mpm@selenic.com>
parents:
10069
diff
changeset
|
27 if '.hgsub' in ctx: |
65b6dc44cdbf
subrepo: fix includes support in .hgsub
Matt Mackall <mpm@selenic.com>
parents:
10069
diff
changeset
|
28 read('.hgsub') |
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 for path, src in ui.configitems('subpaths'): |
a8614c5a5e9a
subrepos: support remapping of .hgsub source paths
Martin Geisler <mg@lazybytes.net>
parents:
11572
diff
changeset
|
31 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
|
32 |
8812
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
33 rev = {} |
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
34 if '.hgsubstate' in ctx: |
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
35 try: |
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
36 for l in ctx['.hgsubstate'].data().splitlines(): |
9752
a22cdd5e56b7
subrepo: more robust split for .hgsubstate parsing
Matt Mackall <mpm@selenic.com>
parents:
9508
diff
changeset
|
37 revision, path = l.split(" ", 1) |
8812
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
38 rev[path] = revision |
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
39 except IOError, err: |
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
40 if err.errno != errno.ENOENT: |
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
41 raise |
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
42 |
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
43 state = {} |
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
44 for path, src in p[''].items(): |
10177
5ca0d220ae21
subrepo: add table-based dispatch for subrepo types
Augie Fackler <durin42@gmail.com>
parents:
10175
diff
changeset
|
45 kind = 'hg' |
5ca0d220ae21
subrepo: add table-based dispatch for subrepo types
Augie Fackler <durin42@gmail.com>
parents:
10175
diff
changeset
|
46 if src.startswith('['): |
5ca0d220ae21
subrepo: add table-based dispatch for subrepo types
Augie Fackler <durin42@gmail.com>
parents:
10175
diff
changeset
|
47 if ']' not in src: |
5ca0d220ae21
subrepo: add table-based dispatch for subrepo types
Augie Fackler <durin42@gmail.com>
parents:
10175
diff
changeset
|
48 raise util.Abort(_('missing ] in subrepo source')) |
5ca0d220ae21
subrepo: add table-based dispatch for subrepo types
Augie Fackler <durin42@gmail.com>
parents:
10175
diff
changeset
|
49 kind, src = src.split(']', 1) |
5ca0d220ae21
subrepo: add table-based dispatch for subrepo types
Augie Fackler <durin42@gmail.com>
parents:
10175
diff
changeset
|
50 kind = kind[1:] |
11775
a8614c5a5e9a
subrepos: support remapping of .hgsub source paths
Martin Geisler <mg@lazybytes.net>
parents:
11572
diff
changeset
|
51 |
a8614c5a5e9a
subrepos: support remapping of .hgsub source paths
Martin Geisler <mg@lazybytes.net>
parents:
11572
diff
changeset
|
52 for pattern, repl in p.items('subpaths'): |
11961
f3075ffa6b30
subrepos: handle backslashes in subpaths
Martin Geisler <mg@lazybytes.net>
parents:
11775
diff
changeset
|
53 # 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
|
54 # does a string decode. |
f3075ffa6b30
subrepos: handle backslashes in subpaths
Martin Geisler <mg@lazybytes.net>
parents:
11775
diff
changeset
|
55 repl = repl.encode('string-escape') |
f3075ffa6b30
subrepos: handle backslashes in subpaths
Martin Geisler <mg@lazybytes.net>
parents:
11775
diff
changeset
|
56 # 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
|
57 # 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
|
58 # extra escapes are needed because re.sub string decodes. |
f3075ffa6b30
subrepos: handle backslashes in subpaths
Martin Geisler <mg@lazybytes.net>
parents:
11775
diff
changeset
|
59 repl = re.sub(r'\\\\([0-9]+)', r'\\\1', repl) |
11775
a8614c5a5e9a
subrepos: support remapping of .hgsub source paths
Martin Geisler <mg@lazybytes.net>
parents:
11572
diff
changeset
|
60 try: |
a8614c5a5e9a
subrepos: support remapping of .hgsub source paths
Martin Geisler <mg@lazybytes.net>
parents:
11572
diff
changeset
|
61 src = re.sub(pattern, repl, src, 1) |
a8614c5a5e9a
subrepos: support remapping of .hgsub source paths
Martin Geisler <mg@lazybytes.net>
parents:
11572
diff
changeset
|
62 except re.error, e: |
a8614c5a5e9a
subrepos: support remapping of .hgsub source paths
Martin Geisler <mg@lazybytes.net>
parents:
11572
diff
changeset
|
63 raise util.Abort(_("bad subrepository pattern in %s: %s") |
a8614c5a5e9a
subrepos: support remapping of .hgsub source paths
Martin Geisler <mg@lazybytes.net>
parents:
11572
diff
changeset
|
64 % (p.source('subpaths', pattern), e)) |
a8614c5a5e9a
subrepos: support remapping of .hgsub source paths
Martin Geisler <mg@lazybytes.net>
parents:
11572
diff
changeset
|
65 |
10457
4f38d03d4975
subrepo: make sure that the source path is stripped
David Soria Parra <dsp@php.net>
parents:
10378
diff
changeset
|
66 state[path] = (src.strip(), rev.get(path, ''), kind) |
8812
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
67 |
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
68 return state |
8813
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
69 |
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
70 def writestate(repo, state): |
11571 | 71 """rewrite .hgsubstate in (outer) repo with these subrepo states""" |
8813
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
72 repo.wwrite('.hgsubstate', |
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
73 ''.join(['%s %s\n' % (state[s][1], s) |
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
74 for s in sorted(state)]), '') |
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
75 |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
76 def submerge(repo, wctx, mctx, actx): |
11571 | 77 """delegated from merge.applyupdates: merging of .hgsubstate file |
78 in working context, merging context and ancestor context""" | |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
79 if mctx == actx: # backwards? |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
80 actx = wctx.p1() |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
81 s1 = wctx.substate |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
82 s2 = mctx.substate |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
83 sa = actx.substate |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
84 sm = {} |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
85 |
9782
c1c40511c276
subrepo: add more debugging output, lose _ markers
Matt Mackall <mpm@selenic.com>
parents:
9781
diff
changeset
|
86 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
|
87 |
9779
58a6f3f4d553
subrepo: add some debug output to submerge
Matt Mackall <mpm@selenic.com>
parents:
9752
diff
changeset
|
88 def debug(s, msg, r=""): |
58a6f3f4d553
subrepo: add some debug output to submerge
Matt Mackall <mpm@selenic.com>
parents:
9752
diff
changeset
|
89 if r: |
10177
5ca0d220ae21
subrepo: add table-based dispatch for subrepo types
Augie Fackler <durin42@gmail.com>
parents:
10175
diff
changeset
|
90 r = "%s:%s:%s" % r |
9782
c1c40511c276
subrepo: add more debugging output, lose _ markers
Matt Mackall <mpm@selenic.com>
parents:
9781
diff
changeset
|
91 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
|
92 |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
93 for s, l in s1.items(): |
11470
34e33d50c26b
subrepo: correctly handle update -C with modified subrepos (issue2022)
Matt Mackall <mpm@selenic.com>
parents:
11463
diff
changeset
|
94 a = sa.get(s, nullstate) |
11463
f0ea93557133
subrepo: fix recording of + in .hgsubstate (issue2217)
Matt Mackall <mpm@selenic.com>
parents:
11455
diff
changeset
|
95 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
|
96 if wctx.sub(s).dirty(): |
11463
f0ea93557133
subrepo: fix recording of + in .hgsubstate (issue2217)
Matt Mackall <mpm@selenic.com>
parents:
11455
diff
changeset
|
97 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
|
98 if wctx == actx: # overwrite |
34e33d50c26b
subrepo: correctly handle update -C with modified subrepos (issue2022)
Matt Mackall <mpm@selenic.com>
parents:
11463
diff
changeset
|
99 a = ld |
11463
f0ea93557133
subrepo: fix recording of + in .hgsubstate (issue2217)
Matt Mackall <mpm@selenic.com>
parents:
11455
diff
changeset
|
100 |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
101 if s in s2: |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
102 r = s2[s] |
11463
f0ea93557133
subrepo: fix recording of + in .hgsubstate (issue2217)
Matt Mackall <mpm@selenic.com>
parents:
11455
diff
changeset
|
103 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
|
104 sm[s] = l |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
105 continue |
11463
f0ea93557133
subrepo: fix recording of + in .hgsubstate (issue2217)
Matt Mackall <mpm@selenic.com>
parents:
11455
diff
changeset
|
106 elif ld == a: # other side changed |
9782
c1c40511c276
subrepo: add more debugging output, lose _ markers
Matt Mackall <mpm@selenic.com>
parents:
9781
diff
changeset
|
107 debug(s, "other changed, get", r) |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
108 wctx.sub(s).get(r) |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
109 sm[s] = r |
11463
f0ea93557133
subrepo: fix recording of + in .hgsubstate (issue2217)
Matt Mackall <mpm@selenic.com>
parents:
11455
diff
changeset
|
110 elif ld[0] != r[0]: # sources differ |
9048
86b4a9b0ddda
ui: extract choice from prompt
Simon Heimberg <simohe@besonet.ch>
parents:
8997
diff
changeset
|
111 if repo.ui.promptchoice( |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
112 _(' subrepository sources for %s differ\n' |
8908
105343f9f744
Fix warning: Seen unexpected token "%"
Dongsheng Song <dongsheng.song@gmail.com>
parents:
8815
diff
changeset
|
113 'use (l)ocal source (%s) or (r)emote source (%s)?') |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
114 % (s, l[0], r[0]), |
9048
86b4a9b0ddda
ui: extract choice from prompt
Simon Heimberg <simohe@besonet.ch>
parents:
8997
diff
changeset
|
115 (_('&Local'), _('&Remote')), 0): |
9782
c1c40511c276
subrepo: add more debugging output, lose _ markers
Matt Mackall <mpm@selenic.com>
parents:
9781
diff
changeset
|
116 debug(s, "prompt changed, get", r) |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
117 wctx.sub(s).get(r) |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
118 sm[s] = r |
11463
f0ea93557133
subrepo: fix recording of + in .hgsubstate (issue2217)
Matt Mackall <mpm@selenic.com>
parents:
11455
diff
changeset
|
119 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
|
120 debug(s, "other side changed, get", r) |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
121 wctx.sub(s).get(r) |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
122 sm[s] = r |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
123 else: |
9782
c1c40511c276
subrepo: add more debugging output, lose _ markers
Matt Mackall <mpm@selenic.com>
parents:
9781
diff
changeset
|
124 debug(s, "both sides changed, merge with", r) |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
125 wctx.sub(s).merge(r) |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
126 sm[s] = l |
11463
f0ea93557133
subrepo: fix recording of + in .hgsubstate (issue2217)
Matt Mackall <mpm@selenic.com>
parents:
11455
diff
changeset
|
127 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
|
128 debug(s, "remote removed, remove") |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
129 wctx.sub(s).remove() |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
130 else: |
9048
86b4a9b0ddda
ui: extract choice from prompt
Simon Heimberg <simohe@besonet.ch>
parents:
8997
diff
changeset
|
131 if repo.ui.promptchoice( |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
132 _(' local changed subrepository %s which remote removed\n' |
8908
105343f9f744
Fix warning: Seen unexpected token "%"
Dongsheng Song <dongsheng.song@gmail.com>
parents:
8815
diff
changeset
|
133 'use (c)hanged version or (d)elete?') % s, |
9049
38b5d5e0efab
filemerge, subrepo: correct indention
Martin Geisler <mg@lazybytes.net>
parents:
9048
diff
changeset
|
134 (_('&Changed'), _('&Delete')), 0): |
9782
c1c40511c276
subrepo: add more debugging output, lose _ markers
Matt Mackall <mpm@selenic.com>
parents:
9781
diff
changeset
|
135 debug(s, "prompt remove") |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
136 wctx.sub(s).remove() |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
137 |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
138 for s, r in s2.items(): |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
139 if s in s1: |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
140 continue |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
141 elif s not in sa: |
9782
c1c40511c276
subrepo: add more debugging output, lose _ markers
Matt Mackall <mpm@selenic.com>
parents:
9781
diff
changeset
|
142 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
|
143 mctx.sub(s).get(r) |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
144 sm[s] = r |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
145 elif r != sa[s]: |
9048
86b4a9b0ddda
ui: extract choice from prompt
Simon Heimberg <simohe@besonet.ch>
parents:
8997
diff
changeset
|
146 if repo.ui.promptchoice( |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
147 _(' remote changed subrepository %s which local removed\n' |
8908
105343f9f744
Fix warning: Seen unexpected token "%"
Dongsheng Song <dongsheng.song@gmail.com>
parents:
8815
diff
changeset
|
148 'use (c)hanged version or (d)elete?') % s, |
9049
38b5d5e0efab
filemerge, subrepo: correct indention
Martin Geisler <mg@lazybytes.net>
parents:
9048
diff
changeset
|
149 (_('&Changed'), _('&Delete')), 0) == 0: |
9782
c1c40511c276
subrepo: add more debugging output, lose _ markers
Matt Mackall <mpm@selenic.com>
parents:
9781
diff
changeset
|
150 debug(s, "prompt recreate", r) |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
151 wctx.sub(s).get(r) |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
152 sm[s] = r |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
153 |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
154 # record merged .hgsubstate |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
155 writestate(repo, sm) |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
156 |
11112
4a9bee613737
subrepo: print paths relative to upper repo root for push/pull/commit
Edouard Gomez <ed.gomez@free.fr>
parents:
11111
diff
changeset
|
157 def relpath(sub): |
11571 | 158 """return path to this subrepo as seen from outermost repo""" |
11112
4a9bee613737
subrepo: print paths relative to upper repo root for push/pull/commit
Edouard Gomez <ed.gomez@free.fr>
parents:
11111
diff
changeset
|
159 if not hasattr(sub, '_repo'): |
4a9bee613737
subrepo: print paths relative to upper repo root for push/pull/commit
Edouard Gomez <ed.gomez@free.fr>
parents:
11111
diff
changeset
|
160 return sub._path |
4a9bee613737
subrepo: print paths relative to upper repo root for push/pull/commit
Edouard Gomez <ed.gomez@free.fr>
parents:
11111
diff
changeset
|
161 parent = sub._repo |
4a9bee613737
subrepo: print paths relative to upper repo root for push/pull/commit
Edouard Gomez <ed.gomez@free.fr>
parents:
11111
diff
changeset
|
162 while hasattr(parent, '_subparent'): |
4a9bee613737
subrepo: print paths relative to upper repo root for push/pull/commit
Edouard Gomez <ed.gomez@free.fr>
parents:
11111
diff
changeset
|
163 parent = parent._subparent |
4a9bee613737
subrepo: print paths relative to upper repo root for push/pull/commit
Edouard Gomez <ed.gomez@free.fr>
parents:
11111
diff
changeset
|
164 return sub._repo.root[len(parent.root)+1:] |
4a9bee613737
subrepo: print paths relative to upper repo root for push/pull/commit
Edouard Gomez <ed.gomez@free.fr>
parents:
11111
diff
changeset
|
165 |
8815
e87b0fc4750b
subrepo: basic push support
Matt Mackall <mpm@selenic.com>
parents:
8814
diff
changeset
|
166 def _abssource(repo, push=False): |
11571 | 167 """return pull/push path of repo - either based on parent repo |
168 .hgsub info or on the subrepos own config""" | |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
169 if hasattr(repo, '_subparent'): |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
170 source = repo._subsource |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
171 if source.startswith('/') or '://' in source: |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
172 return source |
10665
664bb0ce95ed
subrepo: forward the push to argument into _abssource
Edouard Gomez <ed.gomez@free.fr>
parents:
10510
diff
changeset
|
173 parent = _abssource(repo._subparent, push) |
9186
f783bb979fb3
subrepo: use '/' for joining non-local paths
Matt Mackall <mpm@selenic.com>
parents:
8997
diff
changeset
|
174 if '://' in parent: |
f783bb979fb3
subrepo: use '/' for joining non-local paths
Matt Mackall <mpm@selenic.com>
parents:
8997
diff
changeset
|
175 if parent[-1] == '/': |
f783bb979fb3
subrepo: use '/' for joining non-local paths
Matt Mackall <mpm@selenic.com>
parents:
8997
diff
changeset
|
176 parent = parent[:-1] |
11109
a2bc2f2d77a9
subrepo: normalize path part of URLs so that pulling subrepos from webdir works
Edouard Gomez <ed.gomez@free.fr>
parents:
11078
diff
changeset
|
177 r = urlparse.urlparse(parent + '/' + source) |
a2bc2f2d77a9
subrepo: normalize path part of URLs so that pulling subrepos from webdir works
Edouard Gomez <ed.gomez@free.fr>
parents:
11078
diff
changeset
|
178 r = urlparse.urlunparse((r[0], r[1], |
11117
dd543e8da87e
subrepo: fix 2.5ism in url parsing
Matt Mackall <mpm@selenic.com>
parents:
11112
diff
changeset
|
179 posixpath.normpath(r[2]), |
11109
a2bc2f2d77a9
subrepo: normalize path part of URLs so that pulling subrepos from webdir works
Edouard Gomez <ed.gomez@free.fr>
parents:
11078
diff
changeset
|
180 r[3], r[4], r[5])) |
a2bc2f2d77a9
subrepo: normalize path part of URLs so that pulling subrepos from webdir works
Edouard Gomez <ed.gomez@free.fr>
parents:
11078
diff
changeset
|
181 return r |
a2bc2f2d77a9
subrepo: normalize path part of URLs so that pulling subrepos from webdir works
Edouard Gomez <ed.gomez@free.fr>
parents:
11078
diff
changeset
|
182 return posixpath.normpath(os.path.join(parent, repo._subsource)) |
8815
e87b0fc4750b
subrepo: basic push support
Matt Mackall <mpm@selenic.com>
parents:
8814
diff
changeset
|
183 if push and repo.ui.config('paths', 'default-push'): |
e87b0fc4750b
subrepo: basic push support
Matt Mackall <mpm@selenic.com>
parents:
8814
diff
changeset
|
184 return repo.ui.config('paths', 'default-push', repo.root) |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
185 return repo.ui.config('paths', 'default', repo.root) |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
186 |
8813
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
187 def subrepo(ctx, path): |
11571 | 188 """return instance of the right subrepo class for subrepo in path""" |
8813
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
189 # subrepo inherently violates our import layering rules |
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
190 # because it wants to make repo objects from deep inside the stack |
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
191 # so we manually delay the circular imports to not break |
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
192 # scripts that don't use our demand-loading |
9092
9aebeea7ac00
subrepo: use hg.repository instead of creating localrepo directly
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
9049
diff
changeset
|
193 global hg |
9aebeea7ac00
subrepo: use hg.repository instead of creating localrepo directly
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
9049
diff
changeset
|
194 import hg as h |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
195 hg = h |
8813
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
196 |
8997
70f5d3be5917
subrepo: audit subrepo paths
Matt Mackall <mpm@selenic.com>
parents:
8908
diff
changeset
|
197 util.path_auditor(ctx._repo.root)(path) |
8813
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
198 state = ctx.substate.get(path, nullstate) |
10177
5ca0d220ae21
subrepo: add table-based dispatch for subrepo types
Augie Fackler <durin42@gmail.com>
parents:
10175
diff
changeset
|
199 if state[2] not in types: |
10299
e768941f14c1
subrepo: fix errors reported by pylint
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10273
diff
changeset
|
200 raise util.Abort(_('unknown subrepo type %s') % state[2]) |
10177
5ca0d220ae21
subrepo: add table-based dispatch for subrepo types
Augie Fackler <durin42@gmail.com>
parents:
10175
diff
changeset
|
201 return types[state[2]](ctx, path, state[:2]) |
8813
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
202 |
11559
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
203 # subrepo classes need to implement the following abstract class: |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
204 |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
205 class abstractsubrepo(object): |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
206 |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
207 def dirty(self): |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
208 """returns true if the dirstate of the subrepo does not match |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
209 current stored state |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
210 """ |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
211 raise NotImplementedError |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
212 |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
213 def commit(self, text, user, date): |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
214 """commit the current changes to the subrepo with the given |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
215 log message. Use given user and date if possible. Return the |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
216 new state of the subrepo. |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
217 """ |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
218 raise NotImplementedError |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
219 |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
220 def remove(self): |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
221 """remove the subrepo |
8813
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
222 |
11559
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
223 (should verify the dirstate is not dirty first) |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
224 """ |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
225 raise NotImplementedError |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
226 |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
227 def get(self, state): |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
228 """run whatever commands are needed to put the subrepo into |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
229 this state |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
230 """ |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
231 raise NotImplementedError |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
232 |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
233 def merge(self, state): |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
234 """merge currently-saved state with the new state.""" |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
235 raise NotImplementedError |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
236 |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
237 def push(self, force): |
11572 | 238 """perform whatever action is analogous to 'hg push' |
11559
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
239 |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
240 This may be a no-op on some systems. |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
241 """ |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
242 raise NotImplementedError |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
243 |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
244 |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
245 class hgsubrepo(abstractsubrepo): |
8813
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
246 def __init__(self, ctx, path, state): |
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
247 self._path = path |
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
248 self._state = state |
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
249 r = ctx._repo |
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
250 root = r.wjoin(path) |
10666
4c50a90b90fc
subrepo: keep ui and hgrc in sync when creating new repo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10665
diff
changeset
|
251 create = False |
4c50a90b90fc
subrepo: keep ui and hgrc in sync when creating new repo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10665
diff
changeset
|
252 if not os.path.exists(os.path.join(root, '.hg')): |
4c50a90b90fc
subrepo: keep ui and hgrc in sync when creating new repo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10665
diff
changeset
|
253 create = True |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
254 util.makedirs(root) |
10666
4c50a90b90fc
subrepo: keep ui and hgrc in sync when creating new repo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10665
diff
changeset
|
255 self._repo = hg.repository(r.ui, root, create=create) |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
256 self._repo._subparent = r |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
257 self._repo._subsource = state[0] |
8813
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
258 |
10666
4c50a90b90fc
subrepo: keep ui and hgrc in sync when creating new repo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10665
diff
changeset
|
259 if create: |
4c50a90b90fc
subrepo: keep ui and hgrc in sync when creating new repo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10665
diff
changeset
|
260 fp = self._repo.opener("hgrc", "w", text=True) |
4c50a90b90fc
subrepo: keep ui and hgrc in sync when creating new repo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10665
diff
changeset
|
261 fp.write('[paths]\n') |
4c50a90b90fc
subrepo: keep ui and hgrc in sync when creating new repo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10665
diff
changeset
|
262 |
4c50a90b90fc
subrepo: keep ui and hgrc in sync when creating new repo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10665
diff
changeset
|
263 def addpathconfig(key, value): |
4c50a90b90fc
subrepo: keep ui and hgrc in sync when creating new repo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10665
diff
changeset
|
264 fp.write('%s = %s\n' % (key, value)) |
4c50a90b90fc
subrepo: keep ui and hgrc in sync when creating new repo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10665
diff
changeset
|
265 self._repo.ui.setconfig('paths', key, value) |
4c50a90b90fc
subrepo: keep ui and hgrc in sync when creating new repo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10665
diff
changeset
|
266 |
10697
c90d923fff64
subrepo: fix hgrc paths section during subrepo pulling
Edouard Gomez <ed.gomez@free.fr>
parents:
10666
diff
changeset
|
267 defpath = _abssource(self._repo) |
c90d923fff64
subrepo: fix hgrc paths section during subrepo pulling
Edouard Gomez <ed.gomez@free.fr>
parents:
10666
diff
changeset
|
268 defpushpath = _abssource(self._repo, True) |
10666
4c50a90b90fc
subrepo: keep ui and hgrc in sync when creating new repo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10665
diff
changeset
|
269 addpathconfig('default', defpath) |
10697
c90d923fff64
subrepo: fix hgrc paths section during subrepo pulling
Edouard Gomez <ed.gomez@free.fr>
parents:
10666
diff
changeset
|
270 if defpath != defpushpath: |
c90d923fff64
subrepo: fix hgrc paths section during subrepo pulling
Edouard Gomez <ed.gomez@free.fr>
parents:
10666
diff
changeset
|
271 addpathconfig('default-push', defpushpath) |
10666
4c50a90b90fc
subrepo: keep ui and hgrc in sync when creating new repo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10665
diff
changeset
|
272 fp.close() |
4c50a90b90fc
subrepo: keep ui and hgrc in sync when creating new repo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10665
diff
changeset
|
273 |
8813
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
274 def dirty(self): |
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
275 r = self._state[1] |
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
276 if r == '': |
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
277 return True |
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
278 w = self._repo[None] |
10666
4c50a90b90fc
subrepo: keep ui and hgrc in sync when creating new repo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10665
diff
changeset
|
279 if w.p1() != self._repo[r]: # version checked out change |
8813
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
280 return True |
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
281 return w.dirty() # working directory changed |
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
282 |
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
283 def commit(self, text, user, date): |
11112
4a9bee613737
subrepo: print paths relative to upper repo root for push/pull/commit
Edouard Gomez <ed.gomez@free.fr>
parents:
11111
diff
changeset
|
284 self._repo.ui.debug("committing subrepo %s\n" % relpath(self)) |
8813
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
285 n = self._repo.commit(text, user, date) |
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
286 if not n: |
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
287 return self._repo['.'].hex() # different version checked out |
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
288 return node.hex(n) |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
289 |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
290 def remove(self): |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
291 # we can't fully delete the repository as it may contain |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
292 # local-only history |
11112
4a9bee613737
subrepo: print paths relative to upper repo root for push/pull/commit
Edouard Gomez <ed.gomez@free.fr>
parents:
11111
diff
changeset
|
293 self._repo.ui.note(_('removing subrepo %s\n') % relpath(self)) |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
294 hg.clean(self._repo, node.nullid, False) |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
295 |
9507
5987183d6e59
subrepo: add auto-pull for merge
Matt Mackall <mpm@selenic.com>
parents:
9186
diff
changeset
|
296 def _get(self, state): |
10177
5ca0d220ae21
subrepo: add table-based dispatch for subrepo types
Augie Fackler <durin42@gmail.com>
parents:
10175
diff
changeset
|
297 source, revision, kind = state |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
298 try: |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
299 self._repo.lookup(revision) |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
300 except error.RepoError: |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
301 self._repo._subsource = source |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
302 srcurl = _abssource(self._repo) |
10671
001ffc2b3d22
subrepo: wrap long line
Martin Geisler <mg@lazybytes.net>
parents:
10670
diff
changeset
|
303 self._repo.ui.status(_('pulling subrepo %s from %s\n') |
11112
4a9bee613737
subrepo: print paths relative to upper repo root for push/pull/commit
Edouard Gomez <ed.gomez@free.fr>
parents:
11111
diff
changeset
|
304 % (relpath(self), srcurl)) |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
305 other = hg.repository(self._repo.ui, srcurl) |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
306 self._repo.pull(other) |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
307 |
9507
5987183d6e59
subrepo: add auto-pull for merge
Matt Mackall <mpm@selenic.com>
parents:
9186
diff
changeset
|
308 def get(self, state): |
5987183d6e59
subrepo: add auto-pull for merge
Matt Mackall <mpm@selenic.com>
parents:
9186
diff
changeset
|
309 self._get(state) |
10177
5ca0d220ae21
subrepo: add table-based dispatch for subrepo types
Augie Fackler <durin42@gmail.com>
parents:
10175
diff
changeset
|
310 source, revision, kind = state |
9782
c1c40511c276
subrepo: add more debugging output, lose _ markers
Matt Mackall <mpm@selenic.com>
parents:
9781
diff
changeset
|
311 self._repo.ui.debug("getting subrepo %s\n" % self._path) |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
312 hg.clean(self._repo, revision, False) |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
313 |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
314 def merge(self, state): |
9507
5987183d6e59
subrepo: add auto-pull for merge
Matt Mackall <mpm@selenic.com>
parents:
9186
diff
changeset
|
315 self._get(state) |
9781
eccc8aacd6f9
subrepo: do a linear update when appropriate
Matt Mackall <mpm@selenic.com>
parents:
9780
diff
changeset
|
316 cur = self._repo['.'] |
eccc8aacd6f9
subrepo: do a linear update when appropriate
Matt Mackall <mpm@selenic.com>
parents:
9780
diff
changeset
|
317 dst = self._repo[state[1]] |
10251
a19d2993385d
subrepo: fix merging of already merged subrepos (issue1986)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10068
diff
changeset
|
318 anc = dst.ancestor(cur) |
a19d2993385d
subrepo: fix merging of already merged subrepos (issue1986)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10068
diff
changeset
|
319 if anc == cur: |
11112
4a9bee613737
subrepo: print paths relative to upper repo root for push/pull/commit
Edouard Gomez <ed.gomez@free.fr>
parents:
11111
diff
changeset
|
320 self._repo.ui.debug("updating subrepo %s\n" % relpath(self)) |
9781
eccc8aacd6f9
subrepo: do a linear update when appropriate
Matt Mackall <mpm@selenic.com>
parents:
9780
diff
changeset
|
321 hg.update(self._repo, state[1]) |
10251
a19d2993385d
subrepo: fix merging of already merged subrepos (issue1986)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10068
diff
changeset
|
322 elif anc == dst: |
11112
4a9bee613737
subrepo: print paths relative to upper repo root for push/pull/commit
Edouard Gomez <ed.gomez@free.fr>
parents:
11111
diff
changeset
|
323 self._repo.ui.debug("skipping subrepo %s\n" % relpath(self)) |
9781
eccc8aacd6f9
subrepo: do a linear update when appropriate
Matt Mackall <mpm@selenic.com>
parents:
9780
diff
changeset
|
324 else: |
11112
4a9bee613737
subrepo: print paths relative to upper repo root for push/pull/commit
Edouard Gomez <ed.gomez@free.fr>
parents:
11111
diff
changeset
|
325 self._repo.ui.debug("merging subrepo %s\n" % relpath(self)) |
9781
eccc8aacd6f9
subrepo: do a linear update when appropriate
Matt Mackall <mpm@selenic.com>
parents:
9780
diff
changeset
|
326 hg.merge(self._repo, state[1], remind=False) |
8815
e87b0fc4750b
subrepo: basic push support
Matt Mackall <mpm@selenic.com>
parents:
8814
diff
changeset
|
327 |
e87b0fc4750b
subrepo: basic push support
Matt Mackall <mpm@selenic.com>
parents:
8814
diff
changeset
|
328 def push(self, force): |
e87b0fc4750b
subrepo: basic push support
Matt Mackall <mpm@selenic.com>
parents:
8814
diff
changeset
|
329 # push subrepos depth-first for coherent ordering |
e87b0fc4750b
subrepo: basic push support
Matt Mackall <mpm@selenic.com>
parents:
8814
diff
changeset
|
330 c = self._repo[''] |
e87b0fc4750b
subrepo: basic push support
Matt Mackall <mpm@selenic.com>
parents:
8814
diff
changeset
|
331 subs = c.substate # only repos that are committed |
e87b0fc4750b
subrepo: basic push support
Matt Mackall <mpm@selenic.com>
parents:
8814
diff
changeset
|
332 for s in sorted(subs): |
11067
49e14ec67144
subrepo: propagate and catch push failures
Matt Mackall <mpm@selenic.com>
parents:
10954
diff
changeset
|
333 if not c.sub(s).push(force): |
49e14ec67144
subrepo: propagate and catch push failures
Matt Mackall <mpm@selenic.com>
parents:
10954
diff
changeset
|
334 return False |
8815
e87b0fc4750b
subrepo: basic push support
Matt Mackall <mpm@selenic.com>
parents:
8814
diff
changeset
|
335 |
e87b0fc4750b
subrepo: basic push support
Matt Mackall <mpm@selenic.com>
parents:
8814
diff
changeset
|
336 dsturl = _abssource(self._repo, True) |
11111
d2da9e6dd13e
subrepo: print pushing url
Edouard Gomez <ed.gomez@free.fr>
parents:
11109
diff
changeset
|
337 self._repo.ui.status(_('pushing subrepo %s to %s\n') % |
11112
4a9bee613737
subrepo: print paths relative to upper repo root for push/pull/commit
Edouard Gomez <ed.gomez@free.fr>
parents:
11111
diff
changeset
|
338 (relpath(self), dsturl)) |
8815
e87b0fc4750b
subrepo: basic push support
Matt Mackall <mpm@selenic.com>
parents:
8814
diff
changeset
|
339 other = hg.repository(self._repo.ui, dsturl) |
11067
49e14ec67144
subrepo: propagate and catch push failures
Matt Mackall <mpm@selenic.com>
parents:
10954
diff
changeset
|
340 return self._repo.push(other, force) |
10177
5ca0d220ae21
subrepo: add table-based dispatch for subrepo types
Augie Fackler <durin42@gmail.com>
parents:
10175
diff
changeset
|
341 |
11559
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
342 class svnsubrepo(abstractsubrepo): |
10178
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
343 def __init__(self, ctx, path, state): |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
344 self._path = path |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
345 self._state = state |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
346 self._ctx = ctx |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
347 self._ui = ctx._repo.ui |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
348 |
11560
ea2cdee9a1fe
subrepos: let caller specify a filename for SVN commands
Martin Geisler <mg@lazybytes.net>
parents:
11559
diff
changeset
|
349 def _svncommand(self, commands, filename=''): |
ea2cdee9a1fe
subrepos: let caller specify a filename for SVN commands
Martin Geisler <mg@lazybytes.net>
parents:
11559
diff
changeset
|
350 path = os.path.join(self._ctx._repo.origroot, self._path, filename) |
10954
33119d0252c1
subrepo: fix repo root path handling in svn subrepo
Brett Cannon <brett@python.org>
parents:
10697
diff
changeset
|
351 cmd = ['svn'] + commands + [path] |
10178
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
352 cmd = [util.shellquote(arg) for arg in cmd] |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
353 cmd = util.quotecommand(' '.join(cmd)) |
10199
c2e2a5e6c36b
subrepo: force en_US.UTF-8 locale when calling svn
Patrick Mezard <pmezard@gmail.com>
parents:
10197
diff
changeset
|
354 env = dict(os.environ) |
10271
9b38bec5dc29
subrepo: make svn use C locale for portability
Patrick Mezard <pmezard@gmail.com>
parents:
10264
diff
changeset
|
355 # Avoid localized output, preserve current locale for everything else. |
9b38bec5dc29
subrepo: make svn use C locale for portability
Patrick Mezard <pmezard@gmail.com>
parents:
10264
diff
changeset
|
356 env['LC_MESSAGES'] = 'C' |
10199
c2e2a5e6c36b
subrepo: force en_US.UTF-8 locale when calling svn
Patrick Mezard <pmezard@gmail.com>
parents:
10197
diff
changeset
|
357 write, read, err = util.popen3(cmd, env=env, newlines=True) |
10178
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
358 retdata = read.read() |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
359 err = err.read().strip() |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
360 if err: |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
361 raise util.Abort(err) |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
362 return retdata |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
363 |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
364 def _wcrev(self): |
10272
886858b834da
subrepo: svn xml output is much easier to parse
Patrick Mezard <pmezard@gmail.com>
parents:
10271
diff
changeset
|
365 output = self._svncommand(['info', '--xml']) |
886858b834da
subrepo: svn xml output is much easier to parse
Patrick Mezard <pmezard@gmail.com>
parents:
10271
diff
changeset
|
366 doc = xml.dom.minidom.parseString(output) |
886858b834da
subrepo: svn xml output is much easier to parse
Patrick Mezard <pmezard@gmail.com>
parents:
10271
diff
changeset
|
367 entries = doc.getElementsByTagName('entry') |
886858b834da
subrepo: svn xml output is much easier to parse
Patrick Mezard <pmezard@gmail.com>
parents:
10271
diff
changeset
|
368 if not entries: |
10178
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
369 return 0 |
10272
886858b834da
subrepo: svn xml output is much easier to parse
Patrick Mezard <pmezard@gmail.com>
parents:
10271
diff
changeset
|
370 return int(entries[0].getAttribute('revision') or 0) |
10178
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
371 |
10273
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
372 def _wcchanged(self): |
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
373 """Return (changes, extchanges) where changes is True |
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
374 if the working directory was changed, and extchanges is |
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
375 True if any of these changes concern an external entry. |
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
376 """ |
10272
886858b834da
subrepo: svn xml output is much easier to parse
Patrick Mezard <pmezard@gmail.com>
parents:
10271
diff
changeset
|
377 output = self._svncommand(['status', '--xml']) |
10273
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
378 externals, changes = [], [] |
10272
886858b834da
subrepo: svn xml output is much easier to parse
Patrick Mezard <pmezard@gmail.com>
parents:
10271
diff
changeset
|
379 doc = xml.dom.minidom.parseString(output) |
10273
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
380 for e in doc.getElementsByTagName('entry'): |
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
381 s = e.getElementsByTagName('wc-status') |
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
382 if not s: |
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
383 continue |
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
384 item = s[0].getAttribute('item') |
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
385 props = s[0].getAttribute('props') |
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
386 path = e.getAttribute('path') |
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
387 if item == 'external': |
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
388 externals.append(path) |
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
389 if (item not in ('', 'normal', 'unversioned', 'external') |
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
390 or props not in ('', 'none')): |
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
391 changes.append(path) |
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
392 for path in changes: |
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
393 for ext in externals: |
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
394 if path == ext or path.startswith(ext + os.sep): |
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
395 return True, True |
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
396 return bool(changes), False |
10178
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
397 |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
398 def dirty(self): |
10273
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
399 if self._wcrev() == self._state[1] and not self._wcchanged()[0]: |
10178
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
400 return False |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
401 return True |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
402 |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
403 def commit(self, text, user, date): |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
404 # user and date are out of our hands since svn is centralized |
10273
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
405 changed, extchanged = self._wcchanged() |
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
406 if not changed: |
10178
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
407 return self._wcrev() |
10273
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
408 if extchanged: |
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
409 # Do not try to commit externals |
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
410 raise util.Abort(_('cannot commit svn externals')) |
10178
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
411 commitinfo = self._svncommand(['commit', '-m', text]) |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
412 self._ui.status(commitinfo) |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
413 newrev = re.search('Committed revision ([\d]+).', commitinfo) |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
414 if not newrev: |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
415 raise util.Abort(commitinfo.splitlines()[-1]) |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
416 newrev = newrev.groups()[0] |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
417 self._ui.status(self._svncommand(['update', '-r', newrev])) |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
418 return newrev |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
419 |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
420 def remove(self): |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
421 if self.dirty(): |
10299
e768941f14c1
subrepo: fix errors reported by pylint
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10273
diff
changeset
|
422 self._ui.warn(_('not removing repo %s because ' |
e768941f14c1
subrepo: fix errors reported by pylint
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10273
diff
changeset
|
423 'it has changes.\n' % self._path)) |
10178
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
424 return |
10510
f77f3383c666
i18n: mark more strings for translation
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10457
diff
changeset
|
425 self._ui.note(_('removing subrepo %s\n') % self._path) |
10178
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
426 shutil.rmtree(self._ctx.repo.join(self._path)) |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
427 |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
428 def get(self, state): |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
429 status = self._svncommand(['checkout', state[0], '--revision', state[1]]) |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
430 if not re.search('Checked out revision [\d]+.', status): |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
431 raise util.Abort(status.splitlines()[-1]) |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
432 self._ui.status(status) |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
433 |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
434 def merge(self, state): |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
435 old = int(self._state[1]) |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
436 new = int(state[1]) |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
437 if new > old: |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
438 self.get(state) |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
439 |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
440 def push(self, force): |
11455
3827728b54e2
subrepo: fix silent push failure for SVN (issue2241)
Matt Mackall <mpm@selenic.com>
parents:
11117
diff
changeset
|
441 # push is a no-op for SVN |
3827728b54e2
subrepo: fix silent push failure for SVN (issue2241)
Matt Mackall <mpm@selenic.com>
parents:
11117
diff
changeset
|
442 return True |
10178
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
443 |
10177
5ca0d220ae21
subrepo: add table-based dispatch for subrepo types
Augie Fackler <durin42@gmail.com>
parents:
10175
diff
changeset
|
444 types = { |
5ca0d220ae21
subrepo: add table-based dispatch for subrepo types
Augie Fackler <durin42@gmail.com>
parents:
10175
diff
changeset
|
445 'hg': hgsubrepo, |
10178
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
446 'svn': svnsubrepo, |
10177
5ca0d220ae21
subrepo: add table-based dispatch for subrepo types
Augie Fackler <durin42@gmail.com>
parents:
10175
diff
changeset
|
447 } |