##// END OF EJS Templates
bookmarks: hoist getbkfile out of bmstore class...
Augie Fackler -
r27186:34d26e22 default
parent child Browse files
Show More
@@ -121,7 +121,7 b' def clone(orig, ui, source, *args, **opt'
121 121 return orig(ui, source, *args, **opts)
122 122
123 123 def extsetup(ui):
124 extensions.wrapfunction(bookmarks.bmstore, 'getbkfile', getbkfile)
124 extensions.wrapfunction(bookmarks, '_getbkfile', getbkfile)
125 125 extensions.wrapfunction(bookmarks.bmstore, 'recordchange', recordchange)
126 126 extensions.wrapfunction(bookmarks.bmstore, '_writerepo', writerepo)
127 127 extensions.wrapcommand(commands.table, 'clone', clone)
@@ -149,12 +149,12 b' def _getsrcrepo(repo):'
149 149 srcurl, branches = parseurl(source)
150 150 return repository(repo.ui, srcurl)
151 151
152 def getbkfile(orig, self, repo):
152 def getbkfile(orig, repo):
153 153 if _hassharedbookmarks(repo):
154 154 srcrepo = _getsrcrepo(repo)
155 155 if srcrepo is not None:
156 156 repo = srcrepo
157 return orig(self, repo)
157 return orig(repo)
158 158
159 159 def recordchange(orig, self, tr):
160 160 # Continue with write to local bookmarks file as usual
@@ -22,6 +22,25 b' from . import ('
22 22 util,
23 23 )
24 24
25 def _getbkfile(repo):
26 """Hook so that extensions that mess with the store can hook bm storage.
27
28 For core, this just handles wether we should see pending
29 bookmarks or the committed ones. Other extensions (like share)
30 may need to tweak this behavior further.
31 """
32 bkfile = None
33 if 'HG_PENDING' in os.environ:
34 try:
35 bkfile = repo.vfs('bookmarks.pending')
36 except IOError as inst:
37 if inst.errno != errno.ENOENT:
38 raise
39 if bkfile is None:
40 bkfile = repo.vfs('bookmarks')
41 return bkfile
42
43
25 44 class bmstore(dict):
26 45 """Storage for bookmarks.
27 46
@@ -41,7 +60,7 b' class bmstore(dict):'
41 60 dict.__init__(self)
42 61 self._repo = repo
43 62 try:
44 bkfile = self.getbkfile(repo)
63 bkfile = _getbkfile(repo)
45 64 for line in bkfile:
46 65 line = line.strip()
47 66 if not line:
@@ -60,24 +79,6 b' class bmstore(dict):'
60 79 if inst.errno != errno.ENOENT:
61 80 raise
62 81
63 def getbkfile(self, repo):
64 """Hook so that extensions that mess with the store can hook bm storage.
65
66 For core, this just handles wether we should see pending
67 bookmarks or the committed ones. Other extensions (like share)
68 may need to tweak this behavior further.
69 """
70 bkfile = None
71 if 'HG_PENDING' in os.environ:
72 try:
73 bkfile = repo.vfs('bookmarks.pending')
74 except IOError as inst:
75 if inst.errno != errno.ENOENT:
76 raise
77 if bkfile is None:
78 bkfile = repo.vfs('bookmarks')
79 return bkfile
80
81 82 def recordchange(self, tr):
82 83 """record that bookmarks have been changed in a transaction
83 84
General Comments 0
You need to be logged in to leave comments. Login now