Show More
@@ -60,6 +60,7 b' class bmstore(object):' | |||
|
60 | 60 | def __init__(self, repo): |
|
61 | 61 | self._repo = repo |
|
62 | 62 | self._refmap = refmap = {} # refspec: node |
|
63 | self._nodemap = nodemap = {} # node: sorted([refspec, ...]) | |
|
63 | 64 | self._clean = True |
|
64 | 65 | self._aclean = True |
|
65 | 66 | nm = repo.changelog.nodemap |
@@ -76,6 +77,14 b' class bmstore(object):' | |||
|
76 | 77 | if node in nm: |
|
77 | 78 | refspec = encoding.tolocal(refspec) |
|
78 | 79 | refmap[refspec] = node |
|
80 | nrefs = nodemap.get(node) | |
|
81 | if nrefs is None: | |
|
82 | nodemap[node] = [refspec] | |
|
83 | else: | |
|
84 | nrefs.append(refspec) | |
|
85 | if nrefs[-2] > refspec: | |
|
86 | # bookmarks weren't sorted before 4.5 | |
|
87 | nrefs.sort() | |
|
79 | 88 | except (TypeError, ValueError): |
|
80 | 89 | # TypeError: |
|
81 | 90 | # - bin(...) |
@@ -118,6 +127,7 b' class bmstore(object):' | |||
|
118 | 127 | return self._refmap.keys() |
|
119 | 128 | |
|
120 | 129 | # TODO: maybe rename to allnodes()? but nodes would have to be deduplicated |
|
130 | # could be self._nodemap.keys() | |
|
121 | 131 | def values(self): |
|
122 | 132 | return self._refmap.values() |
|
123 | 133 | |
@@ -132,19 +142,29 b' class bmstore(object):' | |||
|
132 | 142 | |
|
133 | 143 | def _set(self, mark, node): |
|
134 | 144 | self._clean = False |
|
145 | if mark in self._refmap: | |
|
146 | self._del(mark) | |
|
135 | 147 | self._refmap[mark] = node |
|
148 | nrefs = self._nodemap.get(node) | |
|
149 | if nrefs is None: | |
|
150 | self._nodemap[node] = [mark] | |
|
151 | else: | |
|
152 | nrefs.append(mark) | |
|
153 | nrefs.sort() | |
|
136 | 154 | |
|
137 | 155 | def _del(self, mark): |
|
138 | 156 | self._clean = False |
|
139 |
|
|
|
157 | node = self._refmap.pop(mark) | |
|
158 | nrefs = self._nodemap[node] | |
|
159 | if len(nrefs) == 1: | |
|
160 | assert nrefs[0] == mark | |
|
161 | del self._nodemap[node] | |
|
162 | else: | |
|
163 | nrefs.remove(mark) | |
|
140 | 164 | |
|
141 | 165 | def names(self, node): |
|
142 | 166 | """Return a sorted list of bookmarks pointing to the specified node""" |
|
143 | marks = [] | |
|
144 | for m, n in self._refmap.iteritems(): | |
|
145 | if n == node: | |
|
146 | marks.append(m) | |
|
147 | return sorted(marks) | |
|
167 | return self._nodemap.get(node, []) | |
|
148 | 168 | |
|
149 | 169 | def changectx(self, mark): |
|
150 | 170 | node = self._refmap[mark] |
@@ -68,6 +68,9 b' list bookmarks' | |||
|
68 | 68 | X 0:f7b1eb17ad24 |
|
69 | 69 | * X2 0:f7b1eb17ad24 |
|
70 | 70 | Y -1:000000000000 |
|
71 | $ hg log -T '{bookmarks % "{rev} {bookmark}\n"}' | |
|
72 | 0 X | |
|
73 | 0 X2 | |
|
71 | 74 | |
|
72 | 75 |
$ |
|
73 | 76 | $ hg add b |
@@ -299,6 +302,11 b' list bookmarks' | |||
|
299 | 302 | Y 2:db815d6d32e6 |
|
300 | 303 | Z 0:f7b1eb17ad24 |
|
301 | 304 | * x y 2:db815d6d32e6 |
|
305 | $ hg log -T '{bookmarks % "{rev} {bookmark}\n"}' | |
|
306 | 2 Y | |
|
307 | 2 x y | |
|
308 | 1 X2 | |
|
309 | 0 Z | |
|
302 | 310 | |
|
303 | 311 | look up stripped bookmark name |
|
304 | 312 | |
@@ -445,6 +453,11 b' list bookmarks' | |||
|
445 | 453 | Y 2:db815d6d32e6 |
|
446 | 454 | * Z 2:db815d6d32e6 |
|
447 | 455 | x y 2:db815d6d32e6 |
|
456 | $ hg log -T '{bookmarks % "{rev} {bookmark}\n"}' | |
|
457 | 2 Y | |
|
458 | 2 Z | |
|
459 | 2 x y | |
|
460 | 1 X2 | |
|
448 | 461 | |
|
449 | 462 | revision but no bookmark name |
|
450 | 463 |
General Comments 0
You need to be logged in to leave comments.
Login now