author | Yuya Nishihara <yuya@tcha.org> |
Sat, 14 Nov 2015 16:45:15 +0900 | |
changeset 27213 | ccae1588117f |
parent 27188 | 6a1301e22bd7 |
child 27276 | 38024b75241a |
permissions | -rw-r--r-- |
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 |
|
25917
aa323b53e3f9
bookmarks: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25743
diff
changeset
|
8 |
from __future__ import absolute_import |
aa323b53e3f9
bookmarks: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25743
diff
changeset
|
9 |
|
aa323b53e3f9
bookmarks: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25743
diff
changeset
|
10 |
import errno |
23360
e06daad65f85
bookmark: read pending data when appropriate
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23317
diff
changeset
|
11 |
import os |
25917
aa323b53e3f9
bookmarks: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25743
diff
changeset
|
12 |
|
aa323b53e3f9
bookmarks: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25743
diff
changeset
|
13 |
from .i18n import _ |
aa323b53e3f9
bookmarks: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25743
diff
changeset
|
14 |
from .node import ( |
aa323b53e3f9
bookmarks: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25743
diff
changeset
|
15 |
bin, |
aa323b53e3f9
bookmarks: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25743
diff
changeset
|
16 |
hex, |
aa323b53e3f9
bookmarks: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25743
diff
changeset
|
17 |
) |
aa323b53e3f9
bookmarks: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25743
diff
changeset
|
18 |
from . import ( |
aa323b53e3f9
bookmarks: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25743
diff
changeset
|
19 |
encoding, |
aa323b53e3f9
bookmarks: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25743
diff
changeset
|
20 |
lock as lockmod, |
aa323b53e3f9
bookmarks: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25743
diff
changeset
|
21 |
obsolete, |
aa323b53e3f9
bookmarks: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25743
diff
changeset
|
22 |
util, |
aa323b53e3f9
bookmarks: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25743
diff
changeset
|
23 |
) |
13350
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
24 |
|
27186
34d26e22a2b0
bookmarks: hoist getbkfile out of bmstore class
Augie Fackler <augie@google.com>
parents:
27185
diff
changeset
|
25 |
def _getbkfile(repo): |
34d26e22a2b0
bookmarks: hoist getbkfile out of bmstore class
Augie Fackler <augie@google.com>
parents:
27185
diff
changeset
|
26 |
"""Hook so that extensions that mess with the store can hook bm storage. |
34d26e22a2b0
bookmarks: hoist getbkfile out of bmstore class
Augie Fackler <augie@google.com>
parents:
27185
diff
changeset
|
27 |
|
34d26e22a2b0
bookmarks: hoist getbkfile out of bmstore class
Augie Fackler <augie@google.com>
parents:
27185
diff
changeset
|
28 |
For core, this just handles wether we should see pending |
34d26e22a2b0
bookmarks: hoist getbkfile out of bmstore class
Augie Fackler <augie@google.com>
parents:
27185
diff
changeset
|
29 |
bookmarks or the committed ones. Other extensions (like share) |
34d26e22a2b0
bookmarks: hoist getbkfile out of bmstore class
Augie Fackler <augie@google.com>
parents:
27185
diff
changeset
|
30 |
may need to tweak this behavior further. |
34d26e22a2b0
bookmarks: hoist getbkfile out of bmstore class
Augie Fackler <augie@google.com>
parents:
27185
diff
changeset
|
31 |
""" |
34d26e22a2b0
bookmarks: hoist getbkfile out of bmstore class
Augie Fackler <augie@google.com>
parents:
27185
diff
changeset
|
32 |
bkfile = None |
34d26e22a2b0
bookmarks: hoist getbkfile out of bmstore class
Augie Fackler <augie@google.com>
parents:
27185
diff
changeset
|
33 |
if 'HG_PENDING' in os.environ: |
34d26e22a2b0
bookmarks: hoist getbkfile out of bmstore class
Augie Fackler <augie@google.com>
parents:
27185
diff
changeset
|
34 |
try: |
34d26e22a2b0
bookmarks: hoist getbkfile out of bmstore class
Augie Fackler <augie@google.com>
parents:
27185
diff
changeset
|
35 |
bkfile = repo.vfs('bookmarks.pending') |
34d26e22a2b0
bookmarks: hoist getbkfile out of bmstore class
Augie Fackler <augie@google.com>
parents:
27185
diff
changeset
|
36 |
except IOError as inst: |
34d26e22a2b0
bookmarks: hoist getbkfile out of bmstore class
Augie Fackler <augie@google.com>
parents:
27185
diff
changeset
|
37 |
if inst.errno != errno.ENOENT: |
34d26e22a2b0
bookmarks: hoist getbkfile out of bmstore class
Augie Fackler <augie@google.com>
parents:
27185
diff
changeset
|
38 |
raise |
34d26e22a2b0
bookmarks: hoist getbkfile out of bmstore class
Augie Fackler <augie@google.com>
parents:
27185
diff
changeset
|
39 |
if bkfile is None: |
34d26e22a2b0
bookmarks: hoist getbkfile out of bmstore class
Augie Fackler <augie@google.com>
parents:
27185
diff
changeset
|
40 |
bkfile = repo.vfs('bookmarks') |
34d26e22a2b0
bookmarks: hoist getbkfile out of bmstore class
Augie Fackler <augie@google.com>
parents:
27185
diff
changeset
|
41 |
return bkfile |
34d26e22a2b0
bookmarks: hoist getbkfile out of bmstore class
Augie Fackler <augie@google.com>
parents:
27185
diff
changeset
|
42 |
|
34d26e22a2b0
bookmarks: hoist getbkfile out of bmstore class
Augie Fackler <augie@google.com>
parents:
27185
diff
changeset
|
43 |
|
17922
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
44 |
class bmstore(dict): |
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
45 |
"""Storage for bookmarks. |
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
46 |
|
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
47 |
This object should do all bookmark reads and writes, so that it's |
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
48 |
fairly simple to replace the storage underlying bookmarks without |
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
49 |
having to clone the logic surrounding bookmarks. |
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
50 |
|
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
51 |
This particular bmstore implementation stores bookmarks as |
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
52 |
{hash}\s{name}\n (the same format as localtags) in |
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
53 |
.hg/bookmarks. The mapping is stored as {name: nodeid}. |
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
54 |
|
25100
d6e7ac651973
bookmarks: rename current to active in variables and comments
Ryan McElroy <rmcelroy@fb.com>
parents:
25081
diff
changeset
|
55 |
This class does NOT handle the "active" bookmark state at this |
17922
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
56 |
time. |
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
57 |
""" |
13351
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
58 |
|
17922
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
59 |
def __init__(self, repo): |
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
60 |
dict.__init__(self) |
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
61 |
self._repo = repo |
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
62 |
try: |
27186
34d26e22a2b0
bookmarks: hoist getbkfile out of bmstore class
Augie Fackler <augie@google.com>
parents:
27185
diff
changeset
|
63 |
bkfile = _getbkfile(repo) |
23360
e06daad65f85
bookmark: read pending data when appropriate
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23317
diff
changeset
|
64 |
for line in bkfile: |
17922
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
65 |
line = line.strip() |
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
66 |
if not line: |
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
67 |
continue |
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
68 |
if ' ' not in line: |
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
69 |
repo.ui.warn(_('malformed line in .hg/bookmarks: %r\n') |
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
70 |
% line) |
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
71 |
continue |
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
72 |
sha, refspec = line.split(' ', 1) |
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
73 |
refspec = encoding.tolocal(refspec) |
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
74 |
try: |
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
75 |
self[refspec] = repo.changelog.lookup(sha) |
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
76 |
except LookupError: |
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
77 |
pass |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25569
diff
changeset
|
78 |
except IOError as inst: |
17922
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
79 |
if inst.errno != errno.ENOENT: |
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
80 |
raise |
27187
d9dcc5c09d77
bmstore: add basic clean-state tracking
Augie Fackler <augie@google.com>
parents:
27186
diff
changeset
|
81 |
self._clean = True |
d9dcc5c09d77
bmstore: add basic clean-state tracking
Augie Fackler <augie@google.com>
parents:
27186
diff
changeset
|
82 |
|
d9dcc5c09d77
bmstore: add basic clean-state tracking
Augie Fackler <augie@google.com>
parents:
27186
diff
changeset
|
83 |
def __setitem__(self, *args, **kwargs): |
d9dcc5c09d77
bmstore: add basic clean-state tracking
Augie Fackler <augie@google.com>
parents:
27186
diff
changeset
|
84 |
self._clean = False |
d9dcc5c09d77
bmstore: add basic clean-state tracking
Augie Fackler <augie@google.com>
parents:
27186
diff
changeset
|
85 |
return dict.__setitem__(self, *args, **kwargs) |
d9dcc5c09d77
bmstore: add basic clean-state tracking
Augie Fackler <augie@google.com>
parents:
27186
diff
changeset
|
86 |
|
d9dcc5c09d77
bmstore: add basic clean-state tracking
Augie Fackler <augie@google.com>
parents:
27186
diff
changeset
|
87 |
def __delitem__(self, key): |
d9dcc5c09d77
bmstore: add basic clean-state tracking
Augie Fackler <augie@google.com>
parents:
27186
diff
changeset
|
88 |
self._clean = False |
d9dcc5c09d77
bmstore: add basic clean-state tracking
Augie Fackler <augie@google.com>
parents:
27186
diff
changeset
|
89 |
return dict.__delitem__(self, key) |
17922
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
90 |
|
22665
8319f7e78395
bookmark: add a `bmstore.recordupdate` to plug bookmarks into the transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22664
diff
changeset
|
91 |
def recordchange(self, tr): |
8319f7e78395
bookmark: add a `bmstore.recordupdate` to plug bookmarks into the transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22664
diff
changeset
|
92 |
"""record that bookmarks have been changed in a transaction |
8319f7e78395
bookmark: add a `bmstore.recordupdate` to plug bookmarks into the transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22664
diff
changeset
|
93 |
|
8319f7e78395
bookmark: add a `bmstore.recordupdate` to plug bookmarks into the transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22664
diff
changeset
|
94 |
The transaction is then responsible for updating the file content.""" |
8319f7e78395
bookmark: add a `bmstore.recordupdate` to plug bookmarks into the transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22664
diff
changeset
|
95 |
tr.addfilegenerator('bookmarks', ('bookmarks',), self._write, |
23317
197e17be5407
transaction: use 'location' instead of 'vfs' objects for file generation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23199
diff
changeset
|
96 |
location='plain') |
22941
da2758c0aca0
bookmarks: inform transaction-related hooks that some bookmarks were moved
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22667
diff
changeset
|
97 |
tr.hookargs['bookmark_moved'] = '1' |
22665
8319f7e78395
bookmark: add a `bmstore.recordupdate` to plug bookmarks into the transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22664
diff
changeset
|
98 |
|
17922
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
99 |
def write(self): |
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
100 |
'''Write bookmarks |
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
101 |
|
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
102 |
Write the given bookmark => hash dictionary to the .hg/bookmarks file |
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
103 |
in a format equal to those of localtags. |
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
104 |
|
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
105 |
We also store a backup of the previous state in undo.bookmarks that |
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
106 |
can be copied back on rollback. |
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
107 |
''' |
27187
d9dcc5c09d77
bmstore: add basic clean-state tracking
Augie Fackler <augie@google.com>
parents:
27186
diff
changeset
|
108 |
if self._clean: |
d9dcc5c09d77
bmstore: add basic clean-state tracking
Augie Fackler <augie@google.com>
parents:
27186
diff
changeset
|
109 |
return |
17922
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
110 |
repo = self._repo |
26031
0b57b77f9b3e
devel-warn: issue a warning when writing bookmarks without holding the wlock
Laurent Charignon <lcharignon@fb.com>
parents:
25917
diff
changeset
|
111 |
if (repo.ui.configbool('devel', 'all-warnings') |
0b57b77f9b3e
devel-warn: issue a warning when writing bookmarks without holding the wlock
Laurent Charignon <lcharignon@fb.com>
parents:
25917
diff
changeset
|
112 |
or repo.ui.configbool('devel', 'check-locks')): |
0b57b77f9b3e
devel-warn: issue a warning when writing bookmarks without holding the wlock
Laurent Charignon <lcharignon@fb.com>
parents:
25917
diff
changeset
|
113 |
l = repo._wlockref and repo._wlockref() |
0b57b77f9b3e
devel-warn: issue a warning when writing bookmarks without holding the wlock
Laurent Charignon <lcharignon@fb.com>
parents:
25917
diff
changeset
|
114 |
if l is None or not l.held: |
0b57b77f9b3e
devel-warn: issue a warning when writing bookmarks without holding the wlock
Laurent Charignon <lcharignon@fb.com>
parents:
25917
diff
changeset
|
115 |
repo.ui.develwarn('bookmarks write with no wlock') |
26520
46dec89fe888
bookmarks: use recordchange instead of writing if transaction is active
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
26031
diff
changeset
|
116 |
|
46dec89fe888
bookmarks: use recordchange instead of writing if transaction is active
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
26031
diff
changeset
|
117 |
tr = repo.currenttransaction() |
46dec89fe888
bookmarks: use recordchange instead of writing if transaction is active
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
26031
diff
changeset
|
118 |
if tr: |
46dec89fe888
bookmarks: use recordchange instead of writing if transaction is active
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
26031
diff
changeset
|
119 |
self.recordchange(tr) |
46dec89fe888
bookmarks: use recordchange instead of writing if transaction is active
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
26031
diff
changeset
|
120 |
# invalidatevolatilesets() is omitted because this doesn't |
46dec89fe888
bookmarks: use recordchange instead of writing if transaction is active
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
26031
diff
changeset
|
121 |
# write changes out actually |
46dec89fe888
bookmarks: use recordchange instead of writing if transaction is active
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
26031
diff
changeset
|
122 |
return |
46dec89fe888
bookmarks: use recordchange instead of writing if transaction is active
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
26031
diff
changeset
|
123 |
|
23469
65e48b8d20f5
bookmarks: factor out repository lookup from writing bookmarks file
Ryan McElroy <rmcelroy@fb.com>
parents:
23458
diff
changeset
|
124 |
self._writerepo(repo) |
25569
2612e6dab189
repoview: invalidate 'visible' filtered revisions when bookmarks change
Laurent Charignon <lcharignon@fb.com>
parents:
25564
diff
changeset
|
125 |
repo.invalidatevolatilesets() |
23469
65e48b8d20f5
bookmarks: factor out repository lookup from writing bookmarks file
Ryan McElroy <rmcelroy@fb.com>
parents:
23458
diff
changeset
|
126 |
|
65e48b8d20f5
bookmarks: factor out repository lookup from writing bookmarks file
Ryan McElroy <rmcelroy@fb.com>
parents:
23458
diff
changeset
|
127 |
def _writerepo(self, repo): |
65e48b8d20f5
bookmarks: factor out repository lookup from writing bookmarks file
Ryan McElroy <rmcelroy@fb.com>
parents:
23458
diff
changeset
|
128 |
"""Factored out for extensibility""" |
24947
a02d293a1079
bookmarks: rename bookmarkcurrent to activebookmark (API)
Ryan McElroy <rmcelroy@fb.com>
parents:
24946
diff
changeset
|
129 |
if repo._activebookmark not in self: |
24944
08ec11e3ae4c
bookmarks: rename unsetcurrent to deactivate (API)
Ryan McElroy <rmcelroy@fb.com>
parents:
24832
diff
changeset
|
130 |
deactivate(repo) |
17922
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
131 |
|
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
132 |
wlock = repo.wlock() |
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
133 |
try: |
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
134 |
|
27188
6a1301e22bd7
bmstore: close file in a finally block in _writerepo
Augie Fackler <augie@google.com>
parents:
27187
diff
changeset
|
135 |
file_ = repo.vfs('bookmarks', 'w', atomictemp=True) |
6a1301e22bd7
bmstore: close file in a finally block in _writerepo
Augie Fackler <augie@google.com>
parents:
27187
diff
changeset
|
136 |
try: |
6a1301e22bd7
bmstore: close file in a finally block in _writerepo
Augie Fackler <augie@google.com>
parents:
27187
diff
changeset
|
137 |
self._write(file_) |
6a1301e22bd7
bmstore: close file in a finally block in _writerepo
Augie Fackler <augie@google.com>
parents:
27187
diff
changeset
|
138 |
except: # re-raises |
6a1301e22bd7
bmstore: close file in a finally block in _writerepo
Augie Fackler <augie@google.com>
parents:
27187
diff
changeset
|
139 |
file_.discard() |
6a1301e22bd7
bmstore: close file in a finally block in _writerepo
Augie Fackler <augie@google.com>
parents:
27187
diff
changeset
|
140 |
raise |
6a1301e22bd7
bmstore: close file in a finally block in _writerepo
Augie Fackler <augie@google.com>
parents:
27187
diff
changeset
|
141 |
finally: |
6a1301e22bd7
bmstore: close file in a finally block in _writerepo
Augie Fackler <augie@google.com>
parents:
27187
diff
changeset
|
142 |
file_.close() |
17922
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
143 |
|
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
144 |
finally: |
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
145 |
wlock.release() |
13351
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
146 |
|
22664
6bd685d2a2de
bookmarks: split bookmark serialization and file handling
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22659
diff
changeset
|
147 |
def _write(self, fp): |
6bd685d2a2de
bookmarks: split bookmark serialization and file handling
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22659
diff
changeset
|
148 |
for name, node in self.iteritems(): |
6bd685d2a2de
bookmarks: split bookmark serialization and file handling
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22659
diff
changeset
|
149 |
fp.write("%s %s\n" % (hex(node), encoding.fromlocal(name))) |
27187
d9dcc5c09d77
bmstore: add basic clean-state tracking
Augie Fackler <augie@google.com>
parents:
27186
diff
changeset
|
150 |
self._clean = True |
22664
6bd685d2a2de
bookmarks: split bookmark serialization and file handling
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22659
diff
changeset
|
151 |
|
24946
c44534209a0a
bookmarks: rename readcurrent to readactive (API)
Ryan McElroy <rmcelroy@fb.com>
parents:
24945
diff
changeset
|
152 |
def readactive(repo): |
c44534209a0a
bookmarks: rename readcurrent to readactive (API)
Ryan McElroy <rmcelroy@fb.com>
parents:
24945
diff
changeset
|
153 |
""" |
c44534209a0a
bookmarks: rename readcurrent to readactive (API)
Ryan McElroy <rmcelroy@fb.com>
parents:
24945
diff
changeset
|
154 |
Get the active bookmark. We can have an active bookmark that updates |
c44534209a0a
bookmarks: rename readcurrent to readactive (API)
Ryan McElroy <rmcelroy@fb.com>
parents:
24945
diff
changeset
|
155 |
itself as we commit. This function returns the name of that bookmark. |
c44534209a0a
bookmarks: rename readcurrent to readactive (API)
Ryan McElroy <rmcelroy@fb.com>
parents:
24945
diff
changeset
|
156 |
It is stored in .hg/bookmarks.current |
c44534209a0a
bookmarks: rename readcurrent to readactive (API)
Ryan McElroy <rmcelroy@fb.com>
parents:
24945
diff
changeset
|
157 |
""" |
13351
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
158 |
mark = None |
14027
78ab705a8147
bookmarks: be more restrictive in our Exception catching
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14004
diff
changeset
|
159 |
try: |
23877
7cc77030c557
localrepo: remove all external users of localrepo.opener
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
23469
diff
changeset
|
160 |
file = repo.vfs('bookmarks.current') |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25569
diff
changeset
|
161 |
except IOError as inst: |
14027
78ab705a8147
bookmarks: be more restrictive in our Exception catching
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14004
diff
changeset
|
162 |
if inst.errno != errno.ENOENT: |
78ab705a8147
bookmarks: be more restrictive in our Exception catching
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14004
diff
changeset
|
163 |
raise |
78ab705a8147
bookmarks: be more restrictive in our Exception catching
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14004
diff
changeset
|
164 |
return None |
78ab705a8147
bookmarks: be more restrictive in our Exception catching
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14004
diff
changeset
|
165 |
try: |
17425
e95ec38f86b0
fix wording and not-completely-trivial spelling errors and bad docstrings
Mads Kiilerich <mads@kiilerich.com>
parents:
16719
diff
changeset
|
166 |
# No readline() in osutil.posixfile, 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
|
167 |
mark = encoding.tolocal((file.readlines() or [''])[0]) |
13627
71a96f6c205d
bookmarks: discard current bookmark if absent from the bookmarks (issue2692)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13478
diff
changeset
|
168 |
if mark == '' or mark not in repo._bookmarks: |
13351
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
169 |
mark = None |
14027
78ab705a8147
bookmarks: be more restrictive in our Exception catching
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14004
diff
changeset
|
170 |
finally: |
13351
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
171 |
file.close() |
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
172 |
return mark |
6c5368cd2df9
bookmarks: move read methods to core
Matt Mackall <mpm@selenic.com>
parents:
13350
diff
changeset
|
173 |
|
24945
e0b0fbd47491
bookmarks: rename setcurrent to activate (API)
Ryan McElroy <rmcelroy@fb.com>
parents:
24944
diff
changeset
|
174 |
def activate(repo, mark): |
e0b0fbd47491
bookmarks: rename setcurrent to activate (API)
Ryan McElroy <rmcelroy@fb.com>
parents:
24944
diff
changeset
|
175 |
""" |
e0b0fbd47491
bookmarks: rename setcurrent to activate (API)
Ryan McElroy <rmcelroy@fb.com>
parents:
24944
diff
changeset
|
176 |
Set the given bookmark to be 'active', meaning that this bookmark will |
e0b0fbd47491
bookmarks: rename setcurrent to activate (API)
Ryan McElroy <rmcelroy@fb.com>
parents:
24944
diff
changeset
|
177 |
follow new commits that are made. |
13350
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
178 |
The name is recorded in .hg/bookmarks.current |
24945
e0b0fbd47491
bookmarks: rename setcurrent to activate (API)
Ryan McElroy <rmcelroy@fb.com>
parents:
24944
diff
changeset
|
179 |
""" |
20100
0f01d0692bc5
bookmarks: make setcurrent with None an error
Siddharth Agarwal <sid0@fb.com>
parents:
20098
diff
changeset
|
180 |
if mark not in repo._bookmarks: |
0f01d0692bc5
bookmarks: make setcurrent with None an error
Siddharth Agarwal <sid0@fb.com>
parents:
20098
diff
changeset
|
181 |
raise AssertionError('bookmark %s does not exist!' % mark) |
0f01d0692bc5
bookmarks: make setcurrent with None an error
Siddharth Agarwal <sid0@fb.com>
parents:
20098
diff
changeset
|
182 |
|
25100
d6e7ac651973
bookmarks: rename current to active in variables and comments
Ryan McElroy <rmcelroy@fb.com>
parents:
25081
diff
changeset
|
183 |
active = repo._activebookmark |
d6e7ac651973
bookmarks: rename current to active in variables and comments
Ryan McElroy <rmcelroy@fb.com>
parents:
25081
diff
changeset
|
184 |
if active == mark: |
13350
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
185 |
return |
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
186 |
|
15908
60cb4f381a78
bookmarks: backout locking change in 12dea4d998ec
Matt Mackall <mpm@selenic.com>
parents:
15887
diff
changeset
|
187 |
wlock = repo.wlock() |
13350
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
188 |
try: |
23877
7cc77030c557
localrepo: remove all external users of localrepo.opener
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
23469
diff
changeset
|
189 |
file = repo.vfs('bookmarks.current', 'w', atomictemp=True) |
14559
e29821ca94cf
bookmarks: recognize the current bookmark when the local encoding isn't UTF-8
LUO Zheng <xmuluo@gmail.com>
parents:
14268
diff
changeset
|
190 |
file.write(encoding.fromlocal(mark)) |
15057
774da7121fc9
atomictempfile: make close() consistent with other file-like objects.
Greg Ward <greg@gerg.ca>
parents:
14946
diff
changeset
|
191 |
file.close() |
13350
a7376b92caaa
bookmarks: move basic io to core
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
192 |
finally: |
15908
60cb4f381a78
bookmarks: backout locking change in 12dea4d998ec
Matt Mackall <mpm@selenic.com>
parents:
15887
diff
changeset
|
193 |
wlock.release() |
24947
a02d293a1079
bookmarks: rename bookmarkcurrent to activebookmark (API)
Ryan McElroy <rmcelroy@fb.com>
parents:
24946
diff
changeset
|
194 |
repo._activebookmark = mark |
13352
f9cd37fca5ba
bookmarks: move update into core
Matt Mackall <mpm@selenic.com>
parents:
13351
diff
changeset
|
195 |
|
24944
08ec11e3ae4c
bookmarks: rename unsetcurrent to deactivate (API)
Ryan McElroy <rmcelroy@fb.com>
parents:
24832
diff
changeset
|
196 |
def deactivate(repo): |
08ec11e3ae4c
bookmarks: rename unsetcurrent to deactivate (API)
Ryan McElroy <rmcelroy@fb.com>
parents:
24832
diff
changeset
|
197 |
""" |
26781
1aee2ab0f902
spelling: trivial spell checking
Mads Kiilerich <madski@unity3d.com>
parents:
26520
diff
changeset
|
198 |
Unset the active bookmark in this repository. |
24944
08ec11e3ae4c
bookmarks: rename unsetcurrent to deactivate (API)
Ryan McElroy <rmcelroy@fb.com>
parents:
24832
diff
changeset
|
199 |
""" |
16191
7c75924a6926
update: delete bookmarks.current when explicitly updating to a rev (issue3276)
Idan Kamara <idankk86@gmail.com>
parents:
15984
diff
changeset
|
200 |
wlock = repo.wlock() |
7c75924a6926
update: delete bookmarks.current when explicitly updating to a rev (issue3276)
Idan Kamara <idankk86@gmail.com>
parents:
15984
diff
changeset
|
201 |
try: |
25081
7642f119c2a2
bookmarks: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
24986
diff
changeset
|
202 |
repo.vfs.unlink('bookmarks.current') |
7642f119c2a2
bookmarks: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
24986
diff
changeset
|
203 |
repo._activebookmark = None |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25569
diff
changeset
|
204 |
except OSError as inst: |
25081
7642f119c2a2
bookmarks: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
24986
diff
changeset
|
205 |
if inst.errno != errno.ENOENT: |
7642f119c2a2
bookmarks: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
24986
diff
changeset
|
206 |
raise |
16191
7c75924a6926
update: delete bookmarks.current when explicitly updating to a rev (issue3276)
Idan Kamara <idankk86@gmail.com>
parents:
15984
diff
changeset
|
207 |
finally: |
7c75924a6926
update: delete bookmarks.current when explicitly updating to a rev (issue3276)
Idan Kamara <idankk86@gmail.com>
parents:
15984
diff
changeset
|
208 |
wlock.release() |
7c75924a6926
update: delete bookmarks.current when explicitly updating to a rev (issue3276)
Idan Kamara <idankk86@gmail.com>
parents:
15984
diff
changeset
|
209 |
|
24986
fb9b7b937b3e
bookmarks: simplify iscurrent to isactivewdirparent (API)
Ryan McElroy <rmcelroy@fb.com>
parents:
24962
diff
changeset
|
210 |
def isactivewdirparent(repo): |
fb9b7b937b3e
bookmarks: simplify iscurrent to isactivewdirparent (API)
Ryan McElroy <rmcelroy@fb.com>
parents:
24962
diff
changeset
|
211 |
""" |
fb9b7b937b3e
bookmarks: simplify iscurrent to isactivewdirparent (API)
Ryan McElroy <rmcelroy@fb.com>
parents:
24962
diff
changeset
|
212 |
Tell whether the 'active' bookmark (the one that follows new commits) |
fb9b7b937b3e
bookmarks: simplify iscurrent to isactivewdirparent (API)
Ryan McElroy <rmcelroy@fb.com>
parents:
24962
diff
changeset
|
213 |
points to one of the parents of the current working directory (wdir). |
18471
2096e025a728
update: update to current bookmark if it moved out from under us (issue3682)
Kevin Bullock <kbullock@ringworld.org>
parents:
18363
diff
changeset
|
214 |
|
24986
fb9b7b937b3e
bookmarks: simplify iscurrent to isactivewdirparent (API)
Ryan McElroy <rmcelroy@fb.com>
parents:
24962
diff
changeset
|
215 |
While this is normally the case, it can on occasion be false; for example, |
fb9b7b937b3e
bookmarks: simplify iscurrent to isactivewdirparent (API)
Ryan McElroy <rmcelroy@fb.com>
parents:
24962
diff
changeset
|
216 |
immediately after a pull, the active bookmark can be moved to point |
fb9b7b937b3e
bookmarks: simplify iscurrent to isactivewdirparent (API)
Ryan McElroy <rmcelroy@fb.com>
parents:
24962
diff
changeset
|
217 |
to a place different than the wdir. This is solved by running `hg update`. |
fb9b7b937b3e
bookmarks: simplify iscurrent to isactivewdirparent (API)
Ryan McElroy <rmcelroy@fb.com>
parents:
24962
diff
changeset
|
218 |
""" |
fb9b7b937b3e
bookmarks: simplify iscurrent to isactivewdirparent (API)
Ryan McElroy <rmcelroy@fb.com>
parents:
24962
diff
changeset
|
219 |
mark = repo._activebookmark |
18471
2096e025a728
update: update to current bookmark if it moved out from under us (issue3682)
Kevin Bullock <kbullock@ringworld.org>
parents:
18363
diff
changeset
|
220 |
marks = repo._bookmarks |
24986
fb9b7b937b3e
bookmarks: simplify iscurrent to isactivewdirparent (API)
Ryan McElroy <rmcelroy@fb.com>
parents:
24962
diff
changeset
|
221 |
parents = [p.node() for p in repo[None].parents()] |
18471
2096e025a728
update: update to current bookmark if it moved out from under us (issue3682)
Kevin Bullock <kbullock@ringworld.org>
parents:
18363
diff
changeset
|
222 |
return (mark in marks and marks[mark] in parents) |
2096e025a728
update: update to current bookmark if it moved out from under us (issue3682)
Kevin Bullock <kbullock@ringworld.org>
parents:
18363
diff
changeset
|
223 |
|
18513
37ce336ab2dd
bookmarks: factor out delete divergent code
Siddharth Agarwal <sid0@fb.com>
parents:
18496
diff
changeset
|
224 |
def deletedivergent(repo, deletefrom, bm): |
37ce336ab2dd
bookmarks: factor out delete divergent code
Siddharth Agarwal <sid0@fb.com>
parents:
18496
diff
changeset
|
225 |
'''Delete divergent versions of bm on nodes in deletefrom. |
37ce336ab2dd
bookmarks: factor out delete divergent code
Siddharth Agarwal <sid0@fb.com>
parents:
18496
diff
changeset
|
226 |
|
37ce336ab2dd
bookmarks: factor out delete divergent code
Siddharth Agarwal <sid0@fb.com>
parents:
18496
diff
changeset
|
227 |
Return True if at least one bookmark was deleted, False otherwise.''' |
37ce336ab2dd
bookmarks: factor out delete divergent code
Siddharth Agarwal <sid0@fb.com>
parents:
18496
diff
changeset
|
228 |
deleted = False |
37ce336ab2dd
bookmarks: factor out delete divergent code
Siddharth Agarwal <sid0@fb.com>
parents:
18496
diff
changeset
|
229 |
marks = repo._bookmarks |
37ce336ab2dd
bookmarks: factor out delete divergent code
Siddharth Agarwal <sid0@fb.com>
parents:
18496
diff
changeset
|
230 |
divergent = [b for b in marks if b.split('@', 1)[0] == bm.split('@', 1)[0]] |
37ce336ab2dd
bookmarks: factor out delete divergent code
Siddharth Agarwal <sid0@fb.com>
parents:
18496
diff
changeset
|
231 |
for mark in divergent: |
21843
92666a869ea4
bookmarks: avoid deleting primary bookmarks on rebase
Matt Mackall <mpm@selenic.com>
parents:
20352
diff
changeset
|
232 |
if mark == '@' or '@' not in mark: |
92666a869ea4
bookmarks: avoid deleting primary bookmarks on rebase
Matt Mackall <mpm@selenic.com>
parents:
20352
diff
changeset
|
233 |
# can't be divergent by definition |
92666a869ea4
bookmarks: avoid deleting primary bookmarks on rebase
Matt Mackall <mpm@selenic.com>
parents:
20352
diff
changeset
|
234 |
continue |
18513
37ce336ab2dd
bookmarks: factor out delete divergent code
Siddharth Agarwal <sid0@fb.com>
parents:
18496
diff
changeset
|
235 |
if mark and marks[mark] in deletefrom: |
37ce336ab2dd
bookmarks: factor out delete divergent code
Siddharth Agarwal <sid0@fb.com>
parents:
18496
diff
changeset
|
236 |
if mark != bm: |
37ce336ab2dd
bookmarks: factor out delete divergent code
Siddharth Agarwal <sid0@fb.com>
parents:
18496
diff
changeset
|
237 |
del marks[mark] |
37ce336ab2dd
bookmarks: factor out delete divergent code
Siddharth Agarwal <sid0@fb.com>
parents:
18496
diff
changeset
|
238 |
deleted = True |
37ce336ab2dd
bookmarks: factor out delete divergent code
Siddharth Agarwal <sid0@fb.com>
parents:
18496
diff
changeset
|
239 |
return deleted |
37ce336ab2dd
bookmarks: factor out delete divergent code
Siddharth Agarwal <sid0@fb.com>
parents:
18496
diff
changeset
|
240 |
|
19523
f37b5a17e6a0
bookmarks: pull --update updates to active bookmark if it moved (issue4007)
Kevin Bullock <kbullock@ringworld.org>
parents:
19110
diff
changeset
|
241 |
def calculateupdate(ui, repo, checkout): |
f37b5a17e6a0
bookmarks: pull --update updates to active bookmark if it moved (issue4007)
Kevin Bullock <kbullock@ringworld.org>
parents:
19110
diff
changeset
|
242 |
'''Return a tuple (targetrev, movemarkfrom) indicating the rev to |
f37b5a17e6a0
bookmarks: pull --update updates to active bookmark if it moved (issue4007)
Kevin Bullock <kbullock@ringworld.org>
parents:
19110
diff
changeset
|
243 |
check out and where to move the active bookmark from, if needed.''' |
f37b5a17e6a0
bookmarks: pull --update updates to active bookmark if it moved (issue4007)
Kevin Bullock <kbullock@ringworld.org>
parents:
19110
diff
changeset
|
244 |
movemarkfrom = None |
f37b5a17e6a0
bookmarks: pull --update updates to active bookmark if it moved (issue4007)
Kevin Bullock <kbullock@ringworld.org>
parents:
19110
diff
changeset
|
245 |
if checkout is None: |
25100
d6e7ac651973
bookmarks: rename current to active in variables and comments
Ryan McElroy <rmcelroy@fb.com>
parents:
25081
diff
changeset
|
246 |
activemark = repo._activebookmark |
24986
fb9b7b937b3e
bookmarks: simplify iscurrent to isactivewdirparent (API)
Ryan McElroy <rmcelroy@fb.com>
parents:
24962
diff
changeset
|
247 |
if isactivewdirparent(repo): |
19523
f37b5a17e6a0
bookmarks: pull --update updates to active bookmark if it moved (issue4007)
Kevin Bullock <kbullock@ringworld.org>
parents:
19110
diff
changeset
|
248 |
movemarkfrom = repo['.'].node() |
25100
d6e7ac651973
bookmarks: rename current to active in variables and comments
Ryan McElroy <rmcelroy@fb.com>
parents:
25081
diff
changeset
|
249 |
elif activemark: |
d6e7ac651973
bookmarks: rename current to active in variables and comments
Ryan McElroy <rmcelroy@fb.com>
parents:
25081
diff
changeset
|
250 |
ui.status(_("updating to active bookmark %s\n") % activemark) |
d6e7ac651973
bookmarks: rename current to active in variables and comments
Ryan McElroy <rmcelroy@fb.com>
parents:
25081
diff
changeset
|
251 |
checkout = activemark |
19523
f37b5a17e6a0
bookmarks: pull --update updates to active bookmark if it moved (issue4007)
Kevin Bullock <kbullock@ringworld.org>
parents:
19110
diff
changeset
|
252 |
return (checkout, movemarkfrom) |
f37b5a17e6a0
bookmarks: pull --update updates to active bookmark if it moved (issue4007)
Kevin Bullock <kbullock@ringworld.org>
parents:
19110
diff
changeset
|
253 |
|
13352
f9cd37fca5ba
bookmarks: move update into core
Matt Mackall <mpm@selenic.com>
parents:
13351
diff
changeset
|
254 |
def update(repo, parents, node): |
19110
741d94aa92e4
bookmarks: resolve divergent bookmarks when moving active bookmark forward
Sean Farley <sean.michael.farley@gmail.com>
parents:
18984
diff
changeset
|
255 |
deletefrom = parents |
13352
f9cd37fca5ba
bookmarks: move update into core
Matt Mackall <mpm@selenic.com>
parents:
13351
diff
changeset
|
256 |
marks = repo._bookmarks |
f9cd37fca5ba
bookmarks: move update into core
Matt Mackall <mpm@selenic.com>
parents:
13351
diff
changeset
|
257 |
update = False |
25100
d6e7ac651973
bookmarks: rename current to active in variables and comments
Ryan McElroy <rmcelroy@fb.com>
parents:
25081
diff
changeset
|
258 |
active = repo._activebookmark |
d6e7ac651973
bookmarks: rename current to active in variables and comments
Ryan McElroy <rmcelroy@fb.com>
parents:
25081
diff
changeset
|
259 |
if not active: |
16706
a270ec977ba6
bookmarks: delete divergent bookmarks on merge
David Soria Parra <dsp@php.net>
parents:
16697
diff
changeset
|
260 |
return False |
a270ec977ba6
bookmarks: delete divergent bookmarks on merge
David Soria Parra <dsp@php.net>
parents:
16697
diff
changeset
|
261 |
|
25100
d6e7ac651973
bookmarks: rename current to active in variables and comments
Ryan McElroy <rmcelroy@fb.com>
parents:
25081
diff
changeset
|
262 |
if marks[active] in parents: |
18513
37ce336ab2dd
bookmarks: factor out delete divergent code
Siddharth Agarwal <sid0@fb.com>
parents:
18496
diff
changeset
|
263 |
new = repo[node] |
19110
741d94aa92e4
bookmarks: resolve divergent bookmarks when moving active bookmark forward
Sean Farley <sean.michael.farley@gmail.com>
parents:
18984
diff
changeset
|
264 |
divs = [repo[b] for b in marks |
25100
d6e7ac651973
bookmarks: rename current to active in variables and comments
Ryan McElroy <rmcelroy@fb.com>
parents:
25081
diff
changeset
|
265 |
if b.split('@', 1)[0] == active.split('@', 1)[0]] |
19110
741d94aa92e4
bookmarks: resolve divergent bookmarks when moving active bookmark forward
Sean Farley <sean.michael.farley@gmail.com>
parents:
18984
diff
changeset
|
266 |
anc = repo.changelog.ancestors([new.rev()]) |
741d94aa92e4
bookmarks: resolve divergent bookmarks when moving active bookmark forward
Sean Farley <sean.michael.farley@gmail.com>
parents:
18984
diff
changeset
|
267 |
deletefrom = [b.node() for b in divs if b.rev() in anc or b == new] |
25100
d6e7ac651973
bookmarks: rename current to active in variables and comments
Ryan McElroy <rmcelroy@fb.com>
parents:
25081
diff
changeset
|
268 |
if validdest(repo, repo[marks[active]], new): |
d6e7ac651973
bookmarks: rename current to active in variables and comments
Ryan McElroy <rmcelroy@fb.com>
parents:
25081
diff
changeset
|
269 |
marks[active] = new.node() |
18513
37ce336ab2dd
bookmarks: factor out delete divergent code
Siddharth Agarwal <sid0@fb.com>
parents:
18496
diff
changeset
|
270 |
update = True |
37ce336ab2dd
bookmarks: factor out delete divergent code
Siddharth Agarwal <sid0@fb.com>
parents:
18496
diff
changeset
|
271 |
|
25100
d6e7ac651973
bookmarks: rename current to active in variables and comments
Ryan McElroy <rmcelroy@fb.com>
parents:
25081
diff
changeset
|
272 |
if deletedivergent(repo, deletefrom, active): |
18513
37ce336ab2dd
bookmarks: factor out delete divergent code
Siddharth Agarwal <sid0@fb.com>
parents:
18496
diff
changeset
|
273 |
update = True |
37ce336ab2dd
bookmarks: factor out delete divergent code
Siddharth Agarwal <sid0@fb.com>
parents:
18496
diff
changeset
|
274 |
|
13352
f9cd37fca5ba
bookmarks: move update into core
Matt Mackall <mpm@selenic.com>
parents:
13351
diff
changeset
|
275 |
if update: |
26999
2d79a354d843
bookmarks: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
26781
diff
changeset
|
276 |
lock = tr = None |
2d79a354d843
bookmarks: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
26781
diff
changeset
|
277 |
try: |
2d79a354d843
bookmarks: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
26781
diff
changeset
|
278 |
lock = repo.lock() |
2d79a354d843
bookmarks: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
26781
diff
changeset
|
279 |
tr = repo.transaction('bookmark') |
2d79a354d843
bookmarks: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
26781
diff
changeset
|
280 |
marks.recordchange(tr) |
2d79a354d843
bookmarks: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
26781
diff
changeset
|
281 |
tr.close() |
2d79a354d843
bookmarks: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
26781
diff
changeset
|
282 |
finally: |
2d79a354d843
bookmarks: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
26781
diff
changeset
|
283 |
lockmod.release(tr, lock) |
15621
013688350c7d
bookmarks: update and updatecurrentbookmark return status
Kevin Bullock <kbullock@ringworld.org>
parents:
15614
diff
changeset
|
284 |
return update |
13353
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
285 |
|
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
286 |
def listbookmarks(repo): |
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
287 |
# 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
|
288 |
# support it (e.g., statichttprepository). |
14946
28762bf809d8
bookmarks: use getattr instead of hasattr
Augie Fackler <durin42@gmail.com>
parents:
14848
diff
changeset
|
289 |
marks = getattr(repo, '_bookmarks', {}) |
13353
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
290 |
|
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
291 |
d = {} |
18496
d1c13a4dc638
bookmarks: hide bookmarks on filtered revs from listkeys
Kevin Bullock <kbullock@ringworld.org>
parents:
18471
diff
changeset
|
292 |
hasnode = repo.changelog.hasnode |
14946
28762bf809d8
bookmarks: use getattr instead of hasattr
Augie Fackler <durin42@gmail.com>
parents:
14848
diff
changeset
|
293 |
for k, v in marks.iteritems(): |
15613
2fad18f15409
bookmarks: shadow divergent bookmarks of foo with foo@n
Matt Mackall <mpm@selenic.com>
parents:
15237
diff
changeset
|
294 |
# don't expose local divergent bookmarks |
18496
d1c13a4dc638
bookmarks: hide bookmarks on filtered revs from listkeys
Kevin Bullock <kbullock@ringworld.org>
parents:
18471
diff
changeset
|
295 |
if hasnode(v) and ('@' not in k or k.endswith('@')): |
15613
2fad18f15409
bookmarks: shadow divergent bookmarks of foo with foo@n
Matt Mackall <mpm@selenic.com>
parents:
15237
diff
changeset
|
296 |
d[k] = hex(v) |
13353
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
297 |
return d |
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
298 |
|
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
299 |
def pushbookmark(repo, key, old, new): |
22667
3acc3f95548c
push: update bookmarks (on server) within a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22666
diff
changeset
|
300 |
w = l = tr = None |
13353
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
301 |
try: |
22667
3acc3f95548c
push: update bookmarks (on server) within a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22666
diff
changeset
|
302 |
w = repo.wlock() |
3acc3f95548c
push: update bookmarks (on server) within a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22666
diff
changeset
|
303 |
l = repo.lock() |
3acc3f95548c
push: update bookmarks (on server) within a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22666
diff
changeset
|
304 |
tr = repo.transaction('bookmarks') |
13353
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
305 |
marks = repo._bookmarks |
22364
5c153c69fdb2
bookmarks: allow pushkey if new equals current
Durham Goode <durham@fb.com>
parents:
21843
diff
changeset
|
306 |
existing = hex(marks.get(key, '')) |
5c153c69fdb2
bookmarks: allow pushkey if new equals current
Durham Goode <durham@fb.com>
parents:
21843
diff
changeset
|
307 |
if existing != old and existing != new: |
13353
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
308 |
return False |
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
309 |
if new == '': |
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
310 |
del marks[key] |
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
311 |
else: |
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
312 |
if new not in repo: |
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
313 |
return False |
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
314 |
marks[key] = repo[new].node() |
22667
3acc3f95548c
push: update bookmarks (on server) within a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22666
diff
changeset
|
315 |
marks.recordchange(tr) |
3acc3f95548c
push: update bookmarks (on server) within a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22666
diff
changeset
|
316 |
tr.close() |
13353
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
317 |
return True |
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
13352
diff
changeset
|
318 |
finally: |
22667
3acc3f95548c
push: update bookmarks (on server) within a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22666
diff
changeset
|
319 |
lockmod.release(tr, l, w) |
13354
4e1ba6ead69c
bookmarks: move diff to core
Matt Mackall <mpm@selenic.com>
parents:
13353
diff
changeset
|
320 |
|
20024
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
321 |
def compare(repo, srcmarks, dstmarks, |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
322 |
srchex=None, dsthex=None, targets=None): |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
323 |
'''Compare bookmarks between srcmarks and dstmarks |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
324 |
|
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
325 |
This returns tuple "(addsrc, adddst, advsrc, advdst, diverge, |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
326 |
differ, invalid)", each are list of bookmarks below: |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
327 |
|
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
328 |
:addsrc: added on src side (removed on dst side, perhaps) |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
329 |
:adddst: added on dst side (removed on src side, perhaps) |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
330 |
:advsrc: advanced on src side |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
331 |
:advdst: advanced on dst side |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
332 |
:diverge: diverge |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
333 |
:differ: changed, but changeset referred on src is unknown on dst |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
334 |
:invalid: unknown on both side |
23081
e62c330a044f
bookmarks: explicitly track identical bookmarks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
22941
diff
changeset
|
335 |
:same: same on both side |
20024
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
336 |
|
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
337 |
Each elements of lists in result tuple is tuple "(bookmark name, |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
338 |
changeset ID on source side, changeset ID on destination |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
339 |
side)". Each changeset IDs are 40 hexadecimal digit string or |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
340 |
None. |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
341 |
|
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
342 |
Changeset IDs of tuples in "addsrc", "adddst", "differ" or |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
343 |
"invalid" list may be unknown for repo. |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
344 |
|
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
345 |
This function expects that "srcmarks" and "dstmarks" return |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
346 |
changeset ID in 40 hexadecimal digit string for specified |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
347 |
bookmark. If not so (e.g. bmstore "repo._bookmarks" returning |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
348 |
binary value), "srchex" or "dsthex" should be specified to convert |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
349 |
into such form. |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
350 |
|
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
351 |
If "targets" is specified, only bookmarks listed in it are |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
352 |
examined. |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
353 |
''' |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
354 |
if not srchex: |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
355 |
srchex = lambda x: x |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
356 |
if not dsthex: |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
357 |
dsthex = lambda x: x |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
358 |
|
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
359 |
if targets: |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
360 |
bset = set(targets) |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
361 |
else: |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
362 |
srcmarkset = set(srcmarks) |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
363 |
dstmarkset = set(dstmarks) |
23081
e62c330a044f
bookmarks: explicitly track identical bookmarks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
22941
diff
changeset
|
364 |
bset = srcmarkset | dstmarkset |
20024
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
365 |
|
23081
e62c330a044f
bookmarks: explicitly track identical bookmarks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
22941
diff
changeset
|
366 |
results = ([], [], [], [], [], [], [], []) |
20024
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
367 |
addsrc = results[0].append |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
368 |
adddst = results[1].append |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
369 |
advsrc = results[2].append |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
370 |
advdst = results[3].append |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
371 |
diverge = results[4].append |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
372 |
differ = results[5].append |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
373 |
invalid = results[6].append |
23081
e62c330a044f
bookmarks: explicitly track identical bookmarks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
22941
diff
changeset
|
374 |
same = results[7].append |
20024
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
375 |
|
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
376 |
for b in sorted(bset): |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
377 |
if b not in srcmarks: |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
378 |
if b in dstmarks: |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
379 |
adddst((b, None, dsthex(dstmarks[b]))) |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
380 |
else: |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
381 |
invalid((b, None, None)) |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
382 |
elif b not in dstmarks: |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
383 |
addsrc((b, srchex(srcmarks[b]), None)) |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
384 |
else: |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
385 |
scid = srchex(srcmarks[b]) |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
386 |
dcid = dsthex(dstmarks[b]) |
23081
e62c330a044f
bookmarks: explicitly track identical bookmarks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
22941
diff
changeset
|
387 |
if scid == dcid: |
e62c330a044f
bookmarks: explicitly track identical bookmarks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
22941
diff
changeset
|
388 |
same((b, scid, dcid)) |
e62c330a044f
bookmarks: explicitly track identical bookmarks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
22941
diff
changeset
|
389 |
elif scid in repo and dcid in repo: |
20024
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
390 |
sctx = repo[scid] |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
391 |
dctx = repo[dcid] |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
392 |
if sctx.rev() < dctx.rev(): |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
393 |
if validdest(repo, sctx, dctx): |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
394 |
advdst((b, scid, dcid)) |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
395 |
else: |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
396 |
diverge((b, scid, dcid)) |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
397 |
else: |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
398 |
if validdest(repo, dctx, sctx): |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
399 |
advsrc((b, scid, dcid)) |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
400 |
else: |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
401 |
diverge((b, scid, dcid)) |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
402 |
else: |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
403 |
# it is too expensive to examine in detail, in this case |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
404 |
differ((b, scid, dcid)) |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
405 |
|
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
406 |
return results |
059b695150c2
bookmarks: add function to centralize the logic to compare bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19951
diff
changeset
|
407 |
|
24355
ca4b89683078
bookmarks: reuse @number bookmark, if it refers changeset referred remotely
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24354
diff
changeset
|
408 |
def _diverge(ui, b, path, localmarks, remotenode): |
24353
3f6bf9f29e7b
bookmarks: prevent divergent bookmark from being updated unexpectedly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24306
diff
changeset
|
409 |
'''Return appropriate diverged bookmark for specified ``path`` |
3f6bf9f29e7b
bookmarks: prevent divergent bookmark from being updated unexpectedly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24306
diff
changeset
|
410 |
|
3f6bf9f29e7b
bookmarks: prevent divergent bookmark from being updated unexpectedly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24306
diff
changeset
|
411 |
This returns None, if it is failed to assign any divergent |
3f6bf9f29e7b
bookmarks: prevent divergent bookmark from being updated unexpectedly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24306
diff
changeset
|
412 |
bookmark name. |
24355
ca4b89683078
bookmarks: reuse @number bookmark, if it refers changeset referred remotely
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24354
diff
changeset
|
413 |
|
ca4b89683078
bookmarks: reuse @number bookmark, if it refers changeset referred remotely
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24354
diff
changeset
|
414 |
This reuses already existing one with "@number" suffix, if it |
ca4b89683078
bookmarks: reuse @number bookmark, if it refers changeset referred remotely
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24354
diff
changeset
|
415 |
refers ``remotenode``. |
24353
3f6bf9f29e7b
bookmarks: prevent divergent bookmark from being updated unexpectedly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24306
diff
changeset
|
416 |
''' |
20025
e8a11791abfc
bookmarks: rewrite "updatefromremote()" by "compare()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20024
diff
changeset
|
417 |
if b == '@': |
e8a11791abfc
bookmarks: rewrite "updatefromremote()" by "compare()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20024
diff
changeset
|
418 |
b = '' |
e8a11791abfc
bookmarks: rewrite "updatefromremote()" by "compare()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20024
diff
changeset
|
419 |
# try to use an @pathalias suffix |
e8a11791abfc
bookmarks: rewrite "updatefromremote()" by "compare()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20024
diff
changeset
|
420 |
# if an @pathalias already exists, we overwrite (update) it |
22629
b3f74b405c20
bookmarks: fix divergent bookmark path normalization
Matt Mackall <mpm@selenic.com>
parents:
22627
diff
changeset
|
421 |
if path.startswith("file:"): |
b3f74b405c20
bookmarks: fix divergent bookmark path normalization
Matt Mackall <mpm@selenic.com>
parents:
22627
diff
changeset
|
422 |
path = util.url(path).path |
20025
e8a11791abfc
bookmarks: rewrite "updatefromremote()" by "compare()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20024
diff
changeset
|
423 |
for p, u in ui.configitems("paths"): |
22629
b3f74b405c20
bookmarks: fix divergent bookmark path normalization
Matt Mackall <mpm@selenic.com>
parents:
22627
diff
changeset
|
424 |
if u.startswith("file:"): |
b3f74b405c20
bookmarks: fix divergent bookmark path normalization
Matt Mackall <mpm@selenic.com>
parents:
22627
diff
changeset
|
425 |
u = util.url(u).path |
20025
e8a11791abfc
bookmarks: rewrite "updatefromremote()" by "compare()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20024
diff
changeset
|
426 |
if path == u: |
24354
194e1e3ebc29
bookmarks: check @pathalias suffix before available @number for efficiency
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24353
diff
changeset
|
427 |
return '%s@%s' % (b, p) |
194e1e3ebc29
bookmarks: check @pathalias suffix before available @number for efficiency
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24353
diff
changeset
|
428 |
|
194e1e3ebc29
bookmarks: check @pathalias suffix before available @number for efficiency
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24353
diff
changeset
|
429 |
# assign a unique "@number" suffix newly |
194e1e3ebc29
bookmarks: check @pathalias suffix before available @number for efficiency
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24353
diff
changeset
|
430 |
for x in range(1, 100): |
194e1e3ebc29
bookmarks: check @pathalias suffix before available @number for efficiency
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24353
diff
changeset
|
431 |
n = '%s@%d' % (b, x) |
24355
ca4b89683078
bookmarks: reuse @number bookmark, if it refers changeset referred remotely
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24354
diff
changeset
|
432 |
if n not in localmarks or localmarks[n] == remotenode: |
24354
194e1e3ebc29
bookmarks: check @pathalias suffix before available @number for efficiency
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24353
diff
changeset
|
433 |
return n |
194e1e3ebc29
bookmarks: check @pathalias suffix before available @number for efficiency
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24353
diff
changeset
|
434 |
|
194e1e3ebc29
bookmarks: check @pathalias suffix before available @number for efficiency
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24353
diff
changeset
|
435 |
return None |
20025
e8a11791abfc
bookmarks: rewrite "updatefromremote()" by "compare()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20024
diff
changeset
|
436 |
|
22666
0f8120c1ecf5
pull: perform bookmark updates in the transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22665
diff
changeset
|
437 |
def updatefromremote(ui, repo, remotemarks, path, trfunc, explicit=()): |
13646
31eac42d9123
bookmarks: separate bookmarks update code from localrepo's pull.
David Soria Parra <dsp@php.net>
parents:
13627
diff
changeset
|
438 |
ui.debug("checking for updated bookmarks\n") |
17922
7f5dab94e48c
bookmarks: introduce a bmstore to manage bookmark persistence
Augie Fackler <raf@durin42.com>
parents:
17918
diff
changeset
|
439 |
localmarks = repo._bookmarks |
23081
e62c330a044f
bookmarks: explicitly track identical bookmarks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
22941
diff
changeset
|
440 |
(addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same |
20025
e8a11791abfc
bookmarks: rewrite "updatefromremote()" by "compare()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20024
diff
changeset
|
441 |
) = compare(repo, remotemarks, localmarks, dsthex=hex) |
15614
260a6449d83a
bookmarks: mark divergent bookmarks with book@pathalias when source in [paths]
Matt Mackall <mpm@selenic.com>
parents:
15613
diff
changeset
|
442 |
|
22644
1ec7cdaf898f
bookmarks: allow `updatefromremote` to be quiet
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22629
diff
changeset
|
443 |
status = ui.status |
1ec7cdaf898f
bookmarks: allow `updatefromremote` to be quiet
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22629
diff
changeset
|
444 |
warn = ui.warn |
1ec7cdaf898f
bookmarks: allow `updatefromremote` to be quiet
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22629
diff
changeset
|
445 |
if ui.configbool('ui', 'quietbookmarkmove', False): |
1ec7cdaf898f
bookmarks: allow `updatefromremote` to be quiet
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22629
diff
changeset
|
446 |
status = warn = ui.debug |
1ec7cdaf898f
bookmarks: allow `updatefromremote` to be quiet
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22629
diff
changeset
|
447 |
|
22659
798185707833
pull: merge bookmark updates and imports
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22658
diff
changeset
|
448 |
explicit = set(explicit) |
20025
e8a11791abfc
bookmarks: rewrite "updatefromremote()" by "compare()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20024
diff
changeset
|
449 |
changed = [] |
e8a11791abfc
bookmarks: rewrite "updatefromremote()" by "compare()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20024
diff
changeset
|
450 |
for b, scid, dcid in addsrc: |
e8a11791abfc
bookmarks: rewrite "updatefromremote()" by "compare()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20024
diff
changeset
|
451 |
if scid in repo: # add remote bookmarks for changes we already have |
22644
1ec7cdaf898f
bookmarks: allow `updatefromremote` to be quiet
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22629
diff
changeset
|
452 |
changed.append((b, bin(scid), status, |
20025
e8a11791abfc
bookmarks: rewrite "updatefromremote()" by "compare()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20024
diff
changeset
|
453 |
_("adding remote bookmark %s\n") % (b))) |
25564
847fce27effc
bookmark: informs of failure to upgrade a bookmark
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25100
diff
changeset
|
454 |
elif b in explicit: |
847fce27effc
bookmark: informs of failure to upgrade a bookmark
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25100
diff
changeset
|
455 |
explicit.remove(b) |
847fce27effc
bookmark: informs of failure to upgrade a bookmark
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25100
diff
changeset
|
456 |
ui.warn(_("remote bookmark %s points to locally missing %s\n") |
847fce27effc
bookmark: informs of failure to upgrade a bookmark
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25100
diff
changeset
|
457 |
% (b, scid[:12])) |
847fce27effc
bookmark: informs of failure to upgrade a bookmark
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25100
diff
changeset
|
458 |
|
20025
e8a11791abfc
bookmarks: rewrite "updatefromremote()" by "compare()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20024
diff
changeset
|
459 |
for b, scid, dcid in advsrc: |
22644
1ec7cdaf898f
bookmarks: allow `updatefromremote` to be quiet
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22629
diff
changeset
|
460 |
changed.append((b, bin(scid), status, |
20025
e8a11791abfc
bookmarks: rewrite "updatefromremote()" by "compare()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20024
diff
changeset
|
461 |
_("updating bookmark %s\n") % (b))) |
22659
798185707833
pull: merge bookmark updates and imports
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22658
diff
changeset
|
462 |
# remove normal movement from explicit set |
798185707833
pull: merge bookmark updates and imports
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22658
diff
changeset
|
463 |
explicit.difference_update(d[0] for d in changed) |
798185707833
pull: merge bookmark updates and imports
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22658
diff
changeset
|
464 |
|
20025
e8a11791abfc
bookmarks: rewrite "updatefromremote()" by "compare()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20024
diff
changeset
|
465 |
for b, scid, dcid in diverge: |
22659
798185707833
pull: merge bookmark updates and imports
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22658
diff
changeset
|
466 |
if b in explicit: |
798185707833
pull: merge bookmark updates and imports
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22658
diff
changeset
|
467 |
explicit.discard(b) |
798185707833
pull: merge bookmark updates and imports
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22658
diff
changeset
|
468 |
changed.append((b, bin(scid), status, |
23199
c35ffa4249ca
bookmarks: fix formatting of exchange message (issue4439)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23081
diff
changeset
|
469 |
_("importing bookmark %s\n") % (b))) |
22659
798185707833
pull: merge bookmark updates and imports
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22658
diff
changeset
|
470 |
else: |
24355
ca4b89683078
bookmarks: reuse @number bookmark, if it refers changeset referred remotely
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24354
diff
changeset
|
471 |
snode = bin(scid) |
ca4b89683078
bookmarks: reuse @number bookmark, if it refers changeset referred remotely
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24354
diff
changeset
|
472 |
db = _diverge(ui, b, path, localmarks, snode) |
24353
3f6bf9f29e7b
bookmarks: prevent divergent bookmark from being updated unexpectedly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24306
diff
changeset
|
473 |
if db: |
24355
ca4b89683078
bookmarks: reuse @number bookmark, if it refers changeset referred remotely
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24354
diff
changeset
|
474 |
changed.append((db, snode, warn, |
24353
3f6bf9f29e7b
bookmarks: prevent divergent bookmark from being updated unexpectedly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24306
diff
changeset
|
475 |
_("divergent bookmark %s stored as %s\n") % |
3f6bf9f29e7b
bookmarks: prevent divergent bookmark from being updated unexpectedly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24306
diff
changeset
|
476 |
(b, db))) |
3f6bf9f29e7b
bookmarks: prevent divergent bookmark from being updated unexpectedly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24306
diff
changeset
|
477 |
else: |
3f6bf9f29e7b
bookmarks: prevent divergent bookmark from being updated unexpectedly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24306
diff
changeset
|
478 |
warn(_("warning: failed to assign numbered name " |
3f6bf9f29e7b
bookmarks: prevent divergent bookmark from being updated unexpectedly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24306
diff
changeset
|
479 |
"to divergent bookmark %s\n") % (b)) |
22659
798185707833
pull: merge bookmark updates and imports
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22658
diff
changeset
|
480 |
for b, scid, dcid in adddst + advdst: |
798185707833
pull: merge bookmark updates and imports
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22658
diff
changeset
|
481 |
if b in explicit: |
798185707833
pull: merge bookmark updates and imports
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22658
diff
changeset
|
482 |
explicit.discard(b) |
798185707833
pull: merge bookmark updates and imports
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22658
diff
changeset
|
483 |
changed.append((b, bin(scid), status, |
23199
c35ffa4249ca
bookmarks: fix formatting of exchange message (issue4439)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23081
diff
changeset
|
484 |
_("importing bookmark %s\n") % (b))) |
25564
847fce27effc
bookmark: informs of failure to upgrade a bookmark
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25100
diff
changeset
|
485 |
for b, scid, dcid in differ: |
847fce27effc
bookmark: informs of failure to upgrade a bookmark
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25100
diff
changeset
|
486 |
if b in explicit: |
847fce27effc
bookmark: informs of failure to upgrade a bookmark
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25100
diff
changeset
|
487 |
explicit.remove(b) |
847fce27effc
bookmark: informs of failure to upgrade a bookmark
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25100
diff
changeset
|
488 |
ui.warn(_("remote bookmark %s points to locally missing %s\n") |
847fce27effc
bookmark: informs of failure to upgrade a bookmark
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25100
diff
changeset
|
489 |
% (b, scid[:12])) |
22659
798185707833
pull: merge bookmark updates and imports
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22658
diff
changeset
|
490 |
|
13646
31eac42d9123
bookmarks: separate bookmarks update code from localrepo's pull.
David Soria Parra <dsp@php.net>
parents:
13627
diff
changeset
|
491 |
if changed: |
22666
0f8120c1ecf5
pull: perform bookmark updates in the transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22665
diff
changeset
|
492 |
tr = trfunc() |
20025
e8a11791abfc
bookmarks: rewrite "updatefromremote()" by "compare()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20024
diff
changeset
|
493 |
for b, node, writer, msg in sorted(changed): |
e8a11791abfc
bookmarks: rewrite "updatefromremote()" by "compare()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20024
diff
changeset
|
494 |
localmarks[b] = node |
e8a11791abfc
bookmarks: rewrite "updatefromremote()" by "compare()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20024
diff
changeset
|
495 |
writer(msg) |
22666
0f8120c1ecf5
pull: perform bookmark updates in the transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22665
diff
changeset
|
496 |
localmarks.recordchange(tr) |
13646
31eac42d9123
bookmarks: separate bookmarks update code from localrepo's pull.
David Soria Parra <dsp@php.net>
parents:
13627
diff
changeset
|
497 |
|
24397
d0ea2028e8e6
bookmarks: add incoming() to replace diff() for incoming bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24355
diff
changeset
|
498 |
def incoming(ui, repo, other): |
d0ea2028e8e6
bookmarks: add incoming() to replace diff() for incoming bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24355
diff
changeset
|
499 |
'''Show bookmarks incoming from other to repo |
d0ea2028e8e6
bookmarks: add incoming() to replace diff() for incoming bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24355
diff
changeset
|
500 |
''' |
d0ea2028e8e6
bookmarks: add incoming() to replace diff() for incoming bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24355
diff
changeset
|
501 |
ui.status(_("searching for changed bookmarks\n")) |
d0ea2028e8e6
bookmarks: add incoming() to replace diff() for incoming bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24355
diff
changeset
|
502 |
|
d0ea2028e8e6
bookmarks: add incoming() to replace diff() for incoming bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24355
diff
changeset
|
503 |
r = compare(repo, other.listkeys('bookmarks'), repo._bookmarks, |
d0ea2028e8e6
bookmarks: add incoming() to replace diff() for incoming bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24355
diff
changeset
|
504 |
dsthex=hex) |
d0ea2028e8e6
bookmarks: add incoming() to replace diff() for incoming bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24355
diff
changeset
|
505 |
addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = r |
d0ea2028e8e6
bookmarks: add incoming() to replace diff() for incoming bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24355
diff
changeset
|
506 |
|
d0ea2028e8e6
bookmarks: add incoming() to replace diff() for incoming bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24355
diff
changeset
|
507 |
incomings = [] |
d0ea2028e8e6
bookmarks: add incoming() to replace diff() for incoming bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24355
diff
changeset
|
508 |
if ui.debugflag: |
d0ea2028e8e6
bookmarks: add incoming() to replace diff() for incoming bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24355
diff
changeset
|
509 |
getid = lambda id: id |
d0ea2028e8e6
bookmarks: add incoming() to replace diff() for incoming bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24355
diff
changeset
|
510 |
else: |
d0ea2028e8e6
bookmarks: add incoming() to replace diff() for incoming bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24355
diff
changeset
|
511 |
getid = lambda id: id[:12] |
24660
bf13b44bbb0a
bookmarks: show detailed status about incoming bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24658
diff
changeset
|
512 |
if ui.verbose: |
bf13b44bbb0a
bookmarks: show detailed status about incoming bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24658
diff
changeset
|
513 |
def add(b, id, st): |
bf13b44bbb0a
bookmarks: show detailed status about incoming bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24658
diff
changeset
|
514 |
incomings.append(" %-25s %s %s\n" % (b, getid(id), st)) |
bf13b44bbb0a
bookmarks: show detailed status about incoming bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24658
diff
changeset
|
515 |
else: |
bf13b44bbb0a
bookmarks: show detailed status about incoming bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24658
diff
changeset
|
516 |
def add(b, id, st): |
bf13b44bbb0a
bookmarks: show detailed status about incoming bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24658
diff
changeset
|
517 |
incomings.append(" %-25s %s\n" % (b, getid(id))) |
24397
d0ea2028e8e6
bookmarks: add incoming() to replace diff() for incoming bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24355
diff
changeset
|
518 |
for b, scid, dcid in addsrc: |
24832
5947a68fa271
bookmarks: add i18n hints to bookmark sync states
Wagner Bruna <wbruna@yahoo.com>
parents:
24661
diff
changeset
|
519 |
# i18n: "added" refers to a bookmark |
24660
bf13b44bbb0a
bookmarks: show detailed status about incoming bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24658
diff
changeset
|
520 |
add(b, scid, _('added')) |
24657
3d7c512b258d
bookmarks: show incoming bookmarks more exactly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24400
diff
changeset
|
521 |
for b, scid, dcid in advsrc: |
24832
5947a68fa271
bookmarks: add i18n hints to bookmark sync states
Wagner Bruna <wbruna@yahoo.com>
parents:
24661
diff
changeset
|
522 |
# i18n: "advanced" refers to a bookmark |
24660
bf13b44bbb0a
bookmarks: show detailed status about incoming bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24658
diff
changeset
|
523 |
add(b, scid, _('advanced')) |
24657
3d7c512b258d
bookmarks: show incoming bookmarks more exactly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24400
diff
changeset
|
524 |
for b, scid, dcid in diverge: |
24832
5947a68fa271
bookmarks: add i18n hints to bookmark sync states
Wagner Bruna <wbruna@yahoo.com>
parents:
24661
diff
changeset
|
525 |
# i18n: "diverged" refers to a bookmark |
24660
bf13b44bbb0a
bookmarks: show detailed status about incoming bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24658
diff
changeset
|
526 |
add(b, scid, _('diverged')) |
24657
3d7c512b258d
bookmarks: show incoming bookmarks more exactly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24400
diff
changeset
|
527 |
for b, scid, dcid in differ: |
24832
5947a68fa271
bookmarks: add i18n hints to bookmark sync states
Wagner Bruna <wbruna@yahoo.com>
parents:
24661
diff
changeset
|
528 |
# i18n: "changed" refers to a bookmark |
24660
bf13b44bbb0a
bookmarks: show detailed status about incoming bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24658
diff
changeset
|
529 |
add(b, scid, _('changed')) |
24397
d0ea2028e8e6
bookmarks: add incoming() to replace diff() for incoming bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24355
diff
changeset
|
530 |
|
d0ea2028e8e6
bookmarks: add incoming() to replace diff() for incoming bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24355
diff
changeset
|
531 |
if not incomings: |
d0ea2028e8e6
bookmarks: add incoming() to replace diff() for incoming bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24355
diff
changeset
|
532 |
ui.status(_("no changed bookmarks found\n")) |
d0ea2028e8e6
bookmarks: add incoming() to replace diff() for incoming bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24355
diff
changeset
|
533 |
return 1 |
d0ea2028e8e6
bookmarks: add incoming() to replace diff() for incoming bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24355
diff
changeset
|
534 |
|
d0ea2028e8e6
bookmarks: add incoming() to replace diff() for incoming bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24355
diff
changeset
|
535 |
for s in sorted(incomings): |
d0ea2028e8e6
bookmarks: add incoming() to replace diff() for incoming bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24355
diff
changeset
|
536 |
ui.write(s) |
d0ea2028e8e6
bookmarks: add incoming() to replace diff() for incoming bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24355
diff
changeset
|
537 |
|
d0ea2028e8e6
bookmarks: add incoming() to replace diff() for incoming bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24355
diff
changeset
|
538 |
return 0 |
d0ea2028e8e6
bookmarks: add incoming() to replace diff() for incoming bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24355
diff
changeset
|
539 |
|
24398
c0096a2bd3ff
bookmarks: add outgoing() to replace diff() for outgoing bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24397
diff
changeset
|
540 |
def outgoing(ui, repo, other): |
c0096a2bd3ff
bookmarks: add outgoing() to replace diff() for outgoing bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24397
diff
changeset
|
541 |
'''Show bookmarks outgoing from repo to other |
c0096a2bd3ff
bookmarks: add outgoing() to replace diff() for outgoing bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24397
diff
changeset
|
542 |
''' |
c0096a2bd3ff
bookmarks: add outgoing() to replace diff() for outgoing bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24397
diff
changeset
|
543 |
ui.status(_("searching for changed bookmarks\n")) |
c0096a2bd3ff
bookmarks: add outgoing() to replace diff() for outgoing bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24397
diff
changeset
|
544 |
|
c0096a2bd3ff
bookmarks: add outgoing() to replace diff() for outgoing bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24397
diff
changeset
|
545 |
r = compare(repo, repo._bookmarks, other.listkeys('bookmarks'), |
c0096a2bd3ff
bookmarks: add outgoing() to replace diff() for outgoing bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24397
diff
changeset
|
546 |
srchex=hex) |
c0096a2bd3ff
bookmarks: add outgoing() to replace diff() for outgoing bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24397
diff
changeset
|
547 |
addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = r |
c0096a2bd3ff
bookmarks: add outgoing() to replace diff() for outgoing bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24397
diff
changeset
|
548 |
|
c0096a2bd3ff
bookmarks: add outgoing() to replace diff() for outgoing bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24397
diff
changeset
|
549 |
outgoings = [] |
c0096a2bd3ff
bookmarks: add outgoing() to replace diff() for outgoing bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24397
diff
changeset
|
550 |
if ui.debugflag: |
c0096a2bd3ff
bookmarks: add outgoing() to replace diff() for outgoing bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24397
diff
changeset
|
551 |
getid = lambda id: id |
c0096a2bd3ff
bookmarks: add outgoing() to replace diff() for outgoing bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24397
diff
changeset
|
552 |
else: |
c0096a2bd3ff
bookmarks: add outgoing() to replace diff() for outgoing bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24397
diff
changeset
|
553 |
getid = lambda id: id[:12] |
24661
8cf70c97a6e1
bookmarks: show detailed status about outgoing bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24660
diff
changeset
|
554 |
if ui.verbose: |
8cf70c97a6e1
bookmarks: show detailed status about outgoing bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24660
diff
changeset
|
555 |
def add(b, id, st): |
8cf70c97a6e1
bookmarks: show detailed status about outgoing bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24660
diff
changeset
|
556 |
outgoings.append(" %-25s %s %s\n" % (b, getid(id), st)) |
8cf70c97a6e1
bookmarks: show detailed status about outgoing bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24660
diff
changeset
|
557 |
else: |
8cf70c97a6e1
bookmarks: show detailed status about outgoing bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24660
diff
changeset
|
558 |
def add(b, id, st): |
8cf70c97a6e1
bookmarks: show detailed status about outgoing bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24660
diff
changeset
|
559 |
outgoings.append(" %-25s %s\n" % (b, getid(id))) |
24398
c0096a2bd3ff
bookmarks: add outgoing() to replace diff() for outgoing bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24397
diff
changeset
|
560 |
for b, scid, dcid in addsrc: |
24832
5947a68fa271
bookmarks: add i18n hints to bookmark sync states
Wagner Bruna <wbruna@yahoo.com>
parents:
24661
diff
changeset
|
561 |
# i18n: "added refers to a bookmark |
24661
8cf70c97a6e1
bookmarks: show detailed status about outgoing bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24660
diff
changeset
|
562 |
add(b, scid, _('added')) |
24658
8ea893ab0572
bookmarks: show outgoing bookmarks more exactly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24657
diff
changeset
|
563 |
for b, scid, dcid in adddst: |
24832
5947a68fa271
bookmarks: add i18n hints to bookmark sync states
Wagner Bruna <wbruna@yahoo.com>
parents:
24661
diff
changeset
|
564 |
# i18n: "deleted" refers to a bookmark |
24661
8cf70c97a6e1
bookmarks: show detailed status about outgoing bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24660
diff
changeset
|
565 |
add(b, ' ' * 40, _('deleted')) |
24658
8ea893ab0572
bookmarks: show outgoing bookmarks more exactly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24657
diff
changeset
|
566 |
for b, scid, dcid in advsrc: |
24832
5947a68fa271
bookmarks: add i18n hints to bookmark sync states
Wagner Bruna <wbruna@yahoo.com>
parents:
24661
diff
changeset
|
567 |
# i18n: "advanced" refers to a bookmark |
24661
8cf70c97a6e1
bookmarks: show detailed status about outgoing bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24660
diff
changeset
|
568 |
add(b, scid, _('advanced')) |
24658
8ea893ab0572
bookmarks: show outgoing bookmarks more exactly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24657
diff
changeset
|
569 |
for b, scid, dcid in diverge: |
24832
5947a68fa271
bookmarks: add i18n hints to bookmark sync states
Wagner Bruna <wbruna@yahoo.com>
parents:
24661
diff
changeset
|
570 |
# i18n: "diverged" refers to a bookmark |
24661
8cf70c97a6e1
bookmarks: show detailed status about outgoing bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24660
diff
changeset
|
571 |
add(b, scid, _('diverged')) |
24658
8ea893ab0572
bookmarks: show outgoing bookmarks more exactly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24657
diff
changeset
|
572 |
for b, scid, dcid in differ: |
24832
5947a68fa271
bookmarks: add i18n hints to bookmark sync states
Wagner Bruna <wbruna@yahoo.com>
parents:
24661
diff
changeset
|
573 |
# i18n: "changed" refers to a bookmark |
24661
8cf70c97a6e1
bookmarks: show detailed status about outgoing bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24660
diff
changeset
|
574 |
add(b, scid, _('changed')) |
24398
c0096a2bd3ff
bookmarks: add outgoing() to replace diff() for outgoing bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24397
diff
changeset
|
575 |
|
c0096a2bd3ff
bookmarks: add outgoing() to replace diff() for outgoing bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24397
diff
changeset
|
576 |
if not outgoings: |
c0096a2bd3ff
bookmarks: add outgoing() to replace diff() for outgoing bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24397
diff
changeset
|
577 |
ui.status(_("no changed bookmarks found\n")) |
c0096a2bd3ff
bookmarks: add outgoing() to replace diff() for outgoing bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24397
diff
changeset
|
578 |
return 1 |
c0096a2bd3ff
bookmarks: add outgoing() to replace diff() for outgoing bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24397
diff
changeset
|
579 |
|
c0096a2bd3ff
bookmarks: add outgoing() to replace diff() for outgoing bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24397
diff
changeset
|
580 |
for s in sorted(outgoings): |
c0096a2bd3ff
bookmarks: add outgoing() to replace diff() for outgoing bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24397
diff
changeset
|
581 |
ui.write(s) |
c0096a2bd3ff
bookmarks: add outgoing() to replace diff() for outgoing bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24397
diff
changeset
|
582 |
|
c0096a2bd3ff
bookmarks: add outgoing() to replace diff() for outgoing bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24397
diff
changeset
|
583 |
return 0 |
c0096a2bd3ff
bookmarks: add outgoing() to replace diff() for outgoing bookmarks
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24397
diff
changeset
|
584 |
|
24400
03c84c966ef5
bookmarks: rewrite comparing bookmarks in commands.summary() by compare()
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24399
diff
changeset
|
585 |
def summary(repo, other): |
03c84c966ef5
bookmarks: rewrite comparing bookmarks in commands.summary() by compare()
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24399
diff
changeset
|
586 |
'''Compare bookmarks between repo and other for "hg summary" output |
03c84c966ef5
bookmarks: rewrite comparing bookmarks in commands.summary() by compare()
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24399
diff
changeset
|
587 |
|
03c84c966ef5
bookmarks: rewrite comparing bookmarks in commands.summary() by compare()
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24399
diff
changeset
|
588 |
This returns "(# of incoming, # of outgoing)" tuple. |
03c84c966ef5
bookmarks: rewrite comparing bookmarks in commands.summary() by compare()
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24399
diff
changeset
|
589 |
''' |
03c84c966ef5
bookmarks: rewrite comparing bookmarks in commands.summary() by compare()
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24399
diff
changeset
|
590 |
r = compare(repo, other.listkeys('bookmarks'), repo._bookmarks, |
03c84c966ef5
bookmarks: rewrite comparing bookmarks in commands.summary() by compare()
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24399
diff
changeset
|
591 |
dsthex=hex) |
03c84c966ef5
bookmarks: rewrite comparing bookmarks in commands.summary() by compare()
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24399
diff
changeset
|
592 |
addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = r |
03c84c966ef5
bookmarks: rewrite comparing bookmarks in commands.summary() by compare()
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24399
diff
changeset
|
593 |
return (len(addsrc), len(adddst)) |
03c84c966ef5
bookmarks: rewrite comparing bookmarks in commands.summary() by compare()
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24399
diff
changeset
|
594 |
|
17550
fc530080013b
bookmarks: extract valid destination logic in a dedicated function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17425
diff
changeset
|
595 |
def validdest(repo, old, new): |
fc530080013b
bookmarks: extract valid destination logic in a dedicated function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17425
diff
changeset
|
596 |
"""Is the new bookmark destination a valid update from the old one""" |
18008
cf91b36f368c
clfilter: `bookmark.validdest` should run on unfiltered repo
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17922
diff
changeset
|
597 |
repo = repo.unfiltered() |
17551
a7b3fdaf768d
bookmark: take successors into account when updating (issue3561)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17550
diff
changeset
|
598 |
if old == new: |
a7b3fdaf768d
bookmark: take successors into account when updating (issue3561)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17550
diff
changeset
|
599 |
# Old == new -> nothing to update. |
17625
b83c18204c36
bookmarks: avoid redundant creation/assignment of "validdests" in "validdest()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17551
diff
changeset
|
600 |
return False |
17551
a7b3fdaf768d
bookmark: take successors into account when updating (issue3561)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17550
diff
changeset
|
601 |
elif not old: |
a7b3fdaf768d
bookmark: take successors into account when updating (issue3561)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17550
diff
changeset
|
602 |
# old is nullrev, anything is valid. |
a7b3fdaf768d
bookmark: take successors into account when updating (issue3561)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17550
diff
changeset
|
603 |
# (new != nullrev has been excluded by the previous check) |
17625
b83c18204c36
bookmarks: avoid redundant creation/assignment of "validdests" in "validdest()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17551
diff
changeset
|
604 |
return True |
17551
a7b3fdaf768d
bookmark: take successors into account when updating (issue3561)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17550
diff
changeset
|
605 |
elif repo.obsstore: |
18984
efef056b1ae9
obsolete: extract foreground computation from bookmark.validdest
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18851
diff
changeset
|
606 |
return new.node() in obsolete.foreground(repo, [old.node()]) |
17551
a7b3fdaf768d
bookmark: take successors into account when updating (issue3561)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17550
diff
changeset
|
607 |
else: |
24180
d8e0c591781c
spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents:
23877
diff
changeset
|
608 |
# still an independent clause as it is lazier (and therefore faster) |
17627
84f12b832ee8
bookmarks: use "changectx.descendant()" for efficient descendant examination
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17625
diff
changeset
|
609 |
return old.descendant(new) |