annotate hgsubversion/editor.py @ 938:f9014e28721b

editor: start separating svn copies from open files The separation is not complete as we still have to update the RevisionData deleted set when registering svn copies. This will be cleaned up once open files are themselves separated from RevisionData. Copied symlinks are also being prefixed with 'link '.
author Patrick Mezard <patrick@mezard.eu>
date Wed, 03 Oct 2012 21:27:02 +0200
parents fb6f6b7fa5a5
children 997de286ba0c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
633
37b2adc64fb3 editor: convert two assertions in apply_textdelta() into raising an IOError
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 601
diff changeset
1 import errno
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
2 import cStringIO
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
3 import sys
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
4
250
79349fd04836 utils: standardizing imported name to hgutil, our_util to util
Daniel Tang <dytang@cs.purdue.edu>
parents: 237
diff changeset
5 from mercurial import util as hgutil
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
6 from mercurial import revlog
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
7 from mercurial import node
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
8
601
0fe490ce2fbb isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 591
diff changeset
9 import svnwrap
250
79349fd04836 utils: standardizing imported name to hgutil, our_util to util
Daniel Tang <dytang@cs.purdue.edu>
parents: 237
diff changeset
10 import util
792
ba65c0b01d4f replay: copy copied directories externals
Patrick Mezard <pmezard@gmail.com>
parents: 791
diff changeset
11 import svnexternals
34
50d55c3e0d85 Some refactors of the previous change, including transparent upgrade of old-style pickled dictionaries.
Augie Fackler <durin42@gmail.com>
parents: 33
diff changeset
12
862
6ef6c413d6de editor: work around svn 1.7 closing the output fp in apply_textdelta()
Patrick Mezard <patrick@mezard.eu>
parents: 843
diff changeset
13 class NeverClosingStringIO(object):
6ef6c413d6de editor: work around svn 1.7 closing the output fp in apply_textdelta()
Patrick Mezard <patrick@mezard.eu>
parents: 843
diff changeset
14 def __init__(self):
6ef6c413d6de editor: work around svn 1.7 closing the output fp in apply_textdelta()
Patrick Mezard <patrick@mezard.eu>
parents: 843
diff changeset
15 self._fp = cStringIO.StringIO()
6ef6c413d6de editor: work around svn 1.7 closing the output fp in apply_textdelta()
Patrick Mezard <patrick@mezard.eu>
parents: 843
diff changeset
16
6ef6c413d6de editor: work around svn 1.7 closing the output fp in apply_textdelta()
Patrick Mezard <patrick@mezard.eu>
parents: 843
diff changeset
17 def __getattr__(self, name):
6ef6c413d6de editor: work around svn 1.7 closing the output fp in apply_textdelta()
Patrick Mezard <patrick@mezard.eu>
parents: 843
diff changeset
18 return getattr(self._fp, name)
6ef6c413d6de editor: work around svn 1.7 closing the output fp in apply_textdelta()
Patrick Mezard <patrick@mezard.eu>
parents: 843
diff changeset
19
6ef6c413d6de editor: work around svn 1.7 closing the output fp in apply_textdelta()
Patrick Mezard <patrick@mezard.eu>
parents: 843
diff changeset
20 def close(self):
6ef6c413d6de editor: work around svn 1.7 closing the output fp in apply_textdelta()
Patrick Mezard <patrick@mezard.eu>
parents: 843
diff changeset
21 # svn 1.7 apply_delta driver now calls close() on passed file
6ef6c413d6de editor: work around svn 1.7 closing the output fp in apply_textdelta()
Patrick Mezard <patrick@mezard.eu>
parents: 843
diff changeset
22 # object which prevent us from calling getvalue() afterwards.
6ef6c413d6de editor: work around svn 1.7 closing the output fp in apply_textdelta()
Patrick Mezard <patrick@mezard.eu>
parents: 843
diff changeset
23 pass
6ef6c413d6de editor: work around svn 1.7 closing the output fp in apply_textdelta()
Patrick Mezard <patrick@mezard.eu>
parents: 843
diff changeset
24
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
25 class RevisionData(object):
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
26
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
27 __slots__ = [
901
bd12a4da0f35 replay: workaround svn not telling us about x/l flags (issue346)
Bryan O'Sullivan <bryano@fb.com>
parents: 891
diff changeset
28 'file', 'added', 'files', 'deleted', 'rev', 'execfiles', 'symlinks', 'batons',
433
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
29 'copies', 'missing', 'emptybranches', 'base', 'externals', 'ui',
528
052050ca59d6 replay: disable maybeedit filtering, could discard copy records
Patrick Mezard <pmezard@gmail.com>
parents: 521
diff changeset
30 'exception',
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
31 ]
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
32
433
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
33 def __init__(self, ui):
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
34 self.ui = ui
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
35 self.clear()
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
36
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
37 def clear(self):
901
bd12a4da0f35 replay: workaround svn not telling us about x/l flags (issue346)
Bryan O'Sullivan <bryano@fb.com>
parents: 891
diff changeset
38 self.added = set()
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
39 self.files = {}
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
40 self.deleted = {}
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
41 self.rev = None
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
42 self.execfiles = {}
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
43 self.symlinks = {}
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
44 self.batons = {}
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
45 # Map fully qualified destination file paths to module source path
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
46 self.copies = {}
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
47 self.missing = set()
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
48 self.emptybranches = {}
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
49 self.externals = {}
434
3e2259fe3c93 editor: move exception data into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 433
diff changeset
50 self.exception = None
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
51
433
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
52 def set(self, path, data, isexec=False, islink=False):
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
53 self.files[path] = data
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
54 self.execfiles[path] = isexec
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
55 self.symlinks[path] = islink
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
56 if path in self.deleted:
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
57 del self.deleted[path]
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
58 if path in self.missing:
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
59 self.missing.remove(path)
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
60
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
61 def delete(self, path):
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
62 self.deleted[path] = True
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
63 if path in self.files:
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
64 del self.files[path]
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
65 self.execfiles[path] = False
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
66 self.symlinks[path] = False
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
67 self.ui.note('D %s\n' % path)
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
68
436
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
69 def findmissing(self, svn):
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
70
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
71 if not self.missing:
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
72 return
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
73
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
74 msg = 'fetching %s files that could not use replay.\n'
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
75 self.ui.debug(msg % len(self.missing))
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
76 root = svn.subdir and svn.subdir[1:] or ''
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
77 r = self.rev.revnum
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
78
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
79 files = set()
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
80 for p in self.missing:
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
81 self.ui.note('.')
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
82 self.ui.flush()
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
83 if p[-1] == '/':
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
84 dir = p[len(root):]
499
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 498
diff changeset
85 new = [p + f for f, k in svn.list_files(dir, r) if k == 'f']
436
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
86 files.update(new)
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
87 else:
591
4359ddd73b00 strip off root file name only once for missing files
Gerhard Weis <gweis@gmx.at>
parents: 587
diff changeset
88 files.add(p)
436
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
89
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
90 i = 1
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
91 self.ui.note('\nfetching files...\n')
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
92 for p in files:
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
93 self.ui.note('.')
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
94 self.ui.flush()
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
95 if i % 50 == 0:
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
96 svn.init_ra_and_client()
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
97 i += 1
499
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 498
diff changeset
98 data, mode = svn.get_file(p[len(root):], r)
436
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
99 self.set(p, data, 'x' in mode, 'l' in mode)
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
100
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
101 self.missing = set()
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
102 self.ui.note('\n')
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
103
937
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
104 class EditingError(Exception):
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
105 pass
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
106
601
0fe490ce2fbb isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 591
diff changeset
107 class HgEditor(svnwrap.Editor):
33
a9c15cae50e5 Faster append-only revmap implementation.
Andreas Hartmetz <ahartmetz@gmail.com>
parents: 23
diff changeset
108
416
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
109 def __init__(self, meta):
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
110 self.meta = meta
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
111 self.ui = meta.ui
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
112 self.repo = meta.repo
433
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
113 self.current = RevisionData(meta.ui)
937
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
114 self._clear()
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
115
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
116 def _clear(self):
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
117 self._filecounter = 0
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
118 self._filebatons = {}
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
119 self._files = {}
938
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
120 # A mapping of svn paths to (data, isexec, islink, copypath) tuples
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
121 self._svncopies = {}
937
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
122
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
123 def _addfilebaton(self, path):
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
124 # XXX: enforce unicity here. This cannot be done right now
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
125 # because copied files are mixed with open files and the cleanup
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
126 # rules in delete_entry() requires the distinction to be made to
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
127 # be implemented correctly.
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
128 self._filecounter += 1
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
129 baton = '%d-%s' % (self._filecounter, path)
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
130 self._filebatons[baton] = path
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
131 self._files[path] = baton
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
132 return baton
413
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
133
673
32089d080ff8 editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 633
diff changeset
134 @svnwrap.ieditor
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
135 def delete_entry(self, path, revision_bogus, parent_baton, pool=None):
545
ebd8fb1a05e4 clean up trailing whitespace
Augie Fackler <durin42@gmail.com>
parents: 540
diff changeset
136 br_path, branch = self.meta.split_branch_path(path)[:2]
133
2242dd1163c6 hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents: 131
diff changeset
137 if br_path == '':
540
8dc759dc9ca9 svnmeta: remove split_branch_tag() exacttag argument
Patrick Mezard <pmezard@gmail.com>
parents: 534
diff changeset
138 if self.meta.get_path_tag(path):
8dc759dc9ca9 svnmeta: remove split_branch_tag() exacttag argument
Patrick Mezard <pmezard@gmail.com>
parents: 534
diff changeset
139 # Tag deletion is not handled as branched deletion
8dc759dc9ca9 svnmeta: remove split_branch_tag() exacttag argument
Patrick Mezard <pmezard@gmail.com>
parents: 534
diff changeset
140 return
414
343da842dbe6 split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 413
diff changeset
141 self.meta.closebranches.add(branch)
938
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
142
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
143 # Delete copied entries, no need to check they exist in hg
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
144 # parent revision.
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
145 if path in self._svncopies:
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
146 del self._svncopies[path]
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
147 prefix = path + '/'
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
148 for f in list(self._svncopies):
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
149 if f.startswith(prefix):
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
150 del self._svncopies[f]
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
151
116
30580c05dccc hg_delta_editor: merge _is_path_valid() and _path_and_branch_from_path()
Patrick Mezard <pmezard@gmail.com>
parents: 111
diff changeset
152 if br_path is not None:
414
343da842dbe6 split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 413
diff changeset
153 ha = self.meta.get_parent_revision(self.current.rev.revnum, branch)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
154 if ha == revlog.nullid:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
155 return
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
156 ctx = self.repo.changectx(ha)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
157 if br_path not in ctx:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
158 br_path2 = ''
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
159 if br_path != '':
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
160 br_path2 = br_path + '/'
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
161 # assuming it is a directory
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
162 self.current.externals[path] = None
250
79349fd04836 utils: standardizing imported name to hgutil, our_util to util
Daniel Tang <dytang@cs.purdue.edu>
parents: 237
diff changeset
163 for f in ctx.walk(util.PrefixMatch(br_path2)):
39
b3c7b844b782 Some more fixes of cases discovered in the melange repo. If anyone knows how I can reproduce a "replaced" state in Subversion, I'd love to be able to make a real test case for this code.
Augie Fackler <durin42@gmail.com>
parents: 38
diff changeset
164 f_p = '%s/%s' % (path, f[len(br_path2):])
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
165 if f_p not in self.current.files:
433
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
166 self.current.delete(f_p)
938
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
167 if f_p in self._svncopies:
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
168 del self._svncopies[f_p]
433
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
169 self.current.delete(path)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
170
673
32089d080ff8 editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 633
diff changeset
171 @svnwrap.ieditor
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
172 def open_file(self, path, parent_baton, base_revision, p=None):
420
59e19c73b0df svnmeta: eliminate unneeded path_and_branch_for_path() method
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 418
diff changeset
173 fpath, branch = self.meta.split_branch_path(path)[:2]
378
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
174 if not fpath:
322
05cd4a5138bf Move some .warn() calls to noisy levels instead.
Augie Fackler <durin42@gmail.com>
parents: 321
diff changeset
175 self.ui.debug('WARNING: Opening non-existant file %s\n' % path)
937
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
176 return None
378
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
177
937
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
178 self.ui.note('M %s\n' % path)
378
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
179
938
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
180 if path in self._svncopies:
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
181 base, isexec, islink, copypath = self._svncopies.pop(path)
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
182 self.current.set(path, base, isexec, islink)
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
183 self.current.copies[path] = copypath
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
184 return self._addfilebaton(path)
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
185
586
704d2ce1d906 editor: fix open_file() on replaced branch
Patrick Mezard <pmezard@gmail.com>
parents: 585
diff changeset
186 if not self.meta.is_path_valid(path):
937
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
187 return None
586
704d2ce1d906 editor: fix open_file() on replaced branch
Patrick Mezard <pmezard@gmail.com>
parents: 585
diff changeset
188
378
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
189 baserev = base_revision
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
190 if baserev is None or baserev == -1:
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
191 baserev = self.current.rev.revnum - 1
586
704d2ce1d906 editor: fix open_file() on replaced branch
Patrick Mezard <pmezard@gmail.com>
parents: 585
diff changeset
192 # Use exact=True because during replacements ('R' action) we select
704d2ce1d906 editor: fix open_file() on replaced branch
Patrick Mezard <pmezard@gmail.com>
parents: 585
diff changeset
193 # replacing branch as parent, but svn delta editor provides delta
704d2ce1d906 editor: fix open_file() on replaced branch
Patrick Mezard <pmezard@gmail.com>
parents: 585
diff changeset
194 # agains replaced branch.
704d2ce1d906 editor: fix open_file() on replaced branch
Patrick Mezard <pmezard@gmail.com>
parents: 585
diff changeset
195 parent = self.meta.get_parent_revision(baserev + 1, branch, True)
378
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
196 ctx = self.repo[parent]
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
197 if fpath not in ctx:
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
198 self.current.missing.add(path)
937
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
199 return None
378
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
200
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
201 fctx = ctx.filectx(fpath)
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
202 base = fctx.data()
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
203 if 'l' in fctx.flags():
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
204 base = 'link ' + base
433
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
205 self.current.set(path, base, 'x' in fctx.flags(), 'l' in fctx.flags())
937
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
206 return self._addfilebaton(path)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
207
673
32089d080ff8 editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 633
diff changeset
208 @svnwrap.ieditor
300
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 299
diff changeset
209 def add_file(self, path, parent_baton=None, copyfrom_path=None,
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 299
diff changeset
210 copyfrom_revision=None, file_pool=None):
938
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
211 if path in self._svncopies:
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
212 raise EditingError('trying to replace copied file %s' % path)
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
213 if path in self.current.deleted:
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
214 del self.current.deleted[path]
420
59e19c73b0df svnmeta: eliminate unneeded path_and_branch_for_path() method
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 418
diff changeset
215 fpath, branch = self.meta.split_branch_path(path, existing=False)[:2]
67
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents: 59
diff changeset
216 if not fpath:
937
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
217 return None
447
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 436
diff changeset
218 if (branch not in self.meta.branches and
517
ef288fb7f2fe svnmeta: is_path_tag() is really get_path_tag()
Patrick Mezard <pmezard@gmail.com>
parents: 499
diff changeset
219 not self.meta.get_path_tag(self.meta.remotename(branch))):
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
220 # we know this branch will exist now, because it has at least one file. Rock.
414
343da842dbe6 split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 413
diff changeset
221 self.meta.branches[branch] = None, 0, self.current.rev.revnum
67
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents: 59
diff changeset
222 if not copyfrom_path:
186
6266ba36ee15 Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 181
diff changeset
223 self.ui.note('A %s\n' % path)
901
bd12a4da0f35 replay: workaround svn not telling us about x/l flags (issue346)
Bryan O'Sullivan <bryano@fb.com>
parents: 891
diff changeset
224 self.current.added.add(path)
433
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
225 self.current.set(path, '', False, False)
937
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
226 return self._addfilebaton(path)
186
6266ba36ee15 Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 181
diff changeset
227 self.ui.note('A+ %s\n' % path)
67
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents: 59
diff changeset
228 (from_file,
420
59e19c73b0df svnmeta: eliminate unneeded path_and_branch_for_path() method
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 418
diff changeset
229 from_branch) = self.meta.split_branch_path(copyfrom_path)[:2]
67
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents: 59
diff changeset
230 if not from_file:
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
231 self.current.missing.add(path)
937
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
232 return None
585
c3ba4ca81d16 editor: fix replaced files content in replay mode
Patrick Mezard <pmezard@gmail.com>
parents: 582
diff changeset
233 # Use exact=True because during replacements ('R' action) we select
c3ba4ca81d16 editor: fix replaced files content in replay mode
Patrick Mezard <pmezard@gmail.com>
parents: 582
diff changeset
234 # replacing branch as parent, but svn delta editor provides delta
c3ba4ca81d16 editor: fix replaced files content in replay mode
Patrick Mezard <pmezard@gmail.com>
parents: 582
diff changeset
235 # agains replaced branch.
414
343da842dbe6 split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 413
diff changeset
236 ha = self.meta.get_parent_revision(copyfrom_revision + 1,
585
c3ba4ca81d16 editor: fix replaced files content in replay mode
Patrick Mezard <pmezard@gmail.com>
parents: 582
diff changeset
237 from_branch, True)
67
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents: 59
diff changeset
238 ctx = self.repo.changectx(ha)
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents: 59
diff changeset
239 if from_file in ctx:
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents: 59
diff changeset
240 fctx = ctx.filectx(from_file)
97
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents: 73
diff changeset
241 flags = fctx.flags()
433
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
242 self.current.set(path, fctx.data(), 'x' in flags, 'l' in flags)
582
44c56a7727c4 editor: fix issamefile() and copy detection in replay mode
Patrick Mezard <pmezard@gmail.com>
parents: 545
diff changeset
243 if from_branch == branch:
44c56a7727c4 editor: fix issamefile() and copy detection in replay mode
Patrick Mezard <pmezard@gmail.com>
parents: 545
diff changeset
244 parentid = self.meta.get_parent_revision(
44c56a7727c4 editor: fix issamefile() and copy detection in replay mode
Patrick Mezard <pmezard@gmail.com>
parents: 545
diff changeset
245 self.current.rev.revnum, branch)
44c56a7727c4 editor: fix issamefile() and copy detection in replay mode
Patrick Mezard <pmezard@gmail.com>
parents: 545
diff changeset
246 if parentid != revlog.nullid:
44c56a7727c4 editor: fix issamefile() and copy detection in replay mode
Patrick Mezard <pmezard@gmail.com>
parents: 545
diff changeset
247 parentctx = self.repo.changectx(parentid)
44c56a7727c4 editor: fix issamefile() and copy detection in replay mode
Patrick Mezard <pmezard@gmail.com>
parents: 545
diff changeset
248 if util.issamefile(parentctx, ctx, from_file):
44c56a7727c4 editor: fix issamefile() and copy detection in replay mode
Patrick Mezard <pmezard@gmail.com>
parents: 545
diff changeset
249 self.current.copies[path] = from_file
937
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
250 return self._addfilebaton(path)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
251
673
32089d080ff8 editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 633
diff changeset
252 @svnwrap.ieditor
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
253 def add_directory(self, path, parent_baton, copyfrom_path,
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
254 copyfrom_revision, dir_pool=None):
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
255 self.current.batons[path] = path
420
59e19c73b0df svnmeta: eliminate unneeded path_and_branch_for_path() method
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 418
diff changeset
256 br_path, branch = self.meta.split_branch_path(path)[:2]
116
30580c05dccc hg_delta_editor: merge _is_path_valid() and _path_and_branch_from_path()
Patrick Mezard <pmezard@gmail.com>
parents: 111
diff changeset
257 if br_path is not None:
30580c05dccc hg_delta_editor: merge _is_path_valid() and _path_and_branch_from_path()
Patrick Mezard <pmezard@gmail.com>
parents: 111
diff changeset
258 if not copyfrom_path and not br_path:
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
259 self.current.emptybranches[branch] = True
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
260 else:
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
261 self.current.emptybranches[branch] = False
116
30580c05dccc hg_delta_editor: merge _is_path_valid() and _path_and_branch_from_path()
Patrick Mezard <pmezard@gmail.com>
parents: 111
diff changeset
262 if br_path is None or not copyfrom_path:
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
263 return path
521
839734dfb5c7 Handle tag subdirectory as tag in replay mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents: 518
diff changeset
264 if self.meta.get_path_tag(path):
839734dfb5c7 Handle tag subdirectory as tag in replay mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents: 518
diff changeset
265 del self.current.emptybranches[branch]
839734dfb5c7 Handle tag subdirectory as tag in replay mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents: 518
diff changeset
266 return path
518
e37738d95b27 editor: remove useless test
Patrick Mezard <pmezard@gmail.com>
parents: 517
diff changeset
267 tag = self.meta.get_path_tag(copyfrom_path)
e37738d95b27 editor: remove useless test
Patrick Mezard <pmezard@gmail.com>
parents: 517
diff changeset
268 if tag not in self.meta.tags:
e37738d95b27 editor: remove useless test
Patrick Mezard <pmezard@gmail.com>
parents: 517
diff changeset
269 tag = None
e37738d95b27 editor: remove useless test
Patrick Mezard <pmezard@gmail.com>
parents: 517
diff changeset
270 if not self.meta.is_path_valid(copyfrom_path):
e37738d95b27 editor: remove useless test
Patrick Mezard <pmezard@gmail.com>
parents: 517
diff changeset
271 self.current.missing.add('%s/' % path)
e37738d95b27 editor: remove useless test
Patrick Mezard <pmezard@gmail.com>
parents: 517
diff changeset
272 return path
59
430af23bef4a Performance fix for branches-from-tags in real replay, which is tied up with
Augie Fackler <durin42@gmail.com>
parents: 55
diff changeset
273 if tag:
534
e38f110e7088 svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents: 528
diff changeset
274 changeid = self.meta.tags[tag]
e38f110e7088 svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents: 528
diff changeset
275 source_rev, source_branch = self.meta.get_source_rev(changeid)[:2]
790
3173f418079c editor: rename add_directory() cp_f* variable into from*
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
276 frompath = ''
59
430af23bef4a Performance fix for branches-from-tags in real replay, which is tied up with
Augie Fackler <durin42@gmail.com>
parents: 55
diff changeset
277 else:
430af23bef4a Performance fix for branches-from-tags in real replay, which is tied up with
Augie Fackler <durin42@gmail.com>
parents: 55
diff changeset
278 source_rev = copyfrom_revision
790
3173f418079c editor: rename add_directory() cp_f* variable into from*
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
279 frompath, source_branch = self.meta.split_branch_path(copyfrom_path)[:2]
3173f418079c editor: rename add_directory() cp_f* variable into from*
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
280 if frompath == '' and br_path == '':
217
6eb691a163cd hg_delta_editor: stop using foobaz as a bogus filename.
Augie Fackler <durin42@gmail.com>
parents: 214
diff changeset
281 assert br_path is not None
414
343da842dbe6 split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 413
diff changeset
282 tmp = source_branch, source_rev, self.current.rev.revnum
343da842dbe6 split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 413
diff changeset
283 self.meta.branches[branch] = tmp
587
c06f59441f8e editor: fix replaced directory copies
Patrick Mezard <pmezard@gmail.com>
parents: 586
diff changeset
284 new_hash = self.meta.get_parent_revision(source_rev + 1, source_branch, True)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
285 if new_hash == node.nullid:
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
286 self.current.missing.add('%s/' % path)
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
287 return path
790
3173f418079c editor: rename add_directory() cp_f* variable into from*
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
288 fromctx = self.repo.changectx(new_hash)
3173f418079c editor: rename add_directory() cp_f* variable into from*
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
289 if frompath != '/' and frompath != '':
3173f418079c editor: rename add_directory() cp_f* variable into from*
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
290 frompath = '%s/' % frompath
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
291 else:
790
3173f418079c editor: rename add_directory() cp_f* variable into from*
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
292 frompath = ''
938
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
293 svncopies = {}
69
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
294 copies = {}
790
3173f418079c editor: rename add_directory() cp_f* variable into from*
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
295 for f in fromctx:
3173f418079c editor: rename add_directory() cp_f* variable into from*
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
296 if not f.startswith(frompath):
69
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
297 continue
790
3173f418079c editor: rename add_directory() cp_f* variable into from*
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
298 fctx = fromctx.filectx(f)
791
05ee7d5351de editor: simplify add_directory() a bit more
Patrick Mezard <pmezard@gmail.com>
parents: 790
diff changeset
299 dest = path + '/' + f[len(frompath):]
938
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
300 flags = fctx.flags()
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
301 islink = 'l' in flags
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
302 data = fctx.data()
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
303 if islink:
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
304 data = 'link ' + data
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
305 svncopies[dest] = (data, 'x' in flags, islink, None)
791
05ee7d5351de editor: simplify add_directory() a bit more
Patrick Mezard <pmezard@gmail.com>
parents: 790
diff changeset
306 if dest in self.current.deleted:
938
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
307 # Remove this once svn copies and edited files are
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
308 # clearly separated.
791
05ee7d5351de editor: simplify add_directory() a bit more
Patrick Mezard <pmezard@gmail.com>
parents: 790
diff changeset
309 del self.current.deleted[dest]
69
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
310 if branch == source_branch:
791
05ee7d5351de editor: simplify add_directory() a bit more
Patrick Mezard <pmezard@gmail.com>
parents: 790
diff changeset
311 copies[dest] = f
69
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
312 if copies:
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
313 # Preserve the directory copy records if no file was changed between
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
314 # the source and destination revisions, or discard it completely.
938
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
315 parentid = self.meta.get_parent_revision(
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
316 self.current.rev.revnum, branch)
69
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
317 if parentid != revlog.nullid:
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
318 parentctx = self.repo.changectx(parentid)
496
5e0dfe59d4c3 copies: fix under-reporting of copies in hg
Augie Fackler <durin42@gmail.com>
parents: 448
diff changeset
319 for k, v in copies.iteritems():
790
3173f418079c editor: rename add_directory() cp_f* variable into from*
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
320 if util.issamefile(parentctx, fromctx, v):
938
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
321 data, isexec, islink = svncopies[k][:-1]
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
322 svncopies[k] = (data, isexec, islink, v)
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
323 self._svncopies.update(svncopies)
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
324
792
ba65c0b01d4f replay: copy copied directories externals
Patrick Mezard <pmezard@gmail.com>
parents: 791
diff changeset
325 # Copy the externals definitions of copied directories
ba65c0b01d4f replay: copy copied directories externals
Patrick Mezard <pmezard@gmail.com>
parents: 791
diff changeset
326 fromext = svnexternals.parse(self.ui, fromctx)
ba65c0b01d4f replay: copy copied directories externals
Patrick Mezard <pmezard@gmail.com>
parents: 791
diff changeset
327 for p, v in fromext.iteritems():
ba65c0b01d4f replay: copy copied directories externals
Patrick Mezard <pmezard@gmail.com>
parents: 791
diff changeset
328 pp = p and (p + '/') or ''
ba65c0b01d4f replay: copy copied directories externals
Patrick Mezard <pmezard@gmail.com>
parents: 791
diff changeset
329 if pp.startswith(frompath):
ba65c0b01d4f replay: copy copied directories externals
Patrick Mezard <pmezard@gmail.com>
parents: 791
diff changeset
330 dest = (path + '/' + pp[len(frompath):]).rstrip('/')
ba65c0b01d4f replay: copy copied directories externals
Patrick Mezard <pmezard@gmail.com>
parents: 791
diff changeset
331 self.current.externals[dest] = v
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
332 return path
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
333
673
32089d080ff8 editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 633
diff changeset
334 @svnwrap.ieditor
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
335 def change_file_prop(self, file_baton, name, value, pool=None):
937
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
336 if file_baton is None:
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
337 return
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
338 path = self._filebatons[file_baton]
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
339 if name == 'svn:executable':
937
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
340 self.current.execfiles[path] = bool(value is not None)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
341 elif name == 'svn:special':
937
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
342 self.current.symlinks[path] = bool(value is not None)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
343
673
32089d080ff8 editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 633
diff changeset
344 @svnwrap.ieditor
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
345 def change_dir_prop(self, dir_baton, name, value, pool=None):
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
346 if dir_baton is None:
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
347 return
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
348 path = self.current.batons[dir_baton]
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
349 if name == 'svn:externals':
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
350 self.current.externals[path] = value
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
351
935
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 934
diff changeset
352 @svnwrap.ieditor
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 934
diff changeset
353 def open_root(self, edit_baton, base_revision, dir_pool=None):
937
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
354 # We should not have to reset these, unfortunately the editor is
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
355 # reused for different revisions.
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
356 self._clear()
935
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 934
diff changeset
357 return None
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 934
diff changeset
358
673
32089d080ff8 editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 633
diff changeset
359 @svnwrap.ieditor
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
360 def open_directory(self, path, parent_baton, base_revision, dir_pool=None):
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
361 self.current.batons[path] = path
420
59e19c73b0df svnmeta: eliminate unneeded path_and_branch_for_path() method
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 418
diff changeset
362 p_, branch = self.meta.split_branch_path(path)[:2]
499
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 498
diff changeset
363 if p_ == '' or (self.meta.layout == 'single' and p_):
540
8dc759dc9ca9 svnmeta: remove split_branch_tag() exacttag argument
Patrick Mezard <pmezard@gmail.com>
parents: 534
diff changeset
364 if not self.meta.get_path_tag(path):
8dc759dc9ca9 svnmeta: remove split_branch_tag() exacttag argument
Patrick Mezard <pmezard@gmail.com>
parents: 534
diff changeset
365 self.current.emptybranches[branch] = False
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
366 return path
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
367
673
32089d080ff8 editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 633
diff changeset
368 @svnwrap.ieditor
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
369 def close_directory(self, dir_baton, dir_pool=None):
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
370 if dir_baton is not None:
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
371 del self.current.batons[dir_baton]
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
372
673
32089d080ff8 editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 633
diff changeset
373 @svnwrap.ieditor
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
374 def apply_textdelta(self, file_baton, base_checksum, pool=None):
211
05243ec295e1 fetch: Fix a bug that caused plaintexts to be interpreted as missing more often than they should be.
Augie Fackler <durin42@gmail.com>
parents: 207
diff changeset
375 # We know coming in here the file must be one of the following options:
05243ec295e1 fetch: Fix a bug that caused plaintexts to be interpreted as missing more often than they should be.
Augie Fackler <durin42@gmail.com>
parents: 207
diff changeset
376 # 1) Deleted (invalid, fail an assertion)
05243ec295e1 fetch: Fix a bug that caused plaintexts to be interpreted as missing more often than they should be.
Augie Fackler <durin42@gmail.com>
parents: 207
diff changeset
377 # 2) Missing a base text (bail quick since we have to fetch a full plaintext)
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
378 # 3) Has a base text in self.current.files, apply deltas
937
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
379 path = self._filebatons.get(file_baton)
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
380 if path is None or not self.meta.is_path_valid(path):
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
381 return lambda x: None
633
37b2adc64fb3 editor: convert two assertions in apply_textdelta() into raising an IOError
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 601
diff changeset
382
937
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
383 base = ''
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
384 if path in self.current.deleted:
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
385 msg = ('cannot apply textdelta to %s: file is deleted' % path)
633
37b2adc64fb3 editor: convert two assertions in apply_textdelta() into raising an IOError
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 601
diff changeset
386 raise IOError(errno.ENOENT, msg)
37b2adc64fb3 editor: convert two assertions in apply_textdelta() into raising an IOError
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 601
diff changeset
387
937
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
388 if (path not in self.current.files and
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
389 path not in self.current.missing):
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
390 msg = ('cannot apply textdelta to %s: file not found' % path)
633
37b2adc64fb3 editor: convert two assertions in apply_textdelta() into raising an IOError
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 601
diff changeset
391 raise IOError(errno.ENOENT, msg)
37b2adc64fb3 editor: convert two assertions in apply_textdelta() into raising an IOError
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 601
diff changeset
392
937
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
393 if path in self.current.missing:
211
05243ec295e1 fetch: Fix a bug that caused plaintexts to be interpreted as missing more often than they should be.
Augie Fackler <durin42@gmail.com>
parents: 207
diff changeset
394 return lambda x: None
937
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
395 base = self.current.files[path]
862
6ef6c413d6de editor: work around svn 1.7 closing the output fp in apply_textdelta()
Patrick Mezard <patrick@mezard.eu>
parents: 843
diff changeset
396 target = NeverClosingStringIO()
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
397 self.stream = target
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
398
601
0fe490ce2fbb isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 591
diff changeset
399 handler = svnwrap.apply_txdelta(base, target)
837
805ef27fbcbe hgsubversion/*.py: add space after comment symbol #
Yonggang Luo <luoyonggang@gmail.com>
parents: 832
diff changeset
400 if not callable(handler): # pragma: no cover
250
79349fd04836 utils: standardizing imported name to hgutil, our_util to util
Daniel Tang <dytang@cs.purdue.edu>
parents: 237
diff changeset
401 raise hgutil.Abort('Error in Subversion bindings: '
79349fd04836 utils: standardizing imported name to hgutil, our_util to util
Daniel Tang <dytang@cs.purdue.edu>
parents: 237
diff changeset
402 'cannot call handler!')
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
403 def txdelt_window(window):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
404 try:
937
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
405 if not self.meta.is_path_valid(path):
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
406 return
932
dfb3afa6c619 stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents: 901
diff changeset
407 try:
dfb3afa6c619 stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents: 901
diff changeset
408 handler(window)
dfb3afa6c619 stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents: 901
diff changeset
409 except AssertionError, e: # pragma: no cover
dfb3afa6c619 stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents: 901
diff changeset
410 # Enhance the exception message
dfb3afa6c619 stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents: 901
diff changeset
411 msg, others = e.args[0], e.args[1:]
dfb3afa6c619 stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents: 901
diff changeset
412
dfb3afa6c619 stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents: 901
diff changeset
413 if msg:
dfb3afa6c619 stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents: 901
diff changeset
414 msg += '\n'
dfb3afa6c619 stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents: 901
diff changeset
415
dfb3afa6c619 stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents: 901
diff changeset
416 msg += _TXDELT_WINDOW_HANDLER_FAILURE_MSG
dfb3afa6c619 stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents: 901
diff changeset
417 e.args = (msg,) + others
dfb3afa6c619 stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents: 901
diff changeset
418 raise e
dfb3afa6c619 stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents: 901
diff changeset
419
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
420 # window being None means commit this file
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
421 if not window:
937
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
422 self.current.files[path] = target.getvalue()
837
805ef27fbcbe hgsubversion/*.py: add space after comment symbol #
Yonggang Luo <luoyonggang@gmail.com>
parents: 832
diff changeset
423 except svnwrap.SubversionException, e: # pragma: no cover
601
0fe490ce2fbb isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 591
diff changeset
424 if e.args[1] == svnwrap.ERR_INCOMPLETE_DATA:
937
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
425 self.current.missing.add(path)
837
805ef27fbcbe hgsubversion/*.py: add space after comment symbol #
Yonggang Luo <luoyonggang@gmail.com>
parents: 832
diff changeset
426 else: # pragma: no cover
250
79349fd04836 utils: standardizing imported name to hgutil, our_util to util
Daniel Tang <dytang@cs.purdue.edu>
parents: 237
diff changeset
427 raise hgutil.Abort(*e.args)
837
805ef27fbcbe hgsubversion/*.py: add space after comment symbol #
Yonggang Luo <luoyonggang@gmail.com>
parents: 832
diff changeset
428 except: # pragma: no cover
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
429 self._exception_info = sys.exc_info()
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
430 raise
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
431 return txdelt_window
932
dfb3afa6c619 stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents: 901
diff changeset
432
938
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
433 def close(self):
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
434 for c in self._svncopies.iteritems():
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
435 dest, (data, isexec, islink, copied) = c
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
436 self.current.set(dest, data, isexec, islink)
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
437 self.current.copies[dest] = copied
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
438 self._svncopies.clear()
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
439
932
dfb3afa6c619 stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents: 901
diff changeset
440 _TXDELT_WINDOW_HANDLER_FAILURE_MSG = (
dfb3afa6c619 stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents: 901
diff changeset
441 "Your SVN repository may not be supplying correct replay deltas."
dfb3afa6c619 stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents: 901
diff changeset
442 " It is strongly"
dfb3afa6c619 stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents: 901
diff changeset
443 "\nadvised that you repull the entire SVN repository using"
dfb3afa6c619 stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents: 901
diff changeset
444 " hg pull --stupid."
dfb3afa6c619 stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents: 901
diff changeset
445 "\nAlternatively, re-pull just this revision using --stupid and verify"
dfb3afa6c619 stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents: 901
diff changeset
446 " that the"
dfb3afa6c619 stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents: 901
diff changeset
447 "\nchangeset is correct."
dfb3afa6c619 stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents: 901
diff changeset
448 )