##// END OF EJS Templates
bookmarks; clean up imports and function wrapping
Matt Mackall -
r7638:f83a2b1d default
parent child Browse files
Show More
@@ -25,12 +25,10 b' This will cause bookmarks to track the b'
25 just updates it. This is similar to git's approach of branching.
25 just updates it. This is similar to git's approach of branching.
26 '''
26 '''
27
27
28 from mercurial.commands import templateopts, hex, short
29 from mercurial import extensions
30 from mercurial.i18n import _
28 from mercurial.i18n import _
31 from mercurial import cmdutil, util, commands, changelog
29 from mercurial.node import nullid, nullrev, hex, short
32 from mercurial.node import nullid, nullrev
30 from mercurial import util, commands, localrepo, repair, extensions
33 import mercurial, mercurial.localrepo, mercurial.repair, os
31 import os
34
32
35 def parse(repo):
33 def parse(repo):
36 '''Parse .hg/bookmarks file and return a dictionary
34 '''Parse .hg/bookmarks file and return a dictionary
@@ -198,7 +196,7 b' def _revstostrip(changelog, node):'
198 saveheads.append(p)
196 saveheads.append(p)
199 return [r for r in tostrip if r not in saveheads]
197 return [r for r in tostrip if r not in saveheads]
200
198
201 def strip(ui, repo, node, backup="all"):
199 def strip(oldstrip, ui, repo, node, backup="all"):
202 """Strip bookmarks if revisions are stripped using
200 """Strip bookmarks if revisions are stripped using
203 the mercurial.strip method. This usually happens during
201 the mercurial.strip method. This usually happens during
204 qpush and qpop"""
202 qpush and qpop"""
@@ -214,11 +212,8 b' def strip(ui, repo, node, backup="all"):'
214 marks[m] = repo.changectx('.').node()
212 marks[m] = repo.changectx('.').node()
215 write(repo, marks)
213 write(repo, marks)
216
214
217 oldstrip = mercurial.repair.strip
218 mercurial.repair.strip = strip
219
220 def reposetup(ui, repo):
215 def reposetup(ui, repo):
221 if not isinstance(repo, mercurial.localrepo.localrepository):
216 if not isinstance(repo, localrepo.localrepository):
222 return
217 return
223
218
224 # init a bookmark cache as otherwise we would get a infinite reading
219 # init a bookmark cache as otherwise we would get a infinite reading
@@ -293,6 +288,11 b' def reposetup(ui, repo):'
293
288
294 repo.__class__ = bookmark_repo
289 repo.__class__ = bookmark_repo
295
290
291 def uisetup(ui):
292 extensions.wrapfunction(repair, "strip", strip)
293 if ui.configbool('bookmarks', 'track.current'):
294 extensions.wrapcommand(commands.table, 'update', updatecurbookmark)
295
296 def updatecurbookmark(orig, ui, repo, *args, **opts):
296 def updatecurbookmark(orig, ui, repo, *args, **opts):
297 '''Set the current bookmark
297 '''Set the current bookmark
298
298
@@ -306,11 +306,6 b' def updatecurbookmark(orig, ui, repo, *a'
306 setcurrent(repo, rev)
306 setcurrent(repo, rev)
307 return res
307 return res
308
308
309 def uisetup(ui):
310 'Replace push with a decorator to provide --non-bookmarked option'
311 if ui.configbool('bookmarks', 'track.current'):
312 extensions.wrapcommand(commands.table, 'update', updatecurbookmark)
313
314 cmdtable = {
309 cmdtable = {
315 "bookmarks":
310 "bookmarks":
316 (bookmark,
311 (bookmark,
General Comments 0
You need to be logged in to leave comments. Login now