[PATCH] identify: restructure code to make it more readable

Adrian Buehlmann adrian at cadifra.com
Mon Apr 18 19:17:34 CDT 2011


On 2011-04-19 00:08, Idan Kamara wrote:
> # HG changeset patch
> # User Idan Kamara <idankk86 at gmail.com>
> # Date 1303164515 -10800
> # Node ID 9dded5e47aecfde3336484534a39da2fcde40317
> # Parent  87c8ba7850a21ef098f8674e2ea70849da6e1ba3
> identify: restructure code to make it more readable

I compared that in kdiff3.

Looks good. Although it's not that easy to review.

Idan's version also has the benefit that it doesn't needlessly get the remote
bookmarks if they aren't requested (IIUC, I'm not a bookmarks expert).

This comes at the price of that new local function getbms(), which is ok
for me.

As a minor nit, I'd recommend to remove these two empty lines on getbms():

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2387,12 +2387,10 @@

         def getbms():
             bms = []
-
             if 'bookmarks' in repo.listkeys('namespaces'):
                 hexremoterev = hex(remoterev)
                 bms = [bm for bm, bmr in repo.listkeys('bookmarks').iteritems()
                        if bmr == hexremoterev]
-
             return bms

         if bookmarks:

In short: +1 for that patch (provided it passes the tests).


More information about the Mercurial-devel mailing list