##// END OF EJS Templates
subrepo: handle svn externals and meta changes (issue1982)...
Patrick Mezard -
r10273:e898bc78 default
parent child Browse files
Show More
@@ -282,27 +282,45 b' class svnsubrepo(object):'
282 return 0
282 return 0
283 return int(entries[0].getAttribute('revision') or 0)
283 return int(entries[0].getAttribute('revision') or 0)
284
284
285 def _wcclean(self):
285 def _wcchanged(self):
286 """Return (changes, extchanges) where changes is True
287 if the working directory was changed, and extchanges is
288 True if any of these changes concern an external entry.
289 """
286 output = self._svncommand(['status', '--xml'])
290 output = self._svncommand(['status', '--xml'])
291 externals, changes = [], []
287 doc = xml.dom.minidom.parseString(output)
292 doc = xml.dom.minidom.parseString(output)
288 for s in doc.getElementsByTagName('wc-status'):
293 for e in doc.getElementsByTagName('entry'):
289 st = s.getAttribute('item')
294 s = e.getElementsByTagName('wc-status')
290 if st and st != 'unversioned':
295 if not s:
291 return False
296 continue
292 props = s.getAttribute('props')
297 item = s[0].getAttribute('item')
293 if props and props != 'none':
298 props = s[0].getAttribute('props')
294 return False
299 path = e.getAttribute('path')
295 return True
300 if item == 'external':
301 externals.append(path)
302 if (item not in ('', 'normal', 'unversioned', 'external')
303 or props not in ('', 'none')):
304 changes.append(path)
305 for path in changes:
306 for ext in externals:
307 if path == ext or path.startswith(ext + os.sep):
308 return True, True
309 return bool(changes), False
296
310
297 def dirty(self):
311 def dirty(self):
298 if self._wcrev() == self._state[1] and self._wcclean():
312 if self._wcrev() == self._state[1] and not self._wcchanged()[0]:
299 return False
313 return False
300 return True
314 return True
301
315
302 def commit(self, text, user, date):
316 def commit(self, text, user, date):
303 # user and date are out of our hands since svn is centralized
317 # user and date are out of our hands since svn is centralized
304 if self._wcclean():
318 changed, extchanged = self._wcchanged()
319 if not changed:
305 return self._wcrev()
320 return self._wcrev()
321 if extchanged:
322 # Do not try to commit externals
323 raise util.Abort(_('cannot commit svn externals'))
306 commitinfo = self._svncommand(['commit', '-m', text])
324 commitinfo = self._svncommand(['commit', '-m', text])
307 self._ui.status(commitinfo)
325 self._ui.status(commitinfo)
308 newrev = re.search('Committed revision ([\d]+).', commitinfo)
326 newrev = re.search('Committed revision ([\d]+).', commitinfo)
@@ -23,9 +23,19 b' WCROOT="`pwd`/svn-wc"'
23 svnadmin create svn-repo
23 svnadmin create svn-repo
24 svn co $SVNREPO svn-wc
24 svn co $SVNREPO svn-wc
25 cd svn-wc
25 cd svn-wc
26 echo alpha > alpha
26 mkdir src
27 svn add alpha
27 echo alpha > src/alpha
28 svn add src
29 mkdir externals
30 echo other > externals/other
31 svn add externals
28 svn ci -m 'Add alpha'
32 svn ci -m 'Add alpha'
33 svn up
34 cat > extdef <<EOF
35 externals -r1 $SVNREPO/externals
36 EOF
37 svn propset -F extdef svn:externals src
38 svn ci -m 'Setting externals'
29 cd ..
39 cd ..
30
40
31 echo % create hg repo
41 echo % create hg repo
@@ -39,8 +49,8 b' echo a > a'
39 hg ci -Am0
49 hg ci -Am0
40
50
41 echo % add first svn sub
51 echo % add first svn sub
42 echo "s = [svn]$SVNREPO" >> .hgsub
52 echo "s = [svn]$SVNREPO/src" >> .hgsub
43 svn co --quiet $SVNREPO s
53 svn co --quiet $SVNREPO/src s
44 hg add .hgsub
54 hg add .hgsub
45 hg ci -m1
55 hg ci -m1
46 echo % debugsub
56 echo % debugsub
@@ -60,14 +70,32 b' hg st'
60
70
61 echo
71 echo
62 echo % add a commit from svn
72 echo % add a commit from svn
63 cd "$WCROOT"
73 cd "$WCROOT"/src
64 svn up
74 svn up
65 echo xyz >> alpha
75 echo xyz >> alpha
76 svn propset svn:mime-type 'text/xml' alpha
66 svn ci -m 'amend a from svn'
77 svn ci -m 'amend a from svn'
67 cd ../sub/t
78 cd ../../sub/t
79
68 echo % this commit from hg will fail
80 echo % this commit from hg will fail
69 echo zzz >> s/alpha
81 echo zzz >> s/alpha
70 hg ci -m 'amend alpha from hg'
82 hg ci -m 'amend alpha from hg'
83 svn revert -q s/alpha
84
85 echo % this commit fails because of meta changes
86 svn propset svn:mime-type 'text/html' s/alpha
87 hg ci -m 'amend alpha from hg'
88 svn revert -q s/alpha
89
90 echo % this commit fails because of externals changes
91 echo zzz > s/externals/other
92 hg ci -m 'amend externals from hg'
93 svn revert -q s/externals/other
94
95 echo % this commit fails because of externals meta changes
96 svn propset svn:mime-type 'text/html' s/externals/other
97 hg ci -m 'amend externals from hg'
98 svn revert -q s/externals/other
71
99
72 echo
100 echo
73 echo % clone
101 echo % clone
@@ -1,9 +1,20 b''
1 % create subversion repo
1 % create subversion repo
2 Checked out revision 0.
2 Checked out revision 0.
3 A alpha
3 A src
4 Adding alpha
4 A src/alpha
5 Transmitting file data .
5 A externals
6 A externals/other
7 Adding externals
8 Adding externals/other
9 Adding src
10 Adding src/alpha
11 Transmitting file data ..
6 Committed revision 1.
12 Committed revision 1.
13 At revision 1.
14 property 'svn:externals' set on 'src'
15 Sending src
16
17 Committed revision 2.
7 % create hg repo
18 % create hg repo
8 % first revision, no sub
19 % first revision, no sub
9 adding a
20 adding a
@@ -11,38 +22,66 b' adding a'
11 committing subrepository s
22 committing subrepository s
12 % debugsub
23 % debugsub
13 path s
24 path s
14 source file:///root/svn-repo
25 source file:///root/svn-repo/src
15 revision 1
26 revision 2
16
27
17 % change file in svn and hg, commit
28 % change file in svn and hg, commit
18 committing subrepository s
29 committing subrepository s
19 Sending s/alpha
30 Sending s/alpha
20 Transmitting file data .
31 Transmitting file data .
21 Committed revision 2.
32 Committed revision 3.
22 At revision 2.
33
34 Fetching external item into 's/externals'
35 External at revision 1.
36
37 At revision 3.
23 path s
38 path s
24 source file:///root/svn-repo
39 source file:///root/svn-repo/src
25 revision 2
40 revision 3
26
41
27 % should be empty despite change to s/a
42 % should be empty despite change to s/a
28
43
29 % add a commit from svn
44 % add a commit from svn
30 U alpha
45 U alpha
31 Updated to revision 2.
46
32 Sending alpha
47 Fetching external item into 'externals'
48 A externals/other
49 Updated external to revision 1.
50
51 Updated to revision 3.
52 property 'svn:mime-type' set on 'alpha'
53 Sending src/alpha
33 Transmitting file data .
54 Transmitting file data .
34 Committed revision 3.
55 Committed revision 4.
35 % this commit from hg will fail
56 % this commit from hg will fail
36 committing subrepository s
57 committing subrepository s
37 abort: svn: Commit failed (details follow):
58 abort: svn: Commit failed (details follow):
38 svn: File '/alpha' is out of date
59 svn: File '/src/alpha' is out of date
60 % this commit fails because of meta changes
61 property 'svn:mime-type' set on 's/alpha'
62 committing subrepository s
63 abort: svn: Commit failed (details follow):
64 svn: File '/src/alpha' is out of date
65 % this commit fails because of externals changes
66 committing subrepository s
67 abort: cannot commit svn externals
68 % this commit fails because of externals meta changes
69 property 'svn:mime-type' set on 's/externals/other'
70 committing subrepository s
71 abort: cannot commit svn externals
39
72
40 % clone
73 % clone
41 updating to branch default
74 updating to branch default
42 A s/alpha
75 A s/alpha
43 Checked out revision 2.
76 U s
77
78 Fetching external item into 's/externals'
79 A s/externals/other
80 Checked out external at revision 1.
81
82 Checked out revision 3.
44 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
83 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
45 % debugsub in clone
84 % debugsub in clone
46 path s
85 path s
47 source file:///root/svn-repo
86 source file:///root/svn-repo/src
48 revision 2
87 revision 3
General Comments 0
You need to be logged in to leave comments. Login now