Mercurial > hgsubversion
annotate hg_delta_editor.py @ 296:9be04de434ed
Get rid of .hg/svn/last_rev:
We now calculate the last known revision by iterating over all known
revisions and finding the highest number. Theoretically, we might be
able to simply read the latest entry, but in practice, that's a bug
waiting to happen. For instance, we might want to achieve
compatibility with '.hg/shamap' as generated by the
ConvertExtension, and it not only cannot offer a guarantee of
linearity, but it also allows more than one conversion to source exists.
I'd say we have other problems to care about until this turns up as a
hotspot in profiling. Such as why we leak circa 100MB of memory per
1000 revisions converted ;)
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Fri, 27 Mar 2009 01:09:36 +0100 |
parents | aacc8cf83e13 |
children | 3e27514d575c |
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 cPickle as pickle |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
3 import os |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
4 import sys |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
5 import tempfile |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
6 import traceback |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
7 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
8 from mercurial import context |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
9 from mercurial import hg |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
10 from mercurial import ui |
6
1a5bb173170b
Fixes for win32 compatibility. Changes suggested by Shun-ichi GOTO, with some alterations by me.
Augie Fackler <durin42@gmail.com>
parents:
0
diff
changeset
|
11 from mercurial import util |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
12 from mercurial import revlog |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
13 from mercurial import node |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
14 from svn import delta |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
15 from svn import core |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
16 |
174
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
17 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
|
18 import util as our_util |
50d55c3e0d85
Some refactors of the previous change, including transparent upgrade of old-style pickled dictionaries.
Augie Fackler <durin42@gmail.com>
parents:
33
diff
changeset
|
19 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
20 def pickle_atomic(data, file_path, dir=None): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
21 """pickle some data to a path atomically. |
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 This is present because I kept corrupting my revmap by managing to hit ^C |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
24 during the pickle of that file. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
25 """ |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
26 try: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
27 f, path = tempfile.mkstemp(prefix='pickling', dir=dir) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
28 f = os.fdopen(f, 'w') |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
29 pickle.dump(data, f) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
30 f.close() |
146
4da9f20aef01
Add some more coverage directives.
Augie Fackler <durin42@gmail.com>
parents:
145
diff
changeset
|
31 except: #pragma: no cover |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
32 raise |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
33 else: |
6
1a5bb173170b
Fixes for win32 compatibility. Changes suggested by Shun-ichi GOTO, with some alterations by me.
Augie Fackler <durin42@gmail.com>
parents:
0
diff
changeset
|
34 util.rename(path, file_path) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
35 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
36 def stash_exception_on_self(fn): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
37 """Stash any exception raised in the method on self. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
38 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
39 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
|
40 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
|
41 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
|
42 got an exception in the replay process. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
43 """ |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
44 def fun(self, *args, **kwargs): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
45 try: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
46 return fn(self, *args, **kwargs) |
146
4da9f20aef01
Add some more coverage directives.
Augie Fackler <durin42@gmail.com>
parents:
145
diff
changeset
|
47 except: #pragma: no cover |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
48 if not hasattr(self, '_exception_info'): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
49 self._exception_info = sys.exc_info() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
50 raise |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
51 return fun |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
52 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
53 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
54 class HgChangeReceiver(delta.Editor): |
33
a9c15cae50e5
Faster append-only revmap implementation.
Andreas Hartmetz <ahartmetz@gmail.com>
parents:
23
diff
changeset
|
55 def add_to_revmap(self, revnum, branch, node_hash): |
a9c15cae50e5
Faster append-only revmap implementation.
Andreas Hartmetz <ahartmetz@gmail.com>
parents:
23
diff
changeset
|
56 f = open(self.revmap_file, 'a') |
a9c15cae50e5
Faster append-only revmap implementation.
Andreas Hartmetz <ahartmetz@gmail.com>
parents:
23
diff
changeset
|
57 f.write(str(revnum) + ' ' + node.hex(node_hash) + ' ' + (branch or '') + '\n') |
a9c15cae50e5
Faster append-only revmap implementation.
Andreas Hartmetz <ahartmetz@gmail.com>
parents:
23
diff
changeset
|
58 f.flush() |
a9c15cae50e5
Faster append-only revmap implementation.
Andreas Hartmetz <ahartmetz@gmail.com>
parents:
23
diff
changeset
|
59 f.close() |
a9c15cae50e5
Faster append-only revmap implementation.
Andreas Hartmetz <ahartmetz@gmail.com>
parents:
23
diff
changeset
|
60 self.revmap[revnum, branch] = node_hash |
a9c15cae50e5
Faster append-only revmap implementation.
Andreas Hartmetz <ahartmetz@gmail.com>
parents:
23
diff
changeset
|
61 |
296
9be04de434ed
Get rid of .hg/svn/last_rev:
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
295
diff
changeset
|
62 def last_known_revision(self): |
9be04de434ed
Get rid of .hg/svn/last_rev:
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
295
diff
changeset
|
63 ''' Obtain the highest numbered -- i.e. latest -- revision known. |
9be04de434ed
Get rid of .hg/svn/last_rev:
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
295
diff
changeset
|
64 |
9be04de434ed
Get rid of .hg/svn/last_rev:
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
295
diff
changeset
|
65 Currently, this function just iterates over the entire revision map |
9be04de434ed
Get rid of .hg/svn/last_rev:
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
295
diff
changeset
|
66 using the max() builtin. This may be slow for extremely large |
9be04de434ed
Get rid of .hg/svn/last_rev:
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
295
diff
changeset
|
67 repositories, but for now, it's fast enough. |
9be04de434ed
Get rid of .hg/svn/last_rev:
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
295
diff
changeset
|
68 ''' |
9be04de434ed
Get rid of .hg/svn/last_rev:
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
295
diff
changeset
|
69 try: |
9be04de434ed
Get rid of .hg/svn/last_rev:
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
295
diff
changeset
|
70 return max(k[0] for k in self.revmap.iterkeys()) |
9be04de434ed
Get rid of .hg/svn/last_rev:
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
295
diff
changeset
|
71 except ValueError: |
9be04de434ed
Get rid of .hg/svn/last_rev:
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
295
diff
changeset
|
72 return 0 |
9be04de434ed
Get rid of .hg/svn/last_rev:
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
295
diff
changeset
|
73 |
124
291925677a9f
tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
Luke Opperman <luke@loppear.com>
parents:
123
diff
changeset
|
74 def __init__(self, path=None, repo=None, ui_=None, |
291925677a9f
tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
Luke Opperman <luke@loppear.com>
parents:
123
diff
changeset
|
75 subdir='', author_host='', |
167
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
76 tag_locations=['tags'], |
179
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
77 authors=None, |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
78 filemap=None): |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
79 """path is the path to the target hg repo. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
80 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
81 subdir is the subdirectory of the edits *on the svn server*. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
82 It is needed for stripping paths off in certain cases. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
83 """ |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
84 if not ui_: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
85 ui_ = ui.ui() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
86 self.ui = ui_ |
124
291925677a9f
tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
Luke Opperman <luke@loppear.com>
parents:
123
diff
changeset
|
87 if repo: |
291925677a9f
tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
Luke Opperman <luke@loppear.com>
parents:
123
diff
changeset
|
88 self.repo = repo |
291925677a9f
tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
Luke Opperman <luke@loppear.com>
parents:
123
diff
changeset
|
89 self.path = os.path.normpath(os.path.join(self.repo.path, '..')) |
291925677a9f
tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
Luke Opperman <luke@loppear.com>
parents:
123
diff
changeset
|
90 elif path: |
291925677a9f
tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
Luke Opperman <luke@loppear.com>
parents:
123
diff
changeset
|
91 self.path = path |
291925677a9f
tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
Luke Opperman <luke@loppear.com>
parents:
123
diff
changeset
|
92 self.__setup_repo(path) |
146
4da9f20aef01
Add some more coverage directives.
Augie Fackler <durin42@gmail.com>
parents:
145
diff
changeset
|
93 else: #pragma: no cover |
124
291925677a9f
tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
Luke Opperman <luke@loppear.com>
parents:
123
diff
changeset
|
94 raise TypeError("Expected either path or repo argument") |
291925677a9f
tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
Luke Opperman <luke@loppear.com>
parents:
123
diff
changeset
|
95 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
96 self.subdir = subdir |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
97 if self.subdir and self.subdir[0] == '/': |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
98 self.subdir = self.subdir[1:] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
99 self.revmap = {} |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
100 if os.path.exists(self.revmap_file): |
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
|
101 self.revmap = our_util.parse_revmap(self.revmap_file) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
102 self.branches = {} |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
103 if os.path.exists(self.branch_info_file): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
104 f = open(self.branch_info_file) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
105 self.branches = pickle.load(f) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
106 f.close() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
107 self.tags = {} |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
108 if os.path.exists(self.tag_info_file): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
109 f = open(self.tag_info_file) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
110 self.tags = pickle.load(f) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
111 f.close() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
112 if os.path.exists(self.tag_locations_file): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
113 f = open(self.tag_locations_file) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
114 self.tag_locations = pickle.load(f) |
8
c89f53103502
Another fix for Win32 compat.
Shun-ichi GOTO <shunichi.goto@gmail.com>
parents:
6
diff
changeset
|
115 f.close() |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
116 else: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
117 self.tag_locations = tag_locations |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
118 pickle_atomic(self.tag_locations, self.tag_locations_file, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
119 self.meta_data_dir) |
295
aacc8cf83e13
Ensure proper handling of nested tag paths by sorting and reversing them.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
293
diff
changeset
|
120 # ensure nested paths are handled properly |
aacc8cf83e13
Ensure proper handling of nested tag paths by sorting and reversing them.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
293
diff
changeset
|
121 self.tag_locations.sort() |
aacc8cf83e13
Ensure proper handling of nested tag paths by sorting and reversing them.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
293
diff
changeset
|
122 self.tag_locations.reverse() |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
123 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
124 self.clear_current_info() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
125 self.author_host = author_host |
167
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
126 self.authors = {} |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
127 if os.path.exists(self.authors_file): |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
128 self.readauthors(self.authors_file) |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
129 if authors and os.path.exists(authors): |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
130 self.readauthors(authors) |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
131 if self.authors: |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
132 self.writeauthors() |
179
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
133 self.includepaths = {} |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
134 self.excludepaths = {} |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
135 if filemap and os.path.exists(filemap): |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
136 self.readfilemap(filemap) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
137 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
138 def __setup_repo(self, repo_path): |
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
|
139 """Verify the repo is going to work out for us. |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
140 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
141 This method will fail an assertion if the repo exists but doesn't have |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
142 the Subversion metadata. |
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
|
143 """ |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
144 if os.path.isdir(repo_path) and len(os.listdir(repo_path)): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
145 self.repo = hg.repository(self.ui, repo_path) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
146 assert os.path.isfile(self.revmap_file) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
147 assert os.path.isfile(self.svn_url_file) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
148 assert os.path.isfile(self.uuid_file) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
149 else: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
150 self.repo = hg.repository(self.ui, repo_path, create=True) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
151 os.makedirs(os.path.dirname(self.uuid_file)) |
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
|
152 f = open(self.revmap_file, 'w') |
50d55c3e0d85
Some refactors of the previous change, including transparent upgrade of old-style pickled dictionaries.
Augie Fackler <durin42@gmail.com>
parents:
33
diff
changeset
|
153 f.write('%s\n' % our_util.REVMAP_FILE_VERSION) |
50d55c3e0d85
Some refactors of the previous change, including transparent upgrade of old-style pickled dictionaries.
Augie Fackler <durin42@gmail.com>
parents:
33
diff
changeset
|
154 f.flush() |
50d55c3e0d85
Some refactors of the previous change, including transparent upgrade of old-style pickled dictionaries.
Augie Fackler <durin42@gmail.com>
parents:
33
diff
changeset
|
155 f.close() |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
156 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
157 def clear_current_info(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
158 '''Clear the info relevant to a replayed revision so that the next |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
159 revision can be replayed. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
160 ''' |
97
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
73
diff
changeset
|
161 # Map files to raw svn data (symlink prefix is preserved) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
162 self.current_files = {} |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
163 self.deleted_files = {} |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
164 self.current_rev = None |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
165 self.current_files_exec = {} |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
166 self.current_files_symlink = {} |
174
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
167 self.dir_batons = {} |
67
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
59
diff
changeset
|
168 # Map fully qualified destination file paths to module source path |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
59
diff
changeset
|
169 self.copies = {} |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
170 self.missing_plaintexts = set() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
171 self.commit_branches_empty = {} |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
172 self.base_revision = None |
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
|
173 self.branches_to_delete = set() |
174
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
174 self.externals = {} |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
175 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
176 def _save_metadata(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
177 '''Save the Subversion metadata. This should really be called after |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
178 every revision is created. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
179 ''' |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
180 pickle_atomic(self.branches, self.branch_info_file, self.meta_data_dir) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
181 pickle_atomic(self.tags, self.tag_info_file, self.meta_data_dir) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
182 |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
183 def branches_in_paths(self, paths, revnum, checkpath, listdir): |
72
9ec2a12c12ae
hg_delta_editor: make branches_in_paths() return the branch svn path too
Patrick Mezard <pmezard@gmail.com>
parents:
69
diff
changeset
|
184 '''Given a list of paths, return mapping of all branches touched |
9ec2a12c12ae
hg_delta_editor: make branches_in_paths() return the branch svn path too
Patrick Mezard <pmezard@gmail.com>
parents:
69
diff
changeset
|
185 to their branch path. |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
186 ''' |
72
9ec2a12c12ae
hg_delta_editor: make branches_in_paths() return the branch svn path too
Patrick Mezard <pmezard@gmail.com>
parents:
69
diff
changeset
|
187 branches = {} |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
188 paths_need_discovery = [] |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
189 for p in paths: |
116
30580c05dccc
hg_delta_editor: merge _is_path_valid() and _path_and_branch_from_path()
Patrick Mezard <pmezard@gmail.com>
parents:
111
diff
changeset
|
190 relpath, branch, branchpath = self._split_branch_path(p) |
30580c05dccc
hg_delta_editor: merge _is_path_valid() and _path_and_branch_from_path()
Patrick Mezard <pmezard@gmail.com>
parents:
111
diff
changeset
|
191 if relpath is not None: |
72
9ec2a12c12ae
hg_delta_editor: make branches_in_paths() return the branch svn path too
Patrick Mezard <pmezard@gmail.com>
parents:
69
diff
changeset
|
192 branches[branch] = branchpath |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
193 elif paths[p].action == 'D' and not self._is_path_tag(p): |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
194 ln = self._localname(p) |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
195 # must check in branches_to_delete as well, because this runs after we |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
196 # already updated the branch map |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
197 if ln in self.branches or ln in self.branches_to_delete: |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
198 branches[self._localname(p)] = p |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
199 else: |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
200 paths_need_discovery.append(p) |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
201 if paths_need_discovery: |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
202 paths_need_discovery = [(len(p), p) for p in paths_need_discovery] |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
203 paths_need_discovery.sort() |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
204 paths_need_discovery = [p[1] for p in paths_need_discovery] |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
205 actually_files = [] |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
206 while paths_need_discovery: |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
207 p = paths_need_discovery.pop(0) |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
208 path_could_be_file = True |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
209 # TODO(augie) Figure out if you can use break here in a for loop, quick |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
210 # testing of that failed earlier. |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
211 ind = 0 |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
212 while ind < len(paths_need_discovery) and not paths_need_discovery: |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
213 if op.startswith(p): |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
214 path_could_be_file = False |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
215 ind += 1 |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
216 if path_could_be_file: |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
217 if checkpath(p, revnum) == 'f': |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
218 actually_files.append(p) |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
219 # if there's a copyfrom_path and there were files inside that copyfrom, |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
220 # we need to detect those branches. It's a little thorny and slow, but |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
221 # seems to be the best option. |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
222 elif paths[p].copyfrom_path and not p.startswith('tags/'): |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
223 paths_need_discovery.extend(['%s/%s' % (p,x[0]) |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
224 for x in listdir(p, revnum) |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
225 if x[1] == 'f']) |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
226 if actually_files: |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
227 filepaths = [p.split('/') for p in actually_files] |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
228 filepaths = [(len(p), p) for p in filepaths] |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
229 filepaths.sort() |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
230 filepaths = [p[1] for p in filepaths] |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
231 while filepaths: |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
232 path = filepaths.pop(0) |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
233 parentdir = '/'.join(path[:-1]) |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
234 filepaths = [p for p in filepaths if not '/'.join(p).startswith(parentdir)] |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
235 branchpath = self._normalize_path(parentdir) |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
236 branchname = self._localname(branchpath) |
207
b20a6c149021
fetch: Fix a bogus case where no files in the root level of trunk caused breakage in the branch detection.
Augie Fackler <durin42@gmail.com>
parents:
203
diff
changeset
|
237 if branchpath.startswith('trunk/'): |
b20a6c149021
fetch: Fix a bogus case where no files in the root level of trunk caused breakage in the branch detection.
Augie Fackler <durin42@gmail.com>
parents:
203
diff
changeset
|
238 branches[self._localname('trunk')] = 'trunk' |
b20a6c149021
fetch: Fix a bogus case where no files in the root level of trunk caused breakage in the branch detection.
Augie Fackler <durin42@gmail.com>
parents:
203
diff
changeset
|
239 continue |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
240 branches[branchname] = branchpath |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
241 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
242 return branches |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
243 |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
244 def _path_and_branch_for_path(self, path, existing=True): |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
245 return self._split_branch_path(path, existing=existing)[:2] |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
246 |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
247 def _localname(self, path): |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
248 """Compute the local name for a branch located at path. |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
249 """ |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
250 assert not path.startswith('tags/') |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
251 if path == 'trunk': |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
252 return None |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
253 elif path.startswith('branches/'): |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
254 return path[len('branches/'):] |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
255 return '../%s' % path |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
256 |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
257 def _remotename(self, branch): |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
258 if branch == 'default' or branch is None: |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
259 return 'trunk' |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
260 elif branch.startswith('../'): |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
261 return branch[3:] |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
262 return 'branches/%s' % branch |
72
9ec2a12c12ae
hg_delta_editor: make branches_in_paths() return the branch svn path too
Patrick Mezard <pmezard@gmail.com>
parents:
69
diff
changeset
|
263 |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
264 def _split_branch_path(self, path, existing=True): |
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 """Figure out which branch inside our repo this path represents, and |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
266 also figure out which path inside that branch it is. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
267 |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
268 Returns a tuple of (path within branch, local branch name, server-side branch path). |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
269 |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
270 If existing=True, will return None, None, None if the file isn't on some known |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
271 branch. If existing=False, then it will guess what the branch would be if it were |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
272 known. |
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
|
273 """ |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
274 path = self._normalize_path(path) |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
275 if path.startswith('tags/'): |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
276 return None, None, None |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
277 test = '' |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
278 path_comps = path.split('/') |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
279 while self._localname(test) not in self.branches and len(path_comps): |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
280 if not test: |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
281 test = path_comps.pop(0) |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
282 else: |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
283 test += '/%s' % path_comps.pop(0) |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
284 if self._localname(test) in self.branches: |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
285 return path[len(test)+1:], self._localname(test), test |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
286 if existing: |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
287 return None, None, None |
207
b20a6c149021
fetch: Fix a bogus case where no files in the root level of trunk caused breakage in the branch detection.
Augie Fackler <durin42@gmail.com>
parents:
203
diff
changeset
|
288 if path.startswith('trunk/'): |
b20a6c149021
fetch: Fix a bogus case where no files in the root level of trunk caused breakage in the branch detection.
Augie Fackler <durin42@gmail.com>
parents:
203
diff
changeset
|
289 path = test.split('/')[1:] |
b20a6c149021
fetch: Fix a bogus case where no files in the root level of trunk caused breakage in the branch detection.
Augie Fackler <durin42@gmail.com>
parents:
203
diff
changeset
|
290 test = 'trunk' |
b20a6c149021
fetch: Fix a bogus case where no files in the root level of trunk caused breakage in the branch detection.
Augie Fackler <durin42@gmail.com>
parents:
203
diff
changeset
|
291 else: |
b20a6c149021
fetch: Fix a bogus case where no files in the root level of trunk caused breakage in the branch detection.
Augie Fackler <durin42@gmail.com>
parents:
203
diff
changeset
|
292 path = test.split('/')[-1] |
b20a6c149021
fetch: Fix a bogus case where no files in the root level of trunk caused breakage in the branch detection.
Augie Fackler <durin42@gmail.com>
parents:
203
diff
changeset
|
293 test = '/'.join(test.split('/')[:-1]) |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
294 return path, self._localname(test), test |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
295 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
296 def set_current_rev(self, rev): |
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
|
297 """Set the revision we're currently converting. |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
131
diff
changeset
|
298 """ |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
299 self.current_rev = rev |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
300 |
97
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
73
diff
changeset
|
301 def set_file(self, path, data, isexec=False, islink=False): |
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
73
diff
changeset
|
302 if islink: |
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
73
diff
changeset
|
303 data = 'link ' + data |
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
73
diff
changeset
|
304 self.current_files[path] = data |
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
73
diff
changeset
|
305 self.current_files_exec[path] = isexec |
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
73
diff
changeset
|
306 self.current_files_symlink[path] = islink |
123
58de7aea8a77
Fix a bug in replay convert where replaced files that couldn't use replay
Augie Fackler <durin42@gmail.com>
parents:
120
diff
changeset
|
307 if path in self.deleted_files: |
58de7aea8a77
Fix a bug in replay convert where replaced files that couldn't use replay
Augie Fackler <durin42@gmail.com>
parents:
120
diff
changeset
|
308 del self.deleted_files[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
|
309 if path in self.missing_plaintexts: |
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
|
310 self.missing_plaintexts.remove(path) |
97
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
73
diff
changeset
|
311 |
145
b37c401b7f92
hg_delta_editor: reset properties of deleted entries
Patrick Mezard <pmezard@gmail.com>
parents:
141
diff
changeset
|
312 def delete_file(self, path): |
b37c401b7f92
hg_delta_editor: reset properties of deleted entries
Patrick Mezard <pmezard@gmail.com>
parents:
141
diff
changeset
|
313 self.deleted_files[path] = True |
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
|
314 if path in self.current_files: |
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
|
315 del self.current_files[path] |
145
b37c401b7f92
hg_delta_editor: reset properties of deleted entries
Patrick Mezard <pmezard@gmail.com>
parents:
141
diff
changeset
|
316 self.current_files_exec[path] = False |
b37c401b7f92
hg_delta_editor: reset properties of deleted entries
Patrick Mezard <pmezard@gmail.com>
parents:
141
diff
changeset
|
317 self.current_files_symlink[path] = False |
186
6266ba36ee15
Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
181
diff
changeset
|
318 self.ui.note('D %s\n' % path) |
145
b37c401b7f92
hg_delta_editor: reset properties of deleted entries
Patrick Mezard <pmezard@gmail.com>
parents:
141
diff
changeset
|
319 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
320 def _normalize_path(self, path): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
321 '''Normalize a path to strip of leading slashes and our subdir if we |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
322 have one. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
323 ''' |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
324 if path and path[0] == '/': |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
325 path = path[1:] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
326 if path and path.startswith(self.subdir): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
327 path = path[len(self.subdir):] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
328 if path and path[0] == '/': |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
329 path = path[1:] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
330 return path |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
331 |
179
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
332 def _is_file_included(self, subpath): |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
333 def checkpathinmap(path, mapping): |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
334 def rpairs(name): |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
335 yield '.', name |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
336 e = len(name) |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
337 while e != -1: |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
338 yield name[:e], name[e+1:] |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
339 e = name.rfind('/', 0, e) |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
340 |
179
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
341 for pre, suf in rpairs(path): |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
342 try: |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
343 return mapping[pre] |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
344 except KeyError, err: |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
345 pass |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
346 return None |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
347 |
179
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
348 if len(self.includepaths) and len(subpath): |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
349 inc = checkpathinmap(subpath, self.includepaths) |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
350 else: |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
351 inc = subpath |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
352 if len(self.excludepaths) and len(subpath): |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
353 exc = checkpathinmap(subpath, self.excludepaths) |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
354 else: |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
355 exc = None |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
356 if inc is None or exc is not None: |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
357 return False |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
358 return True |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
359 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
360 def _is_path_valid(self, path): |
179
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
361 subpath = self._split_branch_path(path)[0] |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
362 if subpath is None: |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
363 return False |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
364 return self._is_file_included(subpath) |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
365 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
366 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
367 def _is_path_tag(self, path): |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
368 """If path could represent the path to a tag, returns the potential tag name. |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
369 |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
370 Note that it's only a tag if it was copied from the path '' in a branch (or tag) |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
371 we have, for our purposes. |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
372 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
373 Otherwise, returns False. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
374 """ |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
375 path = self._normalize_path(path) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
376 for tags_path in self.tag_locations: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
377 if path and (path.startswith(tags_path) and |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
378 len(path) > len('%s/' % tags_path)): |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
379 return path[len(tags_path)+1:] |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
380 return False |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
381 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
382 def get_parent_svn_branch_and_rev(self, number, branch): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
383 number -= 1 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
384 if (number, branch) in self.revmap: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
385 return number, branch |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
386 real_num = 0 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
387 for num, br in self.revmap.iterkeys(): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
388 if br != branch: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
389 continue |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
390 if num <= number and num > real_num: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
391 real_num = num |
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
|
392 if branch in self.branches: |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
131
diff
changeset
|
393 parent_branch = self.branches[branch][0] |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
131
diff
changeset
|
394 parent_branch_rev = self.branches[branch][1] |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
131
diff
changeset
|
395 # check to see if this branch already existed and is the same |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
131
diff
changeset
|
396 if parent_branch_rev < real_num: |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
131
diff
changeset
|
397 return real_num, branch |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
131
diff
changeset
|
398 # if that wasn't true, then this is the a new branch with the |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
131
diff
changeset
|
399 # same name as some old deleted branch |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
131
diff
changeset
|
400 if parent_branch_rev <= 0 and real_num == 0: |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
131
diff
changeset
|
401 return None, None |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
131
diff
changeset
|
402 branch_created_rev = self.branches[branch][2] |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
131
diff
changeset
|
403 if parent_branch == 'trunk': |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
131
diff
changeset
|
404 parent_branch = None |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
131
diff
changeset
|
405 if branch_created_rev <= number+1 and branch != parent_branch: |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
131
diff
changeset
|
406 return self.get_parent_svn_branch_and_rev( |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
131
diff
changeset
|
407 parent_branch_rev+1, |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
131
diff
changeset
|
408 parent_branch) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
409 if real_num != 0: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
410 return real_num, branch |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
411 return None, None |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
412 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
413 def get_parent_revision(self, number, branch): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
414 '''Get the parent revision hash for a commit on a specific branch. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
415 ''' |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
416 r, br = self.get_parent_svn_branch_and_rev(number, branch) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
417 if r is not None: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
418 return self.revmap[r, br] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
419 return revlog.nullid |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
420 |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
421 def _svnpath(self, branch): |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
422 """Return the relative path in svn of branch. |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
423 """ |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
424 if branch == None or branch == 'default': |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
425 return 'trunk' |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
426 elif branch.startswith('../'): |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
427 return branch[3:] |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
428 return 'branches/%s' % branch |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
429 |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
430 def __determine_parent_branch(self, p, src_path, src_rev, revnum): |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
431 if src_path is not None: |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
432 src_file, src_branch = self._path_and_branch_for_path(src_path) |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
433 src_tag = self._is_path_tag(src_path) |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
434 if src_tag != False: |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
435 # also case 2 |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
436 src_branch, src_rev = self.tags[src_tag] |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
437 return {self._localname(p): (src_branch, src_rev, revnum )} |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
438 if src_file == '': |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
439 # case 2 |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
440 return {self._localname(p): (src_branch, src_rev, revnum )} |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
441 return {} |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
442 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
443 def update_branch_tag_map_for_rev(self, revision): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
444 paths = revision.paths |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
445 added_branches = {} |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
446 added_tags = {} |
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
|
447 self.branches_to_delete = set() |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
448 tags_to_delete = set() |
131
4d42dbbb5127
hg_delta_editor: fix parent revision detection on branch copy
Patrick Mezard <pmezard@gmail.com>
parents:
124
diff
changeset
|
449 for p in sorted(paths): |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
450 t_name = self._is_path_tag(p) |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
451 if t_name != False: |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
452 src_p, src_rev = paths[p].copyfrom_path, paths[p].copyfrom_rev |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
453 # if you commit to a tag, I'm calling you stupid and ignoring |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
454 # you. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
455 if src_p is not None and src_rev is not None: |
116
30580c05dccc
hg_delta_editor: merge _is_path_valid() and _path_and_branch_from_path()
Patrick Mezard <pmezard@gmail.com>
parents:
111
diff
changeset
|
456 file, branch = self._path_and_branch_for_path(src_p) |
30580c05dccc
hg_delta_editor: merge _is_path_valid() and _path_and_branch_from_path()
Patrick Mezard <pmezard@gmail.com>
parents:
111
diff
changeset
|
457 if file is None: |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
458 # some crazy people make tags from other tags |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
459 file = '' |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
460 from_tag = self._is_path_tag(src_p) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
461 if not from_tag: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
462 continue |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
463 branch, src_rev = self.tags[from_tag] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
464 if t_name not in added_tags: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
465 added_tags[t_name] = branch, src_rev |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
466 elif file and src_rev > added_tags[t_name][1]: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
467 added_tags[t_name] = branch, src_rev |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
468 elif (paths[p].action == 'D' and p.endswith(t_name) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
469 and t_name in self.tags): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
470 tags_to_delete.add(t_name) |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
471 continue |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
472 # At this point we know the path is not a tag. In that case, we only care if it |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
473 # is the root of a new branch (in this function). This is determined by the |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
474 # following checks: |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
475 # 1. Is the file located inside any currently known branch? |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
476 # If yes, then we're done with it, this isn't interesting. |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
477 # 2. Does the file have copyfrom information that means it is a copy from the root |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
478 # of some other branch? |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
479 # If yes, then we're done: this is a new branch, and we record the copyfrom in |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
480 # added_branches |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
481 # 3. Neither of the above. This could be a branch, but it might never work out for |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
482 # us. It's only ever a branch (as far as we're concerned) if it gets committed |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
483 # to, which we have to detect at file-write time anyway. So we do nothing here. |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
484 # 4. It's the root of an already-known branch, with an action of 'D'. We mark the |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
485 # branch as deleted. |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
486 # 5. It's the parent directory of one or more already-known branches, so we mark them |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
487 # as deleted. |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
488 # 6. It's a branch being replaced by another branch - the action will be 'R'. |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
489 fi, br = self._path_and_branch_for_path(p) |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
490 if fi is not None: |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
491 if fi == '': |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
492 if paths[p].action == 'D': |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
493 self.branches_to_delete.add(br) # case 4 |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
494 elif paths[p].action == 'R': |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
495 added_branches.update(self.__determine_parent_branch(p, paths[p].copyfrom_path, |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
496 paths[p].copyfrom_rev, |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
497 revision.revnum)) |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
498 continue # case 1 |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
499 if paths[p].action == 'D': |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
500 # check for case 5 |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
501 for known in self.branches: |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
502 if self._svnpath(known).startswith(p): |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
503 self.branches_to_delete.add(br) # case 5 |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
504 added_branches.update(self.__determine_parent_branch(p, paths[p].copyfrom_path, |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
505 paths[p].copyfrom_rev, revision.revnum)) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
506 for t in tags_to_delete: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
507 del self.tags[t] |
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
|
508 for br in self.branches_to_delete: |
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
|
509 del self.branches[br] |
156
56dae5beae65
hg_delta_editor: Produce some output when creating a tag.
Augie Fackler <durin42@gmail.com>
parents:
155
diff
changeset
|
510 for t, info in added_tags.items(): |
56dae5beae65
hg_delta_editor: Produce some output when creating a tag.
Augie Fackler <durin42@gmail.com>
parents:
155
diff
changeset
|
511 self.ui.status('Tagged %s@%s as %s\n' % |
56dae5beae65
hg_delta_editor: Produce some output when creating a tag.
Augie Fackler <durin42@gmail.com>
parents:
155
diff
changeset
|
512 (info[0] or 'trunk', info[1], t)) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
513 self.tags.update(added_tags) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
514 self.branches.update(added_branches) |
23
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
8
diff
changeset
|
515 self._save_metadata() |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
516 |
174
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
517 def _updateexternals(self): |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
518 if not self.externals: |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
519 return |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
520 # Accumulate externals records for all branches |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
521 revnum = self.current_rev.revnum |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
522 branches = {} |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
523 for path, entry in self.externals.iteritems(): |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
524 if not self._is_path_valid(path): |
293
fa26c7ef0180
Exception clean-ups; use symbolic names & avoid Python 2.6 deprecations.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
211
diff
changeset
|
525 self.ui.warn('WARNING: Invalid path %s in externals\n' % path) |
174
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
526 continue |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
527 p, b, bp = self._split_branch_path(path) |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
528 if bp not in branches: |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
529 external = svnexternals.externalsfile() |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
530 parent = self.get_parent_revision(revnum, b) |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
531 pctx = self.repo[parent] |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
532 if '.hgsvnexternals' in pctx: |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
533 external.read(pctx['.hgsvnexternals'].data()) |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
534 branches[bp] = external |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
535 else: |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
536 external = branches[bp] |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
537 external[p] = entry |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
538 |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
539 # Register the file changes |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
540 for bp, external in branches.iteritems(): |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
541 path = bp + '/.hgsvnexternals' |
176
c4115b3918e9
Really delete the .hgsvnexternals file when explicitely removed
Patrick Mezard <pmezard@gmail.com>
parents:
174
diff
changeset
|
542 if external: |
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 self.set_file(path, external.write(), False, False) |
176
c4115b3918e9
Really delete the .hgsvnexternals file when explicitely removed
Patrick Mezard <pmezard@gmail.com>
parents:
174
diff
changeset
|
544 else: |
c4115b3918e9
Really delete the .hgsvnexternals file when explicitely removed
Patrick Mezard <pmezard@gmail.com>
parents:
174
diff
changeset
|
545 self.delete_file(path) |
174
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
546 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
547 def commit_current_delta(self): |
146
4da9f20aef01
Add some more coverage directives.
Augie Fackler <durin42@gmail.com>
parents:
145
diff
changeset
|
548 if hasattr(self, '_exception_info'): #pragma: no cover |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
549 traceback.print_exception(*self._exception_info) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
550 raise ReplayException() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
551 if self.missing_plaintexts: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
552 raise MissingPlainTextError() |
174
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
553 self._updateexternals() |
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
|
554 # paranoidly generate the list of files to commit |
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
|
555 files_to_commit = set(self.current_files.keys()) |
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
|
556 files_to_commit.update(self.current_files_symlink.keys()) |
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
|
557 files_to_commit.update(self.current_files_exec.keys()) |
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
|
558 files_to_commit.update(self.deleted_files.keys()) |
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
|
559 # back to a list and sort so we get sane behavior |
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
|
560 files_to_commit = list(files_to_commit) |
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
|
561 files_to_commit.sort() |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
562 branch_batches = {} |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
563 rev = self.current_rev |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
564 date = rev.date.replace('T', ' ').replace('Z', '').split('.')[0] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
565 date += ' -0000' |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
566 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
567 # build up the branches that have files on them |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
568 for f in files_to_commit: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
569 if not self._is_path_valid(f): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
570 continue |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
571 p, b = self._path_and_branch_for_path(f) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
572 if b not in branch_batches: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
573 branch_batches[b] = [] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
574 branch_batches[b].append((p, f)) |
147
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
146
diff
changeset
|
575 # close any branches that need it |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
146
diff
changeset
|
576 closed_revs = set() |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
146
diff
changeset
|
577 for branch in self.branches_to_delete: |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
146
diff
changeset
|
578 closed = revlog.nullid |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
146
diff
changeset
|
579 if 'closed-branches' in self.repo.branchtags(): |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
146
diff
changeset
|
580 closed = self.repo['closed-branches'].node() |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
146
diff
changeset
|
581 branchedits = sorted(filter(lambda x: x[0][1] == branch and x[0][0] < rev.revnum, |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
146
diff
changeset
|
582 self.revmap.iteritems()), reverse=True) |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
146
diff
changeset
|
583 if len(branchedits) < 1: |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
146
diff
changeset
|
584 # can't close a branch that never existed |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
146
diff
changeset
|
585 continue |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
146
diff
changeset
|
586 ha = branchedits[0][1] |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
146
diff
changeset
|
587 closed_revs.add(ha) |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
146
diff
changeset
|
588 # self.get_parent_revision(rev.revnum, branch) |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
146
diff
changeset
|
589 parentctx = self.repo.changectx(ha) |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
146
diff
changeset
|
590 parents = (ha, closed) |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
146
diff
changeset
|
591 def del_all_files(*args): |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
146
diff
changeset
|
592 raise IOError |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
146
diff
changeset
|
593 files = parentctx.manifest().keys() |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
146
diff
changeset
|
594 current_ctx = context.memctx(self.repo, |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
146
diff
changeset
|
595 parents, |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
146
diff
changeset
|
596 rev.message or ' ', |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
146
diff
changeset
|
597 files, |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
146
diff
changeset
|
598 del_all_files, |
167
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
599 self.authorforsvnauthor(rev.author), |
147
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
146
diff
changeset
|
600 date, |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
146
diff
changeset
|
601 {'branch': 'closed-branches'}) |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
146
diff
changeset
|
602 new_hash = self.repo.commitctx(current_ctx) |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
146
diff
changeset
|
603 self.ui.status('Marked branch %s as closed.\n' % (branch or |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
146
diff
changeset
|
604 'default')) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
605 for branch, files in branch_batches.iteritems(): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
606 if branch in self.commit_branches_empty and files: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
607 del self.commit_branches_empty[branch] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
608 files = dict(files) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
609 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
610 parents = (self.get_parent_revision(rev.revnum, branch), |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
611 revlog.nullid) |
147
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
146
diff
changeset
|
612 if parents[0] in closed_revs and branch in self.branches_to_delete: |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
146
diff
changeset
|
613 continue |
154
6fa97cfbf62f
fetch: Refactor extra creation to be shared by real and diff replay.
Augie Fackler <durin42@gmail.com>
parents:
147
diff
changeset
|
614 # TODO this needs to be fixed with the new revmap |
6fa97cfbf62f
fetch: Refactor extra creation to be shared by real and diff replay.
Augie Fackler <durin42@gmail.com>
parents:
147
diff
changeset
|
615 extra = our_util.build_extra(rev.revnum, branch, |
6fa97cfbf62f
fetch: Refactor extra creation to be shared by real and diff replay.
Augie Fackler <durin42@gmail.com>
parents:
147
diff
changeset
|
616 open(self.uuid_file).read(), |
6fa97cfbf62f
fetch: Refactor extra creation to be shared by real and diff replay.
Augie Fackler <durin42@gmail.com>
parents:
147
diff
changeset
|
617 self.subdir) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
618 if branch is not None: |
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
|
619 if (branch not in self.branches |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
131
diff
changeset
|
620 and branch not in self.repo.branchtags()): |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
621 continue |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
622 parent_ctx = self.repo.changectx(parents[0]) |
174
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
623 if '.hgsvnexternals' not in parent_ctx and '.hgsvnexternals' in files: |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
624 # Do not register empty externals files |
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
|
625 if (files['.hgsvnexternals'] in self.current_files |
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
|
626 and not self.current_files[files['.hgsvnexternals']]): |
174
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
627 del files['.hgsvnexternals'] |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
628 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
629 def filectxfn(repo, memctx, path): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
630 current_file = files[path] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
631 if current_file in self.deleted_files: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
632 raise IOError() |
67
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
59
diff
changeset
|
633 copied = self.copies.get(current_file) |
55
987e44afa71e
hg_delta_editor: simplify exec/symlink flags generation
Patrick Mezard <pmezard@gmail.com>
parents:
43
diff
changeset
|
634 flags = parent_ctx.flags(path) |
97
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
73
diff
changeset
|
635 is_exec = self.current_files_exec.get(current_file, 'x' in flags) |
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
73
diff
changeset
|
636 is_link = self.current_files_symlink.get(current_file, 'l' in flags) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
637 if current_file in self.current_files: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
638 data = self.current_files[current_file] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
639 if is_link: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
640 assert data.startswith('link ') |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
641 data = data[len('link '):] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
642 else: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
643 data = parent_ctx.filectx(path).data() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
644 return context.memfilectx(path=path, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
645 data=data, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
646 islink=is_link, isexec=is_exec, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
647 copied=copied) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
648 current_ctx = context.memctx(self.repo, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
649 parents, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
650 rev.message or '...', |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
651 files.keys(), |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
652 filectxfn, |
167
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
653 self.authorforsvnauthor(rev.author), |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
654 date, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
655 extra) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
656 new_hash = self.repo.commitctx(current_ctx) |
198
df4611050286
Output consolidation; decrease the ‘Fetching...’ message to debug level.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
197
diff
changeset
|
657 our_util.describe_commit(self.ui, new_hash, branch) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
658 if (rev.revnum, branch) not in self.revmap: |
33
a9c15cae50e5
Faster append-only revmap implementation.
Andreas Hartmetz <ahartmetz@gmail.com>
parents:
23
diff
changeset
|
659 self.add_to_revmap(rev.revnum, branch, new_hash) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
660 # now we handle branches that need to be committed without any files |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
661 for branch in self.commit_branches_empty: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
662 ha = self.get_parent_revision(rev.revnum, branch) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
663 if ha == node.nullid: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
664 continue |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
665 parent_ctx = self.repo.changectx(ha) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
666 def del_all_files(*args): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
667 raise IOError |
136
cf6fe8457570
Fix an apparent regression where branch name didn't get properly stored for
Augie Fackler <durin42@gmail.com>
parents:
133
diff
changeset
|
668 # True here meant nuke all files, shouldn't happen with branch closing |
146
4da9f20aef01
Add some more coverage directives.
Augie Fackler <durin42@gmail.com>
parents:
145
diff
changeset
|
669 if self.commit_branches_empty[branch]: #pragma: no cover |
197
43d56e973c3c
Replace a few asserts with aborts.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
186
diff
changeset
|
670 raise util.Abort('Empty commit to an open branch attempted. ' |
43d56e973c3c
Replace a few asserts with aborts.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
186
diff
changeset
|
671 'Please report this issue.') |
154
6fa97cfbf62f
fetch: Refactor extra creation to be shared by real and diff replay.
Augie Fackler <durin42@gmail.com>
parents:
147
diff
changeset
|
672 extra = our_util.build_extra(rev.revnum, branch, |
6fa97cfbf62f
fetch: Refactor extra creation to be shared by real and diff replay.
Augie Fackler <durin42@gmail.com>
parents:
147
diff
changeset
|
673 open(self.uuid_file).read(), |
6fa97cfbf62f
fetch: Refactor extra creation to be shared by real and diff replay.
Augie Fackler <durin42@gmail.com>
parents:
147
diff
changeset
|
674 self.subdir) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
675 current_ctx = context.memctx(self.repo, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
676 (ha, node.nullid), |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
677 rev.message or ' ', |
136
cf6fe8457570
Fix an apparent regression where branch name didn't get properly stored for
Augie Fackler <durin42@gmail.com>
parents:
133
diff
changeset
|
678 [], |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
679 del_all_files, |
167
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
680 self.authorforsvnauthor(rev.author), |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
681 date, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
682 extra) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
683 new_hash = self.repo.commitctx(current_ctx) |
198
df4611050286
Output consolidation; decrease the ‘Fetching...’ message to debug level.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
197
diff
changeset
|
684 our_util.describe_commit(self.ui, new_hash, branch) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
685 if (rev.revnum, branch) not in self.revmap: |
33
a9c15cae50e5
Faster append-only revmap implementation.
Andreas Hartmetz <ahartmetz@gmail.com>
parents:
23
diff
changeset
|
686 self.add_to_revmap(rev.revnum, branch, new_hash) |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
687 self._save_metadata() |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
688 self.clear_current_info() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
689 |
167
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
690 def authorforsvnauthor(self, author): |
168
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
167
diff
changeset
|
691 if(author in self.authors): |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
167
diff
changeset
|
692 return self.authors[author] |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
167
diff
changeset
|
693 return '%s%s' %(author, self.author_host) |
167
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
694 |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
695 def readauthors(self, authorfile): |
186
6266ba36ee15
Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
181
diff
changeset
|
696 self.ui.note(('Reading authormap from %s\n') % authorfile) |
167
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
697 f = open(authorfile, 'r') |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
698 for line in f: |
168
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
167
diff
changeset
|
699 if not line.strip(): |
167
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
700 continue |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
701 try: |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
702 srcauth, dstauth = line.split('=', 1) |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
703 srcauth = srcauth.strip() |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
704 dstauth = dstauth.strip() |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
705 if srcauth in self.authors and dstauth != self.authors[srcauth]: |
186
6266ba36ee15
Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
181
diff
changeset
|
706 self.ui.status(('Overriding author mapping for "%s" ' + |
6266ba36ee15
Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
181
diff
changeset
|
707 'from "%s" to "%s"\n') |
6266ba36ee15
Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
181
diff
changeset
|
708 % (srcauth, self.authors[srcauth], dstauth)) |
167
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
709 else: |
186
6266ba36ee15
Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
181
diff
changeset
|
710 self.ui.debug(('Mapping author "%s" to "%s"\n') |
6266ba36ee15
Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
181
diff
changeset
|
711 % (srcauth, dstauth)) |
167
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
712 self.authors[srcauth] = dstauth |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
713 except IndexError: |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
714 self.ui.warn( |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
715 ('Ignoring bad line in author map file %s: %s\n') |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
716 % (authorfile, line.rstrip())) |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
717 f.close() |
168
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
167
diff
changeset
|
718 |
167
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
719 def writeauthors(self): |
186
6266ba36ee15
Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
181
diff
changeset
|
720 self.ui.debug(('Writing author map to %s\n') % self.authors_file) |
167
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
721 f = open(self.authors_file, 'w+') |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
722 for author in self.authors: |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
723 f.write("%s=%s\n" % (author, self.authors[author])) |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
724 f.close() |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
725 |
179
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
726 def readfilemap(self, filemapfile): |
186
6266ba36ee15
Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
181
diff
changeset
|
727 self.ui.note( |
6266ba36ee15
Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
181
diff
changeset
|
728 ('Reading file map from %s\n') |
179
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
729 % filemapfile) |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
730 def addpathtomap(path, mapping, mapname): |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
731 if path in mapping: |
186
6266ba36ee15
Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
181
diff
changeset
|
732 self.ui.warn(('Duplicate %s entry in %s: "%d"\n') % |
6266ba36ee15
Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
181
diff
changeset
|
733 (mapname, filemapfile, path)) |
179
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
734 else: |
186
6266ba36ee15
Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
181
diff
changeset
|
735 self.ui.debug(('%sing %s\n') % |
6266ba36ee15
Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
181
diff
changeset
|
736 (mapname.capitalize().strip('e'), path)) |
179
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
737 mapping[path] = path |
186
6266ba36ee15
Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
181
diff
changeset
|
738 |
179
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
739 f = open(filemapfile, 'r') |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
740 for line in f: |
186
6266ba36ee15
Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
181
diff
changeset
|
741 if line.strip() == '' or line.strip()[0] == '#': |
179
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
742 continue |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
743 try: |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
744 cmd, path = line.split(' ', 1) |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
745 cmd = cmd.strip() |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
746 path = path.strip() |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
747 if cmd == 'include': |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
748 addpathtomap(path, self.includepaths, 'include') |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
749 elif cmd == 'exclude': |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
750 addpathtomap(path, self.excludepaths, 'exclude') |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
751 else: |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
752 self.ui.warn( |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
753 ('Unknown filemap command %s\n') |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
754 % cmd) |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
755 except IndexError: |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
756 self.ui.warn( |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
757 ('Ignoring bad line in filemap %s: %s\n') |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
758 % (filemapfile, line.rstrip())) |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
759 f.close() |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
760 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
761 def meta_data_dir(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
762 return os.path.join(self.path, '.hg', 'svn') |
181
e37f9d3fd5e7
remove decorators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
179
diff
changeset
|
763 meta_data_dir = property(meta_data_dir) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
764 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
765 def meta_file_named(self, name): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
766 return os.path.join(self.meta_data_dir, name) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
767 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
768 def revmap_file(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
769 return self.meta_file_named('rev_map') |
181
e37f9d3fd5e7
remove decorators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
179
diff
changeset
|
770 revmap_file = property(revmap_file) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
771 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
772 def svn_url_file(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
773 return self.meta_file_named('url') |
181
e37f9d3fd5e7
remove decorators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
179
diff
changeset
|
774 svn_url_file = property(svn_url_file) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
775 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
776 def uuid_file(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
777 return self.meta_file_named('uuid') |
181
e37f9d3fd5e7
remove decorators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
179
diff
changeset
|
778 uuid_file = property(uuid_file) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
779 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
780 def branch_info_file(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
781 return self.meta_file_named('branch_info') |
181
e37f9d3fd5e7
remove decorators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
179
diff
changeset
|
782 branch_info_file = property(branch_info_file) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
783 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
784 def tag_info_file(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
785 return self.meta_file_named('tag_info') |
181
e37f9d3fd5e7
remove decorators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
179
diff
changeset
|
786 tag_info_file = property(tag_info_file) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
787 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
788 def tag_locations_file(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
789 return self.meta_file_named('tag_locations') |
181
e37f9d3fd5e7
remove decorators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
179
diff
changeset
|
790 tag_locations_file = property(tag_locations_file) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
791 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
792 def url(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
793 return open(self.svn_url_file).read() |
181
e37f9d3fd5e7
remove decorators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
179
diff
changeset
|
794 url = property(url) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
795 |
167
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
796 def authors_file(self): |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
797 return self.meta_file_named('authors') |
181
e37f9d3fd5e7
remove decorators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
179
diff
changeset
|
798 authors_file = property(authors_file) |
168
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
167
diff
changeset
|
799 |
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
|
800 def load_base_from_ctx(self, svnpath, path, ctx): |
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
|
801 if not self._is_path_valid(svnpath): |
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
|
802 return |
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
|
803 if path in ctx: |
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
|
804 fctx = ctx.filectx(path) |
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
|
805 base = fctx.data() |
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
|
806 if 'l' in fctx.flags(): |
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
|
807 base = 'link ' + base |
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
|
808 self.set_file(svnpath, base, 'x' in fctx.flags(), 'l' in fctx.flags()) |
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
|
809 else: |
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
|
810 self.missing_plaintexts.add(path) |
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
|
811 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
812 def delete_entry(self, path, revision_bogus, parent_baton, pool=None): |
116
30580c05dccc
hg_delta_editor: merge _is_path_valid() and _path_and_branch_from_path()
Patrick Mezard <pmezard@gmail.com>
parents:
111
diff
changeset
|
813 br_path, branch = self._path_and_branch_for_path(path) |
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
|
814 if br_path == '': |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
131
diff
changeset
|
815 self.branches_to_delete.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
|
816 if br_path is not None: |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
817 ha = self.get_parent_revision(self.current_rev.revnum, branch) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
818 if ha == revlog.nullid: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
819 return |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
820 ctx = self.repo.changectx(ha) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
821 if br_path not in ctx: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
822 br_path2 = '' |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
823 if br_path != '': |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
824 br_path2 = br_path + '/' |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
825 # assuming it is a directory |
174
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
826 self.externals[path] = 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
|
827 map(self.delete_file, [pat for pat in self.current_files.iterkeys() |
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
|
828 if pat.startswith(path)]) |
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
|
829 for f in ctx.walk(our_util.PrefixMatch(br_path2)): |
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
|
830 f_p = '%s/%s' % (path, f[len(br_path2):]) |
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
|
831 if f_p not in self.current_files: |
145
b37c401b7f92
hg_delta_editor: reset properties of deleted entries
Patrick Mezard <pmezard@gmail.com>
parents:
141
diff
changeset
|
832 self.delete_file(f_p) |
b37c401b7f92
hg_delta_editor: reset properties of deleted entries
Patrick Mezard <pmezard@gmail.com>
parents:
141
diff
changeset
|
833 self.delete_file(path) |
181
e37f9d3fd5e7
remove decorators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
179
diff
changeset
|
834 delete_entry = stash_exception_on_self(delete_entry) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
835 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
836 def open_file(self, path, parent_baton, base_revision, p=None): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
837 self.current_file = 'foobaz' |
119
ea65fe2b0856
hg_delta_editor: fix update of stray files in branches/
Patrick Mezard <pmezard@gmail.com>
parents:
116
diff
changeset
|
838 fpath, branch = self._path_and_branch_for_path(path) |
ea65fe2b0856
hg_delta_editor: fix update of stray files in branches/
Patrick Mezard <pmezard@gmail.com>
parents:
116
diff
changeset
|
839 if fpath: |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
840 self.current_file = path |
186
6266ba36ee15
Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
181
diff
changeset
|
841 self.ui.note('M %s\n' % path) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
842 if base_revision != -1: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
843 self.base_revision = base_revision |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
844 else: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
845 self.base_revision = 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
|
846 if self.current_file not in self.current_files: |
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
|
847 baserev = base_revision |
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
|
848 if baserev is None or baserev == -1: |
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
|
849 baserev = self.current_rev.revnum - 1 |
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
|
850 parent = self.get_parent_revision(baserev + 1, branch) |
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
|
851 self.load_base_from_ctx(path, fpath, self.repo.changectx(parent)) |
293
fa26c7ef0180
Exception clean-ups; use symbolic names & avoid Python 2.6 deprecations.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
211
diff
changeset
|
852 else: |
fa26c7ef0180
Exception clean-ups; use symbolic names & avoid Python 2.6 deprecations.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
211
diff
changeset
|
853 self.ui.warn('WARNING: Opening non-existant file %s\n' % path) |
181
e37f9d3fd5e7
remove decorators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
179
diff
changeset
|
854 open_file = stash_exception_on_self(open_file) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
855 |
73
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
72
diff
changeset
|
856 def aresamefiles(self, parentctx, childctx, files): |
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
|
857 """Assuming all files exist in childctx and parentctx, return True |
63ece4ea25c9
hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents:
67
diff
changeset
|
858 if none of them was changed in-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
|
859 """ |
63ece4ea25c9
hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents:
67
diff
changeset
|
860 if parentctx == childctx: |
63ece4ea25c9
hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents:
67
diff
changeset
|
861 return True |
63ece4ea25c9
hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents:
67
diff
changeset
|
862 if parentctx.rev() > childctx.rev(): |
63ece4ea25c9
hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents:
67
diff
changeset
|
863 parentctx, childctx = childctx, parentctx |
123
58de7aea8a77
Fix a bug in replay convert where replaced files that couldn't use replay
Augie Fackler <durin42@gmail.com>
parents:
120
diff
changeset
|
864 |
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
|
865 def selfandancestors(selfctx): |
63ece4ea25c9
hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents:
67
diff
changeset
|
866 yield selfctx |
63ece4ea25c9
hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents:
67
diff
changeset
|
867 for ctx in selfctx.ancestors(): |
63ece4ea25c9
hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents:
67
diff
changeset
|
868 yield ctx |
123
58de7aea8a77
Fix a bug in replay convert where replaced files that couldn't use replay
Augie Fackler <durin42@gmail.com>
parents:
120
diff
changeset
|
869 |
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
|
870 files = dict.fromkeys(files) |
63ece4ea25c9
hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents:
67
diff
changeset
|
871 for pctx in selfandancestors(childctx): |
63ece4ea25c9
hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents:
67
diff
changeset
|
872 if pctx.rev() <= parentctx.rev(): |
63ece4ea25c9
hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents:
67
diff
changeset
|
873 return True |
123
58de7aea8a77
Fix a bug in replay convert where replaced files that couldn't use replay
Augie Fackler <durin42@gmail.com>
parents:
120
diff
changeset
|
874 for f in pctx.files(): |
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
|
875 if f in files: |
63ece4ea25c9
hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents:
67
diff
changeset
|
876 return False |
63ece4ea25c9
hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents:
67
diff
changeset
|
877 # parentctx is not an ancestor of childctx, files are unrelated |
63ece4ea25c9
hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents:
67
diff
changeset
|
878 return False |
63ece4ea25c9
hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents:
67
diff
changeset
|
879 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
880 def add_file(self, path, parent_baton, copyfrom_path, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
881 copyfrom_revision, file_pool=None): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
882 self.current_file = 'foobaz' |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
883 self.base_revision = None |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
884 if path in self.deleted_files: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
885 del self.deleted_files[path] |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
886 fpath, branch = self._path_and_branch_for_path(path, existing=False) |
67
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
59
diff
changeset
|
887 if not fpath: |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
59
diff
changeset
|
888 return |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
889 if branch not in self.branches: |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
890 # we know this branch will exist now, because it has at least one file. Rock. |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
891 self.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
|
892 self.current_file = path |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
59
diff
changeset
|
893 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
|
894 self.ui.note('A %s\n' % 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
|
895 self.set_file(path, '', False, False) |
67
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
59
diff
changeset
|
896 return |
186
6266ba36ee15
Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
181
diff
changeset
|
897 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
|
898 (from_file, |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
59
diff
changeset
|
899 from_branch) = self._path_and_branch_for_path(copyfrom_path) |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
59
diff
changeset
|
900 if not from_file: |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
59
diff
changeset
|
901 self.missing_plaintexts.add(path) |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
59
diff
changeset
|
902 return |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
59
diff
changeset
|
903 ha = self.get_parent_revision(copyfrom_revision + 1, |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
59
diff
changeset
|
904 from_branch) |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
59
diff
changeset
|
905 ctx = self.repo.changectx(ha) |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
59
diff
changeset
|
906 if from_file in ctx: |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
59
diff
changeset
|
907 fctx = ctx.filectx(from_file) |
97
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
73
diff
changeset
|
908 flags = fctx.flags() |
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
|
909 self.set_file(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
|
910 if from_branch == 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
|
911 parentid = self.get_parent_revision(self.current_rev.revnum, |
63ece4ea25c9
hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents:
67
diff
changeset
|
912 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
|
913 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
|
914 parentctx = self.repo.changectx(parentid) |
73
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
72
diff
changeset
|
915 if self.aresamefiles(parentctx, ctx, [from_file]): |
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
|
916 self.copies[path] = from_file |
181
e37f9d3fd5e7
remove decorators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
179
diff
changeset
|
917 add_file = stash_exception_on_self(add_file) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
918 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
919 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
|
920 copyfrom_revision, dir_pool=None): |
174
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
921 self.dir_batons[path] = path |
116
30580c05dccc
hg_delta_editor: merge _is_path_valid() and _path_and_branch_from_path()
Patrick Mezard <pmezard@gmail.com>
parents:
111
diff
changeset
|
922 br_path, branch = self._path_and_branch_for_path(path) |
30580c05dccc
hg_delta_editor: merge _is_path_valid() and _path_and_branch_from_path()
Patrick Mezard <pmezard@gmail.com>
parents:
111
diff
changeset
|
923 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
|
924 if not copyfrom_path and not br_path: |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
925 self.commit_branches_empty[branch] = True |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
926 else: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
927 self.commit_branches_empty[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
|
928 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
|
929 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
|
930 if copyfrom_path: |
430af23bef4a
Performance fix for branches-from-tags in real replay, which is tied up with
Augie Fackler <durin42@gmail.com>
parents:
55
diff
changeset
|
931 tag = self._is_path_tag(copyfrom_path) |
430af23bef4a
Performance fix for branches-from-tags in real replay, which is tied up with
Augie Fackler <durin42@gmail.com>
parents:
55
diff
changeset
|
932 if tag not in self.tags: |
430af23bef4a
Performance fix for branches-from-tags in real replay, which is tied up with
Augie Fackler <durin42@gmail.com>
parents:
55
diff
changeset
|
933 tag = None |
430af23bef4a
Performance fix for branches-from-tags in real replay, which is tied up with
Augie Fackler <durin42@gmail.com>
parents:
55
diff
changeset
|
934 if not self._is_path_valid(copyfrom_path) and not tag: |
430af23bef4a
Performance fix for branches-from-tags in real replay, which is tied up with
Augie Fackler <durin42@gmail.com>
parents:
55
diff
changeset
|
935 self.missing_plaintexts.add('%s/' % path) |
174
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
936 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
|
937 if tag: |
430af23bef4a
Performance fix for branches-from-tags in real replay, which is tied up with
Augie Fackler <durin42@gmail.com>
parents:
55
diff
changeset
|
938 source_branch, source_rev = self.tags[tag] |
430af23bef4a
Performance fix for branches-from-tags in real replay, which is tied up with
Augie Fackler <durin42@gmail.com>
parents:
55
diff
changeset
|
939 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
|
940 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
|
941 source_rev = copyfrom_revision |
430af23bef4a
Performance fix for branches-from-tags in real replay, which is tied up with
Augie Fackler <durin42@gmail.com>
parents:
55
diff
changeset
|
942 cp_f, source_branch = self._path_and_branch_for_path(copyfrom_path) |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
943 if cp_f == '' and br_path == '': |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
944 self.branches[branch] = source_branch, source_rev, self.current_rev.revnum |
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
|
945 new_hash = self.get_parent_revision(source_rev + 1, |
430af23bef4a
Performance fix for branches-from-tags in real replay, which is tied up with
Augie Fackler <durin42@gmail.com>
parents:
55
diff
changeset
|
946 source_branch) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
947 if new_hash == node.nullid: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
948 self.missing_plaintexts.add('%s/' % path) |
174
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
949 return path |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
950 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
|
951 if cp_f != '/' and cp_f != '': |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
952 cp_f = '%s/' % cp_f |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
953 else: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
954 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
|
955 copies = {} |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
956 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
|
957 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
|
958 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
|
959 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
|
960 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
|
961 fp_c = path + '/' + f2 |
97
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
73
diff
changeset
|
962 self.set_file(fp_c, fctx.data(), 'x' in fctx.flags(), 'l' in fctx.flags()) |
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
|
963 if fp_c in self.deleted_files: |
63ece4ea25c9
hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents:
67
diff
changeset
|
964 del self.deleted_files[fp_c] |
63ece4ea25c9
hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents:
67
diff
changeset
|
965 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
|
966 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
|
967 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
|
968 # 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
|
969 # the source and destination revisions, or discard it completely. |
63ece4ea25c9
hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents:
67
diff
changeset
|
970 parentid = self.get_parent_revision(self.current_rev.revnum, 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
|
971 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
|
972 parentctx = self.repo.changectx(parentid) |
73
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
72
diff
changeset
|
973 if self.aresamefiles(parentctx, cp_f_ctx, copies.values()): |
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
|
974 self.copies.update(copies) |
174
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
975 return path |
181
e37f9d3fd5e7
remove decorators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
179
diff
changeset
|
976 add_directory = stash_exception_on_self(add_directory) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
977 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
978 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
|
979 if name == 'svn:executable': |
111
5497d1264b4d
fetch_command: Fix mis-converted executable when svn:executable was set to the
Augie Fackler <durin42@gmail.com>
parents:
97
diff
changeset
|
980 self.current_files_exec[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
|
981 elif name == 'svn:special': |
111
5497d1264b4d
fetch_command: Fix mis-converted executable when svn:executable was set to the
Augie Fackler <durin42@gmail.com>
parents:
97
diff
changeset
|
982 self.current_files_symlink[self.current_file] = bool(value is not None) |
181
e37f9d3fd5e7
remove decorators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
179
diff
changeset
|
983 change_file_prop = stash_exception_on_self(change_file_prop) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
984 |
174
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
985 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
|
986 if dir_baton is None: |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
987 return |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
988 path = self.dir_batons[dir_baton] |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
989 if name == 'svn:externals': |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
990 self.externals[path] = value |
181
e37f9d3fd5e7
remove decorators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
179
diff
changeset
|
991 change_dir_prop = stash_exception_on_self(change_dir_prop) |
174
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
992 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
993 def open_directory(self, path, parent_baton, base_revision, dir_pool=None): |
174
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
994 self.dir_batons[path] = path |
116
30580c05dccc
hg_delta_editor: merge _is_path_valid() and _path_and_branch_from_path()
Patrick Mezard <pmezard@gmail.com>
parents:
111
diff
changeset
|
995 p_, branch = self._path_and_branch_for_path(path) |
30580c05dccc
hg_delta_editor: merge _is_path_valid() and _path_and_branch_from_path()
Patrick Mezard <pmezard@gmail.com>
parents:
111
diff
changeset
|
996 if p_ == '': |
30580c05dccc
hg_delta_editor: merge _is_path_valid() and _path_and_branch_from_path()
Patrick Mezard <pmezard@gmail.com>
parents:
111
diff
changeset
|
997 self.commit_branches_empty[branch] = False |
174
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
998 return path |
181
e37f9d3fd5e7
remove decorators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
179
diff
changeset
|
999 open_directory = stash_exception_on_self(open_directory) |
174
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
1000 |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
1001 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
|
1002 if dir_baton is not None: |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
1003 del self.dir_batons[dir_baton] |
181
e37f9d3fd5e7
remove decorators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
179
diff
changeset
|
1004 close_directory = stash_exception_on_self(close_directory) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1005 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1006 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
|
1007 # 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
|
1008 # 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
|
1009 # 2) Missing a base text (bail quick since we have to fetch a full plaintext) |
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
|
1010 # 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
|
1011 base = '' |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1012 if not self._is_path_valid(self.current_file): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1013 return lambda x: 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
|
1014 assert self.current_file not in self.deleted_files, ( |
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
|
1015 'Cannot apply_textdelta to a deleted file: %s' % self.current_file) |
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
|
1016 assert (self.current_file in self.current_files |
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
|
1017 or self.current_file in self.missing_plaintexts), '%s not found' % self.current_file |
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
|
1018 if self.current_file in self.missing_plaintexts: |
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
|
1019 return lambda x: None |
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
|
1020 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
|
1021 source = cStringIO.StringIO(base) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1022 target = cStringIO.StringIO() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1023 self.stream = target |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1024 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1025 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
|
1026 if not callable(handler): #pragma: no cover |
197
43d56e973c3c
Replace a few asserts with aborts.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
186
diff
changeset
|
1027 raise util.Abort('Error in Subversion bindings: ' |
43d56e973c3c
Replace a few asserts with aborts.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
186
diff
changeset
|
1028 'cannot call handler!') |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1029 def txdelt_window(window): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1030 try: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1031 if not self._is_path_valid(self.current_file): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1032 return |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1033 handler(window, baton) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1034 # window being None means commit this file |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1035 if not window: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1036 self.current_files[self.current_file] = target.getvalue() |
146
4da9f20aef01
Add some more coverage directives.
Augie Fackler <durin42@gmail.com>
parents:
145
diff
changeset
|
1037 except core.SubversionException, e: #pragma: no cover |
293
fa26c7ef0180
Exception clean-ups; use symbolic names & avoid Python 2.6 deprecations.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
211
diff
changeset
|
1038 if e.apr_err == core.SVN_ERR_INCOMPLETE_DATA: |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1039 self.missing_plaintexts.add(self.current_file) |
146
4da9f20aef01
Add some more coverage directives.
Augie Fackler <durin42@gmail.com>
parents:
145
diff
changeset
|
1040 else: #pragma: no cover |
293
fa26c7ef0180
Exception clean-ups; use symbolic names & avoid Python 2.6 deprecations.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
211
diff
changeset
|
1041 raise util.Abort(*e.args) |
146
4da9f20aef01
Add some more coverage directives.
Augie Fackler <durin42@gmail.com>
parents:
145
diff
changeset
|
1042 except: #pragma: no cover |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1043 print len(base), self.current_file |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1044 self._exception_info = sys.exc_info() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1045 raise |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1046 return txdelt_window |
181
e37f9d3fd5e7
remove decorators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
179
diff
changeset
|
1047 apply_textdelta = stash_exception_on_self(apply_textdelta) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1048 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1049 class MissingPlainTextError(Exception): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1050 """Exception raised when the repo lacks a source file required for replaying |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1051 a txdelta. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1052 """ |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1053 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1054 class ReplayException(Exception): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1055 """Exception raised when you try and commit but the replay encountered an |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1056 exception. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1057 """ |