Show More
@@ -6,7 +6,7 b'' | |||||
6 | # GNU General Public License version 2 or any later version. |
|
6 | # GNU General Public License version 2 or any later version. | |
7 |
|
7 | |||
8 | from mercurial.i18n import _ |
|
8 | from mercurial.i18n import _ | |
9 | from mercurial.node import hex |
|
9 | from mercurial.node import hex, bin | |
10 | from mercurial import encoding, error, util, obsolete |
|
10 | from mercurial import encoding, error, util, obsolete | |
11 | import errno |
|
11 | import errno | |
12 |
|
12 | |||
@@ -325,48 +325,43 b' def compare(repo, srcmarks, dstmarks,' | |||||
325 |
|
325 | |||
326 | return results |
|
326 | return results | |
327 |
|
327 | |||
|
328 | def _diverge(ui, b, path, localmarks): | |||
|
329 | if b == '@': | |||
|
330 | b = '' | |||
|
331 | # find a unique @ suffix | |||
|
332 | for x in range(1, 100): | |||
|
333 | n = '%s@%d' % (b, x) | |||
|
334 | if n not in localmarks: | |||
|
335 | break | |||
|
336 | # try to use an @pathalias suffix | |||
|
337 | # if an @pathalias already exists, we overwrite (update) it | |||
|
338 | for p, u in ui.configitems("paths"): | |||
|
339 | if path == u: | |||
|
340 | n = '%s@%s' % (b, p) | |||
|
341 | return n | |||
|
342 | ||||
328 | def updatefromremote(ui, repo, remotemarks, path): |
|
343 | def updatefromremote(ui, repo, remotemarks, path): | |
329 | ui.debug("checking for updated bookmarks\n") |
|
344 | ui.debug("checking for updated bookmarks\n") | |
330 | changed = False |
|
|||
331 | localmarks = repo._bookmarks |
|
345 | localmarks = repo._bookmarks | |
332 | for k in sorted(remotemarks): |
|
346 | (addsrc, adddst, advsrc, advdst, diverge, differ, invalid | |
333 | if k in localmarks: |
|
347 | ) = compare(repo, remotemarks, localmarks, dsthex=hex) | |
334 | nr, nl = remotemarks[k], localmarks[k] |
|
|||
335 | if nr in repo: |
|
|||
336 | cr = repo[nr] |
|
|||
337 | cl = repo[nl] |
|
|||
338 | if cl.rev() >= cr.rev(): |
|
|||
339 | continue |
|
|||
340 | if validdest(repo, cl, cr): |
|
|||
341 | localmarks[k] = cr.node() |
|
|||
342 | changed = True |
|
|||
343 | ui.status(_("updating bookmark %s\n") % k) |
|
|||
344 | else: |
|
|||
345 | if k == '@': |
|
|||
346 | kd = '' |
|
|||
347 | else: |
|
|||
348 | kd = k |
|
|||
349 | # find a unique @ suffix |
|
|||
350 | for x in range(1, 100): |
|
|||
351 | n = '%s@%d' % (kd, x) |
|
|||
352 | if n not in localmarks: |
|
|||
353 | break |
|
|||
354 | # try to use an @pathalias suffix |
|
|||
355 | # if an @pathalias already exists, we overwrite (update) it |
|
|||
356 | for p, u in ui.configitems("paths"): |
|
|||
357 | if path == u: |
|
|||
358 | n = '%s@%s' % (kd, p) |
|
|||
359 |
|
348 | |||
360 | localmarks[n] = cr.node() |
|
349 | changed = [] | |
361 | changed = True |
|
350 | for b, scid, dcid in addsrc: | |
362 | ui.warn(_("divergent bookmark %s stored as %s\n") % (k, n)) |
|
351 | if scid in repo: # add remote bookmarks for changes we already have | |
363 | elif remotemarks[k] in repo: |
|
352 | changed.append((b, bin(scid), ui.status, | |
364 | # add remote bookmarks for changes we already have |
|
353 | _("adding remote bookmark %s\n") % (b))) | |
365 | localmarks[k] = repo[remotemarks[k]].node() |
|
354 | for b, scid, dcid in advsrc: | |
366 | changed = True |
|
355 | changed.append((b, bin(scid), ui.status, | |
367 |
|
|
356 | _("updating bookmark %s\n") % (b))) | |
368 |
|
357 | for b, scid, dcid in diverge: | ||
|
358 | db = _diverge(ui, b, path, localmarks) | |||
|
359 | changed.append((db, bin(scid), ui.warn, | |||
|
360 | _("divergent bookmark %s stored as %s\n") % (b, db))) | |||
369 | if changed: |
|
361 | if changed: | |
|
362 | for b, node, writer, msg in sorted(changed): | |||
|
363 | localmarks[b] = node | |||
|
364 | writer(msg) | |||
370 | localmarks.write() |
|
365 | localmarks.write() | |
371 |
|
366 | |||
372 | def diff(ui, dst, src): |
|
367 | def diff(ui, dst, src): |
General Comments 0
You need to be logged in to leave comments.
Login now