annotate tests/svnxml.py @ 24787:9d5c27890790

largefiles: for update -C, only update largefiles when necessary Before, a --clean update with largefiles would use the "optimization" that it didn't read hashes from standin files before and after the update. Instead of trusting the content of the standin files, it would rehash all the actual largefiles that lfdirstate reported clean and update the standins that didn't have the expected content. It could thus in some "impossible" situations automatically recover from some "largefile got out sync with its standin" issues (even there apparently still were weird corner cases where it could fail). This extra checking is similar to what core --clean intentionally do not do, and it made update --clean unbearable slow. Usually in core Mercurial, --clean will rely on the dirstate to find the files it should update. (It is thus intentionally possible (when trying to trick the system or if there should be bugs) to end up in situations where --clean not will restore the working directory content correctly.) Checking every file when we "know" it is ok is however not an option - that would be too slow. Instead, trust the content of the standin files. Use the same logic for --clean as for linear updates and trust the dirstate and that our "logic" will keep them in sync. It is much cheaper to just rehash the largefiles reported dirty by a status walk and read all standins than to hash largefiles. Most of the changes are just a change of indentation now when the different kinds of updates no longer are handled that differently. Standins for added files are however only written when doing a normal update, while deleted and removed files only will be updated for --clean updates.
author Mads Kiilerich <madski@unity3d.com>
date Wed, 15 Apr 2015 15:22:16 -0400
parents c58bdecdb800
children 812eb3b7dc43
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16512
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
1 # Read the output of a "svn log --xml" command on stdin, parse it and
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
2 # print a subset of attributes common to all svn versions tested by
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
3 # hg.
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
4 import xml.dom.minidom, sys
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
5
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
6 def xmltext(e):
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
7 return ''.join(c.data for c
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
8 in e.childNodes
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
9 if c.nodeType == c.TEXT_NODE)
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
10
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
11 def parseentry(entry):
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
12 e = {}
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
13 e['revision'] = entry.getAttribute('revision')
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
14 e['author'] = xmltext(entry.getElementsByTagName('author')[0])
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
15 e['msg'] = xmltext(entry.getElementsByTagName('msg')[0])
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
16 e['paths'] = []
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
17 paths = entry.getElementsByTagName('paths')
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
18 if paths:
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
19 paths = paths[0]
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
20 for p in paths.getElementsByTagName('path'):
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
21 action = p.getAttribute('action')
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
22 path = xmltext(p)
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
23 frompath = p.getAttribute('copyfrom-path')
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
24 fromrev = p.getAttribute('copyfrom-rev')
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
25 e['paths'].append((path, action, frompath, fromrev))
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
26 return e
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
27
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
28 def parselog(data):
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
29 entries = []
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
30 doc = xml.dom.minidom.parseString(data)
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
31 for e in doc.getElementsByTagName('logentry'):
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
32 entries.append(parseentry(e))
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
33 return entries
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
34
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
35 def printentries(entries):
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
36 fp = sys.stdout
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
37 for e in entries:
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
38 for k in ('revision', 'author', 'msg'):
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
39 fp.write(('%s: %s\n' % (k, e[k])).encode('utf-8'))
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
40 for path, action, fpath, frev in sorted(e['paths']):
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
41 frominfo = ''
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
42 if frev:
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
43 frominfo = ' (from %s@%s)' % (fpath, frev)
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
44 p = ' %s %s%s\n' % (action, path, frominfo)
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
45 fp.write(p.encode('utf-8'))
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
46
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
47 if __name__ == '__main__':
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
48 data = sys.stdin.read()
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
49 entries = parselog(data)
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
50 printentries(entries)
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
51