Mercurial > hgsubversion
annotate hg_delta_editor.py @ 168:4f26fa049452
authormap: Add tests, fix in stupid mode.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Tue, 30 Dec 2008 20:14:03 -0600 |
parents | 3cd6a7354207 |
children | f80132c5fea5 |
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 |
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
|
17 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
|
18 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
19 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
|
20 """pickle some data to a path atomically. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
21 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
22 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
|
23 during the pickle of that file. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
24 """ |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
25 try: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
26 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
|
27 f = os.fdopen(f, 'w') |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
28 pickle.dump(data, f) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
29 f.close() |
146
4da9f20aef01
Add some more coverage directives.
Augie Fackler <durin42@gmail.com>
parents:
145
diff
changeset
|
30 except: #pragma: no cover |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
31 raise |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
32 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
|
33 util.rename(path, file_path) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
34 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
35 def stash_exception_on_self(fn): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
36 """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
|
37 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
38 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
|
39 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
|
40 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
|
41 got an exception in the replay process. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
42 """ |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
43 def fun(self, *args, **kwargs): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
44 try: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
45 return fn(self, *args, **kwargs) |
146
4da9f20aef01
Add some more coverage directives.
Augie Fackler <durin42@gmail.com>
parents:
145
diff
changeset
|
46 except: #pragma: no cover |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
47 if not hasattr(self, '_exception_info'): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
48 self._exception_info = sys.exc_info() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
49 raise |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
50 return fun |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
51 |
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 class HgChangeReceiver(delta.Editor): |
33
a9c15cae50e5
Faster append-only revmap implementation.
Andreas Hartmetz <ahartmetz@gmail.com>
parents:
23
diff
changeset
|
54 def add_to_revmap(self, revnum, branch, node_hash): |
a9c15cae50e5
Faster append-only revmap implementation.
Andreas Hartmetz <ahartmetz@gmail.com>
parents:
23
diff
changeset
|
55 f = open(self.revmap_file, 'a') |
a9c15cae50e5
Faster append-only revmap implementation.
Andreas Hartmetz <ahartmetz@gmail.com>
parents:
23
diff
changeset
|
56 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
|
57 f.flush() |
a9c15cae50e5
Faster append-only revmap implementation.
Andreas Hartmetz <ahartmetz@gmail.com>
parents:
23
diff
changeset
|
58 f.close() |
a9c15cae50e5
Faster append-only revmap implementation.
Andreas Hartmetz <ahartmetz@gmail.com>
parents:
23
diff
changeset
|
59 self.revmap[revnum, branch] = node_hash |
a9c15cae50e5
Faster append-only revmap implementation.
Andreas Hartmetz <ahartmetz@gmail.com>
parents:
23
diff
changeset
|
60 |
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
|
61 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
|
62 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
|
63 tag_locations=['tags'], |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
64 authors=None): |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
65 """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
|
66 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
67 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
|
68 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
|
69 """ |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
70 if not ui_: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
71 ui_ = ui.ui() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
72 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
|
73 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
|
74 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
|
75 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
|
76 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
|
77 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
|
78 self.__setup_repo(path) |
146
4da9f20aef01
Add some more coverage directives.
Augie Fackler <durin42@gmail.com>
parents:
145
diff
changeset
|
79 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
|
80 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
|
81 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
82 self.subdir = subdir |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
83 if self.subdir and self.subdir[0] == '/': |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
84 self.subdir = self.subdir[1:] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
85 self.revmap = {} |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
86 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
|
87 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
|
88 self.branches = {} |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
89 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
|
90 f = open(self.branch_info_file) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
91 self.branches = pickle.load(f) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
92 f.close() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
93 self.tags = {} |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
94 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
|
95 f = open(self.tag_info_file) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
96 self.tags = pickle.load(f) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
97 f.close() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
98 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
|
99 f = open(self.tag_locations_file) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
100 self.tag_locations = pickle.load(f) |
8
c89f53103502
Another fix for Win32 compat.
Shun-ichi GOTO <shunichi.goto@gmail.com>
parents:
6
diff
changeset
|
101 f.close() |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
102 else: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
103 self.tag_locations = tag_locations |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
104 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
|
105 self.meta_data_dir) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
106 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
107 self.clear_current_info() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
108 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
|
109 self.authors = {} |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
110 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
|
111 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
|
112 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
|
113 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
|
114 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
|
115 self.writeauthors() |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
116 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
117 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
|
118 """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
|
119 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
120 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
|
121 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
|
122 """ |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
123 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
|
124 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
|
125 assert os.path.isfile(self.revmap_file) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
126 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
|
127 assert os.path.isfile(self.uuid_file) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
128 assert os.path.isfile(self.last_revision_handled_file) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
129 else: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
130 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
|
131 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
|
132 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
|
133 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
|
134 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
|
135 f.close() |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
136 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
137 def clear_current_info(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
138 '''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
|
139 revision can be replayed. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
140 ''' |
97
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
73
diff
changeset
|
141 # 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
|
142 self.current_files = {} |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
143 self.deleted_files = {} |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
144 self.current_rev = None |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
145 self.current_files_exec = {} |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
146 self.current_files_symlink = {} |
67
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
59
diff
changeset
|
147 # 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
|
148 self.copies = {} |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
149 self.missing_plaintexts = set() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
150 self.commit_branches_empty = {} |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
151 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
|
152 self.branches_to_delete = set() |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
153 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
154 def _save_metadata(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
155 '''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
|
156 every revision is created. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
157 ''' |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
158 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
|
159 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
|
160 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
161 def branches_in_paths(self, paths): |
72
9ec2a12c12ae
hg_delta_editor: make branches_in_paths() return the branch svn path too
Patrick Mezard <pmezard@gmail.com>
parents:
69
diff
changeset
|
162 '''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
|
163 to their branch path. |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
164 ''' |
72
9ec2a12c12ae
hg_delta_editor: make branches_in_paths() return the branch svn path too
Patrick Mezard <pmezard@gmail.com>
parents:
69
diff
changeset
|
165 branches = {} |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
166 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
|
167 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
|
168 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
|
169 branches[branch] = branchpath |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
170 return branches |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
171 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
172 def _path_and_branch_for_path(self, path): |
72
9ec2a12c12ae
hg_delta_editor: make branches_in_paths() return the branch svn path too
Patrick Mezard <pmezard@gmail.com>
parents:
69
diff
changeset
|
173 return self._split_branch_path(path)[:2] |
9ec2a12c12ae
hg_delta_editor: make branches_in_paths() return the branch svn path too
Patrick Mezard <pmezard@gmail.com>
parents:
69
diff
changeset
|
174 |
9ec2a12c12ae
hg_delta_editor: make branches_in_paths() return the branch svn path too
Patrick Mezard <pmezard@gmail.com>
parents:
69
diff
changeset
|
175 def _split_branch_path(self, 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
|
176 """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
|
177 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
|
178 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
179 Raises an exception if it can't perform its job. |
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
|
180 """ |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
181 path = self._normalize_path(path) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
182 if path.startswith('trunk'): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
183 p = path[len('trunk'):] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
184 if p and p[0] == '/': |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
185 p = p[1:] |
72
9ec2a12c12ae
hg_delta_editor: make branches_in_paths() return the branch svn path too
Patrick Mezard <pmezard@gmail.com>
parents:
69
diff
changeset
|
186 return p, None, 'trunk' |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
187 elif path.startswith('branches/'): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
188 p = path[len('branches/'):] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
189 br = p.split('/')[0] |
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 if br: |
30580c05dccc
hg_delta_editor: merge _is_path_valid() and _path_and_branch_from_path()
Patrick Mezard <pmezard@gmail.com>
parents:
111
diff
changeset
|
191 p = p[len(br)+1:] |
30580c05dccc
hg_delta_editor: merge _is_path_valid() and _path_and_branch_from_path()
Patrick Mezard <pmezard@gmail.com>
parents:
111
diff
changeset
|
192 if p and p[0] == '/': |
30580c05dccc
hg_delta_editor: merge _is_path_valid() and _path_and_branch_from_path()
Patrick Mezard <pmezard@gmail.com>
parents:
111
diff
changeset
|
193 p = p[1:] |
30580c05dccc
hg_delta_editor: merge _is_path_valid() and _path_and_branch_from_path()
Patrick Mezard <pmezard@gmail.com>
parents:
111
diff
changeset
|
194 return p, br, 'branches/' + br |
72
9ec2a12c12ae
hg_delta_editor: make branches_in_paths() return the branch svn path too
Patrick Mezard <pmezard@gmail.com>
parents:
69
diff
changeset
|
195 return None, None, None |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
196 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
197 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
|
198 """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
|
199 """ |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
200 self.current_rev = rev |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
201 |
97
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
73
diff
changeset
|
202 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
|
203 if islink: |
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
73
diff
changeset
|
204 data = 'link ' + data |
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
73
diff
changeset
|
205 self.current_files[path] = data |
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
73
diff
changeset
|
206 self.current_files_exec[path] = isexec |
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
73
diff
changeset
|
207 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
|
208 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
|
209 del self.deleted_files[path] |
97
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
73
diff
changeset
|
210 |
145
b37c401b7f92
hg_delta_editor: reset properties of deleted entries
Patrick Mezard <pmezard@gmail.com>
parents:
141
diff
changeset
|
211 def delete_file(self, path): |
b37c401b7f92
hg_delta_editor: reset properties of deleted entries
Patrick Mezard <pmezard@gmail.com>
parents:
141
diff
changeset
|
212 self.deleted_files[path] = True |
b37c401b7f92
hg_delta_editor: reset properties of deleted entries
Patrick Mezard <pmezard@gmail.com>
parents:
141
diff
changeset
|
213 self.current_files[path] = '' |
b37c401b7f92
hg_delta_editor: reset properties of deleted entries
Patrick Mezard <pmezard@gmail.com>
parents:
141
diff
changeset
|
214 self.current_files_exec[path] = False |
b37c401b7f92
hg_delta_editor: reset properties of deleted entries
Patrick Mezard <pmezard@gmail.com>
parents:
141
diff
changeset
|
215 self.current_files_symlink[path] = False |
b37c401b7f92
hg_delta_editor: reset properties of deleted entries
Patrick Mezard <pmezard@gmail.com>
parents:
141
diff
changeset
|
216 self.ui.status('D %s\n' % path) |
b37c401b7f92
hg_delta_editor: reset properties of deleted entries
Patrick Mezard <pmezard@gmail.com>
parents:
141
diff
changeset
|
217 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
218 def _normalize_path(self, path): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
219 '''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
|
220 have one. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
221 ''' |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
222 if path and path[0] == '/': |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
223 path = path[1:] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
224 if path and path.startswith(self.subdir): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
225 path = path[len(self.subdir):] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
226 if path and path[0] == '/': |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
227 path = path[1:] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
228 return path |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
229 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
230 def _is_path_valid(self, 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
|
231 return self._split_branch_path(path)[0] is not None |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
232 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
233 def _is_path_tag(self, path): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
234 """If path represents the path to a tag, returns the tag name. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
235 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
236 Otherwise, returns False. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
237 """ |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
238 path = self._normalize_path(path) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
239 for tags_path in self.tag_locations: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
240 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
|
241 len(path) > len('%s/' % tags_path)): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
242 return path[len(tags_path)+1:].split('/')[0] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
243 return False |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
244 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
245 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
|
246 number -= 1 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
247 if (number, branch) in self.revmap: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
248 return number, branch |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
249 real_num = 0 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
250 for num, br in self.revmap.iterkeys(): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
251 if br != branch: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
252 continue |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
253 if num <= number and num > real_num: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
254 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
|
255 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
|
256 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
|
257 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
|
258 # 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
|
259 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
|
260 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
|
261 # 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
|
262 # 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
|
263 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
|
264 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
|
265 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
|
266 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
|
267 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
|
268 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
|
269 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
|
270 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
|
271 parent_branch) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
272 if real_num != 0: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
273 return real_num, branch |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
274 return None, None |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
275 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
276 def get_parent_revision(self, number, branch): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
277 '''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
|
278 ''' |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
279 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
|
280 if r is not None: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
281 return self.revmap[r, br] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
282 return revlog.nullid |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
283 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
284 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
|
285 paths = revision.paths |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
286 added_branches = {} |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
287 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
|
288 self.branches_to_delete = set() |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
289 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
|
290 for p in sorted(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
|
291 fi, br = self._path_and_branch_for_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
|
292 if fi 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
|
293 if fi == '' and paths[p].action != 'D': |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
294 src_p = paths[p].copyfrom_path |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
295 src_rev = paths[p].copyfrom_rev |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
296 src_tag = self._is_path_tag(src_p) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
297 |
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
|
298 if not ((src_p and self._is_path_valid(src_p)) or |
430af23bef4a
Performance fix for branches-from-tags in real replay, which is tied up with
Augie Fackler <durin42@gmail.com>
parents:
55
diff
changeset
|
299 (src_tag and src_tag in self.tags)): |
120
f508c1fa19a5
hg_delta_editor: do not assume branches are copied from trunk by default
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
300 # The branch starts here and is not a copy |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
301 src_branch = None |
120
f508c1fa19a5
hg_delta_editor: do not assume branches are copied from trunk by default
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
302 src_rev = 0 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
303 elif src_tag: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
304 # this is a branch created from a tag. Note that this |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
305 # really does happen (see Django) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
306 src_branch, src_rev = self.tags[src_tag] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
307 else: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
308 # Not from a tag, and from a valid repo path |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
309 (src_p, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
310 src_branch) = self._path_and_branch_for_path(src_p) |
116
30580c05dccc
hg_delta_editor: merge _is_path_valid() and _path_and_branch_from_path()
Patrick Mezard <pmezard@gmail.com>
parents:
111
diff
changeset
|
311 if src_p is None: |
30580c05dccc
hg_delta_editor: merge _is_path_valid() and _path_and_branch_from_path()
Patrick Mezard <pmezard@gmail.com>
parents:
111
diff
changeset
|
312 continue |
155
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
154
diff
changeset
|
313 if (br not in self.branches or |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
154
diff
changeset
|
314 not (src_rev == 0 and src_branch == None)): |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
154
diff
changeset
|
315 added_branches[br] = src_branch, src_rev, revision.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
|
316 elif fi == '' and br in self.branches: |
155
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
154
diff
changeset
|
317 self.branches_to_delete.add(br) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
318 else: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
319 t_name = self._is_path_tag(p) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
320 if t_name == False: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
321 continue |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
322 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
|
323 # 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
|
324 # you. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
325 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
|
326 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
|
327 if file is None: |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
328 # 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
|
329 file = '' |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
330 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
|
331 if not from_tag: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
332 continue |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
333 branch, src_rev = self.tags[from_tag] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
334 if t_name not in added_tags: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
335 added_tags[t_name] = branch, src_rev |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
336 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
|
337 added_tags[t_name] = branch, src_rev |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
338 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
|
339 and t_name in self.tags): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
340 tags_to_delete.add(t_name) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
341 for t in tags_to_delete: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
342 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
|
343 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
|
344 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
|
345 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
|
346 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
|
347 (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
|
348 self.tags.update(added_tags) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
349 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
|
350 self._save_metadata() |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
351 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
352 def commit_current_delta(self): |
146
4da9f20aef01
Add some more coverage directives.
Augie Fackler <durin42@gmail.com>
parents:
145
diff
changeset
|
353 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
|
354 traceback.print_exception(*self._exception_info) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
355 raise ReplayException() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
356 if self.missing_plaintexts: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
357 raise MissingPlainTextError() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
358 files_to_commit = self.current_files.keys() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
359 files_to_commit.extend(self.current_files_symlink.keys()) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
360 files_to_commit.extend(self.current_files_exec.keys()) |
164
2a4b7a86af93
Remove unneeded call to list.
Martin Geisler <mg@daimi.au.dk>
parents:
156
diff
changeset
|
361 files_to_commit = sorted(set(files_to_commit)) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
362 branch_batches = {} |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
363 rev = self.current_rev |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
364 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
|
365 date += ' -0000' |
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 # 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
|
368 for f in files_to_commit: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
369 if not self._is_path_valid(f): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
370 continue |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
371 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
|
372 if b not in branch_batches: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
373 branch_batches[b] = [] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
374 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
|
375 # 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
|
376 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
|
377 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
|
378 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
|
379 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
|
380 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
|
381 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
|
382 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
|
383 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
|
384 # 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
|
385 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
|
386 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
|
387 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
|
388 # 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
|
389 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
|
390 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
|
391 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
|
392 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
|
393 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
|
394 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
|
395 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
|
396 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
|
397 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
|
398 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
|
399 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
|
400 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
|
401 {'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
|
402 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
|
403 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
|
404 'default')) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
405 for branch, files in branch_batches.iteritems(): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
406 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
|
407 del self.commit_branches_empty[branch] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
408 files = dict(files) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
409 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
410 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
|
411 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
|
412 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
|
413 continue |
154
6fa97cfbf62f
fetch: Refactor extra creation to be shared by real and diff replay.
Augie Fackler <durin42@gmail.com>
parents:
147
diff
changeset
|
414 # 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
|
415 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
|
416 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
|
417 self.subdir) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
418 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
|
419 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
|
420 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
|
421 continue |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
422 parent_ctx = self.repo.changectx(parents[0]) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
423 def filectxfn(repo, memctx, path): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
424 current_file = files[path] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
425 if current_file in self.deleted_files: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
426 raise IOError() |
67
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
59
diff
changeset
|
427 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
|
428 flags = parent_ctx.flags(path) |
97
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
73
diff
changeset
|
429 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
|
430 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
|
431 if current_file in self.current_files: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
432 data = self.current_files[current_file] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
433 if is_link: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
434 assert data.startswith('link ') |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
435 data = data[len('link '):] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
436 else: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
437 data = parent_ctx.filectx(path).data() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
438 return context.memfilectx(path=path, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
439 data=data, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
440 islink=is_link, isexec=is_exec, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
441 copied=copied) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
442 current_ctx = context.memctx(self.repo, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
443 parents, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
444 rev.message or '...', |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
445 files.keys(), |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
446 filectxfn, |
167
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
447 self.authorforsvnauthor(rev.author), |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
448 date, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
449 extra) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
450 new_hash = self.repo.commitctx(current_ctx) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
451 self.ui.status('committed as %s on branch %s\n' % |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
452 (node.hex(new_hash), (branch or 'default'))) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
453 if (rev.revnum, branch) not in self.revmap: |
33
a9c15cae50e5
Faster append-only revmap implementation.
Andreas Hartmetz <ahartmetz@gmail.com>
parents:
23
diff
changeset
|
454 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
|
455 # 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
|
456 for branch in self.commit_branches_empty: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
457 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
|
458 if ha == node.nullid: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
459 continue |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
460 parent_ctx = self.repo.changectx(ha) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
461 def del_all_files(*args): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
462 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
|
463 # 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
|
464 if self.commit_branches_empty[branch]: #pragma: no cover |
136
cf6fe8457570
Fix an apparent regression where branch name didn't get properly stored for
Augie Fackler <durin42@gmail.com>
parents:
133
diff
changeset
|
465 assert False, 'Got asked to commit non-closed branch as empty with no files. 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
|
466 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
|
467 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
|
468 self.subdir) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
469 current_ctx = context.memctx(self.repo, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
470 (ha, node.nullid), |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
471 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
|
472 [], |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
473 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
|
474 self.authorforsvnauthor(rev.author), |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
475 date, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
476 extra) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
477 new_hash = self.repo.commitctx(current_ctx) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
478 self.ui.status('committed as %s on branch %s\n' % |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
479 (node.hex(new_hash), (branch or 'default'))) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
480 if (rev.revnum, branch) not in self.revmap: |
33
a9c15cae50e5
Faster append-only revmap implementation.
Andreas Hartmetz <ahartmetz@gmail.com>
parents:
23
diff
changeset
|
481 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
|
482 self.clear_current_info() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
483 |
167
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
484 def authorforsvnauthor(self, author): |
168
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
167
diff
changeset
|
485 if(author in self.authors): |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
167
diff
changeset
|
486 return self.authors[author] |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
167
diff
changeset
|
487 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
|
488 |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
489 def readauthors(self, authorfile): |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
490 self.ui.status( |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
491 ('Reading authormap %s\n') |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
492 % authorfile) |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
493 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
|
494 for line in f: |
168
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
167
diff
changeset
|
495 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
|
496 continue |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
497 try: |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
498 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
|
499 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
|
500 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
|
501 if srcauth in self.authors and dstauth != self.authors[srcauth]: |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
502 self.ui.status( |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
503 ('Overriding mapping for author %s, was %s, now %s\n') |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
504 % (srcauth, 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
|
505 else: |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
506 self.ui.debug(('Mapping author %s to %s\n') |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
507 % (srcauth, dstauth)) |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
508 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
|
509 except IndexError: |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
510 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
|
511 ('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
|
512 % (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
|
513 f.close() |
168
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
167
diff
changeset
|
514 |
167
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
515 def writeauthors(self): |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
516 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
|
517 self.ui.status( |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
518 ('Writing author map file %s\n') |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
519 % 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
|
520 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
|
521 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
|
522 f.close() |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
523 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
524 @property |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
525 def meta_data_dir(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
526 return os.path.join(self.path, '.hg', 'svn') |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
527 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
528 def meta_file_named(self, name): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
529 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
|
530 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
531 @property |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
532 def revmap_file(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
533 return self.meta_file_named('rev_map') |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
534 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
535 @property |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
536 def svn_url_file(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
537 return self.meta_file_named('url') |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
538 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
539 @property |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
540 def uuid_file(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
541 return self.meta_file_named('uuid') |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
542 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
543 @property |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
544 def last_revision_handled_file(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
545 return self.meta_file_named('last_rev') |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
546 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
547 @property |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
548 def branch_info_file(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
549 return self.meta_file_named('branch_info') |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
550 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
551 @property |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
552 def tag_info_file(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
553 return self.meta_file_named('tag_info') |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
554 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
555 @property |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
556 def tag_locations_file(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
557 return self.meta_file_named('tag_locations') |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
558 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
559 @property |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
560 def url(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
561 return open(self.svn_url_file).read() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
562 |
167
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
563 @property |
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
164
diff
changeset
|
564 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
|
565 return self.meta_file_named('authors') |
168
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
167
diff
changeset
|
566 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
567 @stash_exception_on_self |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
568 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
|
569 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
|
570 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
|
571 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
|
572 if br_path is not None: |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
573 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
|
574 if ha == revlog.nullid: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
575 return |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
576 ctx = self.repo.changectx(ha) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
577 if br_path not in ctx: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
578 br_path2 = '' |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
579 if br_path != '': |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
580 br_path2 = br_path + '/' |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
581 # assuming it is a directory |
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
|
582 def delete_x(x): |
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
|
583 self.deleted_files[x] = True |
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
|
584 map(delete_x, [pat for pat in self.current_files.iterkeys() |
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
|
585 if pat.startswith(path)]) |
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
|
586 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
|
587 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
|
588 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
|
589 self.delete_file(f_p) |
b37c401b7f92
hg_delta_editor: reset properties of deleted entries
Patrick Mezard <pmezard@gmail.com>
parents:
141
diff
changeset
|
590 self.delete_file(path) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
591 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
592 @stash_exception_on_self |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
593 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
|
594 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
|
595 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
|
596 if fpath: |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
597 self.current_file = path |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
598 self.ui.status('M %s\n' % path) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
599 if base_revision != -1: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
600 self.base_revision = base_revision |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
601 else: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
602 self.base_revision = None |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
603 self.should_edit_most_recent_plaintext = True |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
604 |
73
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
72
diff
changeset
|
605 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
|
606 """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
|
607 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
|
608 """ |
63ece4ea25c9
hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents:
67
diff
changeset
|
609 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
|
610 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
|
611 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
|
612 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
|
613 |
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
|
614 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
|
615 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
|
616 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
|
617 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
|
618 |
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
|
619 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
|
620 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
|
621 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
|
622 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
|
623 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
|
624 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
|
625 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
|
626 # 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
|
627 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
|
628 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
629 @stash_exception_on_self |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
630 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
|
631 copyfrom_revision, file_pool=None): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
632 self.current_file = 'foobaz' |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
633 self.base_revision = None |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
634 if path in self.deleted_files: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
635 del self.deleted_files[path] |
67
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
59
diff
changeset
|
636 fpath, branch = self._path_and_branch_for_path(path) |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
59
diff
changeset
|
637 if not fpath: |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
59
diff
changeset
|
638 return |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
59
diff
changeset
|
639 self.current_file = path |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
59
diff
changeset
|
640 self.should_edit_most_recent_plaintext = False |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
59
diff
changeset
|
641 if not copyfrom_path: |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
59
diff
changeset
|
642 self.ui.status('A %s\n' % path) |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
59
diff
changeset
|
643 return |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
59
diff
changeset
|
644 self.ui.status('A+ %s\n' % path) |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
59
diff
changeset
|
645 (from_file, |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
59
diff
changeset
|
646 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
|
647 if not from_file: |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
59
diff
changeset
|
648 self.missing_plaintexts.add(path) |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
59
diff
changeset
|
649 return |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
59
diff
changeset
|
650 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
|
651 from_branch) |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
59
diff
changeset
|
652 ctx = self.repo.changectx(ha) |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
59
diff
changeset
|
653 if from_file in ctx: |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
59
diff
changeset
|
654 fctx = ctx.filectx(from_file) |
97
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
73
diff
changeset
|
655 flags = fctx.flags() |
67
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
59
diff
changeset
|
656 cur_file = self.current_file |
97
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
73
diff
changeset
|
657 self.set_file(cur_file, 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
|
658 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
|
659 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
|
660 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
|
661 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
|
662 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
|
663 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
|
664 self.copies[path] = from_file |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
665 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
666 @stash_exception_on_self |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
667 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
|
668 copyfrom_revision, dir_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
|
669 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
|
670 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
|
671 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
|
672 self.commit_branches_empty[branch] = True |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
673 else: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
674 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
|
675 if br_path is None or not copyfrom_path: |
41
496c0354019c
Improved handling of copies from outside of trunk.
Augie Fackler <durin42@gmail.com>
parents:
39
diff
changeset
|
676 return |
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
|
677 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
|
678 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
|
679 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
|
680 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
|
681 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
|
682 self.missing_plaintexts.add('%s/' % 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
|
683 return |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
684 |
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
|
685 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
|
686 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
|
687 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
|
688 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
|
689 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
|
690 cp_f, source_branch = self._path_and_branch_for_path(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
|
691 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
|
692 source_branch) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
693 if new_hash == node.nullid: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
694 self.missing_plaintexts.add('%s/' % path) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
695 return |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
696 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
|
697 if cp_f != '/' and cp_f != '': |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
698 cp_f = '%s/' % cp_f |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
699 else: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
700 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
|
701 copies = {} |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
702 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
|
703 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
|
704 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
|
705 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
|
706 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
|
707 fp_c = path + '/' + f2 |
97
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
73
diff
changeset
|
708 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
|
709 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
|
710 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
|
711 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
|
712 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
|
713 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
|
714 # 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
|
715 # 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
|
716 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
|
717 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
|
718 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
|
719 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
|
720 self.copies.update(copies) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
721 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
722 @stash_exception_on_self |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
723 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
|
724 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
|
725 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
|
726 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
|
727 self.current_files_symlink[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
|
728 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
729 @stash_exception_on_self |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
730 def open_directory(self, path, parent_baton, base_revision, dir_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
|
731 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
|
732 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
|
733 self.commit_branches_empty[branch] = False |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
734 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
735 @stash_exception_on_self |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
736 def apply_textdelta(self, file_baton, base_checksum, pool=None): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
737 base = '' |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
738 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
|
739 return lambda x: None |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
740 if (self.current_file in self.current_files |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
741 and not self.should_edit_most_recent_plaintext): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
742 base = self.current_files[self.current_file] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
743 elif (base_checksum is not None or |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
744 self.should_edit_most_recent_plaintext): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
745 p_, br = self._path_and_branch_for_path(self.current_file) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
746 par_rev = self.current_rev.revnum |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
747 if self.base_revision: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
748 par_rev = self.base_revision + 1 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
749 ha = self.get_parent_revision(par_rev, br) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
750 if ha != revlog.nullid: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
751 ctx = self.repo.changectx(ha) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
752 if not p_ in ctx: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
753 self.missing_plaintexts.add(self.current_file) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
754 # short circuit exit since we can't do anything anyway |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
755 return lambda x: None |
97
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
73
diff
changeset
|
756 fctx = ctx[p_] |
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
73
diff
changeset
|
757 base = fctx.data() |
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
73
diff
changeset
|
758 if 'l' in fctx.flags(): |
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
73
diff
changeset
|
759 base = 'link ' + base |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
760 source = cStringIO.StringIO(base) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
761 target = cStringIO.StringIO() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
762 self.stream = target |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
763 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
764 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
|
765 if not callable(handler): #pragma: no cover |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
766 # TODO(augie) Raise a real exception, don't just fail an assertion. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
767 assert False, 'handler not callable, bindings are broken' |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
768 def txdelt_window(window): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
769 try: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
770 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
|
771 return |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
772 handler(window, baton) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
773 # window being None means commit this file |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
774 if not window: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
775 self.current_files[self.current_file] = target.getvalue() |
146
4da9f20aef01
Add some more coverage directives.
Augie Fackler <durin42@gmail.com>
parents:
145
diff
changeset
|
776 except core.SubversionException, e: #pragma: no cover |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
777 if e.message == 'Delta source ended unexpectedly': |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
778 self.missing_plaintexts.add(self.current_file) |
146
4da9f20aef01
Add some more coverage directives.
Augie Fackler <durin42@gmail.com>
parents:
145
diff
changeset
|
779 else: #pragma: no cover |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
780 self._exception_info = sys.exc_info() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
781 raise |
146
4da9f20aef01
Add some more coverage directives.
Augie Fackler <durin42@gmail.com>
parents:
145
diff
changeset
|
782 except: #pragma: no cover |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
783 print len(base), self.current_file |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
784 self._exception_info = sys.exc_info() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
785 raise |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
786 return txdelt_window |
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 class MissingPlainTextError(Exception): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
789 """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
|
790 a txdelta. |
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 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
793 class ReplayException(Exception): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
794 """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
|
795 exception. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
796 """ |