##// END OF EJS Templates
bookmarks: rename bookmarkcurrent to activebookmark (API)...
Ryan McElroy -
r24947:a02d293a default
parent child Browse files
Show More
@@ -358,7 +358,7 b' def rebase(ui, repo, **opts):'
358
358
359 # Keep track of the current bookmarks in order to reset them later
359 # Keep track of the current bookmarks in order to reset them later
360 currentbookmarks = repo._bookmarks.copy()
360 currentbookmarks = repo._bookmarks.copy()
361 activebookmark = activebookmark or repo._bookmarkcurrent
361 activebookmark = activebookmark or repo._activebookmark
362 if activebookmark:
362 if activebookmark:
363 bookmarks.deactivate(repo)
363 bookmarks.deactivate(repo)
364
364
@@ -1052,7 +1052,7 b' def pullrebase(orig, ui, repo, *args, **'
1052 hg.update(repo, dest)
1052 hg.update(repo, dest)
1053 if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
1053 if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
1054 ui.status(_("updating bookmark %s\n")
1054 ui.status(_("updating bookmark %s\n")
1055 % repo._bookmarkcurrent)
1055 % repo._activebookmark)
1056 else:
1056 else:
1057 if opts.get('tool'):
1057 if opts.get('tool'):
1058 raise util.Abort(_('--tool can only be used with --rebase'))
1058 raise util.Abort(_('--tool can only be used with --rebase'))
@@ -163,7 +163,7 b' def createcmd(ui, repo, pats, opts):'
163
163
164 # we never need the user, so we use a generic user for all shelve operations
164 # we never need the user, so we use a generic user for all shelve operations
165 user = 'shelve@localhost'
165 user = 'shelve@localhost'
166 label = repo._bookmarkcurrent or parent.branch() or 'default'
166 label = repo._activebookmark or parent.branch() or 'default'
167
167
168 # slashes aren't allowed in filenames, therefore we rename it
168 # slashes aren't allowed in filenames, therefore we rename it
169 label = label.replace('/', '_')
169 label = label.replace('/', '_')
@@ -60,7 +60,7 b' def strip(ui, repo, revs, update=True, b'
60
60
61 marks = repo._bookmarks
61 marks = repo._bookmarks
62 if bookmark:
62 if bookmark:
63 if bookmark == repo._bookmarkcurrent:
63 if bookmark == repo._activebookmark:
64 bookmarks.deactivate(repo)
64 bookmarks.deactivate(repo)
65 del marks[bookmark]
65 del marks[bookmark]
66 marks.write()
66 marks.write()
@@ -83,7 +83,7 b' class bmstore(dict):'
83
83
84 def _writerepo(self, repo):
84 def _writerepo(self, repo):
85 """Factored out for extensibility"""
85 """Factored out for extensibility"""
86 if repo._bookmarkcurrent not in self:
86 if repo._activebookmark not in self:
87 deactivate(repo)
87 deactivate(repo)
88
88
89 wlock = repo.wlock()
89 wlock = repo.wlock()
@@ -137,7 +137,7 b' def activate(repo, mark):'
137 if mark not in repo._bookmarks:
137 if mark not in repo._bookmarks:
138 raise AssertionError('bookmark %s does not exist!' % mark)
138 raise AssertionError('bookmark %s does not exist!' % mark)
139
139
140 current = repo._bookmarkcurrent
140 current = repo._activebookmark
141 if current == mark:
141 if current == mark:
142 return
142 return
143
143
@@ -148,7 +148,7 b' def activate(repo, mark):'
148 file.close()
148 file.close()
149 finally:
149 finally:
150 wlock.release()
150 wlock.release()
151 repo._bookmarkcurrent = mark
151 repo._activebookmark = mark
152
152
153 def deactivate(repo):
153 def deactivate(repo):
154 """
154 """
@@ -158,7 +158,7 b' def deactivate(repo):'
158 try:
158 try:
159 try:
159 try:
160 repo.vfs.unlink('bookmarks.current')
160 repo.vfs.unlink('bookmarks.current')
161 repo._bookmarkcurrent = None
161 repo._activebookmark = None
162 except OSError, inst:
162 except OSError, inst:
163 if inst.errno != errno.ENOENT:
163 if inst.errno != errno.ENOENT:
164 raise
164 raise
@@ -172,7 +172,7 b' def iscurrent(repo, mark=None, parents=N'
172 parent of the working directory.
172 parent of the working directory.
173 '''
173 '''
174 if not mark:
174 if not mark:
175 mark = repo._bookmarkcurrent
175 mark = repo._activebookmark
176 if not parents:
176 if not parents:
177 parents = [p.node() for p in repo[None].parents()]
177 parents = [p.node() for p in repo[None].parents()]
178 marks = repo._bookmarks
178 marks = repo._bookmarks
@@ -209,7 +209,7 b' def calculateupdate(ui, repo, checkout):'
209 check out and where to move the active bookmark from, if needed.'''
209 check out and where to move the active bookmark from, if needed.'''
210 movemarkfrom = None
210 movemarkfrom = None
211 if checkout is None:
211 if checkout is None:
212 curmark = repo._bookmarkcurrent
212 curmark = repo._activebookmark
213 if iscurrent(repo):
213 if iscurrent(repo):
214 movemarkfrom = repo['.'].node()
214 movemarkfrom = repo['.'].node()
215 elif curmark:
215 elif curmark:
@@ -221,7 +221,7 b' def update(repo, parents, node):'
221 deletefrom = parents
221 deletefrom = parents
222 marks = repo._bookmarks
222 marks = repo._bookmarks
223 update = False
223 update = False
224 cur = repo._bookmarkcurrent
224 cur = repo._activebookmark
225 if not cur:
225 if not cur:
226 return False
226 return False
227
227
@@ -2480,13 +2480,13 b' def amend(ui, repo, commitfunc, old, ext'
2480 # First, do a regular commit to record all changes in the working
2480 # First, do a regular commit to record all changes in the working
2481 # directory (if there are any)
2481 # directory (if there are any)
2482 ui.callhooks = False
2482 ui.callhooks = False
2483 currentbookmark = repo._bookmarkcurrent
2483 currentbookmark = repo._activebookmark
2484 try:
2484 try:
2485 repo._bookmarkcurrent = None
2485 repo._activebookmark = None
2486 opts['message'] = 'temporary amend commit for %s' % old
2486 opts['message'] = 'temporary amend commit for %s' % old
2487 node = commit(ui, repo, commitfunc, pats, opts)
2487 node = commit(ui, repo, commitfunc, pats, opts)
2488 finally:
2488 finally:
2489 repo._bookmarkcurrent = currentbookmark
2489 repo._activebookmark = currentbookmark
2490 ui.callhooks = True
2490 ui.callhooks = True
2491 ctx = repo[node]
2491 ctx = repo[node]
2492
2492
@@ -2722,7 +2722,7 b' def buildcommittext(repo, ctx, subs, ext'
2722 if ctx.branch():
2722 if ctx.branch():
2723 edittext.append(_("HG: branch '%s'") % ctx.branch())
2723 edittext.append(_("HG: branch '%s'") % ctx.branch())
2724 if bookmarks.iscurrent(repo):
2724 if bookmarks.iscurrent(repo):
2725 edittext.append(_("HG: bookmark '%s'") % repo._bookmarkcurrent)
2725 edittext.append(_("HG: bookmark '%s'") % repo._activebookmark)
2726 edittext.extend([_("HG: subrepo %s") % s for s in subs])
2726 edittext.extend([_("HG: subrepo %s") % s for s in subs])
2727 edittext.extend([_("HG: added %s") % f for f in added])
2727 edittext.extend([_("HG: added %s") % f for f in added])
2728 edittext.extend([_("HG: changed %s") % f for f in modified])
2728 edittext.extend([_("HG: changed %s") % f for f in modified])
@@ -979,7 +979,7 b' def bookmark(ui, repo, *names, **opts):'
979 if mark not in marks:
979 if mark not in marks:
980 raise util.Abort(_("bookmark '%s' does not exist") %
980 raise util.Abort(_("bookmark '%s' does not exist") %
981 mark)
981 mark)
982 if mark == repo._bookmarkcurrent:
982 if mark == repo._activebookmark:
983 bookmarks.deactivate(repo)
983 bookmarks.deactivate(repo)
984 del marks[mark]
984 del marks[mark]
985 marks.write()
985 marks.write()
@@ -994,7 +994,7 b' def bookmark(ui, repo, *names, **opts):'
994 raise util.Abort(_("bookmark '%s' does not exist") % rename)
994 raise util.Abort(_("bookmark '%s' does not exist") % rename)
995 checkconflict(repo, mark, cur, force)
995 checkconflict(repo, mark, cur, force)
996 marks[mark] = marks[rename]
996 marks[mark] = marks[rename]
997 if repo._bookmarkcurrent == rename and not inactive:
997 if repo._activebookmark == rename and not inactive:
998 bookmarks.activate(repo, mark)
998 bookmarks.activate(repo, mark)
999 del marks[rename]
999 del marks[rename]
1000 marks.write()
1000 marks.write()
@@ -1005,7 +1005,7 b' def bookmark(ui, repo, *names, **opts):'
1005 mark = checkformat(mark)
1005 mark = checkformat(mark)
1006 if newact is None:
1006 if newact is None:
1007 newact = mark
1007 newact = mark
1008 if inactive and mark == repo._bookmarkcurrent:
1008 if inactive and mark == repo._activebookmark:
1009 bookmarks.deactivate(repo)
1009 bookmarks.deactivate(repo)
1010 return
1010 return
1011 tgt = cur
1011 tgt = cur
@@ -1015,14 +1015,14 b' def bookmark(ui, repo, *names, **opts):'
1015 marks[mark] = tgt
1015 marks[mark] = tgt
1016 if not inactive and cur == marks[newact] and not rev:
1016 if not inactive and cur == marks[newact] and not rev:
1017 bookmarks.activate(repo, newact)
1017 bookmarks.activate(repo, newact)
1018 elif cur != tgt and newact == repo._bookmarkcurrent:
1018 elif cur != tgt and newact == repo._activebookmark:
1019 bookmarks.deactivate(repo)
1019 bookmarks.deactivate(repo)
1020 marks.write()
1020 marks.write()
1021
1021
1022 elif inactive:
1022 elif inactive:
1023 if len(marks) == 0:
1023 if len(marks) == 0:
1024 ui.status(_("no bookmarks set\n"))
1024 ui.status(_("no bookmarks set\n"))
1025 elif not repo._bookmarkcurrent:
1025 elif not repo._activebookmark:
1026 ui.status(_("no active bookmark\n"))
1026 ui.status(_("no active bookmark\n"))
1027 else:
1027 else:
1028 bookmarks.deactivate(repo)
1028 bookmarks.deactivate(repo)
@@ -1035,7 +1035,7 b' def bookmark(ui, repo, *names, **opts):'
1035 if len(marks) == 0 and not fm:
1035 if len(marks) == 0 and not fm:
1036 ui.status(_("no bookmarks set\n"))
1036 ui.status(_("no bookmarks set\n"))
1037 for bmark, n in sorted(marks.iteritems()):
1037 for bmark, n in sorted(marks.iteritems()):
1038 current = repo._bookmarkcurrent
1038 current = repo._activebookmark
1039 if bmark == current:
1039 if bmark == current:
1040 prefix, label = '*', 'bookmarks.current'
1040 prefix, label = '*', 'bookmarks.current'
1041 else:
1041 else:
@@ -1506,7 +1506,7 b' def commit(ui, repo, *pats, **opts):'
1506 match,
1506 match,
1507 extra=extra)
1507 extra=extra)
1508
1508
1509 current = repo._bookmarkcurrent
1509 current = repo._activebookmark
1510 marks = old.bookmarks()
1510 marks = old.bookmarks()
1511 node = cmdutil.amend(ui, repo, commitfunc, old, extra, pats, opts)
1511 node = cmdutil.amend(ui, repo, commitfunc, old, extra, pats, opts)
1512 if node == old.node():
1512 if node == old.node():
@@ -4702,9 +4702,9 b' def merge(ui, repo, node=None, **opts):'
4702 if node:
4702 if node:
4703 node = scmutil.revsingle(repo, node).node()
4703 node = scmutil.revsingle(repo, node).node()
4704
4704
4705 if not node and repo._bookmarkcurrent:
4705 if not node and repo._activebookmark:
4706 bmheads = repo.bookmarkheads(repo._bookmarkcurrent)
4706 bmheads = repo.bookmarkheads(repo._activebookmark)
4707 curhead = repo[repo._bookmarkcurrent].node()
4707 curhead = repo[repo._activebookmark].node()
4708 if len(bmheads) == 2:
4708 if len(bmheads) == 2:
4709 if curhead == bmheads[0]:
4709 if curhead == bmheads[0]:
4710 node = bmheads[1]
4710 node = bmheads[1]
@@ -4719,7 +4719,7 b' def merge(ui, repo, node=None, **opts):'
4719 "please merge with an explicit rev or bookmark"),
4719 "please merge with an explicit rev or bookmark"),
4720 hint=_("run 'hg heads' to see all heads"))
4720 hint=_("run 'hg heads' to see all heads"))
4721
4721
4722 if not node and not repo._bookmarkcurrent:
4722 if not node and not repo._activebookmark:
4723 branch = repo[None].branch()
4723 branch = repo[None].branch()
4724 bheads = repo.branchheads(branch)
4724 bheads = repo.branchheads(branch)
4725 nbhs = [bh for bh in bheads if not repo[bh].bookmarks()]
4725 nbhs = [bh for bh in bheads if not repo[bh].bookmarks()]
@@ -5049,7 +5049,7 b' def postincoming(ui, repo, modheads, opt'
5049 return 0
5049 return 0
5050 if not ret and not checkout:
5050 if not ret and not checkout:
5051 if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
5051 if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
5052 ui.status(_("updating bookmark %s\n") % repo._bookmarkcurrent)
5052 ui.status(_("updating bookmark %s\n") % repo._activebookmark)
5053 return ret
5053 return ret
5054 if modheads > 1:
5054 if modheads > 1:
5055 currentbranchheads = len(repo.branchheads())
5055 currentbranchheads = len(repo.branchheads())
@@ -5914,7 +5914,7 b' def summary(ui, repo, **opts):'
5914 ui.status(m, label='log.branch')
5914 ui.status(m, label='log.branch')
5915
5915
5916 if marks:
5916 if marks:
5917 current = repo._bookmarkcurrent
5917 current = repo._activebookmark
5918 # i18n: column positioning for "hg summary"
5918 # i18n: column positioning for "hg summary"
5919 ui.write(_('bookmarks:'), label='log.bookmark')
5919 ui.write(_('bookmarks:'), label='log.bookmark')
5920 if current is not None:
5920 if current is not None:
@@ -6405,14 +6405,14 b' def update(ui, repo, node=None, rev=None'
6405
6405
6406 if not ret and movemarkfrom:
6406 if not ret and movemarkfrom:
6407 if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
6407 if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
6408 ui.status(_("updating bookmark %s\n") % repo._bookmarkcurrent)
6408 ui.status(_("updating bookmark %s\n") % repo._activebookmark)
6409 elif brev in repo._bookmarks:
6409 elif brev in repo._bookmarks:
6410 bookmarks.activate(repo, brev)
6410 bookmarks.activate(repo, brev)
6411 ui.status(_("(activating bookmark %s)\n") % brev)
6411 ui.status(_("(activating bookmark %s)\n") % brev)
6412 elif brev:
6412 elif brev:
6413 if repo._bookmarkcurrent:
6413 if repo._activebookmark:
6414 ui.status(_("(leaving bookmark %s)\n") %
6414 ui.status(_("(leaving bookmark %s)\n") %
6415 repo._bookmarkcurrent)
6415 repo._activebookmark)
6416 bookmarks.deactivate(repo)
6416 bookmarks.deactivate(repo)
6417
6417
6418 return ret
6418 return ret
@@ -415,7 +415,7 b' class localrepository(object):'
415 return bookmarks.bmstore(self)
415 return bookmarks.bmstore(self)
416
416
417 @repofilecache('bookmarks.current')
417 @repofilecache('bookmarks.current')
418 def _bookmarkcurrent(self):
418 def _activebookmark(self):
419 return bookmarks.readactive(self)
419 return bookmarks.readactive(self)
420
420
421 def bookmarkheads(self, bookmark):
421 def bookmarkheads(self, bookmark):
@@ -210,7 +210,7 b' def showbookmarks(**args):'
210 """
210 """
211 repo = args['ctx']._repo
211 repo = args['ctx']._repo
212 bookmarks = args['ctx'].bookmarks()
212 bookmarks = args['ctx'].bookmarks()
213 current = repo._bookmarkcurrent
213 current = repo._activebookmark
214 makemap = lambda v: {'bookmark': v, 'current': current}
214 makemap = lambda v: {'bookmark': v, 'current': current}
215 f = _showlist('bookmark', bookmarks, **args)
215 f = _showlist('bookmark', bookmarks, **args)
216 return _hybrid(f, bookmarks, makemap, lambda x: x['bookmark'])
216 return _hybrid(f, bookmarks, makemap, lambda x: x['bookmark'])
@@ -227,7 +227,7 b' def showcurrentbookmark(**args):'
227 import bookmarks as bookmarks # to avoid circular import issues
227 import bookmarks as bookmarks # to avoid circular import issues
228 repo = args['repo']
228 repo = args['repo']
229 if bookmarks.iscurrent(repo):
229 if bookmarks.iscurrent(repo):
230 current = repo._bookmarkcurrent
230 current = repo._activebookmark
231 if current in args['ctx'].bookmarks():
231 if current in args['ctx'].bookmarks():
232 return current
232 return current
233 return ''
233 return ''
General Comments 0
You need to be logged in to leave comments. Login now