Mercurial > hg
annotate mercurial/bookmarks.py @ 13423:4e60dad2261f
tests: test https through http proxy
These tests fails for me with Python 2.6(.nothing)
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Wed, 16 Feb 2011 04:28:11 +0100 |
parents | 5431b3f3e52e |
children | 0fe36c347c00 |
rev | line source |
---|---|
13350
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1 # Mercurial bookmark support code |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
2 # |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
3 # Copyright 2008 David Soria Parra <dsp@php.net> |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
4 # |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
6 # GNU General Public License version 2 or any later version. |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
7 |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
8 from mercurial.i18n import _ |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
9 from mercurial.node import nullid, nullrev, bin, hex, short |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
10 from mercurial import encoding |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
11 import os |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
12 |
13351
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
13 def read(repo): |
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
14 '''Parse .hg/bookmarks file and return a dictionary |
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
15 |
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
16 Bookmarks are stored as {HASH}\\s{NAME}\\n (localtags format) values |
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
17 in the .hg/bookmarks file. |
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
18 Read the file and return a (name=>nodeid) dictionary |
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
19 ''' |
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
20 try: |
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
21 bookmarks = {} |
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
22 for line in repo.opener('bookmarks'): |
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
23 sha, refspec = line.strip().split(' ', 1) |
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
24 refspec = encoding.tolocal(refspec) |
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
25 bookmarks[refspec] = repo.changelog.lookup(sha) |
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
26 except: |
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
27 pass |
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
28 return bookmarks |
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
29 |
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
30 def readcurrent(repo): |
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
31 '''Get the current bookmark |
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
32 |
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
33 If we use gittishsh branches we have a current bookmark that |
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
34 we are on. This function returns the name of the bookmark. It |
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
35 is stored in .hg/bookmarks.current |
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
36 ''' |
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
37 mark = None |
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
38 if os.path.exists(repo.join('bookmarks.current')): |
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
39 file = repo.opener('bookmarks.current') |
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
40 # No readline() in posixfile_nt, reading everything is cheap |
13381
d073468e3c5f
bookmarks: read current bookmark as utf-8 and convert it to local
David Soria Parra <dsp@php.net>
parents:
13354
diff
changeset
|
41 mark = encoding.tolocal((file.readlines() or [''])[0]) |
13351
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
42 if mark == '': |
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
43 mark = None |
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
44 file.close() |
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
45 return mark |
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
46 |
13350
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
47 def write(repo): |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
48 '''Write bookmarks |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
49 |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
50 Write the given bookmark => hash dictionary to the .hg/bookmarks file |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
51 in a format equal to those of localtags. |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
52 |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
53 We also store a backup of the previous state in undo.bookmarks that |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
54 can be copied back on rollback. |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
55 ''' |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
56 refs = repo._bookmarks |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
57 |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
58 try: |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
59 bms = repo.opener('bookmarks').read() |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
60 except IOError: |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
61 bms = '' |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
62 repo.opener('undo.bookmarks', 'w').write(bms) |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
63 |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
64 if repo._bookmarkcurrent not in refs: |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
65 setcurrent(repo, None) |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
66 wlock = repo.wlock() |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
67 try: |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
68 file = repo.opener('bookmarks', 'w', atomictemp=True) |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
69 for refspec, node in refs.iteritems(): |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
70 file.write("%s %s\n" % (hex(node), encoding.fromlocal(refspec))) |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
71 file.rename() |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
72 |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
73 # touch 00changelog.i so hgweb reloads bookmarks (no lock needed) |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
74 try: |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
75 os.utime(repo.sjoin('00changelog.i'), None) |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
76 except OSError: |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
77 pass |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
78 |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
79 finally: |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
80 wlock.release() |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
81 |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
82 def setcurrent(repo, mark): |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
83 '''Set the name of the bookmark that we are currently on |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
84 |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
85 Set the name of the bookmark that we are on (hg update <bookmark>). |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
86 The name is recorded in .hg/bookmarks.current |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
87 ''' |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
88 current = repo._bookmarkcurrent |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
89 if current == mark: |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
90 return |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
91 |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
92 refs = repo._bookmarks |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
93 |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
94 # do not update if we do update to a rev equal to the current bookmark |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
95 if (mark and mark not in refs and |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
96 current and refs[current] == repo.changectx('.').node()): |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
97 return |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
98 if mark not in refs: |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
99 mark = '' |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
100 wlock = repo.wlock() |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
101 try: |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
102 file = repo.opener('bookmarks.current', 'w', atomictemp=True) |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
103 file.write(mark) |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
104 file.rename() |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
105 finally: |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
106 wlock.release() |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
107 repo._bookmarkcurrent = mark |
13352
f9cd37fca5ba
bookmarks: move update into core
Matt Mackall <mpm@selenic.com>
parents:
13351
diff
changeset
|
108 |
f9cd37fca5ba
bookmarks: move update into core
Matt Mackall <mpm@selenic.com>
parents:
13351
diff
changeset
|
109 def update(repo, parents, node): |
f9cd37fca5ba
bookmarks: move update into core
Matt Mackall <mpm@selenic.com>
parents:
13351
diff
changeset
|
110 marks = repo._bookmarks |
f9cd37fca5ba
bookmarks: move update into core
Matt Mackall <mpm@selenic.com>
parents:
13351
diff
changeset
|
111 update = False |
13416
5431b3f3e52e
bookmarks: make track.current=True default behaviour and remove option (BC)
David Soria Parra <dsp@php.net>
parents:
13381
diff
changeset
|
112 mark = repo._bookmarkcurrent |
5431b3f3e52e
bookmarks: make track.current=True default behaviour and remove option (BC)
David Soria Parra <dsp@php.net>
parents:
13381
diff
changeset
|
113 if mark and marks[mark] in parents: |
5431b3f3e52e
bookmarks: make track.current=True default behaviour and remove option (BC)
David Soria Parra <dsp@php.net>
parents:
13381
diff
changeset
|
114 marks[mark] = node |
5431b3f3e52e
bookmarks: make track.current=True default behaviour and remove option (BC)
David Soria Parra <dsp@php.net>
parents:
13381
diff
changeset
|
115 update = True |
13352
f9cd37fca5ba
bookmarks: move update into core
Matt Mackall <mpm@selenic.com>
parents:
13351
diff
changeset
|
116 if update: |
f9cd37fca5ba
bookmarks: move update into core
Matt Mackall <mpm@selenic.com>
parents:
13351
diff
changeset
|
117 write(repo) |
13353
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
118 |
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
119 def listbookmarks(repo): |
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
120 # We may try to list bookmarks on a repo type that does not |
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
121 # support it (e.g., statichttprepository). |
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
122 if not hasattr(repo, '_bookmarks'): |
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
123 return {} |
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
124 |
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
125 d = {} |
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
126 for k, v in repo._bookmarks.iteritems(): |
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
127 d[k] = hex(v) |
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
128 return d |
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
129 |
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
130 def pushbookmark(repo, key, old, new): |
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
131 w = repo.wlock() |
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
132 try: |
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
133 marks = repo._bookmarks |
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
134 if hex(marks.get(key, '')) != old: |
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
135 return False |
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
136 if new == '': |
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
137 del marks[key] |
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
138 else: |
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
139 if new not in repo: |
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
140 return False |
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
141 marks[key] = repo[new].node() |
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
142 write(repo) |
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
143 return True |
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
144 finally: |
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
145 w.release() |
13354
4e1ba6ead69c
bookmarks: move diff to core
Matt Mackall <mpm@selenic.com>
parents:
13353
diff
changeset
|
146 |
4e1ba6ead69c
bookmarks: move diff to core
Matt Mackall <mpm@selenic.com>
parents:
13353
diff
changeset
|
147 def diff(ui, repo, remote): |
4e1ba6ead69c
bookmarks: move diff to core
Matt Mackall <mpm@selenic.com>
parents:
13353
diff
changeset
|
148 ui.status(_("searching for changed bookmarks\n")) |
4e1ba6ead69c
bookmarks: move diff to core
Matt Mackall <mpm@selenic.com>
parents:
13353
diff
changeset
|
149 |
4e1ba6ead69c
bookmarks: move diff to core
Matt Mackall <mpm@selenic.com>
parents:
13353
diff
changeset
|
150 lmarks = repo.listkeys('bookmarks') |
4e1ba6ead69c
bookmarks: move diff to core
Matt Mackall <mpm@selenic.com>
parents:
13353
diff
changeset
|
151 rmarks = remote.listkeys('bookmarks') |
4e1ba6ead69c
bookmarks: move diff to core
Matt Mackall <mpm@selenic.com>
parents:
13353
diff
changeset
|
152 |
4e1ba6ead69c
bookmarks: move diff to core
Matt Mackall <mpm@selenic.com>
parents:
13353
diff
changeset
|
153 diff = sorted(set(rmarks) - set(lmarks)) |
4e1ba6ead69c
bookmarks: move diff to core
Matt Mackall <mpm@selenic.com>
parents:
13353
diff
changeset
|
154 for k in diff: |
4e1ba6ead69c
bookmarks: move diff to core
Matt Mackall <mpm@selenic.com>
parents:
13353
diff
changeset
|
155 ui.write(" %-25s %s\n" % (k, rmarks[k][:12])) |
4e1ba6ead69c
bookmarks: move diff to core
Matt Mackall <mpm@selenic.com>
parents:
13353
diff
changeset
|
156 |
4e1ba6ead69c
bookmarks: move diff to core
Matt Mackall <mpm@selenic.com>
parents:
13353
diff
changeset
|
157 if len(diff) <= 0: |
4e1ba6ead69c
bookmarks: move diff to core
Matt Mackall <mpm@selenic.com>
parents:
13353
diff
changeset
|
158 ui.status(_("no changed bookmarks found\n")) |
4e1ba6ead69c
bookmarks: move diff to core
Matt Mackall <mpm@selenic.com>
parents:
13353
diff
changeset
|
159 return 1 |
4e1ba6ead69c
bookmarks: move diff to core
Matt Mackall <mpm@selenic.com>
parents:
13353
diff
changeset
|
160 return 0 |