Mercurial > hg
comparison hgext/convert/git.py @ 46113:59fa3890d40a
node: import symbols explicitly
There is no point in lazy importing mercurial.node, it is used all over
the place anyway. So consistently import the used symbols directly.
Fix one file using symbols indirectly via mercurial.revlog.
Differential Revision: https://phab.mercurial-scm.org/D9480
author | Joerg Sonnenberger <joerg@bec.de> |
---|---|
date | Tue, 01 Dec 2020 21:54:46 +0100 |
parents | 8ff1ecfadcd1 |
children | f7621fa14b84 |
comparison
equal
deleted
inserted
replaced
46112:d6afa9c149c3 | 46113:59fa3890d40a |
---|---|
7 from __future__ import absolute_import | 7 from __future__ import absolute_import |
8 | 8 |
9 import os | 9 import os |
10 | 10 |
11 from mercurial.i18n import _ | 11 from mercurial.i18n import _ |
12 from mercurial.node import nullhex | |
12 from mercurial import ( | 13 from mercurial import ( |
13 config, | 14 config, |
14 error, | 15 error, |
15 node as nodemod, | |
16 pycompat, | 16 pycompat, |
17 ) | 17 ) |
18 | 18 |
19 from . import common | 19 from . import common |
20 | 20 |
190 if ret: | 190 if ret: |
191 raise error.Abort(_(b'cannot retrieve git head "%s"') % rev) | 191 raise error.Abort(_(b'cannot retrieve git head "%s"') % rev) |
192 return heads | 192 return heads |
193 | 193 |
194 def catfile(self, rev, ftype): | 194 def catfile(self, rev, ftype): |
195 if rev == nodemod.nullhex: | 195 if rev == nullhex: |
196 raise IOError | 196 raise IOError |
197 self.catfilepipe[0].write(rev + b'\n') | 197 self.catfilepipe[0].write(rev + b'\n') |
198 self.catfilepipe[0].flush() | 198 self.catfilepipe[0].flush() |
199 info = self.catfilepipe[1].readline().split() | 199 info = self.catfilepipe[1].readline().split() |
200 if info[1] != ftype: | 200 if info[1] != ftype: |
212 # read the trailing newline | 212 # read the trailing newline |
213 self.catfilepipe[1].read(1) | 213 self.catfilepipe[1].read(1) |
214 return data | 214 return data |
215 | 215 |
216 def getfile(self, name, rev): | 216 def getfile(self, name, rev): |
217 if rev == nodemod.nullhex: | 217 if rev == nullhex: |
218 return None, None | 218 return None, None |
219 if name == b'.hgsub': | 219 if name == b'.hgsub': |
220 data = b'\n'.join([m.hgsub() for m in self.submoditer()]) | 220 data = b'\n'.join([m.hgsub() for m in self.submoditer()]) |
221 mode = b'' | 221 mode = b'' |
222 elif name == b'.hgsubstate': | 222 elif name == b'.hgsubstate': |
226 data = self.catfile(rev, b"blob") | 226 data = self.catfile(rev, b"blob") |
227 mode = self.modecache[(name, rev)] | 227 mode = self.modecache[(name, rev)] |
228 return data, mode | 228 return data, mode |
229 | 229 |
230 def submoditer(self): | 230 def submoditer(self): |
231 null = nodemod.nullhex | 231 null = nullhex |
232 for m in sorted(self.submodules, key=lambda p: p.path): | 232 for m in sorted(self.submodules, key=lambda p: p.path): |
233 if m.node != null: | 233 if m.node != null: |
234 yield m | 234 yield m |
235 | 235 |
236 def parsegitmodules(self, content): | 236 def parsegitmodules(self, content): |
314 return | 314 return |
315 | 315 |
316 subexists[0] = True | 316 subexists[0] = True |
317 if entry[4] == b'D' or renamesource: | 317 if entry[4] == b'D' or renamesource: |
318 subdeleted[0] = True | 318 subdeleted[0] = True |
319 changes.append((b'.hgsub', nodemod.nullhex)) | 319 changes.append((b'.hgsub', nullhex)) |
320 else: | 320 else: |
321 changes.append((b'.hgsub', b'')) | 321 changes.append((b'.hgsub', b'')) |
322 elif entry[1] == b'160000' or entry[0] == b':160000': | 322 elif entry[1] == b'160000' or entry[0] == b':160000': |
323 if not skipsubmodules: | 323 if not skipsubmodules: |
324 subexists[0] = True | 324 subexists[0] = True |
325 else: | 325 else: |
326 if renamesource: | 326 if renamesource: |
327 h = nodemod.nullhex | 327 h = nullhex |
328 self.modecache[(f, h)] = (p and b"x") or (s and b"l") or b"" | 328 self.modecache[(f, h)] = (p and b"x") or (s and b"l") or b"" |
329 changes.append((f, h)) | 329 changes.append((f, h)) |
330 | 330 |
331 while i < lcount: | 331 while i < lcount: |
332 l = difftree[i] | 332 l = difftree[i] |
359 copies[fdest] = f | 359 copies[fdest] = f |
360 entry = None | 360 entry = None |
361 | 361 |
362 if subexists[0]: | 362 if subexists[0]: |
363 if subdeleted[0]: | 363 if subdeleted[0]: |
364 changes.append((b'.hgsubstate', nodemod.nullhex)) | 364 changes.append((b'.hgsubstate', nullhex)) |
365 else: | 365 else: |
366 self.retrievegitmodules(version) | 366 self.retrievegitmodules(version) |
367 changes.append((b'.hgsubstate', b'')) | 367 changes.append((b'.hgsubstate', b'')) |
368 return (changes, copies, set()) | 368 return (changes, copies, set()) |
369 | 369 |