##// 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 return orig(ui, source, *args, **opts)
121 return orig(ui, source, *args, **opts)
122
122
123 def extsetup(ui):
123 def extsetup(ui):
124 extensions.wrapfunction(bookmarks.bmstore, 'getbkfile', getbkfile)
124 extensions.wrapfunction(bookmarks, '_getbkfile', getbkfile)
125 extensions.wrapfunction(bookmarks.bmstore, 'recordchange', recordchange)
125 extensions.wrapfunction(bookmarks.bmstore, 'recordchange', recordchange)
126 extensions.wrapfunction(bookmarks.bmstore, '_writerepo', writerepo)
126 extensions.wrapfunction(bookmarks.bmstore, '_writerepo', writerepo)
127 extensions.wrapcommand(commands.table, 'clone', clone)
127 extensions.wrapcommand(commands.table, 'clone', clone)
@@ -149,12 +149,12 b' def _getsrcrepo(repo):'
149 srcurl, branches = parseurl(source)
149 srcurl, branches = parseurl(source)
150 return repository(repo.ui, srcurl)
150 return repository(repo.ui, srcurl)
151
151
152 def getbkfile(orig, self, repo):
152 def getbkfile(orig, repo):
153 if _hassharedbookmarks(repo):
153 if _hassharedbookmarks(repo):
154 srcrepo = _getsrcrepo(repo)
154 srcrepo = _getsrcrepo(repo)
155 if srcrepo is not None:
155 if srcrepo is not None:
156 repo = srcrepo
156 repo = srcrepo
157 return orig(self, repo)
157 return orig(repo)
158
158
159 def recordchange(orig, self, tr):
159 def recordchange(orig, self, tr):
160 # Continue with write to local bookmarks file as usual
160 # Continue with write to local bookmarks file as usual
@@ -22,6 +22,25 b' from . import ('
22 util,
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 class bmstore(dict):
44 class bmstore(dict):
26 """Storage for bookmarks.
45 """Storage for bookmarks.
27
46
@@ -41,7 +60,7 b' class bmstore(dict):'
41 dict.__init__(self)
60 dict.__init__(self)
42 self._repo = repo
61 self._repo = repo
43 try:
62 try:
44 bkfile = self.getbkfile(repo)
63 bkfile = _getbkfile(repo)
45 for line in bkfile:
64 for line in bkfile:
46 line = line.strip()
65 line = line.strip()
47 if not line:
66 if not line:
@@ -60,24 +79,6 b' class bmstore(dict):'
60 if inst.errno != errno.ENOENT:
79 if inst.errno != errno.ENOENT:
61 raise
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 def recordchange(self, tr):
82 def recordchange(self, tr):
82 """record that bookmarks have been changed in a transaction
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