annotate hgsubversion/editor.py @ 957:397af94ce98c

editor: improve debug information when fetching files in replay
author Patrick Mezard <patrick@mezard.eu>
date Sun, 14 Oct 2012 12:35:13 +0100
parents 9c3b4f59e7e6
children 506dcb241cef
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 sys
943
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
3 import tempfile
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
4 import shutil
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
5 import os
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
6
250
79349fd04836 utils: standardizing imported name to hgutil, our_util to util
Daniel Tang <dytang@cs.purdue.edu>
parents: 237
diff changeset
7 from mercurial import util as hgutil
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
8 from mercurial import revlog
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
9 from mercurial import node
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
10
601
0fe490ce2fbb isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 591
diff changeset
11 import svnwrap
250
79349fd04836 utils: standardizing imported name to hgutil, our_util to util
Daniel Tang <dytang@cs.purdue.edu>
parents: 237
diff changeset
12 import util
792
ba65c0b01d4f replay: copy copied directories externals
Patrick Mezard <pmezard@gmail.com>
parents: 791
diff changeset
13 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
14
945
bfbfc9be3faa editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
15 class EditingError(Exception):
bfbfc9be3faa editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
16 pass
bfbfc9be3faa editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
17
943
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
18 class FileStore(object):
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
19 def __init__(self, maxsize=None):
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
20 self._tempdir = None
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
21 self._files = {}
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
22 self._created = 0
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
23 self._maxsize = maxsize
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
24 if self._maxsize is None:
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
25 self._maxsize = 100*(2**20)
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
26 self._size = 0
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
27 self._data = {}
945
bfbfc9be3faa editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
28 self._popped = set()
943
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
29
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
30 def setfile(self, fname, data):
945
bfbfc9be3faa editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
31 if fname in self._popped:
bfbfc9be3faa editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
32 raise EditingError('trying to set a popped file %s' % fname)
bfbfc9be3faa editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
33
943
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
34 if self._maxsize < 0 or (len(data) + self._size) <= self._maxsize:
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
35 self._data[fname] = data
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
36 self._size += len(data)
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
37 else:
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
38 if self._tempdir is None:
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
39 self._tempdir = tempfile.mkdtemp(prefix='hg-subversion-')
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
40 # Avoid filename issues with these simple names
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
41 fn = str(self._created)
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
42 fp = hgutil.posixfile(os.path.join(self._tempdir, fn), 'wb')
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
43 try:
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
44 fp.write(data)
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
45 finally:
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
46 fp.close()
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
47 self._created += 1
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
48 self._files[fname] = fn
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
49
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
50 def delfile(self, fname):
945
bfbfc9be3faa editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
51 if fname in self._popped:
bfbfc9be3faa editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
52 raise EditingError('trying to delete a popped file %s' % fname)
bfbfc9be3faa editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
53
943
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
54 if fname in self._data:
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
55 del self._data[fname]
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
56 elif fname in self._files:
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
57 path = os.path.join(self._tempdir, self._files.pop(fname))
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
58 os.unlink(path)
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
59
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
60 def getfile(self, fname):
945
bfbfc9be3faa editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
61 if fname in self._popped:
bfbfc9be3faa editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
62 raise EditingError('trying to get a popped file %s' % fname)
bfbfc9be3faa editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
63
943
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
64 if fname in self._data:
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
65 return self._data[fname]
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
66 if self._tempdir is None or fname not in self._files:
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
67 raise IOError
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
68 path = os.path.join(self._tempdir, self._files[fname])
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
69 fp = hgutil.posixfile(path, 'rb')
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
70 try:
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
71 return fp.read()
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
72 finally:
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
73 fp.close()
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
74
945
bfbfc9be3faa editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
75 def popfile(self, fname):
bfbfc9be3faa editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
76 self.delfile(fname)
bfbfc9be3faa editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
77 self._popped.add(fname)
bfbfc9be3faa editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
78
943
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
79 def files(self):
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
80 return list(self._files) + list(self._data)
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
81
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
82 def close(self):
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
83 if self._tempdir is not None:
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
84 tempdir, self._tempdir = self._tempdir, None
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
85 shutil.rmtree(tempdir)
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
86 self._files = None
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
87 self._data = None
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
88
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
89 class RevisionData(object):
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
90
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
91 __slots__ = [
943
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
92 'file', 'added', '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
93 'copies', 'missing', 'emptybranches', 'base', 'externals', 'ui',
949
297e2b4a6e2c editor: add addmissing() and test config to make it fail
Patrick Mezard <patrick@mezard.eu>
parents: 948
diff changeset
94 'exception', 'store', '_failonmissing',
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
95 ]
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
96
433
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
97 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
98 self.ui = ui
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
99 self.clear()
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
100
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
101 def clear(self):
944
d6db289f1548 pull: add hgsubversion.filestoresize to control memory consumption
Patrick Mezard <patrick@mezard.eu>
parents: 943
diff changeset
102 self.store = FileStore(util.getfilestoresize(self.ui))
901
bd12a4da0f35 replay: workaround svn not telling us about x/l flags (issue346)
Bryan O'Sullivan <bryano@fb.com>
parents: 891
diff changeset
103 self.added = set()
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
104 self.deleted = {}
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
105 self.rev = None
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
106 self.execfiles = {}
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
107 self.symlinks = {}
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
108 self.batons = {}
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
109 # 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
110 self.copies = {}
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
111 self.missing = set()
949
297e2b4a6e2c editor: add addmissing() and test config to make it fail
Patrick Mezard <patrick@mezard.eu>
parents: 948
diff changeset
112 # Used in tests and debugging
297e2b4a6e2c editor: add addmissing() and test config to make it fail
Patrick Mezard <patrick@mezard.eu>
parents: 948
diff changeset
113 self._failonmissing = self.ui.config(
297e2b4a6e2c editor: add addmissing() and test config to make it fail
Patrick Mezard <patrick@mezard.eu>
parents: 948
diff changeset
114 'hgsubversion', 'failonmissing', False)
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
115 self.emptybranches = {}
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
116 self.externals = {}
434
3e2259fe3c93 editor: move exception data into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 433
diff changeset
117 self.exception = None
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
118
942
4d9e80f6ba43 editor: do not touch RevisionData copies from the editor
Patrick Mezard <patrick@mezard.eu>
parents: 941
diff changeset
119 def set(self, path, data, isexec=False, islink=False, copypath=None):
943
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
120 self.store.setfile(path, data)
433
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
121 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
122 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
123 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
124 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
125 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
126 self.missing.remove(path)
942
4d9e80f6ba43 editor: do not touch RevisionData copies from the editor
Patrick Mezard <patrick@mezard.eu>
parents: 941
diff changeset
127 if copypath is not None:
4d9e80f6ba43 editor: do not touch RevisionData copies from the editor
Patrick Mezard <patrick@mezard.eu>
parents: 941
diff changeset
128 self.copies[path] = copypath
433
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
129
943
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
130 def get(self, path):
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
131 if path in self.deleted:
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
132 raise IOError(errno.ENOENT, '%s is deleted' % path)
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
133 data = self.store.getfile(path)
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
134 isexec = self.execfiles.get(path)
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
135 islink = self.symlinks.get(path)
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
136 copied = self.copies.get(path)
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
137 return data, isexec, islink, copied
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
138
945
bfbfc9be3faa editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
139 def pop(self, path):
bfbfc9be3faa editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
140 ret = self.get(path)
bfbfc9be3faa editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
141 self.store.popfile(path)
bfbfc9be3faa editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
142 return ret
bfbfc9be3faa editor: add a pop() method to RevisionMeta to reduce resource usage
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
143
433
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
144 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
145 self.deleted[path] = True
943
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
146 self.store.delfile(path)
433
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
147 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
148 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
149 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
150
943
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
151 def files(self):
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
152 """Return a sorted list of changed files."""
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
153 files = set(self.store.files())
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
154 for g in (self.symlinks, self.execfiles, self.deleted):
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
155 files.update(g)
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
156 return sorted(files)
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
157
949
297e2b4a6e2c editor: add addmissing() and test config to make it fail
Patrick Mezard <patrick@mezard.eu>
parents: 948
diff changeset
158 def addmissing(self, path):
297e2b4a6e2c editor: add addmissing() and test config to make it fail
Patrick Mezard <patrick@mezard.eu>
parents: 948
diff changeset
159 if self._failonmissing:
297e2b4a6e2c editor: add addmissing() and test config to make it fail
Patrick Mezard <patrick@mezard.eu>
parents: 948
diff changeset
160 raise EditingError('missing entry: %s' % path)
297e2b4a6e2c editor: add addmissing() and test config to make it fail
Patrick Mezard <patrick@mezard.eu>
parents: 948
diff changeset
161 self.missing.add(path)
297e2b4a6e2c editor: add addmissing() and test config to make it fail
Patrick Mezard <patrick@mezard.eu>
parents: 948
diff changeset
162
436
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
163 def findmissing(self, svn):
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
164
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
165 if not self.missing:
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
166 return
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
167
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
168 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
169 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
170 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
171 r = self.rev.revnum
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
172
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
173 files = set()
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
174 for p in self.missing:
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
175 self.ui.note('.')
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
176 self.ui.flush()
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
177 if p[-1] == '/':
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
178 dir = p[len(root):]
499
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 498
diff changeset
179 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
180 files.update(new)
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
181 else:
591
4359ddd73b00 strip off root file name only once for missing files
Gerhard Weis <gweis@gmx.at>
parents: 587
diff changeset
182 files.add(p)
436
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
183
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
184 i = 1
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
185 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
186 for p in files:
957
397af94ce98c editor: improve debug information when fetching files in replay
Patrick Mezard <patrick@mezard.eu>
parents: 952
diff changeset
187 if self.ui.debugflag:
397af94ce98c editor: improve debug information when fetching files in replay
Patrick Mezard <patrick@mezard.eu>
parents: 952
diff changeset
188 self.ui.debug('fetching %s\n' % p)
397af94ce98c editor: improve debug information when fetching files in replay
Patrick Mezard <patrick@mezard.eu>
parents: 952
diff changeset
189 else:
397af94ce98c editor: improve debug information when fetching files in replay
Patrick Mezard <patrick@mezard.eu>
parents: 952
diff changeset
190 self.ui.note('.')
436
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
191 self.ui.flush()
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
192 if i % 50 == 0:
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
193 svn.init_ra_and_client()
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
194 i += 1
499
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 498
diff changeset
195 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
196 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
197
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
198 self.missing = set()
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
199 self.ui.note('\n')
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
200
943
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
201 def close(self):
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
202 self.store.close()
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 942
diff changeset
203
940
34a1217b8218 editor: resolve files copied by directory copy on-demand
Patrick Mezard <patrick@mezard.eu>
parents: 939
diff changeset
204 class CopiedFile(object):
34a1217b8218 editor: resolve files copied by directory copy on-demand
Patrick Mezard <patrick@mezard.eu>
parents: 939
diff changeset
205 def __init__(self, node, path, copypath):
34a1217b8218 editor: resolve files copied by directory copy on-demand
Patrick Mezard <patrick@mezard.eu>
parents: 939
diff changeset
206 self.node = node
34a1217b8218 editor: resolve files copied by directory copy on-demand
Patrick Mezard <patrick@mezard.eu>
parents: 939
diff changeset
207 self.path = path
34a1217b8218 editor: resolve files copied by directory copy on-demand
Patrick Mezard <patrick@mezard.eu>
parents: 939
diff changeset
208 self.copypath = copypath
34a1217b8218 editor: resolve files copied by directory copy on-demand
Patrick Mezard <patrick@mezard.eu>
parents: 939
diff changeset
209
951
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 950
diff changeset
210 def resolve(self, getctxfn, ctx=None):
940
34a1217b8218 editor: resolve files copied by directory copy on-demand
Patrick Mezard <patrick@mezard.eu>
parents: 939
diff changeset
211 if ctx is None:
951
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 950
diff changeset
212 ctx = getctxfn(self.node)
940
34a1217b8218 editor: resolve files copied by directory copy on-demand
Patrick Mezard <patrick@mezard.eu>
parents: 939
diff changeset
213 fctx = ctx[self.path]
34a1217b8218 editor: resolve files copied by directory copy on-demand
Patrick Mezard <patrick@mezard.eu>
parents: 939
diff changeset
214 data = fctx.data()
34a1217b8218 editor: resolve files copied by directory copy on-demand
Patrick Mezard <patrick@mezard.eu>
parents: 939
diff changeset
215 flags = fctx.flags()
34a1217b8218 editor: resolve files copied by directory copy on-demand
Patrick Mezard <patrick@mezard.eu>
parents: 939
diff changeset
216 islink = 'l' in flags
34a1217b8218 editor: resolve files copied by directory copy on-demand
Patrick Mezard <patrick@mezard.eu>
parents: 939
diff changeset
217 if islink:
34a1217b8218 editor: resolve files copied by directory copy on-demand
Patrick Mezard <patrick@mezard.eu>
parents: 939
diff changeset
218 data = 'link ' + data
34a1217b8218 editor: resolve files copied by directory copy on-demand
Patrick Mezard <patrick@mezard.eu>
parents: 939
diff changeset
219 return data, 'x' in flags, islink, self.copypath
34a1217b8218 editor: resolve files copied by directory copy on-demand
Patrick Mezard <patrick@mezard.eu>
parents: 939
diff changeset
220
601
0fe490ce2fbb isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 591
diff changeset
221 class HgEditor(svnwrap.Editor):
33
a9c15cae50e5 Faster append-only revmap implementation.
Andreas Hartmetz <ahartmetz@gmail.com>
parents: 23
diff changeset
222
416
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
223 def __init__(self, meta):
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
224 self.meta = meta
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
225 self.ui = meta.ui
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
226 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
227 self.current = RevisionData(meta.ui)
937
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
228 self._clear()
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
229
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
230 def _clear(self):
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
231 self._filecounter = 0
940
34a1217b8218 editor: resolve files copied by directory copy on-demand
Patrick Mezard <patrick@mezard.eu>
parents: 939
diff changeset
232 # A mapping of svn paths to CopiedFile entries
938
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
233 self._svncopies = {}
939
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
234 # A mapping of batons to (path, data, isexec, islink, copypath) tuples
948
e2090fabc1a9 editor: use SimpleStringIO in apply_text()
Patrick Mezard <patrick@mezard.eu>
parents: 947
diff changeset
235 # data is a SimpleStringIO if the file was edited, a string
e2090fabc1a9 editor: use SimpleStringIO in apply_text()
Patrick Mezard <patrick@mezard.eu>
parents: 947
diff changeset
236 # otherwise.
939
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
237 self._openfiles = {}
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
238 # A mapping of file paths to batons
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
239 self._openpaths = {}
941
febca88dd261 editor: handle deleted files in editor
Patrick Mezard <patrick@mezard.eu>
parents: 940
diff changeset
240 self._deleted = set()
951
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 950
diff changeset
241 self._getctx = util.lrucachefunc(self.repo.changectx, 3)
939
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
242
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
243 def _openfile(self, path, data, isexec, islink, copypath, create=False):
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
244 if path in self._openpaths:
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
245 raise EditingError('trying to open an already opened file %s'
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
246 % path)
941
febca88dd261 editor: handle deleted files in editor
Patrick Mezard <patrick@mezard.eu>
parents: 940
diff changeset
247 if not create and path in self._deleted:
939
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
248 raise EditingError('trying to open a deleted file %s' % path)
941
febca88dd261 editor: handle deleted files in editor
Patrick Mezard <patrick@mezard.eu>
parents: 940
diff changeset
249 if path in self._deleted:
febca88dd261 editor: handle deleted files in editor
Patrick Mezard <patrick@mezard.eu>
parents: 940
diff changeset
250 self._deleted.remove(path)
937
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
251 self._filecounter += 1
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
252 baton = '%d-%s' % (self._filecounter, path)
939
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
253 self._openfiles[baton] = (path, data, isexec, islink, copypath)
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
254 self._openpaths[path] = baton
937
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
255 return baton
413
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
256
941
febca88dd261 editor: handle deleted files in editor
Patrick Mezard <patrick@mezard.eu>
parents: 940
diff changeset
257 def _deletefile(self, path):
febca88dd261 editor: handle deleted files in editor
Patrick Mezard <patrick@mezard.eu>
parents: 940
diff changeset
258 self._deleted.add(path)
febca88dd261 editor: handle deleted files in editor
Patrick Mezard <patrick@mezard.eu>
parents: 940
diff changeset
259 if path in self._svncopies:
febca88dd261 editor: handle deleted files in editor
Patrick Mezard <patrick@mezard.eu>
parents: 940
diff changeset
260 del self._svncopies[path]
febca88dd261 editor: handle deleted files in editor
Patrick Mezard <patrick@mezard.eu>
parents: 940
diff changeset
261
673
32089d080ff8 editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 633
diff changeset
262 @svnwrap.ieditor
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
263 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
264 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
265 if br_path == '':
540
8dc759dc9ca9 svnmeta: remove split_branch_tag() exacttag argument
Patrick Mezard <pmezard@gmail.com>
parents: 534
diff changeset
266 if self.meta.get_path_tag(path):
8dc759dc9ca9 svnmeta: remove split_branch_tag() exacttag argument
Patrick Mezard <pmezard@gmail.com>
parents: 534
diff changeset
267 # 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
268 return
414
343da842dbe6 split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 413
diff changeset
269 self.meta.closebranches.add(branch)
938
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
270
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
271 # 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
272 # parent revision.
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
273 if path in self._svncopies:
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
274 del self._svncopies[path]
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
275 prefix = path + '/'
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
276 for f in list(self._svncopies):
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
277 if f.startswith(prefix):
941
febca88dd261 editor: handle deleted files in editor
Patrick Mezard <patrick@mezard.eu>
parents: 940
diff changeset
278 self._deletefile(f)
938
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
279
116
30580c05dccc hg_delta_editor: merge _is_path_valid() and _path_and_branch_from_path()
Patrick Mezard <pmezard@gmail.com>
parents: 111
diff changeset
280 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
281 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
282 if ha == revlog.nullid:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
283 return
951
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 950
diff changeset
284 ctx = self._getctx(ha)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
285 if br_path not in ctx:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
286 br_path2 = ''
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
287 if br_path != '':
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
288 br_path2 = br_path + '/'
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
289 # 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
290 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
291 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
292 f_p = '%s/%s' % (path, f[len(br_path2):])
941
febca88dd261 editor: handle deleted files in editor
Patrick Mezard <patrick@mezard.eu>
parents: 940
diff changeset
293 self._deletefile(f_p)
febca88dd261 editor: handle deleted files in editor
Patrick Mezard <patrick@mezard.eu>
parents: 940
diff changeset
294 self._deletefile(path)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
295
673
32089d080ff8 editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 633
diff changeset
296 @svnwrap.ieditor
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
297 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
298 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
299 if not fpath:
322
05cd4a5138bf Move some .warn() calls to noisy levels instead.
Augie Fackler <durin42@gmail.com>
parents: 321
diff changeset
300 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
301 return None
378
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
302
937
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
303 self.ui.note('M %s\n' % path)
378
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
304
938
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
305 if path in self._svncopies:
940
34a1217b8218 editor: resolve files copied by directory copy on-demand
Patrick Mezard <patrick@mezard.eu>
parents: 939
diff changeset
306 copy = self._svncopies.pop(path)
951
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 950
diff changeset
307 base, isexec, islink, copypath = copy.resolve(self._getctx)
939
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
308 return self._openfile(path, base, isexec, islink, copypath)
938
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
309
586
704d2ce1d906 editor: fix open_file() on replaced branch
Patrick Mezard <pmezard@gmail.com>
parents: 585
diff changeset
310 if not self.meta.is_path_valid(path):
937
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
311 return None
586
704d2ce1d906 editor: fix open_file() on replaced branch
Patrick Mezard <pmezard@gmail.com>
parents: 585
diff changeset
312
378
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
313 baserev = base_revision
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
314 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
315 baserev = self.current.rev.revnum - 1
586
704d2ce1d906 editor: fix open_file() on replaced branch
Patrick Mezard <pmezard@gmail.com>
parents: 585
diff changeset
316 # 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
317 # 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
318 # agains replaced branch.
704d2ce1d906 editor: fix open_file() on replaced branch
Patrick Mezard <pmezard@gmail.com>
parents: 585
diff changeset
319 parent = self.meta.get_parent_revision(baserev + 1, branch, True)
951
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 950
diff changeset
320 ctx = self._getctx(parent)
378
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
321 if fpath not in ctx:
949
297e2b4a6e2c editor: add addmissing() and test config to make it fail
Patrick Mezard <patrick@mezard.eu>
parents: 948
diff changeset
322 self.current.addmissing(path)
937
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
323 return None
378
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
324
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
325 fctx = ctx.filectx(fpath)
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
326 base = fctx.data()
939
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
327 flags = fctx.flags()
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
328 if 'l' in flags:
378
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
329 base = 'link ' + base
939
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
330 return self._openfile(path, base, 'x' in flags, 'l' in flags, None)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
331
673
32089d080ff8 editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 633
diff changeset
332 @svnwrap.ieditor
300
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 299
diff changeset
333 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
334 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
335 if path in self._svncopies:
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
336 raise EditingError('trying to replace copied file %s' % path)
941
febca88dd261 editor: handle deleted files in editor
Patrick Mezard <patrick@mezard.eu>
parents: 940
diff changeset
337 if path in self._deleted:
febca88dd261 editor: handle deleted files in editor
Patrick Mezard <patrick@mezard.eu>
parents: 940
diff changeset
338 self._deleted.remove(path)
420
59e19c73b0df svnmeta: eliminate unneeded path_and_branch_for_path() method
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 418
diff changeset
339 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
340 if not fpath:
937
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
341 return None
447
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 436
diff changeset
342 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
343 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
344 # 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
345 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
346 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
347 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
348 self.current.added.add(path)
939
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
349 return self._openfile(path, '', False, False, None, create=True)
186
6266ba36ee15 Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 181
diff changeset
350 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
351 (from_file,
420
59e19c73b0df svnmeta: eliminate unneeded path_and_branch_for_path() method
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 418
diff changeset
352 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
353 if not from_file:
949
297e2b4a6e2c editor: add addmissing() and test config to make it fail
Patrick Mezard <patrick@mezard.eu>
parents: 948
diff changeset
354 self.current.addmissing(path)
937
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
355 return None
585
c3ba4ca81d16 editor: fix replaced files content in replay mode
Patrick Mezard <pmezard@gmail.com>
parents: 582
diff changeset
356 # 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
357 # 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
358 # agains replaced branch.
414
343da842dbe6 split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 413
diff changeset
359 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
360 from_branch, True)
951
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 950
diff changeset
361 ctx = self._getctx(ha)
939
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
362 if from_file not in ctx:
949
297e2b4a6e2c editor: add addmissing() and test config to make it fail
Patrick Mezard <patrick@mezard.eu>
parents: 948
diff changeset
363 self.current.addmissing(path)
939
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
364 return None
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
365
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
366 fctx = ctx.filectx(from_file)
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
367 flags = fctx.flags()
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
368 self.current.set(path, fctx.data(), 'x' in flags, 'l' in flags)
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
369 copypath = None
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
370 if from_branch == branch:
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
371 parentid = self.meta.get_parent_revision(
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
372 self.current.rev.revnum, branch)
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
373 if parentid != revlog.nullid:
951
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 950
diff changeset
374 parentctx = self._getctx(parentid)
939
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
375 if util.issamefile(parentctx, ctx, from_file):
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
376 copypath = from_file
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
377 return self._openfile(path, fctx.data(), 'x' in flags, 'l' in flags,
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
378 copypath, create=True)
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
379
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
380 @svnwrap.ieditor
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
381 def close_file(self, file_baton, checksum, pool=None):
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
382 if file_baton is None:
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
383 return
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
384 if file_baton not in self._openfiles:
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
385 raise EditingError('trying to close a non-open file %s'
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
386 % file_baton)
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
387 path, data, isexec, islink, copypath = self._openfiles.pop(file_baton)
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
388 del self._openpaths[path]
948
e2090fabc1a9 editor: use SimpleStringIO in apply_text()
Patrick Mezard <patrick@mezard.eu>
parents: 947
diff changeset
389 if not isinstance(data, basestring):
e2090fabc1a9 editor: use SimpleStringIO in apply_text()
Patrick Mezard <patrick@mezard.eu>
parents: 947
diff changeset
390 # Files can be opened, properties changed and apply_text
e2090fabc1a9 editor: use SimpleStringIO in apply_text()
Patrick Mezard <patrick@mezard.eu>
parents: 947
diff changeset
391 # never called, in which case data is still a string.
e2090fabc1a9 editor: use SimpleStringIO in apply_text()
Patrick Mezard <patrick@mezard.eu>
parents: 947
diff changeset
392 data = data.getvalue()
942
4d9e80f6ba43 editor: do not touch RevisionData copies from the editor
Patrick Mezard <patrick@mezard.eu>
parents: 941
diff changeset
393 self.current.set(path, data, isexec, islink, copypath)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
394
673
32089d080ff8 editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 633
diff changeset
395 @svnwrap.ieditor
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
396 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
397 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
398 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
399 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
400 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
401 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
402 self.current.emptybranches[branch] = True
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
403 else:
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
404 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
405 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
406 return path
521
839734dfb5c7 Handle tag subdirectory as tag in replay mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents: 518
diff changeset
407 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
408 del self.current.emptybranches[branch]
839734dfb5c7 Handle tag subdirectory as tag in replay mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents: 518
diff changeset
409 return path
518
e37738d95b27 editor: remove useless test
Patrick Mezard <pmezard@gmail.com>
parents: 517
diff changeset
410 tag = self.meta.get_path_tag(copyfrom_path)
e37738d95b27 editor: remove useless test
Patrick Mezard <pmezard@gmail.com>
parents: 517
diff changeset
411 if tag not in self.meta.tags:
e37738d95b27 editor: remove useless test
Patrick Mezard <pmezard@gmail.com>
parents: 517
diff changeset
412 tag = None
950
a80b01ceb1fc editor: relax copyfrom dir checks to avoid extra missing entries
Patrick Mezard <patrick@mezard.eu>
parents: 949
diff changeset
413 if not self.meta.is_path_valid(copyfrom_path, existing=False):
a80b01ceb1fc editor: relax copyfrom dir checks to avoid extra missing entries
Patrick Mezard <patrick@mezard.eu>
parents: 949
diff changeset
414 # The source path only exists at copyfrom_revision, use
a80b01ceb1fc editor: relax copyfrom dir checks to avoid extra missing entries
Patrick Mezard <patrick@mezard.eu>
parents: 949
diff changeset
415 # existing=False to guess a possible branch location and
a80b01ceb1fc editor: relax copyfrom dir checks to avoid extra missing entries
Patrick Mezard <patrick@mezard.eu>
parents: 949
diff changeset
416 # test it against the filemap. The actual path and
a80b01ceb1fc editor: relax copyfrom dir checks to avoid extra missing entries
Patrick Mezard <patrick@mezard.eu>
parents: 949
diff changeset
417 # revision will be resolved below if necessary.
949
297e2b4a6e2c editor: add addmissing() and test config to make it fail
Patrick Mezard <patrick@mezard.eu>
parents: 948
diff changeset
418 self.current.addmissing('%s/' % path)
518
e37738d95b27 editor: remove useless test
Patrick Mezard <pmezard@gmail.com>
parents: 517
diff changeset
419 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
420 if tag:
534
e38f110e7088 svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents: 528
diff changeset
421 changeid = self.meta.tags[tag]
e38f110e7088 svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents: 528
diff changeset
422 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
423 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
424 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
425 source_rev = copyfrom_revision
790
3173f418079c editor: rename add_directory() cp_f* variable into from*
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
426 frompath, source_branch = self.meta.split_branch_path(copyfrom_path)[:2]
587
c06f59441f8e editor: fix replaced directory copies
Patrick Mezard <pmezard@gmail.com>
parents: 586
diff changeset
427 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
428 if new_hash == node.nullid:
949
297e2b4a6e2c editor: add addmissing() and test config to make it fail
Patrick Mezard <patrick@mezard.eu>
parents: 948
diff changeset
429 self.current.addmissing('%s/' % path)
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
430 return path
951
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 950
diff changeset
431 fromctx = self._getctx(new_hash)
790
3173f418079c editor: rename add_directory() cp_f* variable into from*
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
432 if frompath != '/' and frompath != '':
3173f418079c editor: rename add_directory() cp_f* variable into from*
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
433 frompath = '%s/' % frompath
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
434 else:
790
3173f418079c editor: rename add_directory() cp_f* variable into from*
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
435 frompath = ''
947
e1cb98792cf4 editor: do not reread all data upon branching
Patrick Mezard <patrick@mezard.eu>
parents: 945
diff changeset
436
e1cb98792cf4 editor: do not reread all data upon branching
Patrick Mezard <patrick@mezard.eu>
parents: 945
diff changeset
437 copyfromparent = False
e1cb98792cf4 editor: do not reread all data upon branching
Patrick Mezard <patrick@mezard.eu>
parents: 945
diff changeset
438 if frompath == '' and br_path == '':
e1cb98792cf4 editor: do not reread all data upon branching
Patrick Mezard <patrick@mezard.eu>
parents: 945
diff changeset
439 pnode = self.meta.get_parent_revision(
e1cb98792cf4 editor: do not reread all data upon branching
Patrick Mezard <patrick@mezard.eu>
parents: 945
diff changeset
440 self.current.rev.revnum, branch)
e1cb98792cf4 editor: do not reread all data upon branching
Patrick Mezard <patrick@mezard.eu>
parents: 945
diff changeset
441 if pnode == new_hash:
e1cb98792cf4 editor: do not reread all data upon branching
Patrick Mezard <patrick@mezard.eu>
parents: 945
diff changeset
442 # Data parent is topological parent and relative paths
e1cb98792cf4 editor: do not reread all data upon branching
Patrick Mezard <patrick@mezard.eu>
parents: 945
diff changeset
443 # are the same, not need to do anything but restore
e1cb98792cf4 editor: do not reread all data upon branching
Patrick Mezard <patrick@mezard.eu>
parents: 945
diff changeset
444 # files marked as deleted.
e1cb98792cf4 editor: do not reread all data upon branching
Patrick Mezard <patrick@mezard.eu>
parents: 945
diff changeset
445 copyfromparent = True
952
9c3b4f59e7e6 stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents: 951
diff changeset
446 # Get the parent which would have been used for this branch
9c3b4f59e7e6 stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents: 951
diff changeset
447 # without the replace action.
9c3b4f59e7e6 stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents: 951
diff changeset
448 oldpnode = self.meta.get_parent_revision(
9c3b4f59e7e6 stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents: 951
diff changeset
449 self.current.rev.revnum, branch, exact=True)
9c3b4f59e7e6 stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents: 951
diff changeset
450 if (oldpnode != revlog.nullid
9c3b4f59e7e6 stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents: 951
diff changeset
451 and util.isancestor(self._getctx(oldpnode), fromctx)):
9c3b4f59e7e6 stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents: 951
diff changeset
452 # Branch-wide replacement, unmark the branch as deleted
9c3b4f59e7e6 stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents: 951
diff changeset
453 self.meta.closebranches.discard(branch)
947
e1cb98792cf4 editor: do not reread all data upon branching
Patrick Mezard <patrick@mezard.eu>
parents: 945
diff changeset
454
938
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
455 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
456 copies = {}
790
3173f418079c editor: rename add_directory() cp_f* variable into from*
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
457 for f in fromctx:
3173f418079c editor: rename add_directory() cp_f* variable into from*
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
458 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
459 continue
791
05ee7d5351de editor: simplify add_directory() a bit more
Patrick Mezard <pmezard@gmail.com>
parents: 790
diff changeset
460 dest = path + '/' + f[len(frompath):]
941
febca88dd261 editor: handle deleted files in editor
Patrick Mezard <patrick@mezard.eu>
parents: 940
diff changeset
461 if dest in self._deleted:
febca88dd261 editor: handle deleted files in editor
Patrick Mezard <patrick@mezard.eu>
parents: 940
diff changeset
462 self._deleted.remove(dest)
947
e1cb98792cf4 editor: do not reread all data upon branching
Patrick Mezard <patrick@mezard.eu>
parents: 945
diff changeset
463 if copyfromparent:
e1cb98792cf4 editor: do not reread all data upon branching
Patrick Mezard <patrick@mezard.eu>
parents: 945
diff changeset
464 continue
e1cb98792cf4 editor: do not reread all data upon branching
Patrick Mezard <patrick@mezard.eu>
parents: 945
diff changeset
465 svncopies[dest] = CopiedFile(new_hash, f, None)
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
466 if branch == source_branch:
791
05ee7d5351de editor: simplify add_directory() a bit more
Patrick Mezard <pmezard@gmail.com>
parents: 790
diff changeset
467 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
468 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
469 # 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
470 # 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
471 parentid = self.meta.get_parent_revision(
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
472 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
473 if parentid != revlog.nullid:
951
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 950
diff changeset
474 parentctx = self._getctx(parentid)
496
5e0dfe59d4c3 copies: fix under-reporting of copies in hg
Augie Fackler <durin42@gmail.com>
parents: 448
diff changeset
475 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
476 if util.issamefile(parentctx, fromctx, v):
940
34a1217b8218 editor: resolve files copied by directory copy on-demand
Patrick Mezard <patrick@mezard.eu>
parents: 939
diff changeset
477 svncopies[k].copypath = v
938
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
478 self._svncopies.update(svncopies)
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
479
792
ba65c0b01d4f replay: copy copied directories externals
Patrick Mezard <pmezard@gmail.com>
parents: 791
diff changeset
480 # Copy the externals definitions of copied directories
ba65c0b01d4f replay: copy copied directories externals
Patrick Mezard <pmezard@gmail.com>
parents: 791
diff changeset
481 fromext = svnexternals.parse(self.ui, fromctx)
ba65c0b01d4f replay: copy copied directories externals
Patrick Mezard <pmezard@gmail.com>
parents: 791
diff changeset
482 for p, v in fromext.iteritems():
ba65c0b01d4f replay: copy copied directories externals
Patrick Mezard <pmezard@gmail.com>
parents: 791
diff changeset
483 pp = p and (p + '/') or ''
ba65c0b01d4f replay: copy copied directories externals
Patrick Mezard <pmezard@gmail.com>
parents: 791
diff changeset
484 if pp.startswith(frompath):
ba65c0b01d4f replay: copy copied directories externals
Patrick Mezard <pmezard@gmail.com>
parents: 791
diff changeset
485 dest = (path + '/' + pp[len(frompath):]).rstrip('/')
ba65c0b01d4f replay: copy copied directories externals
Patrick Mezard <pmezard@gmail.com>
parents: 791
diff changeset
486 self.current.externals[dest] = v
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
487 return path
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
488
673
32089d080ff8 editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 633
diff changeset
489 @svnwrap.ieditor
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
490 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
491 if file_baton is None:
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
492 return
939
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
493 path, data, isexec, islink, copypath = self._openfiles[file_baton]
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
494 changed = False
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
495 if name == 'svn:executable':
939
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
496 changed = True
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
497 isexec = bool(value is not None)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
498 elif name == 'svn:special':
939
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
499 changed = True
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
500 islink = bool(value is not None)
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
501 if changed:
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
502 self._openfiles[file_baton] = (path, data, isexec, islink, copypath)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
503
673
32089d080ff8 editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 633
diff changeset
504 @svnwrap.ieditor
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
505 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
506 if dir_baton is None:
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
507 return
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
508 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
509 if name == 'svn:externals':
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
510 self.current.externals[path] = value
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
511
935
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 934
diff changeset
512 @svnwrap.ieditor
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 934
diff changeset
513 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
514 # 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
515 # reused for different revisions.
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
516 self._clear()
935
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 934
diff changeset
517 return None
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 934
diff changeset
518
673
32089d080ff8 editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 633
diff changeset
519 @svnwrap.ieditor
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
520 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
521 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
522 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
523 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
524 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
525 self.current.emptybranches[branch] = False
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
526 return path
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
527
673
32089d080ff8 editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 633
diff changeset
528 @svnwrap.ieditor
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
529 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
530 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
531 del self.current.batons[dir_baton]
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
532
673
32089d080ff8 editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 633
diff changeset
533 @svnwrap.ieditor
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
534 def apply_textdelta(self, file_baton, base_checksum, pool=None):
939
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
535 if file_baton is None:
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
536 return lambda x: None
939
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
537 if file_baton not in self._openfiles:
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
538 raise EditingError('trying to patch a closed file %s' % file_baton)
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
539 path, base, isexec, islink, copypath = self._openfiles[file_baton]
948
e2090fabc1a9 editor: use SimpleStringIO in apply_text()
Patrick Mezard <patrick@mezard.eu>
parents: 947
diff changeset
540 if not isinstance(base, basestring):
e2090fabc1a9 editor: use SimpleStringIO in apply_text()
Patrick Mezard <patrick@mezard.eu>
parents: 947
diff changeset
541 raise EditingError('trying to edit a file again: %s' % path)
939
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
542 if not self.meta.is_path_valid(path):
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
543 return lambda x: None
939
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
544
948
e2090fabc1a9 editor: use SimpleStringIO in apply_text()
Patrick Mezard <patrick@mezard.eu>
parents: 947
diff changeset
545 target = svnwrap.SimpleStringIO(closing=False)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
546 self.stream = target
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
547
601
0fe490ce2fbb isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 591
diff changeset
548 handler = svnwrap.apply_txdelta(base, target)
837
805ef27fbcbe hgsubversion/*.py: add space after comment symbol #
Yonggang Luo <luoyonggang@gmail.com>
parents: 832
diff changeset
549 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
550 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
551 'cannot call handler!')
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
552 def txdelt_window(window):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
553 try:
937
fb6f6b7fa5a5 editor: implement file batons
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
554 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
555 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
556 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
557 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
558 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
559 # 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
560 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
561
dfb3afa6c619 stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents: 901
diff changeset
562 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
563 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
564
dfb3afa6c619 stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents: 901
diff changeset
565 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
566 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
567 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
568
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
569 # window being None means commit this file
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
570 if not window:
939
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
571 self._openfiles[file_baton] = (
948
e2090fabc1a9 editor: use SimpleStringIO in apply_text()
Patrick Mezard <patrick@mezard.eu>
parents: 947
diff changeset
572 path, target, isexec, islink, copypath)
837
805ef27fbcbe hgsubversion/*.py: add space after comment symbol #
Yonggang Luo <luoyonggang@gmail.com>
parents: 832
diff changeset
573 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
574 if e.args[1] == svnwrap.ERR_INCOMPLETE_DATA:
949
297e2b4a6e2c editor: add addmissing() and test config to make it fail
Patrick Mezard <patrick@mezard.eu>
parents: 948
diff changeset
575 self.current.addmissing(path)
837
805ef27fbcbe hgsubversion/*.py: add space after comment symbol #
Yonggang Luo <luoyonggang@gmail.com>
parents: 832
diff changeset
576 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
577 raise hgutil.Abort(*e.args)
837
805ef27fbcbe hgsubversion/*.py: add space after comment symbol #
Yonggang Luo <luoyonggang@gmail.com>
parents: 832
diff changeset
578 except: # pragma: no cover
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
579 self._exception_info = sys.exc_info()
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
580 raise
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
581 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
582
938
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
583 def close(self):
939
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
584 if self._openfiles:
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
585 for e in self._openfiles.itervalues():
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
586 self.ui.debug('error: %s was not closed\n' % e[0])
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
587 raise EditingError('%d edited files were not closed'
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
588 % len(self._openfiles))
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
589
940
34a1217b8218 editor: resolve files copied by directory copy on-demand
Patrick Mezard <patrick@mezard.eu>
parents: 939
diff changeset
590 # Resolve by changelog entries to avoid extra reads
34a1217b8218 editor: resolve files copied by directory copy on-demand
Patrick Mezard <patrick@mezard.eu>
parents: 939
diff changeset
591 nodes = {}
34a1217b8218 editor: resolve files copied by directory copy on-demand
Patrick Mezard <patrick@mezard.eu>
parents: 939
diff changeset
592 for path, copy in self._svncopies.iteritems():
34a1217b8218 editor: resolve files copied by directory copy on-demand
Patrick Mezard <patrick@mezard.eu>
parents: 939
diff changeset
593 nodes.setdefault(copy.node, []).append((path, copy))
34a1217b8218 editor: resolve files copied by directory copy on-demand
Patrick Mezard <patrick@mezard.eu>
parents: 939
diff changeset
594 for node, copies in nodes.iteritems():
34a1217b8218 editor: resolve files copied by directory copy on-demand
Patrick Mezard <patrick@mezard.eu>
parents: 939
diff changeset
595 for path, copy in copies:
951
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 950
diff changeset
596 data, isexec, islink, copied = copy.resolve(self._getctx)
942
4d9e80f6ba43 editor: do not touch RevisionData copies from the editor
Patrick Mezard <patrick@mezard.eu>
parents: 941
diff changeset
597 self.current.set(path, data, isexec, islink, copied)
938
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
598 self._svncopies.clear()
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 937
diff changeset
599
941
febca88dd261 editor: handle deleted files in editor
Patrick Mezard <patrick@mezard.eu>
parents: 940
diff changeset
600 for f in self._deleted:
febca88dd261 editor: handle deleted files in editor
Patrick Mezard <patrick@mezard.eu>
parents: 940
diff changeset
601 self.current.delete(f)
febca88dd261 editor: handle deleted files in editor
Patrick Mezard <patrick@mezard.eu>
parents: 940
diff changeset
602 self._deleted.clear()
febca88dd261 editor: handle deleted files in editor
Patrick Mezard <patrick@mezard.eu>
parents: 940
diff changeset
603
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
604 _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
605 "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
606 " 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
607 "\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
608 " 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
609 "\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
610 " 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
611 "\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
612 )