Mercurial > hgsubversion
annotate hgsubversion/stupid.py @ 1549:8410a978c650
compathacks: be compatible with upstream 8a0cac20a1ad memfilectx change
See hg change 8a0cac20a1ad. Since the interface has changed
more than one time, switch to explicit keywords arguments to avoid
surprises.
Since hgsubversion targets hg >= 3.2.4, drop support for hg 3.0 and 3.1
here.
author | Jun Wu <quark@fb.com> |
---|---|
date | Tue, 19 Dec 2017 14:29:55 -0800 |
parents | d03995e69785 |
children | cff81f35b31e |
rev | line source |
---|---|
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1 import cStringIO |
531
cf4fe45bf8fd
Change all instantiations of IOError to set both errno and strerror.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
529
diff
changeset
|
2 import errno |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
3 import re |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
4 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
5 from mercurial import context |
822
033b86e0f56d
stupid/filemap: disable this since it doesn't currently work
Augie Fackler <durin42@gmail.com>
parents:
814
diff
changeset
|
6 from mercurial import node |
033b86e0f56d
stupid/filemap: disable this since it doesn't currently work
Augie Fackler <durin42@gmail.com>
parents:
814
diff
changeset
|
7 from mercurial import patch |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
8 from mercurial import revlog |
822
033b86e0f56d
stupid/filemap: disable this since it doesn't currently work
Augie Fackler <durin42@gmail.com>
parents:
814
diff
changeset
|
9 from mercurial import util as hgutil |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
10 |
1103
6e1dbf6cbc92
compathacks: new module to collect hacks to work around hg internals changing
Augie Fackler <raf@durin42.com>
parents:
1088
diff
changeset
|
11 import compathacks |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
12 import svnwrap |
174
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
13 import svnexternals |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
14 import util |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
15 |
859
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
16 # Here is a diff mixing content and property changes in svn >= 1.7 |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
17 # |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
18 # Index: a |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
19 # =================================================================== |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
20 # --- a (revision 12) |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
21 # +++ a (working copy) |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
22 # @@ -1,2 +1,3 @@ |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
23 # a |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
24 # a |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
25 # +a |
932
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
920
diff
changeset
|
26 # |
859
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
27 # Property changes on: a |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
28 # ___________________________________________________________________ |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
29 # Added: svn:executable |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
30 # ## -0,0 +1 ## |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
31 # +* |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
32 |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
33 class ParseError(Exception): |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
34 pass |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
35 |
859
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
36 index_header = r'''Index: ([^\n]*) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
37 =* |
859
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
38 ''' |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
39 |
859
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
40 property_header = r'''Property changes on: ([^\n]*) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
41 _* |
859
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
42 ''' |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
43 |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
44 headers_re = re.compile('(?:' + '|'.join([ |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
45 index_header, |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
46 property_header, |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
47 ]) + ')') |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
48 |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
49 property_special_added = r'''(?:Added|Name): (svn:special) |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
50 (?: \+|## -0,0 \+1 ## |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
51 \+)''' |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
52 |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
53 property_special_deleted = r'''(?:Deleted|Name): (svn:special) |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
54 (?: \-|## -1 \+0,0 ## |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
55 \-)''' |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
56 |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
57 property_exec_added = r'''(?:Added|Name): (svn:executable) |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
58 (?: \+|## -0,0 \+1 ## |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
59 \+)''' |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
60 |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
61 property_exec_deleted = r'''(?:Deleted|Name): (svn:executable) |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
62 (?: \-|## -1 \+0,0 ## |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
63 \-)''' |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
64 |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
65 properties_re = re.compile('(?:' + '|'.join([ |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
66 property_special_added, |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
67 property_special_deleted, |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
68 property_exec_added, |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
69 property_exec_deleted, |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
70 ]) + ')') |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
71 |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
72 class filediff: |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
73 def __init__(self, name): |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
74 self.name = name |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
75 self.diff = None |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
76 self.binary = False |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
77 self.executable = None |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
78 self.symlink = None |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
79 self.hasprops = False |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
80 |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
81 def isempty(self): |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
82 return (not self.diff and not self.binary and not self.hasprops) |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
83 |
860
4cf20a687bff
stupid: ignore directories svn:mergeinfo in svn >= 1.7
Patrick Mezard <patrick@mezard.eu>
parents:
859
diff
changeset
|
84 def maybedir(self): |
4cf20a687bff
stupid: ignore directories svn:mergeinfo in svn >= 1.7
Patrick Mezard <patrick@mezard.eu>
parents:
859
diff
changeset
|
85 return (not self.diff and not self.binary and self.hasprops |
4cf20a687bff
stupid: ignore directories svn:mergeinfo in svn >= 1.7
Patrick Mezard <patrick@mezard.eu>
parents:
859
diff
changeset
|
86 and self.symlink is None and self.executable is None) |
4cf20a687bff
stupid: ignore directories svn:mergeinfo in svn >= 1.7
Patrick Mezard <patrick@mezard.eu>
parents:
859
diff
changeset
|
87 |
859
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
88 def parsediff(diff): |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
89 changes = {} |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
90 headers = headers_re.split(diff)[1:] |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
91 if (len(headers) % 3) != 0: |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
92 # headers should be a sequence of (index file, property file, data) |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
93 raise ParseError('unexpected diff format') |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
94 files = [] |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
95 for i in xrange(len(headers)/3): |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
96 iname, pname, data = headers[3*i:3*i+3] |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
97 fname = iname or pname |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
98 if fname not in changes: |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
99 changes[fname] = filediff(fname) |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
100 files.append(changes[fname]) |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
101 f = changes[fname] |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
102 if iname is not None: |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
103 if data.strip(): |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
104 f.binary = data.lstrip().startswith( |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
105 'Cannot display: file marked as a binary type.') |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
106 if not f.binary and '@@' in data: |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
107 # Non-empty diff |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
108 f.diff = data |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
109 else: |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
110 f.hasprops = True |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
111 for m in properties_re.finditer(data): |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
112 p = m.group(1, 2, 3, 4) |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
113 if p[0] or p[1]: |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
114 f.symlink = bool(p[0]) |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
115 elif p[2] or p[3]: |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
116 f.executable = bool(p[2]) |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
117 return files |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
118 |
239
e2214c8fc91f
Put all stupid stuff in it's own module (separate from fetch-command).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
237
diff
changeset
|
119 |
e2214c8fc91f
Put all stupid stuff in it's own module (separate from fetch-command).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
237
diff
changeset
|
120 class BadPatchApply(Exception): |
e2214c8fc91f
Put all stupid stuff in it's own module (separate from fetch-command).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
237
diff
changeset
|
121 pass |
e2214c8fc91f
Put all stupid stuff in it's own module (separate from fetch-command).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
237
diff
changeset
|
122 |
837
805ef27fbcbe
hgsubversion/*.py: add space after comment symbol #
Yonggang Luo <luoyonggang@gmail.com>
parents:
832
diff
changeset
|
123 def print_your_svn_is_old_message(ui): # pragma: no cover |
239
e2214c8fc91f
Put all stupid stuff in it's own module (separate from fetch-command).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
237
diff
changeset
|
124 ui.status("In light of that, I'll fall back and do diffs, but it won't do " |
e2214c8fc91f
Put all stupid stuff in it's own module (separate from fetch-command).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
237
diff
changeset
|
125 "as good a job. You should really upgrade your server.\n") |
e2214c8fc91f
Put all stupid stuff in it's own module (separate from fetch-command).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
237
diff
changeset
|
126 |
127
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
127 def mempatchproxy(parentctx, files): |
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
128 # Avoid circular references patch.patchfile -> mempatch |
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
129 patchfile = patch.patchfile |
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
130 |
605
b72850177e5c
stupid: update monkeypatch for 91c58cf54eee
Augie Fackler <durin42@gmail.com>
parents:
601
diff
changeset
|
131 # TODO(durin42): make this a compat path for hg < 1.6. |
127
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
132 class mempatch(patchfile): |
605
b72850177e5c
stupid: update monkeypatch for 91c58cf54eee
Augie Fackler <durin42@gmail.com>
parents:
601
diff
changeset
|
133 def __init__(self, ui, fname, opener, missing=False, eolmode=None): |
b72850177e5c
stupid: update monkeypatch for 91c58cf54eee
Augie Fackler <durin42@gmail.com>
parents:
601
diff
changeset
|
134 patchfile.__init__(self, ui, fname, None, False, eolmode) |
133
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
135 |
127
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
136 def readlines(self, fname): |
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
137 if fname not in parentctx: |
531
cf4fe45bf8fd
Change all instantiations of IOError to set both errno and strerror.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
529
diff
changeset
|
138 raise IOError(errno.ENOENT, 'Cannot find %r to patch' % fname) |
129
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
139 fctx = parentctx[fname] |
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
140 data = fctx.data() |
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
141 if 'l' in fctx.flags(): |
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
142 data = 'link ' + data |
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
143 return cStringIO.StringIO(data).readlines() |
127
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
144 |
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
145 def writelines(self, fname, lines): |
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
146 files[fname] = ''.join(lines) |
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
147 |
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
148 def unlink(self, fname): |
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
149 files[fname] = None |
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
150 |
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
151 return mempatch |
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
152 |
200
2e8c527f0456
stupid replay: Don't actually try and apply diffs to files we don't have anyway.
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
153 |
416
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
415
diff
changeset
|
154 def filteriterhunks(meta): |
200
2e8c527f0456
stupid replay: Don't actually try and apply diffs to files we don't have anyway.
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
155 iterhunks = patch.iterhunks |
801
37ad86983a6d
stupid: fix patch.iterhunks() wrapper after hg.28762bb767dc
Patrick Mezard <pmezard@gmail.com>
parents:
787
diff
changeset
|
156 def filterhunks(*args, **kwargs): |
37ad86983a6d
stupid: fix patch.iterhunks() wrapper after hg.28762bb767dc
Patrick Mezard <pmezard@gmail.com>
parents:
787
diff
changeset
|
157 # ui, fp, sourcefile=None, textmode=False |
200
2e8c527f0456
stupid replay: Don't actually try and apply diffs to files we don't have anyway.
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
158 applycurrent = False |
424
3ae8edc3d8f1
stupid: handle the new eol option in hg-crew.
Augie Fackler <durin42@gmail.com>
parents:
422
diff
changeset
|
159 # Passing False instead of textmode because we should never |
3ae8edc3d8f1
stupid: handle the new eol option in hg-crew.
Augie Fackler <durin42@gmail.com>
parents:
422
diff
changeset
|
160 # be ignoring EOL type. |
1122
cc2049298699
stupid: remove pre-1.9 code from filteriterhunks
Sean Farley <sean.michael.farley@gmail.com>
parents:
1103
diff
changeset
|
161 fp = args[0] |
cc2049298699
stupid: remove pre-1.9 code from filteriterhunks
Sean Farley <sean.michael.farley@gmail.com>
parents:
1103
diff
changeset
|
162 gen = iterhunks(fp) |
552
2d44461e8617
fix filterhunks for both crew and 1.4
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
547
diff
changeset
|
163 for data in gen: |
200
2e8c527f0456
stupid replay: Don't actually try and apply diffs to files we don't have anyway.
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
164 if data[0] == 'file': |
416
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
415
diff
changeset
|
165 if data[1][1] in meta.filemap: |
200
2e8c527f0456
stupid replay: Don't actually try and apply diffs to files we don't have anyway.
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
166 applycurrent = True |
2e8c527f0456
stupid replay: Don't actually try and apply diffs to files we don't have anyway.
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
167 else: |
2e8c527f0456
stupid replay: Don't actually try and apply diffs to files we don't have anyway.
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
168 applycurrent = False |
2e8c527f0456
stupid replay: Don't actually try and apply diffs to files we don't have anyway.
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
169 assert data[0] != 'git', 'Filtering git hunks not supported.' |
2e8c527f0456
stupid replay: Don't actually try and apply diffs to files we don't have anyway.
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
170 if applycurrent: |
2e8c527f0456
stupid replay: Don't actually try and apply diffs to files we don't have anyway.
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
171 yield data |
2e8c527f0456
stupid replay: Don't actually try and apply diffs to files we don't have anyway.
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
172 return filterhunks |
2e8c527f0456
stupid replay: Don't actually try and apply diffs to files we don't have anyway.
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
173 |
1278 | 174 class svnbackend(patch.repobackend): |
175 def getfile(self, fname): | |
176 # In Mercurial >= 3.2, if fname is missing, data will be None and we | |
177 # should return None, None in that case. Earlier versions will raise | |
178 # an IOError which we let propagate up the stack. | |
179 f = super(svnbackend, self).getfile(fname) | |
180 if f is None: | |
181 return None, None | |
182 data, flags = f | |
183 if data is None: | |
184 return None, None | |
185 islink, isexec = flags | |
186 if islink: | |
187 data = 'link ' + data | |
188 return data, (islink, isexec) | |
814
d32735c507cd
stupid: use new patching facility introduced by adbf5e7df96d
Patrick Mezard <pmezard@gmail.com>
parents:
811
diff
changeset
|
189 |
d32735c507cd
stupid: use new patching facility introduced by adbf5e7df96d
Patrick Mezard <pmezard@gmail.com>
parents:
811
diff
changeset
|
190 def patchrepo(ui, meta, parentctx, patchfp): |
944
d6db289f1548
pull: add hgsubversion.filestoresize to control memory consumption
Patrick Mezard <patrick@mezard.eu>
parents:
932
diff
changeset
|
191 store = patch.filestore(util.getfilestoresize(ui)) |
814
d32735c507cd
stupid: use new patching facility introduced by adbf5e7df96d
Patrick Mezard <pmezard@gmail.com>
parents:
811
diff
changeset
|
192 try: |
d32735c507cd
stupid: use new patching facility introduced by adbf5e7df96d
Patrick Mezard <pmezard@gmail.com>
parents:
811
diff
changeset
|
193 touched = set() |
d32735c507cd
stupid: use new patching facility introduced by adbf5e7df96d
Patrick Mezard <pmezard@gmail.com>
parents:
811
diff
changeset
|
194 backend = svnbackend(ui, meta.repo, parentctx, store) |
932
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
920
diff
changeset
|
195 |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
920
diff
changeset
|
196 try: |
1320
2061fd988f3f
stupid: adapt to Mercurial 3.4 changes
Siddharth Agarwal <sid0@fb.com>
parents:
1287
diff
changeset
|
197 try: |
2061fd988f3f
stupid: adapt to Mercurial 3.4 changes
Siddharth Agarwal <sid0@fb.com>
parents:
1287
diff
changeset
|
198 ret = patch.patchbackend(ui, backend, patchfp, 0, files=touched) |
2061fd988f3f
stupid: adapt to Mercurial 3.4 changes
Siddharth Agarwal <sid0@fb.com>
parents:
1287
diff
changeset
|
199 except TypeError: |
2061fd988f3f
stupid: adapt to Mercurial 3.4 changes
Siddharth Agarwal <sid0@fb.com>
parents:
1287
diff
changeset
|
200 # Mercurial >= 3.4 have an extra prefix parameter |
2061fd988f3f
stupid: adapt to Mercurial 3.4 changes
Siddharth Agarwal <sid0@fb.com>
parents:
1287
diff
changeset
|
201 ret = patch.patchbackend(ui, backend, patchfp, 0, '', |
2061fd988f3f
stupid: adapt to Mercurial 3.4 changes
Siddharth Agarwal <sid0@fb.com>
parents:
1287
diff
changeset
|
202 files=touched) |
932
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
920
diff
changeset
|
203 if ret < 0: |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
920
diff
changeset
|
204 raise BadPatchApply('patching failed') |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
920
diff
changeset
|
205 if ret > 0: |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
920
diff
changeset
|
206 raise BadPatchApply('patching succeeded with fuzz') |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
920
diff
changeset
|
207 except patch.PatchError, e: |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
920
diff
changeset
|
208 raise BadPatchApply(str(e)) |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
920
diff
changeset
|
209 |
814
d32735c507cd
stupid: use new patching facility introduced by adbf5e7df96d
Patrick Mezard <pmezard@gmail.com>
parents:
811
diff
changeset
|
210 files = {} |
d32735c507cd
stupid: use new patching facility introduced by adbf5e7df96d
Patrick Mezard <pmezard@gmail.com>
parents:
811
diff
changeset
|
211 for f in touched: |
d32735c507cd
stupid: use new patching facility introduced by adbf5e7df96d
Patrick Mezard <pmezard@gmail.com>
parents:
811
diff
changeset
|
212 try: |
d32735c507cd
stupid: use new patching facility introduced by adbf5e7df96d
Patrick Mezard <pmezard@gmail.com>
parents:
811
diff
changeset
|
213 data, mode, copied = store.getfile(f) |
d32735c507cd
stupid: use new patching facility introduced by adbf5e7df96d
Patrick Mezard <pmezard@gmail.com>
parents:
811
diff
changeset
|
214 files[f] = data |
d32735c507cd
stupid: use new patching facility introduced by adbf5e7df96d
Patrick Mezard <pmezard@gmail.com>
parents:
811
diff
changeset
|
215 except IOError: |
d32735c507cd
stupid: use new patching facility introduced by adbf5e7df96d
Patrick Mezard <pmezard@gmail.com>
parents:
811
diff
changeset
|
216 files[f] = None |
d32735c507cd
stupid: use new patching facility introduced by adbf5e7df96d
Patrick Mezard <pmezard@gmail.com>
parents:
811
diff
changeset
|
217 return files |
d32735c507cd
stupid: use new patching facility introduced by adbf5e7df96d
Patrick Mezard <pmezard@gmail.com>
parents:
811
diff
changeset
|
218 finally: |
d32735c507cd
stupid: use new patching facility introduced by adbf5e7df96d
Patrick Mezard <pmezard@gmail.com>
parents:
811
diff
changeset
|
219 store.close() |
d32735c507cd
stupid: use new patching facility introduced by adbf5e7df96d
Patrick Mezard <pmezard@gmail.com>
parents:
811
diff
changeset
|
220 |
532
b847e1a3ccd0
stupid: use real branch path in diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
531
diff
changeset
|
221 def diff_branchrev(ui, svn, meta, branch, branchpath, r, parentctx): |
108
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
222 """Extract all 'branch' content at a given revision. |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
223 |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
224 Return a tuple (files, filectxfn) where 'files' is the list of all files |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
225 in the branch at the given revision, and 'filectxfn' is a memctx compatible |
109
460443a96497
fetch_command: only raise BadPatchApply() from stupid_diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
108
diff
changeset
|
226 callable to retrieve individual file information. Raise BadPatchApply upon |
460443a96497
fetch_command: only raise BadPatchApply() from stupid_diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
108
diff
changeset
|
227 error. |
108
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
228 """ |
109
460443a96497
fetch_command: only raise BadPatchApply() from stupid_diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
108
diff
changeset
|
229 try: |
536
460eb781d840
Handle subdirectory tags in stupid mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents:
535
diff
changeset
|
230 prev, pbranch, ppath = meta.get_source_rev(ctx=parentctx) |
460eb781d840
Handle subdirectory tags in stupid mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents:
535
diff
changeset
|
231 except KeyError: |
460eb781d840
Handle subdirectory tags in stupid mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents:
535
diff
changeset
|
232 prev, pbranch, ppath = None, None, None |
460eb781d840
Handle subdirectory tags in stupid mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents:
535
diff
changeset
|
233 try: |
460eb781d840
Handle subdirectory tags in stupid mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents:
535
diff
changeset
|
234 if prev is None or pbranch == branch: |
109
460443a96497
fetch_command: only raise BadPatchApply() from stupid_diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
108
diff
changeset
|
235 # letting patch handle binaries sounded |
460443a96497
fetch_command: only raise BadPatchApply() from stupid_diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
108
diff
changeset
|
236 # cool, but it breaks patch in sad ways |
920
1be4ea4f3c0d
stupid: diff with the good revision when restoring branch
Patrick Mezard <patrick@mezard.eu>
parents:
864
diff
changeset
|
237 d = svn.get_unified_diff(branchpath, r.revnum, other_rev=prev, |
1be4ea4f3c0d
stupid: diff with the good revision when restoring branch
Patrick Mezard <patrick@mezard.eu>
parents:
864
diff
changeset
|
238 deleted=False, ignore_type=False) |
109
460443a96497
fetch_command: only raise BadPatchApply() from stupid_diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
108
diff
changeset
|
239 else: |
532
b847e1a3ccd0
stupid: use real branch path in diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
531
diff
changeset
|
240 d = svn.get_unified_diff(branchpath, r.revnum, |
536
460eb781d840
Handle subdirectory tags in stupid mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents:
535
diff
changeset
|
241 other_path=ppath, other_rev=prev, |
109
460443a96497
fetch_command: only raise BadPatchApply() from stupid_diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
108
diff
changeset
|
242 deleted=True, ignore_type=True) |
460443a96497
fetch_command: only raise BadPatchApply() from stupid_diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
108
diff
changeset
|
243 if d: |
460443a96497
fetch_command: only raise BadPatchApply() from stupid_diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
108
diff
changeset
|
244 raise BadPatchApply('branch creation with mods') |
460443a96497
fetch_command: only raise BadPatchApply() from stupid_diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
108
diff
changeset
|
245 except svnwrap.SubversionRepoCanNotDiff: |
460443a96497
fetch_command: only raise BadPatchApply() from stupid_diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
108
diff
changeset
|
246 raise BadPatchApply('subversion diffing code is not supported') |
601
0fe490ce2fbb
isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
588
diff
changeset
|
247 except svnwrap.SubversionException, e: |
0fe490ce2fbb
isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
588
diff
changeset
|
248 if len(e.args) > 1 and e.args[1] != svnwrap.ERR_FS_NOT_FOUND: |
109
460443a96497
fetch_command: only raise BadPatchApply() from stupid_diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
108
diff
changeset
|
249 raise |
460443a96497
fetch_command: only raise BadPatchApply() from stupid_diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
108
diff
changeset
|
250 raise BadPatchApply('previous revision does not exist') |
169
f1919e1c35bf
fetch_command: cancel patching when encountering binary diffs
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
251 if '\0' in d: |
f1919e1c35bf
fetch_command: cancel patching when encountering binary diffs
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
252 raise BadPatchApply('binary diffs are not supported') |
127
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
253 files_data = {} |
859
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
254 changed = parsediff(d) |
529
68667b627bd5
stupid: replace dicts with sets
Patrick Mezard <pmezard@gmail.com>
parents:
528
diff
changeset
|
255 # Here we ensure that all files, including the new empty ones |
68667b627bd5
stupid: replace dicts with sets
Patrick Mezard <pmezard@gmail.com>
parents:
528
diff
changeset
|
256 # are marked as touched. Content is loaded on demand. |
859
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
257 touched_files = set(f.name for f in changed) |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
258 d2 = '\n'.join(f.diff for f in changed if f.diff) |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
259 if changed: |
811
ccefff0c4f91
stupid: extract old patching code into patchrepo()
Patrick Mezard <pmezard@gmail.com>
parents:
801
diff
changeset
|
260 files_data = patchrepo(ui, meta, parentctx, cStringIO.StringIO(d2)) |
127
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
261 for x in files_data.iterkeys(): |
186
6266ba36ee15
Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
185
diff
changeset
|
262 ui.note('M %s\n' % x) |
108
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
263 else: |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
264 ui.status('Not using patch for %s, diff had no hunks.\n' % |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
265 r.revnum) |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
266 |
528
052050ca59d6
replay: disable maybeedit filtering, could discard copy records
Patrick Mezard <pmezard@gmail.com>
parents:
517
diff
changeset
|
267 unknown_files = set() |
108
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
268 for p in r.paths: |
528
052050ca59d6
replay: disable maybeedit filtering, could discard copy records
Patrick Mezard <pmezard@gmail.com>
parents:
517
diff
changeset
|
269 action = r.paths[p].action |
532
b847e1a3ccd0
stupid: use real branch path in diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
531
diff
changeset
|
270 if not p.startswith(branchpath) or action not in 'DR': |
528
052050ca59d6
replay: disable maybeedit filtering, could discard copy records
Patrick Mezard <pmezard@gmail.com>
parents:
517
diff
changeset
|
271 continue |
532
b847e1a3ccd0
stupid: use real branch path in diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
531
diff
changeset
|
272 if branchpath: |
b847e1a3ccd0
stupid: use real branch path in diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
531
diff
changeset
|
273 p2 = p[len(branchpath)+1:].strip('/') |
528
052050ca59d6
replay: disable maybeedit filtering, could discard copy records
Patrick Mezard <pmezard@gmail.com>
parents:
517
diff
changeset
|
274 else: |
052050ca59d6
replay: disable maybeedit filtering, could discard copy records
Patrick Mezard <pmezard@gmail.com>
parents:
517
diff
changeset
|
275 p2 = p |
052050ca59d6
replay: disable maybeedit filtering, could discard copy records
Patrick Mezard <pmezard@gmail.com>
parents:
517
diff
changeset
|
276 if p2 in parentctx: |
052050ca59d6
replay: disable maybeedit filtering, could discard copy records
Patrick Mezard <pmezard@gmail.com>
parents:
517
diff
changeset
|
277 toucheds = [p2] |
052050ca59d6
replay: disable maybeedit filtering, could discard copy records
Patrick Mezard <pmezard@gmail.com>
parents:
517
diff
changeset
|
278 else: |
108
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
279 # If this isn't in the parent ctx, it must've been a dir |
528
052050ca59d6
replay: disable maybeedit filtering, could discard copy records
Patrick Mezard <pmezard@gmail.com>
parents:
517
diff
changeset
|
280 toucheds = [f for f in parentctx if f.startswith(p2 + '/')] |
052050ca59d6
replay: disable maybeedit filtering, could discard copy records
Patrick Mezard <pmezard@gmail.com>
parents:
517
diff
changeset
|
281 if action == 'R': |
052050ca59d6
replay: disable maybeedit filtering, could discard copy records
Patrick Mezard <pmezard@gmail.com>
parents:
517
diff
changeset
|
282 # Files were replaced, we don't know if they still exist |
052050ca59d6
replay: disable maybeedit filtering, could discard copy records
Patrick Mezard <pmezard@gmail.com>
parents:
517
diff
changeset
|
283 unknown_files.update(toucheds) |
052050ca59d6
replay: disable maybeedit filtering, could discard copy records
Patrick Mezard <pmezard@gmail.com>
parents:
517
diff
changeset
|
284 else: |
052050ca59d6
replay: disable maybeedit filtering, could discard copy records
Patrick Mezard <pmezard@gmail.com>
parents:
517
diff
changeset
|
285 files_data.update((f, None) for f in toucheds) |
108
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
286 |
529
68667b627bd5
stupid: replace dicts with sets
Patrick Mezard <pmezard@gmail.com>
parents:
528
diff
changeset
|
287 touched_files.update(files_data) |
68667b627bd5
stupid: replace dicts with sets
Patrick Mezard <pmezard@gmail.com>
parents:
528
diff
changeset
|
288 touched_files.update(unknown_files) |
129
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
289 |
860
4cf20a687bff
stupid: ignore directories svn:mergeinfo in svn >= 1.7
Patrick Mezard <patrick@mezard.eu>
parents:
859
diff
changeset
|
290 # As of svn 1.7, diff may contain a lot of property changes for |
4cf20a687bff
stupid: ignore directories svn:mergeinfo in svn >= 1.7
Patrick Mezard <patrick@mezard.eu>
parents:
859
diff
changeset
|
291 # directories. We do not what to include these in our touched |
4cf20a687bff
stupid: ignore directories svn:mergeinfo in svn >= 1.7
Patrick Mezard <patrick@mezard.eu>
parents:
859
diff
changeset
|
292 # files list so we try to filter them while minimizing the number |
4cf20a687bff
stupid: ignore directories svn:mergeinfo in svn >= 1.7
Patrick Mezard <patrick@mezard.eu>
parents:
859
diff
changeset
|
293 # of svn API calls. |
4cf20a687bff
stupid: ignore directories svn:mergeinfo in svn >= 1.7
Patrick Mezard <patrick@mezard.eu>
parents:
859
diff
changeset
|
294 property_files = set(f.name for f in changed if f.maybedir()) |
4cf20a687bff
stupid: ignore directories svn:mergeinfo in svn >= 1.7
Patrick Mezard <patrick@mezard.eu>
parents:
859
diff
changeset
|
295 property_files.discard('.') |
4cf20a687bff
stupid: ignore directories svn:mergeinfo in svn >= 1.7
Patrick Mezard <patrick@mezard.eu>
parents:
859
diff
changeset
|
296 touched_files.discard('.') |
4cf20a687bff
stupid: ignore directories svn:mergeinfo in svn >= 1.7
Patrick Mezard <patrick@mezard.eu>
parents:
859
diff
changeset
|
297 branchprefix = (branchpath and branchpath + '/') or branchpath |
4cf20a687bff
stupid: ignore directories svn:mergeinfo in svn >= 1.7
Patrick Mezard <patrick@mezard.eu>
parents:
859
diff
changeset
|
298 for f in list(property_files): |
4cf20a687bff
stupid: ignore directories svn:mergeinfo in svn >= 1.7
Patrick Mezard <patrick@mezard.eu>
parents:
859
diff
changeset
|
299 if f in parentctx: |
4cf20a687bff
stupid: ignore directories svn:mergeinfo in svn >= 1.7
Patrick Mezard <patrick@mezard.eu>
parents:
859
diff
changeset
|
300 continue |
4cf20a687bff
stupid: ignore directories svn:mergeinfo in svn >= 1.7
Patrick Mezard <patrick@mezard.eu>
parents:
859
diff
changeset
|
301 # We can be smarter here by checking if f is a subcomponent |
4cf20a687bff
stupid: ignore directories svn:mergeinfo in svn >= 1.7
Patrick Mezard <patrick@mezard.eu>
parents:
859
diff
changeset
|
302 # of a know path in parentctx or touched_files. KISS for now. |
4cf20a687bff
stupid: ignore directories svn:mergeinfo in svn >= 1.7
Patrick Mezard <patrick@mezard.eu>
parents:
859
diff
changeset
|
303 kind = svn.checkpath(branchprefix + f, r.revnum) |
4cf20a687bff
stupid: ignore directories svn:mergeinfo in svn >= 1.7
Patrick Mezard <patrick@mezard.eu>
parents:
859
diff
changeset
|
304 if kind == 'd': |
4cf20a687bff
stupid: ignore directories svn:mergeinfo in svn >= 1.7
Patrick Mezard <patrick@mezard.eu>
parents:
859
diff
changeset
|
305 touched_files.discard(f) |
4cf20a687bff
stupid: ignore directories svn:mergeinfo in svn >= 1.7
Patrick Mezard <patrick@mezard.eu>
parents:
859
diff
changeset
|
306 |
532
b847e1a3ccd0
stupid: use real branch path in diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
531
diff
changeset
|
307 copies = getcopies(svn, meta, branch, branchpath, r, touched_files, |
110
a4dcffaa6538
fetch_command: pass parent changectx instead of identifier
Patrick Mezard <pmezard@gmail.com>
parents:
109
diff
changeset
|
308 parentctx) |
108
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
309 |
863
c24130e9ddb7
stupid: add comment noting why we track modified binary files
Augie Fackler <raf@durin42.com>
parents:
859
diff
changeset
|
310 # We note binary files because svn's diff format doesn't describe |
c24130e9ddb7
stupid: add comment noting why we track modified binary files
Augie Fackler <raf@durin42.com>
parents:
859
diff
changeset
|
311 # what changed, only that a change occurred. This means we'll have |
c24130e9ddb7
stupid: add comment noting why we track modified binary files
Augie Fackler <raf@durin42.com>
parents:
859
diff
changeset
|
312 # to pull them as fulltexts from the server outside the diff |
c24130e9ddb7
stupid: add comment noting why we track modified binary files
Augie Fackler <raf@durin42.com>
parents:
859
diff
changeset
|
313 # apply. |
859
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
314 binary_files = set(f.name for f in changed if f.binary) |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
315 exec_files = dict((f.name, f.executable) for f in changed |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
316 if f.executable is not None) |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
317 link_files = dict((f.name, f.symlink) for f in changed |
1d07e86f5797
stupid: handle changes in svn 1.7 diff format
Patrick Mezard <patrick@mezard.eu>
parents:
837
diff
changeset
|
318 if f.symlink is not None) |
108
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
319 def filectxfn(repo, memctx, path): |
129
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
320 if path in files_data and files_data[path] is None: |
1240
57000c9b53f1
stupid: in diff_branchrev, use compat hack for filectxfn for deleted files
Siddharth Agarwal <sid0@fb.com>
parents:
1228
diff
changeset
|
321 return compathacks.filectxfn_deleted(memctx, path) |
129
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
322 |
528
052050ca59d6
replay: disable maybeedit filtering, could discard copy records
Patrick Mezard <pmezard@gmail.com>
parents:
517
diff
changeset
|
323 if path in binary_files or path in unknown_files: |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
497
diff
changeset
|
324 pa = path |
532
b847e1a3ccd0
stupid: use real branch path in diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
531
diff
changeset
|
325 if branchpath: |
b847e1a3ccd0
stupid: use real branch path in diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
531
diff
changeset
|
326 pa = branchpath + '/' + path |
1240
57000c9b53f1
stupid: in diff_branchrev, use compat hack for filectxfn for deleted files
Siddharth Agarwal <sid0@fb.com>
parents:
1228
diff
changeset
|
327 try: |
57000c9b53f1
stupid: in diff_branchrev, use compat hack for filectxfn for deleted files
Siddharth Agarwal <sid0@fb.com>
parents:
1228
diff
changeset
|
328 data, mode = svn.get_file(pa, r.revnum) |
57000c9b53f1
stupid: in diff_branchrev, use compat hack for filectxfn for deleted files
Siddharth Agarwal <sid0@fb.com>
parents:
1228
diff
changeset
|
329 except IOError: |
57000c9b53f1
stupid: in diff_branchrev, use compat hack for filectxfn for deleted files
Siddharth Agarwal <sid0@fb.com>
parents:
1228
diff
changeset
|
330 return compathacks.filectxfn_deleted_reraise(memctx) |
128
bab5bcbbb3dc
fetch_command: in stupid mode, load binary files when necessary
Patrick Mezard <pmezard@gmail.com>
parents:
127
diff
changeset
|
331 isexe = 'x' in mode |
bab5bcbbb3dc
fetch_command: in stupid mode, load binary files when necessary
Patrick Mezard <pmezard@gmail.com>
parents:
127
diff
changeset
|
332 islink = 'l' in mode |
129
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
333 else: |
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
334 isexe = exec_files.get(path, 'x' in parentctx.flags(path)) |
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
335 islink = link_files.get(path, 'l' in parentctx.flags(path)) |
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
336 data = '' |
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
337 if path in files_data: |
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
338 data = files_data[path] |
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
339 if islink: |
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
340 data = data[len('link '):] |
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
341 elif path in parentctx: |
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
342 data = parentctx[path].data() |
133
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
343 |
108
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
344 copied = copies.get(path) |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
497
diff
changeset
|
345 # TODO this branch feels like it should not be required, |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
497
diff
changeset
|
346 # and this may actually imply a bug in getcopies |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
497
diff
changeset
|
347 if copied not in parentctx.manifest(): |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
497
diff
changeset
|
348 copied = None |
1221
f87502fd4d65
stupid: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
1103
diff
changeset
|
349 return compathacks.makememfilectx(repo, |
1549
8410a978c650
compathacks: be compatible with upstream 8a0cac20a1ad memfilectx change
Jun Wu <quark@fb.com>
parents:
1527
diff
changeset
|
350 memctx=memctx, |
1221
f87502fd4d65
stupid: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
1103
diff
changeset
|
351 path=path, |
f87502fd4d65
stupid: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
1103
diff
changeset
|
352 data=data, |
f87502fd4d65
stupid: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
1103
diff
changeset
|
353 islink=islink, |
f87502fd4d65
stupid: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
1103
diff
changeset
|
354 isexec=isexe, |
f87502fd4d65
stupid: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
1103
diff
changeset
|
355 copied=copied) |
108
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
356 |
129
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
357 return list(touched_files), filectxfn |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
358 |
588
2723152c8111
stupid: fix getcopies() logic
Patrick Mezard <pmezard@gmail.com>
parents:
583
diff
changeset
|
359 def makecopyfinder(meta, r, branchpath): |
73
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
360 """Return a function detecting copies. |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
361 |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
362 Returned copyfinder(path) returns None if no copy information can |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
363 be found or ((source, sourcerev), sourcepath) where "sourcepath" is the |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
364 copy source path, "sourcerev" the source svn revision and "source" is the |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
365 copy record path causing the copy to occur. If a single file was copied |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
366 "sourcepath" and "source" are the same, while file copies dectected from |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
367 directory copies return the copied source directory in "source". |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
368 """ |
588
2723152c8111
stupid: fix getcopies() logic
Patrick Mezard <pmezard@gmail.com>
parents:
583
diff
changeset
|
369 # cache changeset contexts and map them to source svn revisions |
2723152c8111
stupid: fix getcopies() logic
Patrick Mezard <pmezard@gmail.com>
parents:
583
diff
changeset
|
370 ctxs = {} |
2723152c8111
stupid: fix getcopies() logic
Patrick Mezard <pmezard@gmail.com>
parents:
583
diff
changeset
|
371 def getctx(branch, svnrev): |
2723152c8111
stupid: fix getcopies() logic
Patrick Mezard <pmezard@gmail.com>
parents:
583
diff
changeset
|
372 if svnrev in ctxs: |
2723152c8111
stupid: fix getcopies() logic
Patrick Mezard <pmezard@gmail.com>
parents:
583
diff
changeset
|
373 return ctxs[svnrev] |
2723152c8111
stupid: fix getcopies() logic
Patrick Mezard <pmezard@gmail.com>
parents:
583
diff
changeset
|
374 changeid = meta.get_parent_revision(svnrev + 1, branch, True) |
2723152c8111
stupid: fix getcopies() logic
Patrick Mezard <pmezard@gmail.com>
parents:
583
diff
changeset
|
375 ctx = None |
2723152c8111
stupid: fix getcopies() logic
Patrick Mezard <pmezard@gmail.com>
parents:
583
diff
changeset
|
376 if changeid != revlog.nullid: |
2723152c8111
stupid: fix getcopies() logic
Patrick Mezard <pmezard@gmail.com>
parents:
583
diff
changeset
|
377 ctx = meta.repo.changectx(changeid) |
2723152c8111
stupid: fix getcopies() logic
Patrick Mezard <pmezard@gmail.com>
parents:
583
diff
changeset
|
378 ctxs[svnrev] = ctx |
2723152c8111
stupid: fix getcopies() logic
Patrick Mezard <pmezard@gmail.com>
parents:
583
diff
changeset
|
379 return ctx |
2723152c8111
stupid: fix getcopies() logic
Patrick Mezard <pmezard@gmail.com>
parents:
583
diff
changeset
|
380 |
73
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
381 # filter copy information for current branch |
495
44bde69b6c49
stupid: detect renames with empty branchpath properly
Augie Fackler <durin42@gmail.com>
parents:
494
diff
changeset
|
382 branchpath = (branchpath and branchpath + '/') or '' |
73
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
383 copies = [] |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
384 for path, e in r.paths.iteritems(): |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
385 if not e.copyfrom_path: |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
386 continue |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
387 if not path.startswith(branchpath): |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
388 continue |
588
2723152c8111
stupid: fix getcopies() logic
Patrick Mezard <pmezard@gmail.com>
parents:
583
diff
changeset
|
389 # compute converted source path and revision |
2723152c8111
stupid: fix getcopies() logic
Patrick Mezard <pmezard@gmail.com>
parents:
583
diff
changeset
|
390 frompath, frombranch = meta.split_branch_path(e.copyfrom_path)[:2] |
2723152c8111
stupid: fix getcopies() logic
Patrick Mezard <pmezard@gmail.com>
parents:
583
diff
changeset
|
391 if frompath is None: |
2723152c8111
stupid: fix getcopies() logic
Patrick Mezard <pmezard@gmail.com>
parents:
583
diff
changeset
|
392 continue |
2723152c8111
stupid: fix getcopies() logic
Patrick Mezard <pmezard@gmail.com>
parents:
583
diff
changeset
|
393 fromctx = getctx(frombranch, e.copyfrom_rev) |
2723152c8111
stupid: fix getcopies() logic
Patrick Mezard <pmezard@gmail.com>
parents:
583
diff
changeset
|
394 if fromctx is None: |
73
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
395 continue |
588
2723152c8111
stupid: fix getcopies() logic
Patrick Mezard <pmezard@gmail.com>
parents:
583
diff
changeset
|
396 destpath = path[len(branchpath):] |
2723152c8111
stupid: fix getcopies() logic
Patrick Mezard <pmezard@gmail.com>
parents:
583
diff
changeset
|
397 copies.append((destpath, (frompath, fromctx))) |
73
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
398 |
163 | 399 copies.sort(reverse=True) |
73
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
400 exactcopies = dict(copies) |
101
a3b717e4abf5
Cleanups based on pyflakes output.
Augie Fackler <durin42@gmail.com>
parents:
98
diff
changeset
|
401 |
73
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
402 def finder(path): |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
403 if path in exactcopies: |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
404 return exactcopies[path], exactcopies[path][0] |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
405 # look for parent directory copy, longest first |
588
2723152c8111
stupid: fix getcopies() logic
Patrick Mezard <pmezard@gmail.com>
parents:
583
diff
changeset
|
406 for dest, (source, sourcectx) in copies: |
73
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
407 dest = dest + '/' |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
408 if not path.startswith(dest): |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
409 continue |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
410 sourcepath = source + '/' + path[len(dest):] |
588
2723152c8111
stupid: fix getcopies() logic
Patrick Mezard <pmezard@gmail.com>
parents:
583
diff
changeset
|
411 return (source, sourcectx), sourcepath |
73
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
412 return None |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
413 |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
414 return finder |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
415 |
416
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
415
diff
changeset
|
416 def getcopies(svn, meta, branch, branchpath, r, files, parentctx): |
73
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
417 """Return a mapping {dest: source} for every file copied into r. |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
418 """ |
110
a4dcffaa6538
fetch_command: pass parent changectx instead of identifier
Patrick Mezard <pmezard@gmail.com>
parents:
109
diff
changeset
|
419 if parentctx.node() == revlog.nullid: |
73
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
420 return {} |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
421 |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
422 # Extract svn copy information, group them by copy source. |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
423 # The idea is to duplicate the replay behaviour where copies are |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
424 # evaluated per copy event (one event for all files in a directory copy, |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
425 # one event for single file copy). We assume that copy events match |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
426 # copy sources in revision info. |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
427 svncopies = {} |
588
2723152c8111
stupid: fix getcopies() logic
Patrick Mezard <pmezard@gmail.com>
parents:
583
diff
changeset
|
428 finder = makecopyfinder(meta, r, branchpath) |
73
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
429 for f in files: |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
430 copy = finder(f) |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
431 if copy: |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
432 svncopies.setdefault(copy[0], []).append((f, copy[1])) |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
433 if not svncopies: |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
434 return {} |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
435 |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
436 # check svn copies really make sense in mercurial |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
437 hgcopies = {} |
588
2723152c8111
stupid: fix getcopies() logic
Patrick Mezard <pmezard@gmail.com>
parents:
583
diff
changeset
|
438 for (sourcepath, sourcectx), copies in svncopies.iteritems(): |
496
5e0dfe59d4c3
copies: fix under-reporting of copies in hg
Augie Fackler <durin42@gmail.com>
parents:
495
diff
changeset
|
439 for k, v in copies: |
497
cad864ed29de
util: make aresamefiles take one file and just be issamefile instead.
Augie Fackler <durin42@gmail.com>
parents:
496
diff
changeset
|
440 if not util.issamefile(sourcectx, parentctx, v): |
496
5e0dfe59d4c3
copies: fix under-reporting of copies in hg
Augie Fackler <durin42@gmail.com>
parents:
495
diff
changeset
|
441 continue |
5e0dfe59d4c3
copies: fix under-reporting of copies in hg
Augie Fackler <durin42@gmail.com>
parents:
495
diff
changeset
|
442 hgcopies.update({k: v}) |
73
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
443 return hgcopies |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
444 |
762
c31a1f92e1c6
svnexternals: preliminary support for subrepos based externals
Patrick Mezard <pmezard@gmail.com>
parents:
758
diff
changeset
|
445 def fetch_externals(ui, svn, branchpath, r, parentctx): |
174
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
446 """Extract svn:externals for the current revision and branch |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
447 |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
448 Return an externalsfile instance or None if there are no externals |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
449 to convert and never were. |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
450 """ |
762
c31a1f92e1c6
svnexternals: preliminary support for subrepos based externals
Patrick Mezard <pmezard@gmail.com>
parents:
758
diff
changeset
|
451 externals = svnexternals.parse(ui, parentctx) |
174
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
452 # Detect property additions only, changes are handled by checking |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
453 # existing entries individually. Projects are unlikely to store |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
454 # externals on many different root directories, so we trade code |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
455 # duplication and complexity for a constant lookup price at every |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
456 # revision in the common case. |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
457 dirs = set(externals) |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
458 if parentctx.node() == revlog.nullid: |
832
e9af7eba88db
globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents:
831
diff
changeset
|
459 dirs.update([p for p, k in svn.list_files(branchpath, r.revnum) if k == 'd']) |
174
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
460 dirs.add('') |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
461 else: |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
497
diff
changeset
|
462 branchprefix = (branchpath and branchpath + '/') or branchpath |
174
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
463 for path, e in r.paths.iteritems(): |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
464 if e.action == 'D': |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
465 continue |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
466 if not path.startswith(branchprefix) and path != branchpath: |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
467 continue |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
468 kind = svn.checkpath(path, r.revnum) |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
469 if kind != 'd': |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
470 continue |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
471 path = path[len(branchprefix):] |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
472 dirs.add(path) |
184
d3ea6c98a086
Do not recurse for externals on copied directory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
182
diff
changeset
|
473 if e.action == 'M' or (e.action == 'A' and e.copyfrom_path): |
d3ea6c98a086
Do not recurse for externals on copied directory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
182
diff
changeset
|
474 # Do not recurse in copied directories, changes are marked |
d3ea6c98a086
Do not recurse for externals on copied directory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
182
diff
changeset
|
475 # as 'M', except for the copied one. |
174
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
476 continue |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
477 for child, k in svn.list_files(branchprefix + path, r.revnum): |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
478 if k == 'd': |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
479 dirs.add((path + '/' + child).strip('/')) |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
480 |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
481 # Retrieve new or updated values |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
482 for dir in dirs: |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
483 try: |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
497
diff
changeset
|
484 dpath = (branchpath and branchpath + '/' + dir) or dir |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
497
diff
changeset
|
485 values = svn.list_props(dpath, r.revnum) |
174
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
486 externals[dir] = values.get('svn:externals', '') |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
487 except IOError: |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
488 externals[dir] = '' |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
489 return externals |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
490 |
239
e2214c8fc91f
Put all stupid stuff in it's own module (separate from fetch-command).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
237
diff
changeset
|
491 |
416
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
415
diff
changeset
|
492 def fetch_branchrev(svn, meta, branch, branchpath, r, parentctx): |
77
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
493 """Extract all 'branch' content at a given revision. |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
494 |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
495 Return a tuple (files, filectxfn) where 'files' is the list of all files |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
496 in the branch at the given revision, and 'filectxfn' is a memctx compatible |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
497 callable to retrieve individual file information. |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
498 """ |
87
b033d74be76b
fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents:
79
diff
changeset
|
499 files = [] |
110
a4dcffaa6538
fetch_command: pass parent changectx instead of identifier
Patrick Mezard <pmezard@gmail.com>
parents:
109
diff
changeset
|
500 if parentctx.node() == revlog.nullid: |
88
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
501 # Initial revision, fetch all files |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
502 for path, kind in svn.list_files(branchpath, r.revnum): |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
503 if kind == 'f': |
87
b033d74be76b
fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents:
79
diff
changeset
|
504 files.append(path) |
88
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
505 else: |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
497
diff
changeset
|
506 branchprefix = (branchpath and branchpath + '/') or '' |
88
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
507 for path, e in r.paths.iteritems(): |
952
9c3b4f59e7e6
stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents:
944
diff
changeset
|
508 if path == branchpath: |
9c3b4f59e7e6
stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents:
944
diff
changeset
|
509 if e.action != 'R' or branch not in meta.branches: |
9c3b4f59e7e6
stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents:
944
diff
changeset
|
510 # Full-branch replacements are handled as reverts, |
9c3b4f59e7e6
stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents:
944
diff
changeset
|
511 # skip everything else. |
9c3b4f59e7e6
stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents:
944
diff
changeset
|
512 continue |
9c3b4f59e7e6
stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents:
944
diff
changeset
|
513 elif not path.startswith(branchprefix): |
87
b033d74be76b
fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents:
79
diff
changeset
|
514 continue |
417
8630d1ebcdb9
svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
416
diff
changeset
|
515 if not meta.is_path_valid(path): |
179
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
516 continue |
88
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
517 kind = svn.checkpath(path, r.revnum) |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
518 path = path[len(branchprefix):] |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
519 if kind == 'f': |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
520 files.append(path) |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
521 elif kind == 'd': |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
522 if e.action == 'M': |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
523 continue |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
524 dirpath = branchprefix + path |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
525 for child, k in svn.list_files(dirpath, r.revnum): |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
526 if k == 'f': |
656
1add57910c82
stupid: remove an incorrect, implicit assumption in fetch_branchrev()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
648
diff
changeset
|
527 if path: |
1add57910c82
stupid: remove an incorrect, implicit assumption in fetch_branchrev()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
648
diff
changeset
|
528 childpath = '%s/%s' % (path, child) |
1add57910c82
stupid: remove an incorrect, implicit assumption in fetch_branchrev()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
648
diff
changeset
|
529 else: |
1add57910c82
stupid: remove an incorrect, implicit assumption in fetch_branchrev()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
648
diff
changeset
|
530 childpath = child |
1add57910c82
stupid: remove an incorrect, implicit assumption in fetch_branchrev()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
648
diff
changeset
|
531 files.append(childpath) |
583
a016b253910b
stupid: handle directory replacement in very stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
574
diff
changeset
|
532 if e.action == 'R': |
a016b253910b
stupid: handle directory replacement in very stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
574
diff
changeset
|
533 # Check all files in replaced directory |
a016b253910b
stupid: handle directory replacement in very stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
574
diff
changeset
|
534 path = path + '/' |
a016b253910b
stupid: handle directory replacement in very stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
574
diff
changeset
|
535 files += [f for f in parentctx if f.startswith(path)] |
88
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
536 else: |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
537 if path in parentctx: |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
538 files.append(path) |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
539 continue |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
540 # Assume it's a deleted directory |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
541 path = path + '/' |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
542 deleted = [f for f in parentctx if f.startswith(path)] |
101
a3b717e4abf5
Cleanups based on pyflakes output.
Augie Fackler <durin42@gmail.com>
parents:
98
diff
changeset
|
543 files += deleted |
87
b033d74be76b
fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents:
79
diff
changeset
|
544 |
416
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
415
diff
changeset
|
545 copies = getcopies(svn, meta, branch, branchpath, r, files, parentctx) |
101
a3b717e4abf5
Cleanups based on pyflakes output.
Augie Fackler <durin42@gmail.com>
parents:
98
diff
changeset
|
546 |
77
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
547 def filectxfn(repo, memctx, path): |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
497
diff
changeset
|
548 svnpath = path |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
497
diff
changeset
|
549 if branchpath: |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
497
diff
changeset
|
550 svnpath = branchpath + '/' + path |
1241
eecfbd1fac0a
stupid: in fetch_branchrev, use compat hack for filectxfn for deleted files
Siddharth Agarwal <sid0@fb.com>
parents:
1240
diff
changeset
|
551 try: |
eecfbd1fac0a
stupid: in fetch_branchrev, use compat hack for filectxfn for deleted files
Siddharth Agarwal <sid0@fb.com>
parents:
1240
diff
changeset
|
552 data, mode = svn.get_file(svnpath, r.revnum) |
eecfbd1fac0a
stupid: in fetch_branchrev, use compat hack for filectxfn for deleted files
Siddharth Agarwal <sid0@fb.com>
parents:
1240
diff
changeset
|
553 except IOError: |
eecfbd1fac0a
stupid: in fetch_branchrev, use compat hack for filectxfn for deleted files
Siddharth Agarwal <sid0@fb.com>
parents:
1240
diff
changeset
|
554 return compathacks.filectxfn_deleted_reraise(memctx) |
77
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
555 isexec = 'x' in mode |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
556 islink = 'l' in mode |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
557 copied = copies.get(path) |
535
715d2e3e153b
stupid: port hack from stupid to moderately stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
532
diff
changeset
|
558 # TODO this branch feels like it should not be required, |
715d2e3e153b
stupid: port hack from stupid to moderately stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
532
diff
changeset
|
559 # and this may actually imply a bug in getcopies |
715d2e3e153b
stupid: port hack from stupid to moderately stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
532
diff
changeset
|
560 if copied not in parentctx.manifest(): |
715d2e3e153b
stupid: port hack from stupid to moderately stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
532
diff
changeset
|
561 copied = None |
1221
f87502fd4d65
stupid: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
1103
diff
changeset
|
562 return compathacks.makememfilectx(repo, |
1549
8410a978c650
compathacks: be compatible with upstream 8a0cac20a1ad memfilectx change
Jun Wu <quark@fb.com>
parents:
1527
diff
changeset
|
563 memctx=memctx, |
1221
f87502fd4d65
stupid: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
1103
diff
changeset
|
564 path=path, |
f87502fd4d65
stupid: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
1103
diff
changeset
|
565 data=data, |
f87502fd4d65
stupid: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
1103
diff
changeset
|
566 islink=islink, |
f87502fd4d65
stupid: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
1103
diff
changeset
|
567 isexec=isexec, |
f87502fd4d65
stupid: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
1103
diff
changeset
|
568 copied=copied) |
77
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
569 |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
570 return files, filectxfn |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
571 |
416
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
415
diff
changeset
|
572 def checkbranch(meta, r, branch): |
1472
cf79525f507c
maps: change branchedits to accept revnum directly
Jun Wu <quark@fb.com>
parents:
1434
diff
changeset
|
573 branchedits = meta.revmap.branchedits(branch, r.revnum) |
373
8c91e6a69d05
Get rid of duplicate branch closing detection code for stupid mode.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
368
diff
changeset
|
574 if not branchedits: |
8c91e6a69d05
Get rid of duplicate branch closing detection code for stupid mode.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
368
diff
changeset
|
575 return None |
8c91e6a69d05
Get rid of duplicate branch closing detection code for stupid mode.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
368
diff
changeset
|
576 branchtip = branchedits[0][1] |
416
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
415
diff
changeset
|
577 for child in meta.repo[branchtip].children(): |
375
af9fc01299b4
Make branch closing more Mercurial-like.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
374
diff
changeset
|
578 b = child.branch() != 'default' and child.branch() or None |
af9fc01299b4
Make branch closing more Mercurial-like.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
374
diff
changeset
|
579 if b == branch and child.extra().get('close'): |
373
8c91e6a69d05
Get rid of duplicate branch closing detection code for stupid mode.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
368
diff
changeset
|
580 return None |
8c91e6a69d05
Get rid of duplicate branch closing detection code for stupid mode.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
368
diff
changeset
|
581 return branchtip |
8c91e6a69d05
Get rid of duplicate branch closing detection code for stupid mode.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
368
diff
changeset
|
582 |
1046
36fe4b316a6b
stupid: fix --startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1045
diff
changeset
|
583 def branches_in_paths(meta, tbdelta, paths, revnum, checkpath, listdir, |
36fe4b316a6b
stupid: fix --startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1045
diff
changeset
|
584 firstrun): |
377
7e9269555e72
Move HgChangeReceiver.branches_in_paths() to the stupid module.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
376
diff
changeset
|
585 '''Given a list of paths, return mapping of all branches touched |
7e9269555e72
Move HgChangeReceiver.branches_in_paths() to the stupid module.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
376
diff
changeset
|
586 to their branch path. |
7e9269555e72
Move HgChangeReceiver.branches_in_paths() to the stupid module.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
376
diff
changeset
|
587 ''' |
7e9269555e72
Move HgChangeReceiver.branches_in_paths() to the stupid module.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
376
diff
changeset
|
588 branches = {} |
1046
36fe4b316a6b
stupid: fix --startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1045
diff
changeset
|
589 if firstrun: |
36fe4b316a6b
stupid: fix --startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1045
diff
changeset
|
590 paths_need_discovery = [p for (p, t) in listdir('', revnum) |
36fe4b316a6b
stupid: fix --startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1045
diff
changeset
|
591 if t == 'f'] |
36fe4b316a6b
stupid: fix --startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1045
diff
changeset
|
592 else: |
36fe4b316a6b
stupid: fix --startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1045
diff
changeset
|
593 paths_need_discovery = [] |
36fe4b316a6b
stupid: fix --startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1045
diff
changeset
|
594 |
377
7e9269555e72
Move HgChangeReceiver.branches_in_paths() to the stupid module.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
376
diff
changeset
|
595 for p in paths: |
540
8dc759dc9ca9
svnmeta: remove split_branch_tag() exacttag argument
Patrick Mezard <pmezard@gmail.com>
parents:
536
diff
changeset
|
596 relpath, branch, branchpath = meta.split_branch_path(p) |
377
7e9269555e72
Move HgChangeReceiver.branches_in_paths() to the stupid module.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
376
diff
changeset
|
597 if relpath is not None: |
7e9269555e72
Move HgChangeReceiver.branches_in_paths() to the stupid module.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
376
diff
changeset
|
598 branches[branch] = branchpath |
517
ef288fb7f2fe
svnmeta: is_path_tag() is really get_path_tag()
Patrick Mezard <pmezard@gmail.com>
parents:
514
diff
changeset
|
599 elif paths[p].action == 'D' and not meta.get_path_tag(p): |
417
8630d1ebcdb9
svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
416
diff
changeset
|
600 ln = meta.localname(p) |
377
7e9269555e72
Move HgChangeReceiver.branches_in_paths() to the stupid module.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
376
diff
changeset
|
601 # must check in branches_to_delete as well, because this runs after we |
7e9269555e72
Move HgChangeReceiver.branches_in_paths() to the stupid module.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
376
diff
changeset
|
602 # already updated the branch map |
416
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
415
diff
changeset
|
603 if ln in meta.branches or ln in tbdelta['branches'][1]: |
377
7e9269555e72
Move HgChangeReceiver.branches_in_paths() to the stupid module.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
376
diff
changeset
|
604 branches[ln] = p |
7e9269555e72
Move HgChangeReceiver.branches_in_paths() to the stupid module.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
376
diff
changeset
|
605 else: |
7e9269555e72
Move HgChangeReceiver.branches_in_paths() to the stupid module.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
376
diff
changeset
|
606 paths_need_discovery.append(p) |
7e9269555e72
Move HgChangeReceiver.branches_in_paths() to the stupid module.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
376
diff
changeset
|
607 |
7e9269555e72
Move HgChangeReceiver.branches_in_paths() to the stupid module.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
376
diff
changeset
|
608 if not paths_need_discovery: |
7e9269555e72
Move HgChangeReceiver.branches_in_paths() to the stupid module.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
376
diff
changeset
|
609 return branches |
7e9269555e72
Move HgChangeReceiver.branches_in_paths() to the stupid module.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
376
diff
changeset
|
610 |
7e9269555e72
Move HgChangeReceiver.branches_in_paths() to the stupid module.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
376
diff
changeset
|
611 actually_files = [] |
7e9269555e72
Move HgChangeReceiver.branches_in_paths() to the stupid module.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
376
diff
changeset
|
612 while paths_need_discovery: |
7e9269555e72
Move HgChangeReceiver.branches_in_paths() to the stupid module.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
376
diff
changeset
|
613 p = paths_need_discovery.pop(0) |
1087
ed3cae9a0930
stupid: cleanup unnecessary, always-true if statement
David Schleimer <dschleimer@fb.com>
parents:
1086
diff
changeset
|
614 if checkpath(p, revnum) == 'f': |
ed3cae9a0930
stupid: cleanup unnecessary, always-true if statement
David Schleimer <dschleimer@fb.com>
parents:
1086
diff
changeset
|
615 actually_files.append(p) |
ed3cae9a0930
stupid: cleanup unnecessary, always-true if statement
David Schleimer <dschleimer@fb.com>
parents:
1086
diff
changeset
|
616 # if there's a copyfrom_path and there were files inside that copyfrom, |
ed3cae9a0930
stupid: cleanup unnecessary, always-true if statement
David Schleimer <dschleimer@fb.com>
parents:
1086
diff
changeset
|
617 # we need to detect those branches. It's a little thorny and slow, but |
ed3cae9a0930
stupid: cleanup unnecessary, always-true if statement
David Schleimer <dschleimer@fb.com>
parents:
1086
diff
changeset
|
618 # seems to be the best option. |
ed3cae9a0930
stupid: cleanup unnecessary, always-true if statement
David Schleimer <dschleimer@fb.com>
parents:
1086
diff
changeset
|
619 elif paths[p].copyfrom_path and not meta.get_path_tag(p): |
ed3cae9a0930
stupid: cleanup unnecessary, always-true if statement
David Schleimer <dschleimer@fb.com>
parents:
1086
diff
changeset
|
620 paths_need_discovery.extend(['%s/%s' % (p, x[0]) |
ed3cae9a0930
stupid: cleanup unnecessary, always-true if statement
David Schleimer <dschleimer@fb.com>
parents:
1086
diff
changeset
|
621 for x in listdir(p, revnum) |
ed3cae9a0930
stupid: cleanup unnecessary, always-true if statement
David Schleimer <dschleimer@fb.com>
parents:
1086
diff
changeset
|
622 if x[1] == 'f']) |
377
7e9269555e72
Move HgChangeReceiver.branches_in_paths() to the stupid module.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
376
diff
changeset
|
623 |
1088
31917a6be09c
stupid: only check branch mappings for discovered files once
David Schleimer <dschleimer@fb.com>
parents:
1087
diff
changeset
|
624 for path in actually_files: |
31917a6be09c
stupid: only check branch mappings for discovered files once
David Schleimer <dschleimer@fb.com>
parents:
1087
diff
changeset
|
625 if meta.get_path_tag(path): |
377
7e9269555e72
Move HgChangeReceiver.branches_in_paths() to the stupid module.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
376
diff
changeset
|
626 continue |
1088
31917a6be09c
stupid: only check branch mappings for discovered files once
David Schleimer <dschleimer@fb.com>
parents:
1087
diff
changeset
|
627 fpath, branch, bpath = meta.split_branch_path(path, existing=False) |
31917a6be09c
stupid: only check branch mappings for discovered files once
David Schleimer <dschleimer@fb.com>
parents:
1087
diff
changeset
|
628 if bpath is None: |
31917a6be09c
stupid: only check branch mappings for discovered files once
David Schleimer <dschleimer@fb.com>
parents:
1087
diff
changeset
|
629 continue |
31917a6be09c
stupid: only check branch mappings for discovered files once
David Schleimer <dschleimer@fb.com>
parents:
1087
diff
changeset
|
630 branches[branch] = bpath |
1031
4e4c47351102
stupid: use layouts library for detecting branch mapping
David Schleimer <dschleimer@fb.com>
parents:
1028
diff
changeset
|
631 |
377
7e9269555e72
Move HgChangeReceiver.branches_in_paths() to the stupid module.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
376
diff
changeset
|
632 return branches |
7e9269555e72
Move HgChangeReceiver.branches_in_paths() to the stupid module.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
376
diff
changeset
|
633 |
787
4bbc6bf947f5
replay: fetch full revision at most once per run (issue252)
Patrick Mezard <pmezard@gmail.com>
parents:
769
diff
changeset
|
634 def convert_rev(ui, meta, svn, r, tbdelta, firstrun): |
1365
89997a5fc181
stupid: self-disable if svn bindings are too new to work with stupid mode
Augie Fackler <raf@durin42.com>
parents:
1320
diff
changeset
|
635 if svnwrap.subversion_version >= (1, 9, 0): |
89997a5fc181
stupid: self-disable if svn bindings are too new to work with stupid mode
Augie Fackler <raf@durin42.com>
parents:
1320
diff
changeset
|
636 raise hgutil.Abort( |
89997a5fc181
stupid: self-disable if svn bindings are too new to work with stupid mode
Augie Fackler <raf@durin42.com>
parents:
1320
diff
changeset
|
637 "hgsubversion doesn't support stupid mode with Subversion 1.9." |
89997a5fc181
stupid: self-disable if svn bindings are too new to work with stupid mode
Augie Fackler <raf@durin42.com>
parents:
1320
diff
changeset
|
638 ' Please email hgsubversion@googlegroups.com and let us know you' |
89997a5fc181
stupid: self-disable if svn bindings are too new to work with stupid mode
Augie Fackler <raf@durin42.com>
parents:
1320
diff
changeset
|
639 ' saw this, otherwise we may remove stupid mode entirely.') |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
640 # this server fails at replay |
367
ce64d57172a3
Generate separate data structure containing revision's tags/branches changes.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
366
diff
changeset
|
641 |
822
033b86e0f56d
stupid/filemap: disable this since it doesn't currently work
Augie Fackler <durin42@gmail.com>
parents:
814
diff
changeset
|
642 if meta.filemap: |
033b86e0f56d
stupid/filemap: disable this since it doesn't currently work
Augie Fackler <durin42@gmail.com>
parents:
814
diff
changeset
|
643 raise hgutil.Abort('filemaps currently unsupported with stupid replay.') |
033b86e0f56d
stupid/filemap: disable this since it doesn't currently work
Augie Fackler <durin42@gmail.com>
parents:
814
diff
changeset
|
644 |
416
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
415
diff
changeset
|
645 branches = branches_in_paths(meta, tbdelta, r.paths, r.revnum, |
1046
36fe4b316a6b
stupid: fix --startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1045
diff
changeset
|
646 svn.checkpath, svn.list_files, firstrun) |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
647 brpaths = branches.values() |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
648 bad_branch_paths = {} |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
649 for br, bp in branches.iteritems(): |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
650 bad_branch_paths[br] = [] |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
651 |
490 | 652 # This next block might be needed, but for now I'm omitting it until it |
653 # can be proven necessary. | |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
654 # for bad in brpaths: |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
655 # if bad.startswith(bp) and len(bad) > len(bp): |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
656 # bad_branch_paths[br].append(bad[len(bp)+1:]) |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
657 |
490 | 658 # We've go a branch that contains other branches. We have to be careful |
659 # to get results similar to real replay in this case. | |
416
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
415
diff
changeset
|
660 for existingbr in meta.branches: |
417
8630d1ebcdb9
svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
416
diff
changeset
|
661 bad = meta.remotename(existingbr) |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
662 if bad.startswith(bp) and len(bad) > len(bp): |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
663 bad_branch_paths[br].append(bad[len(bp)+1:]) |
373
8c91e6a69d05
Get rid of duplicate branch closing detection code for stupid mode.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
368
diff
changeset
|
664 |
8c91e6a69d05
Get rid of duplicate branch closing detection code for stupid mode.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
368
diff
changeset
|
665 deleted_branches = {} |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
666 for p in r.paths: |
547
9e6499c415a9
tags: fix files edited during tag creation
Augie Fackler <durin42@gmail.com>
parents:
540
diff
changeset
|
667 tag = meta.get_path_tag(p) |
9e6499c415a9
tags: fix files edited during tag creation
Augie Fackler <durin42@gmail.com>
parents:
540
diff
changeset
|
668 if tag and tag not in meta.tags: |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
669 continue |
417
8630d1ebcdb9
svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
416
diff
changeset
|
670 branch = meta.localname(p) |
416
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
415
diff
changeset
|
671 if not (r.paths[p].action == 'R' and branch in meta.branches): |
373
8c91e6a69d05
Get rid of duplicate branch closing detection code for stupid mode.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
368
diff
changeset
|
672 continue |
952
9c3b4f59e7e6
stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents:
944
diff
changeset
|
673 # Check the branch is not being replaced by one of its |
9c3b4f59e7e6
stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents:
944
diff
changeset
|
674 # ancestors, it happens a lot with project-wide reverts. |
9c3b4f59e7e6
stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents:
944
diff
changeset
|
675 frompath = r.paths[p].copyfrom_path |
9c3b4f59e7e6
stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents:
944
diff
changeset
|
676 frompath, frombranch = meta.split_branch_path( |
9c3b4f59e7e6
stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents:
944
diff
changeset
|
677 frompath, existing=False)[:2] |
9c3b4f59e7e6
stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents:
944
diff
changeset
|
678 if frompath == '': |
9c3b4f59e7e6
stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents:
944
diff
changeset
|
679 fromnode = meta.get_parent_revision( |
9c3b4f59e7e6
stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents:
944
diff
changeset
|
680 r.paths[p].copyfrom_rev + 1, frombranch, exact=True) |
9c3b4f59e7e6
stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents:
944
diff
changeset
|
681 if fromnode != node.nullid: |
9c3b4f59e7e6
stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents:
944
diff
changeset
|
682 fromctx = meta.repo[fromnode] |
9c3b4f59e7e6
stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents:
944
diff
changeset
|
683 pctx = meta.repo[meta.get_parent_revision( |
9c3b4f59e7e6
stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents:
944
diff
changeset
|
684 r.revnum, branch, exact=True)] |
9c3b4f59e7e6
stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents:
944
diff
changeset
|
685 if util.isancestor(pctx, fromctx): |
9c3b4f59e7e6
stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents:
944
diff
changeset
|
686 continue |
1028
c4b25a903ad3
layouts: consistently return None for default branch
David Schleimer <dschleimer@fb.com>
parents:
952
diff
changeset
|
687 closed = checkbranch(meta, r, branch) |
c4b25a903ad3
layouts: consistently return None for default branch
David Schleimer <dschleimer@fb.com>
parents:
952
diff
changeset
|
688 if closed is not None: |
c4b25a903ad3
layouts: consistently return None for default branch
David Schleimer <dschleimer@fb.com>
parents:
952
diff
changeset
|
689 deleted_branches[branch] = closed |
237
c90cfa665b81
Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
234
diff
changeset
|
690 |
416
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
415
diff
changeset
|
691 date = meta.fixdate(r.date) |
472
ba65e97538d1
stupid: take tbdelta closed branches in account
Patrick Mezard <pmezard@gmail.com>
parents:
452
diff
changeset
|
692 check_deleted_branches = set(tbdelta['branches'][1]) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
693 for b in branches: |
1356
57d65269d30c
maps: allow an empty map to not convert specific branches
Sean Farley <sean@farley.io>
parents:
1320
diff
changeset
|
694 |
57d65269d30c
maps: allow an empty map to not convert specific branches
Sean Farley <sean@farley.io>
parents:
1320
diff
changeset
|
695 if meta.skipbranch(b): |
57d65269d30c
maps: allow an empty map to not convert specific branches
Sean Farley <sean@farley.io>
parents:
1320
diff
changeset
|
696 continue |
57d65269d30c
maps: allow an empty map to not convert specific branches
Sean Farley <sean@farley.io>
parents:
1320
diff
changeset
|
697 |
416
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
415
diff
changeset
|
698 parentctx = meta.repo[meta.get_parent_revision(r.revnum, b)] |
536
460eb781d840
Handle subdirectory tags in stupid mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents:
535
diff
changeset
|
699 tag = meta.get_path_tag(meta.remotename(b)) |
119
ea65fe2b0856
hg_delta_editor: fix update of stray files in branches/
Patrick Mezard <pmezard@gmail.com>
parents:
118
diff
changeset
|
700 kind = svn.checkpath(branches[b], r.revnum) |
ea65fe2b0856
hg_delta_editor: fix update of stray files in branches/
Patrick Mezard <pmezard@gmail.com>
parents:
118
diff
changeset
|
701 if kind != 'd': |
536
460eb781d840
Handle subdirectory tags in stupid mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents:
535
diff
changeset
|
702 if not tag: |
460eb781d840
Handle subdirectory tags in stupid mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents:
535
diff
changeset
|
703 # Branch does not exist at this revision. Get parent |
460eb781d840
Handle subdirectory tags in stupid mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents:
535
diff
changeset
|
704 # revision and remove everything. |
460eb781d840
Handle subdirectory tags in stupid mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents:
535
diff
changeset
|
705 deleted_branches[b] = parentctx.node() |
133
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
706 continue |
179
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
707 |
861
6fc7f74f0cf6
stupid: force non-incremental mode for unrelated branches creation
Patrick Mezard <patrick@mezard.eu>
parents:
860
diff
changeset
|
708 # The nullrev check might not be necessary in theory but svn < |
6fc7f74f0cf6
stupid: force non-incremental mode for unrelated branches creation
Patrick Mezard <patrick@mezard.eu>
parents:
860
diff
changeset
|
709 # 1.7 failed to diff branch creation so the diff_branchrev() |
6fc7f74f0cf6
stupid: force non-incremental mode for unrelated branches creation
Patrick Mezard <patrick@mezard.eu>
parents:
860
diff
changeset
|
710 # path does not support this case with svn >= 1.7. We can fix |
6fc7f74f0cf6
stupid: force non-incremental mode for unrelated branches creation
Patrick Mezard <patrick@mezard.eu>
parents:
860
diff
changeset
|
711 # it, or we can force the existing fetch_branchrev() path. Do |
6fc7f74f0cf6
stupid: force non-incremental mode for unrelated branches creation
Patrick Mezard <patrick@mezard.eu>
parents:
860
diff
changeset
|
712 # the latter for now. |
1434
0a6b3da6d34c
RevMap: move lastpulled from SVNMeta down into RevMap
Augie Fackler <raf@durin42.com>
parents:
1367
diff
changeset
|
713 incremental = (meta.revmap.firstpulled > 0 and |
1046
36fe4b316a6b
stupid: fix --startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1045
diff
changeset
|
714 parentctx.rev() != node.nullrev and |
36fe4b316a6b
stupid: fix --startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1045
diff
changeset
|
715 not firstrun) |
648
8fb38602e3ed
stupid: always fetch the entire first revision
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
640
diff
changeset
|
716 |
8fb38602e3ed
stupid: always fetch the entire first revision
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
640
diff
changeset
|
717 if incremental: |
8fb38602e3ed
stupid: always fetch the entire first revision
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
640
diff
changeset
|
718 try: |
8fb38602e3ed
stupid: always fetch the entire first revision
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
640
diff
changeset
|
719 files_touched, filectxfn2 = diff_branchrev( |
8fb38602e3ed
stupid: always fetch the entire first revision
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
640
diff
changeset
|
720 ui, svn, meta, b, branches[b], r, parentctx) |
8fb38602e3ed
stupid: always fetch the entire first revision
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
640
diff
changeset
|
721 except BadPatchApply, e: |
8fb38602e3ed
stupid: always fetch the entire first revision
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
640
diff
changeset
|
722 # Either this revision or the previous one does not exist. |
8fb38602e3ed
stupid: always fetch the entire first revision
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
640
diff
changeset
|
723 ui.note("Fetching entire revision: %s.\n" % e.args[0]) |
8fb38602e3ed
stupid: always fetch the entire first revision
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
640
diff
changeset
|
724 incremental = False |
8fb38602e3ed
stupid: always fetch the entire first revision
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
640
diff
changeset
|
725 if not incremental: |
401
9e87f7047bf1
stupid: simplify stupid committing code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
377
diff
changeset
|
726 files_touched, filectxfn2 = fetch_branchrev( |
416
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
415
diff
changeset
|
727 svn, meta, b, branches[b], r, parentctx) |
401
9e87f7047bf1
stupid: simplify stupid committing code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
377
diff
changeset
|
728 |
757
6e18d9ab6557
pull: stop handling .hgsvnexternals explicitely in memctx
Patrick Mezard <pmezard@gmail.com>
parents:
739
diff
changeset
|
729 externals = {} |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
497
diff
changeset
|
730 if meta.layout != 'single': |
762
c31a1f92e1c6
svnexternals: preliminary support for subrepos based externals
Patrick Mezard <pmezard@gmail.com>
parents:
758
diff
changeset
|
731 externals = fetch_externals(ui, svn, branches[b], r, parentctx) |
757
6e18d9ab6557
pull: stop handling .hgsvnexternals explicitely in memctx
Patrick Mezard <pmezard@gmail.com>
parents:
739
diff
changeset
|
732 externals = svnexternals.getchanges(ui, meta.repo, parentctx, |
6e18d9ab6557
pull: stop handling .hgsvnexternals explicitely in memctx
Patrick Mezard <pmezard@gmail.com>
parents:
739
diff
changeset
|
733 externals) |
6e18d9ab6557
pull: stop handling .hgsvnexternals explicitely in memctx
Patrick Mezard <pmezard@gmail.com>
parents:
739
diff
changeset
|
734 files_touched.extend(externals) |
401
9e87f7047bf1
stupid: simplify stupid committing code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
377
diff
changeset
|
735 |
9e87f7047bf1
stupid: simplify stupid committing code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
377
diff
changeset
|
736 def filectxfn(repo, memctx, path): |
757
6e18d9ab6557
pull: stop handling .hgsvnexternals explicitely in memctx
Patrick Mezard <pmezard@gmail.com>
parents:
739
diff
changeset
|
737 if path in externals: |
6e18d9ab6557
pull: stop handling .hgsvnexternals explicitely in memctx
Patrick Mezard <pmezard@gmail.com>
parents:
739
diff
changeset
|
738 if externals[path] is None: |
557
d74bf020a61c
replay/stupid: raise the correct errno in IOError to fix hg >= e553a425751d
Augie Fackler <durin42@gmail.com>
parents:
552
diff
changeset
|
739 raise IOError(errno.ENOENT, 'no externals') |
1221
f87502fd4d65
stupid: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
1103
diff
changeset
|
740 return compathacks.makememfilectx(repo, |
1549
8410a978c650
compathacks: be compatible with upstream 8a0cac20a1ad memfilectx change
Jun Wu <quark@fb.com>
parents:
1527
diff
changeset
|
741 memctx=memctx, |
1221
f87502fd4d65
stupid: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
1103
diff
changeset
|
742 path=path, |
f87502fd4d65
stupid: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
1103
diff
changeset
|
743 data=externals[path], |
f87502fd4d65
stupid: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
1103
diff
changeset
|
744 islink=False, |
f87502fd4d65
stupid: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
1103
diff
changeset
|
745 isexec=False, |
f87502fd4d65
stupid: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
1103
diff
changeset
|
746 copied=None) |
401
9e87f7047bf1
stupid: simplify stupid committing code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
377
diff
changeset
|
747 for bad in bad_branch_paths[b]: |
9e87f7047bf1
stupid: simplify stupid committing code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
377
diff
changeset
|
748 if path.startswith(bad): |
557
d74bf020a61c
replay/stupid: raise the correct errno in IOError to fix hg >= e553a425751d
Augie Fackler <durin42@gmail.com>
parents:
552
diff
changeset
|
749 raise IOError(errno.ENOENT, 'Path %s is bad' % path) |
401
9e87f7047bf1
stupid: simplify stupid committing code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
377
diff
changeset
|
750 return filectxfn2(repo, memctx, path) |
9e87f7047bf1
stupid: simplify stupid committing code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
377
diff
changeset
|
751 |
59
430af23bef4a
Performance fix for branches-from-tags in real replay, which is tied up with
Augie Fackler <durin42@gmail.com>
parents:
58
diff
changeset
|
752 if '' in files_touched: |
430af23bef4a
Performance fix for branches-from-tags in real replay, which is tied up with
Augie Fackler <durin42@gmail.com>
parents:
58
diff
changeset
|
753 files_touched.remove('') |
416
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
415
diff
changeset
|
754 excluded = [f for f in files_touched if f not in meta.filemap] |
188
f48cd62a9de4
fetch_command: fix coding style
Patrick Mezard <pmezard@gmail.com>
parents:
187
diff
changeset
|
755 for f in excluded: |
f48cd62a9de4
fetch_command: fix coding style
Patrick Mezard <pmezard@gmail.com>
parents:
187
diff
changeset
|
756 files_touched.remove(f) |
401
9e87f7047bf1
stupid: simplify stupid committing code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
377
diff
changeset
|
757 |
536
460eb781d840
Handle subdirectory tags in stupid mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents:
535
diff
changeset
|
758 if b: |
460eb781d840
Handle subdirectory tags in stupid mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents:
535
diff
changeset
|
759 # Regular tag without modifications, it will be committed by |
460eb781d840
Handle subdirectory tags in stupid mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents:
535
diff
changeset
|
760 # svnmeta.committag(), we can skip the whole branch for now |
460eb781d840
Handle subdirectory tags in stupid mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents:
535
diff
changeset
|
761 if (tag and tag not in meta.tags and |
460eb781d840
Handle subdirectory tags in stupid mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents:
535
diff
changeset
|
762 b not in meta.branches |
1103
6e1dbf6cbc92
compathacks: new module to collect hacks to work around hg internals changing
Augie Fackler <raf@durin42.com>
parents:
1088
diff
changeset
|
763 and b not in compathacks.branchset(meta.repo) |
547
9e6499c415a9
tags: fix files edited during tag creation
Augie Fackler <durin42@gmail.com>
parents:
540
diff
changeset
|
764 and not files_touched): |
536
460eb781d840
Handle subdirectory tags in stupid mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents:
535
diff
changeset
|
765 continue |
460eb781d840
Handle subdirectory tags in stupid mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents:
535
diff
changeset
|
766 |
401
9e87f7047bf1
stupid: simplify stupid committing code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
377
diff
changeset
|
767 if parentctx.node() == node.nullid and not files_touched: |
494
6eea269ff134
stupid: remove stray print statements, keep one as a ui.debug
Augie Fackler <durin42@gmail.com>
parents:
490
diff
changeset
|
768 meta.repo.ui.debug('skipping commit since parent is null and no files touched.\n') |
401
9e87f7047bf1
stupid: simplify stupid committing code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
377
diff
changeset
|
769 continue |
9e87f7047bf1
stupid: simplify stupid committing code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
377
diff
changeset
|
770 |
9e87f7047bf1
stupid: simplify stupid committing code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
377
diff
changeset
|
771 for f in files_touched: |
9e87f7047bf1
stupid: simplify stupid committing code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
377
diff
changeset
|
772 if f: |
9e87f7047bf1
stupid: simplify stupid committing code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
377
diff
changeset
|
773 # this is a case that really shouldn't ever happen, it means |
9e87f7047bf1
stupid: simplify stupid committing code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
377
diff
changeset
|
774 # something is very wrong |
9e87f7047bf1
stupid: simplify stupid committing code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
377
diff
changeset
|
775 assert f[0] != '/' |
9e87f7047bf1
stupid: simplify stupid committing code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
377
diff
changeset
|
776 |
422
6086363e8230
svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
418
diff
changeset
|
777 extra = meta.genextra(r.revnum, b) |
447
0d3b5acb1d51
tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents:
444
diff
changeset
|
778 if tag: |
0d3b5acb1d51
tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents:
444
diff
changeset
|
779 if parentctx.node() == node.nullid: |
0d3b5acb1d51
tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents:
444
diff
changeset
|
780 continue |
0d3b5acb1d51
tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents:
444
diff
changeset
|
781 extra.update({'branch': parentctx.extra().get('branch', None), |
0d3b5acb1d51
tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents:
444
diff
changeset
|
782 'close': 1}) |
0d3b5acb1d51
tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents:
444
diff
changeset
|
783 |
640
a3d20d6e96b0
stupid: handle branch mapping.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
634
diff
changeset
|
784 origbranch = extra.get('branch', None) |
574
8e025a6f0db4
add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
557
diff
changeset
|
785 meta.mapbranch(extra) |
1526
5adfb81c4680
util: add method for forcing unicode objects back to utf8 bytes
Augie Fackler <raf@durin42.com>
parents:
1472
diff
changeset
|
786 current_ctx = context.memctx( |
5adfb81c4680
util: add method for forcing unicode objects back to utf8 bytes
Augie Fackler <raf@durin42.com>
parents:
1472
diff
changeset
|
787 meta.repo, |
5adfb81c4680
util: add method for forcing unicode objects back to utf8 bytes
Augie Fackler <raf@durin42.com>
parents:
1472
diff
changeset
|
788 [parentctx.node(), revlog.nullid], |
1527
d03995e69785
meta: force user and message to be bytes
Augie Fackler <raf@durin42.com>
parents:
1526
diff
changeset
|
789 util.forceutf8(meta.getmessage(r)), |
1526
5adfb81c4680
util: add method for forcing unicode objects back to utf8 bytes
Augie Fackler <raf@durin42.com>
parents:
1472
diff
changeset
|
790 [util.forceutf8(f) for f in files_touched], |
5adfb81c4680
util: add method for forcing unicode objects back to utf8 bytes
Augie Fackler <raf@durin42.com>
parents:
1472
diff
changeset
|
791 filectxfn, |
1527
d03995e69785
meta: force user and message to be bytes
Augie Fackler <raf@durin42.com>
parents:
1526
diff
changeset
|
792 util.forceutf8(meta.authors[r.author]), |
1526
5adfb81c4680
util: add method for forcing unicode objects back to utf8 bytes
Augie Fackler <raf@durin42.com>
parents:
1472
diff
changeset
|
793 date, |
5adfb81c4680
util: add method for forcing unicode objects back to utf8 bytes
Augie Fackler <raf@durin42.com>
parents:
1472
diff
changeset
|
794 extra) |
831
be5bbb2f2d68
svnrepo: kludge to work around hash changes between stupid and replay in hg 1.9
Augie Fackler <durin42@gmail.com>
parents:
822
diff
changeset
|
795 ha = meta.repo.svn_commitctx(current_ctx) |
401
9e87f7047bf1
stupid: simplify stupid committing code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
377
diff
changeset
|
796 |
447
0d3b5acb1d51
tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents:
444
diff
changeset
|
797 if not tag: |
640
a3d20d6e96b0
stupid: handle branch mapping.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
634
diff
changeset
|
798 if (not origbranch in meta.branches |
a3d20d6e96b0
stupid: handle branch mapping.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
634
diff
changeset
|
799 and not meta.get_path_tag(meta.remotename(origbranch))): |
a3d20d6e96b0
stupid: handle branch mapping.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
634
diff
changeset
|
800 meta.branches[origbranch] = None, 0, r.revnum |
447
0d3b5acb1d51
tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents:
444
diff
changeset
|
801 meta.revmap[r.revnum, b] = ha |
452
ae35c389cdef
tags: allow editing tags of closed branches without reopening the branch
Augie Fackler <durin42@gmail.com>
parents:
447
diff
changeset
|
802 else: |
634
a400f3bf5611
replay/stupid: fix tagging on a branch renamed using a branch map
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
623
diff
changeset
|
803 meta.movetag(tag, ha, r, date) |
547
9e6499c415a9
tags: fix files edited during tag creation
Augie Fackler <durin42@gmail.com>
parents:
540
diff
changeset
|
804 meta.addedtags.pop(tag, None) |
452
ae35c389cdef
tags: allow editing tags of closed branches without reopening the branch
Augie Fackler <durin42@gmail.com>
parents:
447
diff
changeset
|
805 util.describe_commit(ui, ha, b) |
373
8c91e6a69d05
Get rid of duplicate branch closing detection code for stupid mode.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
368
diff
changeset
|
806 |
8c91e6a69d05
Get rid of duplicate branch closing detection code for stupid mode.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
368
diff
changeset
|
807 # These are branches with an 'R' status in svn log. This means they were |
147
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
141
diff
changeset
|
808 # replaced by some other branch, so we need to verify they get marked as closed. |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
141
diff
changeset
|
809 for branch in check_deleted_branches: |
416
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
415
diff
changeset
|
810 closed = checkbranch(meta, r, branch) |
373
8c91e6a69d05
Get rid of duplicate branch closing detection code for stupid mode.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
368
diff
changeset
|
811 if closed is not None: |
8c91e6a69d05
Get rid of duplicate branch closing detection code for stupid mode.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
368
diff
changeset
|
812 deleted_branches[branch] = closed |
8c91e6a69d05
Get rid of duplicate branch closing detection code for stupid mode.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
368
diff
changeset
|
813 |
432
4bf90f8c9b7b
consolidate metadata calls from stupid and replay code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
424
diff
changeset
|
814 return deleted_branches |