Patchwork D2875: remotenames: introduce a config option to allow creation of remote bookmarks

login
register
mail settings
Submitter phabricator
Date March 22, 2018, 7:35 a.m.
Message ID <4ff20a683f54b374b9dd7971aa1579d1@localhost.localdomain>
Download mbox | patch
Permalink /patch/29777/
State Not Applicable
Headers show

Comments

phabricator - March 22, 2018, 7:35 a.m.
pulkit updated this revision to Diff 7251.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2875?vs=7105&id=7251

REVISION DETAIL
  https://phab.mercurial-scm.org/D2875

AFFECTED FILES
  hgext/remotenames.py
  tests/test-logexchange.t

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/tests/test-logexchange.t b/tests/test-logexchange.t
--- a/tests/test-logexchange.t
+++ b/tests/test-logexchange.t
@@ -523,3 +523,57 @@ 
      date:        Thu Jan 01 00:00:00 1970 +0000
      summary:     Added a
   
+Testing the remotenames.createbookmark config option
+
+  $ hg bookmarks -R ../server2/
+     $TESTTMP/server/bar 6:87d6d6676308
+     $TESTTMP/server/foo 3:62615734edd5
+     bar                       6:87d6d6676308
+     foo                       3:62615734edd5
+
+  $ hg push ../server2/ -B nonexistant
+  pushing to ../server2/
+  searching for changes
+  abort: bookmark 'nonexistant' does not exists on remote
+  [255]
+
+  $ hg push ../server2/ -r . -B nonexistant --config remotenames.createremotebookmark=True
+  pushing to ../server2/
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+  exporting bookmark nonexistant
+
+  $ hg bookmarks -R ../server2/
+     $TESTTMP/server/bar 6:87d6d6676308
+     $TESTTMP/server/foo 3:62615734edd5
+     bar                       6:87d6d6676308
+     foo                       3:62615734edd5
+     nonexistant               9:aa6a885086c0
+
+  $ hg log -R ../server2/ -r tip
+  changeset:   9:aa6a885086c0
+  branch:      wat
+  bookmark:    nonexistant
+  tag:         tip
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     added foobar
+  
+Check synchornising of remotenames after push
+
+  $ hg log -G -r .
+  @  changeset:   9:aa6a885086c0
+  |  branch:      wat
+  ~  tag:         tip
+     remote bookmark:  $TESTTMP/server2/nonexistant
+     remote bookmark:  default/foo
+     hoisted name:  foo
+     remote branch:  $TESTTMP/server2/wat
+     remote branch:  default/wat
+     user:        test
+     date:        Thu Jan 01 00:00:00 1970 +0000
+     summary:     added foobar
+  
diff --git a/hgext/remotenames.py b/hgext/remotenames.py
--- a/hgext/remotenames.py
+++ b/hgext/remotenames.py
@@ -29,6 +29,10 @@ 
   the server. Errors if bookmark does not exists on the server. If multiple
   bookmarks are specified using `-B` flag, fallbacks to default behavior.
   (default: False)
+
+remotenames.createremotebookmark
+  Boolean value indicating whether a creating a new bookmark on the server using
+  remotenames.pushtobookmark config is allowed or not. (default: False)
 """
 
 from __future__ import absolute_import
@@ -83,6 +87,9 @@ 
 configitem('remotenames', 'pushtobookmark',
     default=False,
 )
+configitem('remotenames', 'createremotebookmark',
+    default=False,
+)
 
 def expushdiscoverybookmarks(pushop):
     # config not set, fallback to normal push behavior
@@ -102,7 +109,7 @@ 
     old = ''
     if bookmark in remotemarks:
         old = remotemarks[bookmark]
-    else:
+    elif not pushop.repo.ui.configbool('remotenames', 'createremotebookmark'):
         msg = _("bookmark '%s' does not exists on remote")
         raise error.Abort(msg % bookmark)