[PATCH 3 of 6 remotenames-ext] selectivepull: add function to get default bookmarks

Stanislau Hlebik stash at fb.com
Mon Jan 30 10:56:01 EST 2017


# HG changeset patch
# User Stanislau Hlebik <stash at fb.com>
# Date 1485791649 28800
#      Mon Jan 30 07:54:09 2017 -0800
# Node ID 3e17b130293b0c65918041ad4e51a32a909e4f48
# Parent  a7786a178d5cb9abed981c76e47588fffede7511
selectivepull: add function to get default bookmarks

Small refactoring: move logic to get default bookmarks to separate function

diff --git a/remotenames.py b/remotenames.py
--- a/remotenames.py
+++ b/remotenames.py
@@ -77,6 +77,16 @@
 def _isselectivepull(ui):
     return ui.configbool('remotenames', 'selectivepull', False)
 
+def _getselectivepulldefaultbookmarks(ui, remotebookmarks):
+    default_book = ui.config('remotenames', 'selectivepulldefault')
+    if not default_book:
+        raise error.Abort(_('no default bookmark specified for selectivepull'))
+    if default_book in remotebookmarks:
+        return {default_book: remotebookmarks[default_book]}
+    else:
+        raise error.Abort(
+            _('default bookmark %s is not found on remote') % default_book)
+
 def _trypullremotebookmark(mayberemotebookmark, repo, ui):
     ui.warn(_('`%s` not found: assuming it is a remote bookmark '
               'and trying to pull it\n') % mayberemotebookmark)
@@ -117,16 +127,8 @@
             if bookmark in remotebookmarks:
                 bookmarks[bookmark] = remotebookmarks[bookmark]
         if not bookmarks:
-            default_book = repo.ui.config('remotenames', 'selectivepulldefault')
-            if not default_book:
-                raise error.Abort(
-                    _('no default bookmark specified for selectivepull'))
-            if default_book in remotebookmarks:
-                bookmarks = {default_book: remotebookmarks[default_book]}
-            else:
-                raise error.Abort(
-                    _('default bookmark %s is not found on remote') %
-                    default_book)
+            bookmarks = _getselectivepulldefaultbookmarks(repo.ui,
+                                                          remotebookmarks)
 
         if kwargs.get('bookmarks'):
             for bookmark in kwargs['bookmarks']:


More information about the Mercurial-devel mailing list