annotate hgsubversion/editor.py @ 498:990e07054f29

replay: fix potential over-reporting of edited files in hg changelog
author Augie Fackler <durin42@gmail.com>
date Fri, 16 Oct 2009 18:37:19 -0400
parents cad864ed29de
children 1fd3cfa47c5e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1 import cStringIO
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
2 import sys
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
3
250
79349fd04836 utils: standardizing imported name to hgutil, our_util to util
Daniel Tang <dytang@cs.purdue.edu>
parents: 237
diff changeset
4 from mercurial import util as hgutil
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
5 from mercurial import revlog
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
6 from mercurial import node
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
7 from svn import delta
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
8 from svn import core
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
9
250
79349fd04836 utils: standardizing imported name to hgutil, our_util to util
Daniel Tang <dytang@cs.purdue.edu>
parents: 237
diff changeset
10 import util
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
11
363
ccef78b91ac9 Move exception classes in hg_delta_editor up top.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 362
diff changeset
12
362
705f33c0a323 Replace stash_exception_on_self() by @ieditor.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 352
diff changeset
13 def ieditor(fn):
705f33c0a323 Replace stash_exception_on_self() by @ieditor.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 352
diff changeset
14 """Helps identify methods used by the SVN editor interface.
705f33c0a323 Replace stash_exception_on_self() by @ieditor.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 352
diff changeset
15
705f33c0a323 Replace stash_exception_on_self() by @ieditor.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 352
diff changeset
16 Stash any exception raised in the method on self.
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
17
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
18 This is required because the SWIG bindings just mutate any exception into
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
19 a generic Subversion exception with no way of telling what the original was.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
20 This allows the editor object to notice when you try and commit and really
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
21 got an exception in the replay process.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
22 """
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
23 def fun(self, *args, **kwargs):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
24 try:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
25 return fn(self, *args, **kwargs)
146
4da9f20aef01 Add some more coverage directives.
Augie Fackler <durin42@gmail.com>
parents: 145
diff changeset
26 except: #pragma: no cover
434
3e2259fe3c93 editor: move exception data into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 433
diff changeset
27 if self.current.exception is not None:
3e2259fe3c93 editor: move exception data into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 433
diff changeset
28 self.current.exception = sys.exc_info()
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
29 raise
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
30 return fun
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
31
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
32
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
33 class RevisionData(object):
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
34
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
35 __slots__ = [
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
36 'file', 'files', 'deleted', 'rev', 'execfiles', 'symlinks', 'batons',
433
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
37 'copies', 'missing', 'emptybranches', 'base', 'externals', 'ui',
498
990e07054f29 replay: fix potential over-reporting of edited files in hg changelog
Augie Fackler <durin42@gmail.com>
parents: 497
diff changeset
38 'exception', 'maybeedits',
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
39 ]
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
40
433
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
41 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
42 self.ui = ui
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
43 self.clear()
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
44
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
45 def clear(self):
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
46 self.file = None
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
47 self.files = {}
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
48 self.deleted = {}
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
49 self.rev = None
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
50 self.execfiles = {}
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
51 self.symlinks = {}
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
52 self.batons = {}
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
53 # 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
54 self.copies = {}
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
55 self.missing = set()
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
56 self.emptybranches = {}
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
57 self.base = None
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
58 self.externals = {}
434
3e2259fe3c93 editor: move exception data into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 433
diff changeset
59 self.exception = None
498
990e07054f29 replay: fix potential over-reporting of edited files in hg changelog
Augie Fackler <durin42@gmail.com>
parents: 497
diff changeset
60 self.maybeedits = set()
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
61
433
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
62 def set(self, path, data, isexec=False, islink=False):
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
63 if islink:
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
64 data = 'link ' + data
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
65 self.files[path] = data
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
66 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
67 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
68 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
69 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
70 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
71 self.missing.remove(path)
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
72
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
73 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
74 self.deleted[path] = True
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
75 if path in self.files:
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
76 del self.files[path]
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
77 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
78 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
79 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
80
436
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
81 def findmissing(self, svn):
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
82
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
83 if not self.missing:
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
84 return
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
85
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
86 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
87 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
88 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
89 r = self.rev.revnum
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
90
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
91 files = set()
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
92 for p in self.missing:
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
93 self.ui.note('.')
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
94 self.ui.flush()
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
95 if p[-1] == '/':
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
96 dir = p[len(root):]
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
97 new = [dir + f for f, k in svn.list_files(dir, r) if k == 'f']
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
98 files.update(new)
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
99 else:
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
100 files.add(p[len(root):])
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
101
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
102 i = 1
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
103 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
104 for p in files:
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
105 self.ui.note('.')
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
106 self.ui.flush()
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
107 if i % 50 == 0:
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
108 svn.init_ra_and_client()
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
109 i += 1
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
110 data, mode = svn.get_file(p, r)
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
111 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
112
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
113 self.missing = set()
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
114 self.ui.note('\n')
404162e4bb53 editor: move find missing files routine into RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
115
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
116
421
8277113036f1 editor: rename hg_delta_editor.HgChangeReceiver to editor.HgEditor
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 420
diff changeset
117 class HgEditor(delta.Editor):
33
a9c15cae50e5 Faster append-only revmap implementation.
Andreas Hartmetz <ahartmetz@gmail.com>
parents: 23
diff changeset
118
416
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
119 def __init__(self, meta):
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
120 self.meta = meta
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
121 self.ui = meta.ui
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
122 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
123 self.current = RevisionData(meta.ui)
413
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
124
362
705f33c0a323 Replace stash_exception_on_self() by @ieditor.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 352
diff changeset
125 @ieditor
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
126 def delete_entry(self, path, revision_bogus, parent_baton, pool=None):
420
59e19c73b0df svnmeta: eliminate unneeded path_and_branch_for_path() method
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 418
diff changeset
127 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
128 if br_path == '':
414
343da842dbe6 split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 413
diff changeset
129 self.meta.closebranches.add(branch)
116
30580c05dccc hg_delta_editor: merge _is_path_valid() and _path_and_branch_from_path()
Patrick Mezard <pmezard@gmail.com>
parents: 111
diff changeset
130 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
131 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
132 if ha == revlog.nullid:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
133 return
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
134 ctx = self.repo.changectx(ha)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
135 if br_path not in ctx:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
136 br_path2 = ''
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
137 if br_path != '':
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
138 br_path2 = br_path + '/'
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
139 # 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
140 self.current.externals[path] = None
433
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
141 map(self.current.delete, [pat for pat in self.current.files.iterkeys()
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
142 if pat.startswith(path+'/')])
250
79349fd04836 utils: standardizing imported name to hgutil, our_util to util
Daniel Tang <dytang@cs.purdue.edu>
parents: 237
diff changeset
143 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
144 f_p = '%s/%s' % (path, f[len(br_path2):])
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
145 if f_p not in self.current.files:
433
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
146 self.current.delete(f_p)
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
147 self.current.delete(path)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
148
362
705f33c0a323 Replace stash_exception_on_self() by @ieditor.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 352
diff changeset
149 @ieditor
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
150 def open_file(self, path, parent_baton, base_revision, p=None):
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
151 self.current.file = None
420
59e19c73b0df svnmeta: eliminate unneeded path_and_branch_for_path() method
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 418
diff changeset
152 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
153 if not fpath:
322
05cd4a5138bf Move some .warn() calls to noisy levels instead.
Augie Fackler <durin42@gmail.com>
parents: 321
diff changeset
154 self.ui.debug('WARNING: Opening non-existant file %s\n' % path)
378
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
155 return
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
156
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
157 self.current.file = path
378
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
158 self.ui.note('M %s\n' % path)
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
159 if base_revision != -1:
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
160 self.current.base = base_revision
378
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
161 else:
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
162 self.current.base = None
378
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
163
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
164 if self.current.file in self.current.files:
378
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
165 return
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
166
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
167 baserev = base_revision
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
168 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
169 baserev = self.current.rev.revnum - 1
414
343da842dbe6 split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 413
diff changeset
170 parent = self.meta.get_parent_revision(baserev + 1, branch)
378
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
171
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
172 ctx = self.repo[parent]
417
8630d1ebcdb9 svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 416
diff changeset
173 if not self.meta.is_path_valid(path):
378
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
174 return
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
175
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
176 if fpath not in ctx:
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
177 self.current.missing.add(path)
378
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
178
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
179 fctx = ctx.filectx(fpath)
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
180 base = fctx.data()
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
181 if 'l' in fctx.flags():
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
182 base = 'link ' + base
433
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
183 self.current.set(path, base, 'x' in fctx.flags(), 'l' in fctx.flags())
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
184
362
705f33c0a323 Replace stash_exception_on_self() by @ieditor.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 352
diff changeset
185 @ieditor
300
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 299
diff changeset
186 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
187 copyfrom_revision=None, file_pool=None):
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
188 self.current.file = None
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
189 self.current.base = None
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
190 if path in self.current.deleted:
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
191 del self.current.deleted[path]
420
59e19c73b0df svnmeta: eliminate unneeded path_and_branch_for_path() method
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 418
diff changeset
192 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
193 if not fpath:
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents: 59
diff changeset
194 return
447
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 436
diff changeset
195 if (branch not in self.meta.branches and
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 436
diff changeset
196 not self.meta.is_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
197 # 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
198 self.meta.branches[branch] = None, 0, self.current.rev.revnum
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
199 self.current.file = path
67
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents: 59
diff changeset
200 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
201 self.ui.note('A %s\n' % path)
433
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
202 self.current.set(path, '', False, False)
67
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents: 59
diff changeset
203 return
186
6266ba36ee15 Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 181
diff changeset
204 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
205 (from_file,
420
59e19c73b0df svnmeta: eliminate unneeded path_and_branch_for_path() method
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 418
diff changeset
206 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
207 if not from_file:
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
208 self.current.missing.add(path)
67
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents: 59
diff changeset
209 return
414
343da842dbe6 split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 413
diff changeset
210 ha = self.meta.get_parent_revision(copyfrom_revision + 1,
343da842dbe6 split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 413
diff changeset
211 from_branch)
67
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents: 59
diff changeset
212 ctx = self.repo.changectx(ha)
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents: 59
diff changeset
213 if from_file in ctx:
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents: 59
diff changeset
214 fctx = ctx.filectx(from_file)
97
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents: 73
diff changeset
215 flags = fctx.flags()
433
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
216 self.current.set(path, fctx.data(), 'x' in flags, 'l' in flags)
67
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents: 59
diff changeset
217 if from_branch == branch:
414
343da842dbe6 split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 413
diff changeset
218 parentid = self.meta.get_parent_revision(self.current.rev.revnum,
343da842dbe6 split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 413
diff changeset
219 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
220 if parentid != revlog.nullid:
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
221 parentctx = self.repo.changectx(parentid)
497
cad864ed29de util: make aresamefiles take one file and just be issamefile instead.
Augie Fackler <durin42@gmail.com>
parents: 496
diff changeset
222 if util.issamefile(parentctx, ctx, from_file):
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
223 self.current.copies[path] = from_file
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
224
362
705f33c0a323 Replace stash_exception_on_self() by @ieditor.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 352
diff changeset
225 @ieditor
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
226 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
227 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
228 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
229 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
230 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
231 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
232 self.current.emptybranches[branch] = True
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
233 else:
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
234 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
235 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
236 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
237 if copyfrom_path:
417
8630d1ebcdb9 svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 416
diff changeset
238 tag = self.meta.is_path_tag(copyfrom_path)
414
343da842dbe6 split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 413
diff changeset
239 if tag not in self.meta.tags:
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
240 tag = None
417
8630d1ebcdb9 svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 416
diff changeset
241 if not self.meta.is_path_valid(copyfrom_path) and not tag:
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
242 self.current.missing.add('%s/' % path)
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
243 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
244 if tag:
448
fbc7cf4fd701 tags: reinstate a tag map file in a better way
Augie Fackler <durin42@gmail.com>
parents: 447
diff changeset
245 ci = self.meta.repo[self.meta.tags[tag]].extra()['convert_revision']
fbc7cf4fd701 tags: reinstate a tag map file in a better way
Augie Fackler <durin42@gmail.com>
parents: 447
diff changeset
246 source_rev, source_branch, = self.meta.parse_converted_revision(ci)
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
247 cp_f = ''
430af23bef4a Performance fix for branches-from-tags in real replay, which is tied up with
Augie Fackler <durin42@gmail.com>
parents: 55
diff changeset
248 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
249 source_rev = copyfrom_revision
420
59e19c73b0df svnmeta: eliminate unneeded path_and_branch_for_path() method
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 418
diff changeset
250 cp_f, source_branch = self.meta.split_branch_path(copyfrom_path)[:2]
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
251 if cp_f == '' and br_path == '':
217
6eb691a163cd hg_delta_editor: stop using foobaz as a bogus filename.
Augie Fackler <durin42@gmail.com>
parents: 214
diff changeset
252 assert br_path is not None
414
343da842dbe6 split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 413
diff changeset
253 tmp = source_branch, source_rev, self.current.rev.revnum
343da842dbe6 split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 413
diff changeset
254 self.meta.branches[branch] = tmp
343da842dbe6 split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 413
diff changeset
255 new_hash = self.meta.get_parent_revision(source_rev + 1, source_branch)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
256 if new_hash == node.nullid:
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
257 self.current.missing.add('%s/' % path)
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
258 return path
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
259 cp_f_ctx = self.repo.changectx(new_hash)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
260 if cp_f != '/' and cp_f != '':
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
261 cp_f = '%s/' % cp_f
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
262 else:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
263 cp_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
264 copies = {}
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
265 for f in cp_f_ctx:
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
266 if not f.startswith(cp_f):
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
267 continue
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
268 f2 = f[len(cp_f):]
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
269 fctx = cp_f_ctx.filectx(f)
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
270 fp_c = path + '/' + f2
433
a2a15fa7afb1 editor: move set_file() and delete_file() methods to RevisionData class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
271 self.current.set(fp_c, fctx.data(), 'x' in fctx.flags(), 'l' in fctx.flags())
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
272 if fp_c in self.current.deleted:
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
273 del self.current.deleted[fp_c]
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
274 if branch == source_branch:
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
275 copies[fp_c] = f
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
276 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
277 # 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
278 # the source and destination revisions, or discard it completely.
414
343da842dbe6 split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 413
diff changeset
279 parentid = self.meta.get_parent_revision(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
280 if parentid != revlog.nullid:
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
281 parentctx = self.repo.changectx(parentid)
496
5e0dfe59d4c3 copies: fix under-reporting of copies in hg
Augie Fackler <durin42@gmail.com>
parents: 448
diff changeset
282 for k, v in copies.iteritems():
497
cad864ed29de util: make aresamefiles take one file and just be issamefile instead.
Augie Fackler <durin42@gmail.com>
parents: 496
diff changeset
283 if util.issamefile(parentctx, cp_f_ctx, v):
498
990e07054f29 replay: fix potential over-reporting of edited files in hg changelog
Augie Fackler <durin42@gmail.com>
parents: 497
diff changeset
284 self.current.maybeedits.add(k)
496
5e0dfe59d4c3 copies: fix under-reporting of copies in hg
Augie Fackler <durin42@gmail.com>
parents: 448
diff changeset
285 self.current.copies.update({k: v})
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
286 return path
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
287
362
705f33c0a323 Replace stash_exception_on_self() by @ieditor.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 352
diff changeset
288 @ieditor
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
289 def change_file_prop(self, file_baton, name, value, pool=None):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
290 if name == 'svn:executable':
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
291 self.current.execfiles[self.current.file] = bool(value is not None)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
292 elif name == 'svn:special':
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
293 self.current.symlinks[self.current.file] = bool(value is not None)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
294
362
705f33c0a323 Replace stash_exception_on_self() by @ieditor.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 352
diff changeset
295 @ieditor
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
296 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
297 if dir_baton is None:
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
298 return
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
299 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
300 if name == 'svn:externals':
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
301 self.current.externals[path] = value
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
302
362
705f33c0a323 Replace stash_exception_on_self() by @ieditor.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 352
diff changeset
303 @ieditor
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
304 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
305 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
306 p_, 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
307 if p_ == '':
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
308 self.current.emptybranches[branch] = False
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
309 return path
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
310
362
705f33c0a323 Replace stash_exception_on_self() by @ieditor.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 352
diff changeset
311 @ieditor
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
312 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
313 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
314 del self.current.batons[dir_baton]
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
315
362
705f33c0a323 Replace stash_exception_on_self() by @ieditor.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 352
diff changeset
316 @ieditor
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
317 def apply_textdelta(self, file_baton, base_checksum, pool=None):
211
05243ec295e1 fetch: Fix a bug that caused plaintexts to be interpreted as missing more often than they should be.
Augie Fackler <durin42@gmail.com>
parents: 207
diff changeset
318 # We know coming in here the file must be one of the following options:
05243ec295e1 fetch: Fix a bug that caused plaintexts to be interpreted as missing more often than they should be.
Augie Fackler <durin42@gmail.com>
parents: 207
diff changeset
319 # 1) Deleted (invalid, fail an assertion)
05243ec295e1 fetch: Fix a bug that caused plaintexts to be interpreted as missing more often than they should be.
Augie Fackler <durin42@gmail.com>
parents: 207
diff changeset
320 # 2) Missing a base text (bail quick since we have to fetch a full plaintext)
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
321 # 3) Has a base text in self.current.files, apply deltas
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
322 base = ''
417
8630d1ebcdb9 svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 416
diff changeset
323 if not self.meta.is_path_valid(self.current.file):
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
324 return lambda x: None
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
325 assert self.current.file not in self.current.deleted, (
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
326 'Cannot apply_textdelta to a deleted file: %s' % self.current.file)
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
327 assert (self.current.file in self.current.files
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
328 or self.current.file in self.current.missing), '%s not found' % self.current.file
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
329 if self.current.file in self.current.missing:
211
05243ec295e1 fetch: Fix a bug that caused plaintexts to be interpreted as missing more often than they should be.
Augie Fackler <durin42@gmail.com>
parents: 207
diff changeset
330 return lambda x: None
498
990e07054f29 replay: fix potential over-reporting of edited files in hg changelog
Augie Fackler <durin42@gmail.com>
parents: 497
diff changeset
331 # If we apply a textdelta, the body of the file is going to change.
990e07054f29 replay: fix potential over-reporting of edited files in hg changelog
Augie Fackler <durin42@gmail.com>
parents: 497
diff changeset
332 # There's little reason to check and see if it matches the parent, because
990e07054f29 replay: fix potential over-reporting of edited files in hg changelog
Augie Fackler <durin42@gmail.com>
parents: 497
diff changeset
333 # that's extremely unlikely. If we see cases where that happens,
990e07054f29 replay: fix potential over-reporting of edited files in hg changelog
Augie Fackler <durin42@gmail.com>
parents: 497
diff changeset
334 # maybe this line can go, but until then, it stays.
990e07054f29 replay: fix potential over-reporting of edited files in hg changelog
Augie Fackler <durin42@gmail.com>
parents: 497
diff changeset
335 self.current.maybeedits.discard(self.current.file)
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
336 base = self.current.files[self.current.file]
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
337 source = cStringIO.StringIO(base)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
338 target = cStringIO.StringIO()
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
339 self.stream = target
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
340
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
341 handler, baton = delta.svn_txdelta_apply(source, target, None)
146
4da9f20aef01 Add some more coverage directives.
Augie Fackler <durin42@gmail.com>
parents: 145
diff changeset
342 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
343 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
344 'cannot call handler!')
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
345 def txdelt_window(window):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
346 try:
417
8630d1ebcdb9 svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 416
diff changeset
347 if not self.meta.is_path_valid(self.current.file):
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
348 return
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
349 handler(window, baton)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
350 # window being None means commit this file
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
351 if not window:
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
352 self.current.files[self.current.file] = target.getvalue()
146
4da9f20aef01 Add some more coverage directives.
Augie Fackler <durin42@gmail.com>
parents: 145
diff changeset
353 except core.SubversionException, e: #pragma: no cover
224
2165461d2dd8 Exception clean-ups; use symbolic names & avoid Python 2.6 deprecations.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 211
diff changeset
354 if e.apr_err == core.SVN_ERR_INCOMPLETE_DATA:
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
355 self.current.missing.add(self.current.file)
146
4da9f20aef01 Add some more coverage directives.
Augie Fackler <durin42@gmail.com>
parents: 145
diff changeset
356 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
357 raise hgutil.Abort(*e.args)
146
4da9f20aef01 Add some more coverage directives.
Augie Fackler <durin42@gmail.com>
parents: 145
diff changeset
358 except: #pragma: no cover
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
359 print len(base), self.current.file
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
360 self._exception_info = sys.exc_info()
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
361 raise
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
362 return txdelt_window