Show More
@@ -17,6 +17,46 b' from . import (' | |||||
17 | # directory name in .hg/ in which remotenames files will be present |
|
17 | # directory name in .hg/ in which remotenames files will be present | |
18 | remotenamedir = 'remotenames' |
|
18 | remotenamedir = 'remotenames' | |
19 |
|
19 | |||
|
20 | def readremotenamefile(repo, filename): | |||
|
21 | """ | |||
|
22 | reads a file from .hg/remotenames/ directory and yields it's content | |||
|
23 | filename: the file to be read | |||
|
24 | yield a tuple (node, remotepath, name) | |||
|
25 | """ | |||
|
26 | ||||
|
27 | vfs = vfsmod.vfs(repo.vfs.join(remotenamedir)) | |||
|
28 | if not vfs.exists(filename): | |||
|
29 | return | |||
|
30 | f = vfs(filename) | |||
|
31 | lineno = 0 | |||
|
32 | for line in f: | |||
|
33 | line = line.strip() | |||
|
34 | if not line: | |||
|
35 | continue | |||
|
36 | # contains the version number | |||
|
37 | if lineno == 0: | |||
|
38 | lineno += 1 | |||
|
39 | try: | |||
|
40 | node, remote, rname = line.split('\0') | |||
|
41 | yield node, remote, rname | |||
|
42 | except ValueError: | |||
|
43 | pass | |||
|
44 | ||||
|
45 | f.close() | |||
|
46 | ||||
|
47 | def readremotenames(repo): | |||
|
48 | """ | |||
|
49 | read the details about the remotenames stored in .hg/remotenames/ and | |||
|
50 | yields a tuple (node, remotepath, name). It does not yields information | |||
|
51 | about whether an entry yielded is branch or bookmark. To get that | |||
|
52 | information, call the respective functions. | |||
|
53 | """ | |||
|
54 | ||||
|
55 | for bmentry in readremotenamefile(repo, 'bookmarks'): | |||
|
56 | yield bmentry | |||
|
57 | for branchentry in readremotenamefile(repo, 'branches'): | |||
|
58 | yield branchentry | |||
|
59 | ||||
20 | def writeremotenamefile(repo, remotepath, names, nametype): |
|
60 | def writeremotenamefile(repo, remotepath, names, nametype): | |
21 | vfs = vfsmod.vfs(repo.vfs.join(remotenamedir)) |
|
61 | vfs = vfsmod.vfs(repo.vfs.join(remotenamedir)) | |
22 | f = vfs(nametype, 'w', atomictemp=True) |
|
62 | f = vfs(nametype, 'w', atomictemp=True) |
General Comments 0
You need to be logged in to leave comments.
Login now