D1974: narrow: import experimental extension from narrowhg revision cb51d673e9c5

2018-02-08 Thread idlsoft (Sandu Turcan)
idlsoft added inline comments.

INLINE COMMENTS

> indygreg wrote in narrowbundle2.py:336
> We may want to remove this feature for the time being, as it is very Google 
> specific. I'm happy to provide a mechanism for extensions to hook in here to 
> enforce ACLs. But there's nothing in core that deals with path-based access 
> control and I think things should remain that way in order to keep the code 
> simple.
> 
> For the time being at least. I do acknowledge value in the feature and it is 
> something I'd like to see in core some day. I just think we should stabilize 
> the partial clone functionality first before we start forcing people to think 
> about path-based access control.

I've contributed the ACL code originally.
It's a relatively trivial piece of code, at least compared to the rest of the 
codebase, and it is called conditionally. 
I hope it can stay, my company is about to migrate from git to hg because of it.

> indygreg wrote in narrowbundle2.py:378-380
> Silently adding a repo requirement during a pull or unbundle operation 
> doesn't feel right to me. At least not at this juncture. For at least as long 
> as the feature is experimental, I think we should refuse to apply (or fetch) 
> a narrow bundle if the repo isn't already narrow. We can provide an `hg 
> debug*` command to add the requirement to make people's lives easier.

This was added to support seamless clone from an ACLed repo. The user doesn't 
know ahead of time about server-side narrowing.

REPOSITORY
  rHG Mercurial

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

To: durin42, #hg-reviewers
Cc: idlsoft, martinvonz, indygreg, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2231: narrow: fix for getting the username when running http server

2018-02-13 Thread idlsoft (Sandu Turcan)
idlsoft created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/narrow/narrowbundle2.py

CHANGE DETAILS

diff --git a/hgext/narrow/narrowbundle2.py b/hgext/narrow/narrowbundle2.py
--- a/hgext/narrow/narrowbundle2.py
+++ b/hgext/narrow/narrowbundle2.py
@@ -327,13 +327,14 @@
 part.addparam('treemanifest', '1')
 
 def applyacl_narrow(repo, kwargs):
-username = repo.ui.shortuser(repo.ui.username())
-user_includes = repo.ui.configlist(
+ui = repo.ui
+username = ui.shortuser(ui.environ.get('REMOTE_USER') or ui.username())
+user_includes = ui.configlist(
 _NARROWACL_SECTION, username + '.includes',
-repo.ui.configlist(_NARROWACL_SECTION, 'default.includes'))
-user_excludes = repo.ui.configlist(
+ui.configlist(_NARROWACL_SECTION, 'default.includes'))
+user_excludes = ui.configlist(
 _NARROWACL_SECTION, username + '.excludes',
-repo.ui.configlist(_NARROWACL_SECTION, 'default.excludes'))
+ui.configlist(_NARROWACL_SECTION, 'default.excludes'))
 if not user_includes:
 raise error.Abort(_("{} configuration for user {} is empty")
   .format(_NARROWACL_SECTION, username))



To: idlsoft, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2231: narrow: fix for getting the username when running http server

2018-02-13 Thread idlsoft (Sandu Turcan)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG4224f26c0d35: narrow: fix for getting the username when 
running http server (authored by idlsoft, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2231?vs=5649&id=5653

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

AFFECTED FILES
  hgext/narrow/narrowbundle2.py

CHANGE DETAILS

diff --git a/hgext/narrow/narrowbundle2.py b/hgext/narrow/narrowbundle2.py
--- a/hgext/narrow/narrowbundle2.py
+++ b/hgext/narrow/narrowbundle2.py
@@ -327,13 +327,14 @@
 part.addparam('treemanifest', '1')
 
 def applyacl_narrow(repo, kwargs):
-username = repo.ui.shortuser(repo.ui.username())
-user_includes = repo.ui.configlist(
+ui = repo.ui
+username = ui.shortuser(ui.environ.get('REMOTE_USER') or ui.username())
+user_includes = ui.configlist(
 _NARROWACL_SECTION, username + '.includes',
-repo.ui.configlist(_NARROWACL_SECTION, 'default.includes'))
-user_excludes = repo.ui.configlist(
+ui.configlist(_NARROWACL_SECTION, 'default.includes'))
+user_excludes = ui.configlist(
 _NARROWACL_SECTION, username + '.excludes',
-repo.ui.configlist(_NARROWACL_SECTION, 'default.excludes'))
+ui.configlist(_NARROWACL_SECTION, 'default.excludes'))
 if not user_includes:
 raise error.Abort(_("{} configuration for user {} is empty")
   .format(_NARROWACL_SECTION, username))



To: idlsoft, #hg-reviewers, durin42
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2231: narrow: fix for getting the username when running http server

2018-02-15 Thread idlsoft (Sandu Turcan)
idlsoft added inline comments.

INLINE COMMENTS

> martinvonz wrote in narrowbundle2.py:331
> But you're okay with this version for now? This commit is currently the 
> bottom-most draft commit in the "committed" repo, so please accept it if 
> you're okay with it. I would have accepted, but I saw this comment and wasn't 
> sure if you thought this was bad enough to not queue it.

Ideally I would have liked to have a `userid` method in repo.ui (or something 
like that), and have it used by both `narrow`  and `acl` extension.
But I think this deserves a longer discussion, hence the quick fix.

REPOSITORY
  rHG Mercurial

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

To: idlsoft, #hg-reviewers, durin42
Cc: martinvonz, indygreg, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D3750: ACL: added bookmarks support (from https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-March/080650.html)

2018-06-15 Thread idlsoft (Sandu Turcan)
idlsoft created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/acl.py
  tests/test-acl.t

CHANGE DETAILS

diff --git a/tests/test-acl.t b/tests/test-acl.t
--- a/tests/test-acl.t
+++ b/tests/test-acl.t
@@ -15,7 +15,7 @@
   > #  LOGNAME=$user hg --cws a --debug push ../b
   > # fails with "This variable is read only."
   > # Use env to work around this.
-  > env LOGNAME=$user hg --cwd a --debug push ../b
+  > env LOGNAME=$user hg --cwd a --debug push ../b $*
   > hg --cwd b rollback
   > hg --cwd b --quiet tip
   > echo
@@ -47,6 +47,7 @@
   > cat > $config < [hooks]
   > pretxnchangegroup.acl = python:hgext.acl.hook
+  > prepushkey.acl = python:hgext.acl.hook
   > [acl]
   > sources = push
   > [extensions]
@@ -148,14 +149,16 @@
 
   $ echo '[hooks]' >> $config
   $ echo 'pretxnchangegroup.acl = python:hgext.acl.hook' >> $config
+  $ echo 'prepushkey.acl = python:hgext.acl.hook' >> $config
 
 Extension disabled for lack of acl.sources
 
   $ do_push fred
   Pushing as user fred
   hgrc = """
   [hooks]
   pretxnchangegroup.acl = python:hgext.acl.hook
+  prepushkey.acl = python:hgext.acl.hook
   """
   pushing to ../b
   query 1; heads
@@ -220,6 +223,7 @@
   hgrc = """
   [hooks]
   pretxnchangegroup.acl = python:hgext.acl.hook
+  prepushkey.acl = python:hgext.acl.hook
   [acl]
   sources = push
   """
@@ -295,6 +299,7 @@
   hgrc = """
   [hooks]
   pretxnchangegroup.acl = python:hgext.acl.hook
+  prepushkey.acl = python:hgext.acl.hook
   [acl]
   sources = push
   [acl.allow]
@@ -362,6 +367,7 @@
   hgrc = """
   [hooks]
   pretxnchangegroup.acl = python:hgext.acl.hook
+  prepushkey.acl = python:hgext.acl.hook
   [acl]
   sources = push
   [acl.allow]
@@ -434,6 +440,7 @@
   hgrc = """
   [hooks]
   pretxnchangegroup.acl = python:hgext.acl.hook
+  prepushkey.acl = python:hgext.acl.hook
   [acl]
   sources = push
   [acl.allow]
@@ -503,6 +510,7 @@
   hgrc = """
   [hooks]
   pretxnchangegroup.acl = python:hgext.acl.hook
+  prepushkey.acl = python:hgext.acl.hook
   [acl]
   sources = push
   [acl.allow]
@@ -577,6 +585,7 @@
   hgrc = """
   [hooks]
   pretxnchangegroup.acl = python:hgext.acl.hook
+  prepushkey.acl = python:hgext.acl.hook
   [acl]
   sources = push
   [acl.allow]
@@ -649,6 +658,7 @@
   hgrc = """
   [hooks]
   pretxnchangegroup.acl = python:hgext.acl.hook
+  prepushkey.acl = python:hgext.acl.hook
   [acl]
   sources = push
   [acl.allow]
@@ -712,6 +722,180 @@
   0:6675d58eff77
   
 
+fred is not blocked from moving bookmarks
+
+  $ hg -R a book -q moving-bookmark -r 1
+  $ hg -R b book -q moving-bookmark -r 0
+  $ cp $config normalconfig
+  $ do_push fred -r 1
+  Pushing as user fred
+  hgrc = """
+  [hooks]
+  pretxnchangegroup.acl = python:hgext.acl.hook
+  prepushkey.acl = python:hgext.acl.hook
+  [acl]
+  sources = push
+  [acl.allow]
+  foo/** = fred
+  [acl.deny]
+  foo/bar/** = fred
+  foo/Bar/** = fred
+  """
+  pushing to ../b
+  query 1; heads
+  searching for changes
+  all remote heads known locally
+  listing keys for "phases"
+  checking for updated bookmarks
+  listing keys for "bookmarks"
+  listing keys for "bookmarks"
+  1 changesets found
+  list of changesets:
+  ef1ea85a6374b77d6da9dcda9541f498f2d17df7
+  bundle2-output-bundle: "HG20", 7 parts total
+  bundle2-output-part: "replycaps" 205 bytes payload
+  bundle2-output-part: "check:bookmarks" 37 bytes payload
+  bundle2-output-part: "check:phases" 24 bytes payload
+  bundle2-output-part: "check:heads" streamed payload
+  bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload
+  bundle2-output-part: "phase-heads" 24 bytes payload
+  bundle2-output-part: "bookmarks" 37 bytes payload
+  bundle2-input-bundle: with-transaction
+  bundle2-input-part: "replycaps" supported
+  bundle2-input-part: total payload size 205
+  bundle2-input-part: "check:bookmarks" supported
+  bundle2-input-part: total payload size 37
+  bundle2-input-part: "check:phases" supported
+  bundle2-input-part: total payload size 24
+  bundle2-input-part: "check:heads" supported
+  bundle2-input-part: total payload size 20
+  bundle2-input-part: "changegroup" (params: 1 mandatory) supported
+  adding changesets
+  add changeset ef1ea85a6374
+  adding manifests
+  adding file changes
+  adding foo/file.txt revisions
+  added 1 changesets with 1 changes to 1 files
+  calling hook pretxnchangegroup.acl: hgext.acl.hook
+  acl: checking access for user "fred"
+  acl: acl.allow.branches not enabled
+  acl: acl.deny.branches not enabled
+  acl: acl.allow enabled, 1 entries for user fred
+  acl: acl.deny enabled, 2 entries for user fred
+  acl: branch access granted: "ef1ea85a6374" on branch "default"
+  acl: path access granted: "ef1ea85a6374"
+  bundle2-input-part: total payload size 520
+  bundle2-input-part: "phase-heads" supported
+  bundle2-input-part: t

D3750: ACL: added bookmarks support (from https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-March/080650.html)

2018-07-03 Thread idlsoft (Sandu Turcan)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG6beb8347b709: acl: add bookmarks support (authored by 
idlsoft, committed by ).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D3750?vs=9096&id=9416#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3750?vs=9096&id=9416

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

AFFECTED FILES
  hgext/acl.py
  tests/test-acl.t

CHANGE DETAILS

diff --git a/tests/test-acl.t b/tests/test-acl.t
--- a/tests/test-acl.t
+++ b/tests/test-acl.t
@@ -15,7 +15,7 @@
   > #  LOGNAME=$user hg --cws a --debug push ../b
   > # fails with "This variable is read only."
   > # Use env to work around this.
-  > env LOGNAME=$user hg --cwd a --debug push ../b
+  > env LOGNAME=$user hg --cwd a --debug push ../b $*
   > hg --cwd b rollback
   > hg --cwd b --quiet tip
   > echo
@@ -47,6 +47,7 @@
   > cat > $config < [hooks]
   > pretxnchangegroup.acl = python:hgext.acl.hook
+  > prepushkey.acl = python:hgext.acl.hook
   > [acl]
   > sources = push
   > [extensions]
@@ -148,14 +149,16 @@
 
   $ echo '[hooks]' >> $config
   $ echo 'pretxnchangegroup.acl = python:hgext.acl.hook' >> $config
+  $ echo 'prepushkey.acl = python:hgext.acl.hook' >> $config
 
 Extension disabled for lack of acl.sources
 
   $ do_push fred
   Pushing as user fred
   hgrc = """
   [hooks]
   pretxnchangegroup.acl = python:hgext.acl.hook
+  prepushkey.acl = python:hgext.acl.hook
   """
   pushing to ../b
   query 1; heads
@@ -220,6 +223,7 @@
   hgrc = """
   [hooks]
   pretxnchangegroup.acl = python:hgext.acl.hook
+  prepushkey.acl = python:hgext.acl.hook
   [acl]
   sources = push
   """
@@ -295,6 +299,7 @@
   hgrc = """
   [hooks]
   pretxnchangegroup.acl = python:hgext.acl.hook
+  prepushkey.acl = python:hgext.acl.hook
   [acl]
   sources = push
   [acl.allow]
@@ -362,6 +367,7 @@
   hgrc = """
   [hooks]
   pretxnchangegroup.acl = python:hgext.acl.hook
+  prepushkey.acl = python:hgext.acl.hook
   [acl]
   sources = push
   [acl.allow]
@@ -434,6 +440,7 @@
   hgrc = """
   [hooks]
   pretxnchangegroup.acl = python:hgext.acl.hook
+  prepushkey.acl = python:hgext.acl.hook
   [acl]
   sources = push
   [acl.allow]
@@ -503,6 +510,7 @@
   hgrc = """
   [hooks]
   pretxnchangegroup.acl = python:hgext.acl.hook
+  prepushkey.acl = python:hgext.acl.hook
   [acl]
   sources = push
   [acl.allow]
@@ -577,6 +585,7 @@
   hgrc = """
   [hooks]
   pretxnchangegroup.acl = python:hgext.acl.hook
+  prepushkey.acl = python:hgext.acl.hook
   [acl]
   sources = push
   [acl.allow]
@@ -649,6 +658,7 @@
   hgrc = """
   [hooks]
   pretxnchangegroup.acl = python:hgext.acl.hook
+  prepushkey.acl = python:hgext.acl.hook
   [acl]
   sources = push
   [acl.allow]
@@ -712,6 +722,178 @@
   0:6675d58eff77
   
 
+fred is not blocked from moving bookmarks
+
+  $ hg -R a book -q moving-bookmark -r 1
+  $ hg -R b book -q moving-bookmark -r 0
+  $ cp $config normalconfig
+  $ do_push fred -r 1
+  Pushing as user fred
+  hgrc = """
+  [hooks]
+  pretxnchangegroup.acl = python:hgext.acl.hook
+  prepushkey.acl = python:hgext.acl.hook
+  [acl]
+  sources = push
+  [acl.allow]
+  foo/** = fred
+  [acl.deny]
+  foo/bar/** = fred
+  foo/Bar/** = fred
+  """
+  pushing to ../b
+  query 1; heads
+  searching for changes
+  all remote heads known locally
+  listing keys for "phases"
+  checking for updated bookmarks
+  listing keys for "bookmarks"
+  listing keys for "bookmarks"
+  1 changesets found
+  list of changesets:
+  ef1ea85a6374b77d6da9dcda9541f498f2d17df7
+  bundle2-output-bundle: "HG20", 7 parts total
+  bundle2-output-part: "replycaps" 205 bytes payload
+  bundle2-output-part: "check:bookmarks" 37 bytes payload
+  bundle2-output-part: "check:phases" 24 bytes payload
+  bundle2-output-part: "check:heads" streamed payload
+  bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload
+  bundle2-output-part: "phase-heads" 24 bytes payload
+  bundle2-output-part: "bookmarks" 37 bytes payload
+  bundle2-input-bundle: with-transaction
+  bundle2-input-part: "replycaps" supported
+  bundle2-input-part: total payload size 205
+  bundle2-input-part: "check:bookmarks" supported
+  bundle2-input-part: total payload size 37
+  bundle2-input-part: "check:phases" supported
+  bundle2-input-part: total payload size 24
+  bundle2-input-part: "check:heads" supported
+  bundle2-input-part: total payload size 20
+  bundle2-input-part: "changegroup" (params: 1 mandatory) supported
+  adding changesets
+  add changeset ef1ea85a6374
+  adding manifests
+  adding file changes
+  adding foo/file.txt revisions
+  added 1 changesets with 1 changes to 1 files
+  calling hook pretxnchangegroup.acl: hgext.acl.hook
+  acl: checking access for user "fred"
+  acl: acl.allow.branches not enabled
+  acl: acl.deny.branches not enabled
+  acl: acl.allow enabled, 1 entries for user fred
+  acl: acl.deny enabled, 2 entries for user fred
+

D4311: New bookflow extension for bookmark-based branching

2018-08-16 Thread idlsoft (Sandu Turcan)
idlsoft created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/bookflow.py

CHANGE DETAILS

diff --git a/hgext/bookflow.py b/hgext/bookflow.py
--- a/hgext/bookflow.py
+++ b/hgext/bookflow.py
@@ -45,8 +45,10 @@
 
 def bookmarks_update(orig, repo, parents, node):
 if len(parents) == 2:
+# called during commit
 return orig(repo, parents, node)
 else:
+# called during update
 return False
 
 



To: idlsoft, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D4311: New bookflow extension for bookmark-based branching

2018-08-16 Thread idlsoft (Sandu Turcan)
idlsoft added a comment.


  This was submitted in error, not sure how to delete it.

REPOSITORY
  rHG Mercurial

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

To: idlsoft, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D4312: New bookflow extension for bookmark-based branching

2018-08-16 Thread idlsoft (Sandu Turcan)
idlsoft created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/bookflow.py
  tests/test-bookflow.t

CHANGE DETAILS

diff --git a/tests/test-bookflow.t b/tests/test-bookflow.t
new file mode 100644
--- /dev/null
+++ b/tests/test-bookflow.t
@@ -0,0 +1,188 @@
+initialize
+  $ alias hgg="hg --config extensions.bookflow=`dirname 
$TESTDIR`/hgext/bookflow.py"
+  $ make_changes() { d=`pwd`; [ ! -z $1 ] && cd $1; echo "test $(basename 
`pwd`)" >> test; hgg commit -Am"${2:-test}"; r=$?; cd $d; return $r; }
+  $ assert_clean() { ls -1 $1 | grep -v "test$" | cat;}
+  $ ls -1a
+  .
+  ..
+  $ hg init a
+  $ cd a
+  $ echo 'test' > test; hg commit -Am'test'
+  adding test
+
+clone to b
+
+  $ mkdir ../b
+  $ cd ../b
+  $ hg clone ../a .
+  updating to branch default
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hgg branch X
+  abort: Branching should be done using bookmarks:
+  hg bookmark X
+  [255]
+  $ hgg bookmark X
+  $ hgg bookmarks
+  * X 0:* (glob)
+  $ make_changes
+  $ hgg push ../a > /dev/null
+
+  $ hg bookmarks
+   \* X 1:* (glob)
+
+change a
+  $ cd ../a
+  $ hgg up
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo 'test' >> test; hg commit -Am'test'
+
+
+pull in b
+  $ cd ../b
+  $ hgg pull -u
+  pulling from $TESTTMP/a
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+  new changesets * (glob)
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (leaving bookmark X)
+  $ assert_clean
+  $ hg bookmarks
+ X 1:* (glob)
+
+check protection of @ bookmark
+  $ hgg bookmark @
+  $ hgg bookmarks
+   \* @ 2:* (glob)
+ X 1:* (glob)
+  $ make_changes
+  abort: Can't commit, bookmark @ is protected
+  [255]
+
+  $ assert_clean
+  $ hgg bookmarks
+   \* @ 2:* (glob)
+ X 1:* (glob)
+
+  $ hgg --config bookflow.protect= commit  -Am"Updated test"
+
+  $ hgg bookmarks
+   \* @ 3:* (glob)
+ X 1:* (glob)
+
+check requirement for an active bookmark
+  $ hgg bookmark -i
+  $ hgg bookmarks
+ @ 3:* (glob)
+ X 1:* (glob)
+  $ make_changes
+  abort: Can't commit without an active bookmark
+  [255]
+  $ hgg revert test
+  $ rm test.orig
+  $ assert_clean
+
+
+make the bookmark move by updating it on a, and then pulling
+# add a commit to a
+  $ cd ../a
+  $ hg bookmark X
+  $ hgg bookmarks
+   \* X 2:* (glob)
+  $ make_changes
+  $ hgg bookmarks
+   * X 3:81af7977fdb9
+
+# go back to b, and check out X
+  $ cd ../b
+  $ hgg up X
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (activating bookmark X)
+  $ hgg bookmarks
+ @ 3:* (glob)
+   \* X 1:* (glob)
+
+# pull, this should move the bookmark forward, because it was changed remotely
+  $ hgg pull -u | grep "updating to active bookmark X"
+  updating to active bookmark X
+
+  $ hgg bookmarks
+ @ 3:* (glob)
+   * X 4:81af7977fdb9
+
+the bookmark should not move if it diverged from remote
+  $ assert_clean ../a
+  $ assert_clean ../b
+  $ make_changes ../a
+  $ make_changes ../b
+  $ assert_clean ../a
+  $ assert_clean ../b
+  $ hgg --cwd ../a bookmarks
+   * X 4:238292f60a57
+  $ hgg --cwd ../b bookmarks
+ @ 3:* (glob)
+   * X 5:096f7e86892d
+  $ cd ../b
+  $ # make sure we can't push after bookmarks diverged
+  $ hgg push -B X | grep abort
+  abort: push creates new remote head * with bookmark 'X'! (glob)
+  (pull and merge or see 'hg help push' for details about pushing new heads)
+  [1]
+  $ hgg pull -u | grep divergent
+  divergent bookmark X stored as X@default
+  1 other divergent bookmarks for "X"
+  $ hgg bookmarks
+ @ 3:* (glob)
+   * X 5:096f7e86892d
+ X@default 6:238292f60a57
+  $ hgg id -in
+  096f7e86892d 5
+  $ make_changes
+  $ assert_clean
+  $ hgg bookmarks
+ @ 3:* (glob)
+   * X 7:227f941aeb07
+ X@default 6:238292f60a57
+
+now merge with the remote bookmark
+  $ hgg merge X@default --tool :local > /dev/null
+  $ assert_clean
+  $ hgg commit -m"Merged with X@default"
+  $ hgg bookmarks
+ @ 3:* (glob)
+   * X 8:26fed9bb3219
+  $ hgg push -B X | grep bookmark
+  pushing to $TESTTMP/a (?)
+  updating bookmark X
+  $ c

D4353: bookflow: support shelve and enforce working directory pointing to the active bookmark

2018-08-22 Thread idlsoft (Sandu Turcan)
idlsoft created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/bookflow.py
  tests/test-bookflow.t

CHANGE DETAILS

diff --git a/tests/test-bookflow.t b/tests/test-bookflow.t
--- a/tests/test-bookflow.t
+++ b/tests/test-bookflow.t
@@ -1,6 +1,5 @@
 initialize
-  $ alias hgg="hg --config extensions.bookflow=`dirname 
$TESTDIR`/hgext/bookflow.py"
-  $ make_changes() { d=`pwd`; [ ! -z $1 ] && cd $1; echo "test $(basename 
`pwd`)" >> test; hgg commit -Am"${2:-test}"; r=$?; cd $d; return $r; }
+  $ make_changes() { d=`pwd`; [ ! -z $1 ] && cd $1; echo "test $(basename 
`pwd`)" >> test; hg commit -Am"${2:-test}"; r=$?; cd $d; return $r; }
   $ assert_clean() { ls -1 $1 | grep -v "test$" | cat;}
   $ ls -1a
   .
@@ -17,29 +16,31 @@
   $ hg clone ../a .
   updating to branch default
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hgg branch X
-  abort: Branching should be done using bookmarks:
+  $ echo "[extensions]" >> .hg/hgrc
+  $ echo "bookflow=" >> .hg/hgrc
+  $ hg branch X
+  abort: branching should be done using bookmarks:
   hg bookmark X
   [255]
-  $ hgg bookmark X
-  $ hgg bookmarks
+  $ hg bookmark X
+  $ hg bookmarks
   * X 0:* (glob)
   $ make_changes
-  $ hgg push ../a > /dev/null
+  $ hg push ../a > /dev/null
 
   $ hg bookmarks
\* X 1:* (glob)
 
 change a
   $ cd ../a
-  $ hgg up
+  $ hg up
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ echo 'test' >> test; hg commit -Am'test'
 
 
 pull in b
   $ cd ../b
-  $ hgg pull -u
+  $ hg pull -u
   pulling from $TESTTMP/a
   searching for changes
   adding changesets
@@ -54,62 +55,62 @@
  X 1:* (glob)
 
 check protection of @ bookmark
-  $ hgg bookmark @
-  $ hgg bookmarks
+  $ hg bookmark @
+  $ hg bookmarks
\* @ 2:* (glob)
  X 1:* (glob)
   $ make_changes
-  abort: Can't commit, bookmark @ is protected
+  abort: can't commit, bookmark @ is protected
   [255]
 
   $ assert_clean
-  $ hgg bookmarks
+  $ hg bookmarks
\* @ 2:* (glob)
  X 1:* (glob)
 
-  $ hgg --config bookflow.protect= commit  -Am"Updated test"
+  $ hg --config bookflow.protect= commit  -Am"Updated test"
 
-  $ hgg bookmarks
+  $ hg bookmarks
\* @ 3:* (glob)
  X 1:* (glob)
 
 check requirement for an active bookmark
-  $ hgg bookmark -i
-  $ hgg bookmarks
+  $ hg bookmark -i
+  $ hg bookmarks
  @ 3:* (glob)
  X 1:* (glob)
   $ make_changes
-  abort: Can't commit without an active bookmark
+  abort: can't commit without an active bookmark
   [255]
-  $ hgg revert test
+  $ hg revert test
   $ rm test.orig
   $ assert_clean
 
 
 make the bookmark move by updating it on a, and then pulling
 # add a commit to a
   $ cd ../a
   $ hg bookmark X
-  $ hgg bookmarks
+  $ hg bookmarks
\* X 2:* (glob)
   $ make_changes
-  $ hgg bookmarks
+  $ hg bookmarks
* X 3:81af7977fdb9
 
 # go back to b, and check out X
   $ cd ../b
-  $ hgg up X
+  $ hg up X
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   (activating bookmark X)
-  $ hgg bookmarks
+  $ hg bookmarks
  @ 3:* (glob)
\* X 1:* (glob)
 
 # pull, this should move the bookmark forward, because it was changed remotely
-  $ hgg pull -u | grep "updating to active bookmark X"
+  $ hg pull -u | grep "updating to active bookmark X"
   updating to active bookmark X
 
-  $ hgg bookmarks
+  $ hg bookmarks
  @ 3:* (glob)
* X 4:81af7977fdb9
 
@@ -120,69 +121,160 @@
   $ make_changes ../b
   $ assert_clean ../a
   $ assert_clean ../b
-  $ hgg --cwd ../a bookmarks
+  $ hg --cwd ../a bookmarks
* X 4:238292f60a57
-  $ hgg --cwd ../b bookmarks
+  $ hg --cwd ../b bookmarks
  @ 3:* (glob)
* X 5:096f7e86892d
   $ cd ../b
   $ # make sure we can't push after bookmarks diverged
-  $ hgg push -B X | grep abort
+  $ hg push -B X | grep abort
   abort: push creates new remote head * with bookmark 'X'! (glob)
   (pull and merge or see 'hg help push' for details about pushing new heads)
   [1]
-  $ hgg pull -u | grep divergent
+  $ hg pull -u | grep divergent
   divergent bookmark X stored as X@default
   1 other divergent bookmarks for "X"
-  $ hgg bookmarks
+  $ hg bookmarks
  @ 3:* (glob)
* X 5:096f7e86892d
  X@default 6:238292f60a57
-  $ hgg id -in
+  $ hg id -in
   096f7e86892d 5
   $ make_changes
   $ assert_clean

D4353: bookflow: support shelve and enforce working directory pointing to the active bookmark

2018-08-22 Thread idlsoft (Sandu Turcan)
idlsoft abandoned this revision.
idlsoft added a comment.


  Created a new one instead of updating https://phab.mercurial-scm.org/D4312

REPOSITORY
  rHG Mercurial

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

To: idlsoft, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D4312: New bookflow extension for bookmark-based branching

2018-08-22 Thread idlsoft (Sandu Turcan)
idlsoft updated this revision to Diff 10506.

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4312?vs=10406&id=10506

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

AFFECTED FILES
  hgext/bookflow.py
  tests/test-bookflow.t

CHANGE DETAILS

diff --git a/tests/test-bookflow.t b/tests/test-bookflow.t
--- a/tests/test-bookflow.t
+++ b/tests/test-bookflow.t
@@ -1,6 +1,5 @@
 initialize
-  $ alias hgg="hg --config extensions.bookflow=`dirname 
$TESTDIR`/hgext/bookflow.py"
-  $ make_changes() { d=`pwd`; [ ! -z $1 ] && cd $1; echo "test $(basename 
`pwd`)" >> test; hgg commit -Am"${2:-test}"; r=$?; cd $d; return $r; }
+  $ make_changes() { d=`pwd`; [ ! -z $1 ] && cd $1; echo "test $(basename 
`pwd`)" >> test; hg commit -Am"${2:-test}"; r=$?; cd $d; return $r; }
   $ assert_clean() { ls -1 $1 | grep -v "test$" | cat;}
   $ ls -1a
   .
@@ -17,29 +16,31 @@
   $ hg clone ../a .
   updating to branch default
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hgg branch X
-  abort: Branching should be done using bookmarks:
+  $ echo "[extensions]" >> .hg/hgrc
+  $ echo "bookflow=" >> .hg/hgrc
+  $ hg branch X
+  abort: branching should be done using bookmarks:
   hg bookmark X
   [255]
-  $ hgg bookmark X
-  $ hgg bookmarks
+  $ hg bookmark X
+  $ hg bookmarks
   * X 0:* (glob)
   $ make_changes
-  $ hgg push ../a > /dev/null
+  $ hg push ../a > /dev/null
 
   $ hg bookmarks
\* X 1:* (glob)
 
 change a
   $ cd ../a
-  $ hgg up
+  $ hg up
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ echo 'test' >> test; hg commit -Am'test'
 
 
 pull in b
   $ cd ../b
-  $ hgg pull -u
+  $ hg pull -u
   pulling from $TESTTMP/a
   searching for changes
   adding changesets
@@ -54,34 +55,34 @@
  X 1:* (glob)
 
 check protection of @ bookmark
-  $ hgg bookmark @
-  $ hgg bookmarks
+  $ hg bookmark @
+  $ hg bookmarks
\* @ 2:* (glob)
  X 1:* (glob)
   $ make_changes
-  abort: Can't commit, bookmark @ is protected
+  abort: can't commit, bookmark @ is protected
   [255]
 
   $ assert_clean
-  $ hgg bookmarks
+  $ hg bookmarks
\* @ 2:* (glob)
  X 1:* (glob)
 
-  $ hgg --config bookflow.protect= commit  -Am"Updated test"
+  $ hg --config bookflow.protect= commit  -Am"Updated test"
 
-  $ hgg bookmarks
+  $ hg bookmarks
\* @ 3:* (glob)
  X 1:* (glob)
 
 check requirement for an active bookmark
-  $ hgg bookmark -i
-  $ hgg bookmarks
+  $ hg bookmark -i
+  $ hg bookmarks
  @ 3:* (glob)
  X 1:* (glob)
   $ make_changes
-  abort: Can't commit without an active bookmark
+  abort: can't commit without an active bookmark
   [255]
-  $ hgg revert test
+  $ hg revert test
   $ rm test.orig
   $ assert_clean
 
@@ -90,26 +91,26 @@
 # add a commit to a
   $ cd ../a
   $ hg bookmark X
-  $ hgg bookmarks
+  $ hg bookmarks
\* X 2:* (glob)
   $ make_changes
-  $ hgg bookmarks
+  $ hg bookmarks
* X 3:81af7977fdb9
 
 # go back to b, and check out X
   $ cd ../b
-  $ hgg up X
+  $ hg up X
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   (activating bookmark X)
-  $ hgg bookmarks
+  $ hg bookmarks
  @ 3:* (glob)
\* X 1:* (glob)
 
 # pull, this should move the bookmark forward, because it was changed remotely
-  $ hgg pull -u | grep "updating to active bookmark X"
+  $ hg pull -u | grep "updating to active bookmark X"
   updating to active bookmark X
 
-  $ hgg bookmarks
+  $ hg bookmarks
  @ 3:* (glob)
* X 4:81af7977fdb9
 
@@ -120,69 +121,160 @@
   $ make_changes ../b
   $ assert_clean ../a
   $ assert_clean ../b
-  $ hgg --cwd ../a bookmarks
+  $ hg --cwd ../a bookmarks
* X 4:238292f60a57
-  $ hgg --cwd ../b bookmarks
+  $ hg --cwd ../b bookmarks
  @ 3:* (glob)
* X 5:096f7e86892d
   $ cd ../b
   $ # make sure we can't push after bookmarks diverged
-  $ hgg push -B X | grep abort
+  $ hg push -B X | grep abort
   abort: push creates new remote head * with bookmark 'X'! (glob)
   (pull and merge or see 'hg help push' for details about pushing new heads)
   [1]
-  $ hgg pull -u | grep divergent
+  $ hg pull -u | grep divergent
   divergent bookmark X stored as X@default
   1 other divergent bookmarks for "X"
-  $ hgg bookmarks
+  $ hg bookmarks
  @ 3:* (glob)
* X 5:096f7e86892d
  X@default 6:238292f60a57
-  $ hgg id -in
+  $ hg id -in
   096f7e86892d 5
   $ make_changes
   $ assert_clean
-  $ hgg bookmarks
+  $ hg bookmarks
  @ 

D4312: New bookflow extension for bookmark-based branching

2018-08-22 Thread idlsoft (Sandu Turcan)
idlsoft updated this revision to Diff 10507.

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4312?vs=10506&id=10507

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

AFFECTED FILES
  hgext/bookflow.py
  tests/test-bookflow.t

CHANGE DETAILS

diff --git a/tests/test-bookflow.t b/tests/test-bookflow.t
new file mode 100644
--- /dev/null
+++ b/tests/test-bookflow.t
@@ -0,0 +1,280 @@
+initialize
+  $ make_changes() { d=`pwd`; [ ! -z $1 ] && cd $1; echo "test $(basename 
`pwd`)" >> test; hg commit -Am"${2:-test}"; r=$?; cd $d; return $r; }
+  $ assert_clean() { ls -1 $1 | grep -v "test$" | cat;}
+  $ ls -1a
+  .
+  ..
+  $ hg init a
+  $ cd a
+  $ echo 'test' > test; hg commit -Am'test'
+  adding test
+
+clone to b
+
+  $ mkdir ../b
+  $ cd ../b
+  $ hg clone ../a .
+  updating to branch default
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo "[extensions]" >> .hg/hgrc
+  $ echo "bookflow=" >> .hg/hgrc
+  $ hg branch X
+  abort: branching should be done using bookmarks:
+  hg bookmark X
+  [255]
+  $ hg bookmark X
+  $ hg bookmarks
+  * X 0:* (glob)
+  $ make_changes
+  $ hg push ../a > /dev/null
+
+  $ hg bookmarks
+   \* X 1:* (glob)
+
+change a
+  $ cd ../a
+  $ hg up
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo 'test' >> test; hg commit -Am'test'
+
+
+pull in b
+  $ cd ../b
+  $ hg pull -u
+  pulling from $TESTTMP/a
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+  new changesets * (glob)
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (leaving bookmark X)
+  $ assert_clean
+  $ hg bookmarks
+ X 1:* (glob)
+
+check protection of @ bookmark
+  $ hg bookmark @
+  $ hg bookmarks
+   \* @ 2:* (glob)
+ X 1:* (glob)
+  $ make_changes
+  abort: can't commit, bookmark @ is protected
+  [255]
+
+  $ assert_clean
+  $ hg bookmarks
+   \* @ 2:* (glob)
+ X 1:* (glob)
+
+  $ hg --config bookflow.protect= commit  -Am"Updated test"
+
+  $ hg bookmarks
+   \* @ 3:* (glob)
+ X 1:* (glob)
+
+check requirement for an active bookmark
+  $ hg bookmark -i
+  $ hg bookmarks
+ @ 3:* (glob)
+ X 1:* (glob)
+  $ make_changes
+  abort: can't commit without an active bookmark
+  [255]
+  $ hg revert test
+  $ rm test.orig
+  $ assert_clean
+
+
+make the bookmark move by updating it on a, and then pulling
+# add a commit to a
+  $ cd ../a
+  $ hg bookmark X
+  $ hg bookmarks
+   \* X 2:* (glob)
+  $ make_changes
+  $ hg bookmarks
+   * X 3:81af7977fdb9
+
+# go back to b, and check out X
+  $ cd ../b
+  $ hg up X
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (activating bookmark X)
+  $ hg bookmarks
+ @ 3:* (glob)
+   \* X 1:* (glob)
+
+# pull, this should move the bookmark forward, because it was changed remotely
+  $ hg pull -u | grep "updating to active bookmark X"
+  updating to active bookmark X
+
+  $ hg bookmarks
+ @ 3:* (glob)
+   * X 4:81af7977fdb9
+
+the bookmark should not move if it diverged from remote
+  $ assert_clean ../a
+  $ assert_clean ../b
+  $ make_changes ../a
+  $ make_changes ../b
+  $ assert_clean ../a
+  $ assert_clean ../b
+  $ hg --cwd ../a bookmarks
+   * X 4:238292f60a57
+  $ hg --cwd ../b bookmarks
+ @ 3:* (glob)
+   * X 5:096f7e86892d
+  $ cd ../b
+  $ # make sure we can't push after bookmarks diverged
+  $ hg push -B X | grep abort
+  abort: push creates new remote head * with bookmark 'X'! (glob)
+  (pull and merge or see 'hg help push' for details about pushing new heads)
+  [1]
+  $ hg pull -u | grep divergent
+  divergent bookmark X stored as X@default
+  1 other divergent bookmarks for "X"
+  $ hg bookmarks
+ @ 3:* (glob)
+   * X 5:096f7e86892d
+ X@default 6:238292f60a57
+  $ hg id -in
+  096f7e86892d 5
+  $ make_changes
+  $ assert_clean
+  $ hg bookmarks
+ @ 3:* (glob)
+   * X 7:227f941aeb07
+ X@default 6:238292f60a57
+
+now merge with the remote bookmark
+  $ hg merge X@default --tool :local > /dev/null
+  $ assert_clean
+  $ hg commit -m"Merged with X@default"
+  $ hg bookmarks
+ @ 3:* (glob)
+   * X 8:26fed9bb3219
+  $ hg push -B X | grep bookmark
+  pushing to $TESTTMP/a (?)
+  updating bookmark X
+  $ cd ../a
+  $ hg up > /dev/null
+  $ hg bookmarks
+   * X  

D4312: New bookflow extension for bookmark-based branching

2018-08-22 Thread idlsoft (Sandu Turcan)
idlsoft updated this revision to Diff 10508.

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4312?vs=10507&id=10508

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

AFFECTED FILES
  hgext/bookflow.py
  tests/test-bookflow.t

CHANGE DETAILS

diff --git a/tests/test-bookflow.t b/tests/test-bookflow.t
new file mode 100644
--- /dev/null
+++ b/tests/test-bookflow.t
@@ -0,0 +1,280 @@
+initialize
+  $ make_changes() { d=`pwd`; [ ! -z $1 ] && cd $1; echo "test $(basename 
`pwd`)" >> test; hg commit -Am"${2:-test}"; r=$?; cd $d; return $r; }
+  $ assert_clean() { ls -1 $1 | grep -v "test$" | cat;}
+  $ ls -1a
+  .
+  ..
+  $ hg init a
+  $ cd a
+  $ echo 'test' > test; hg commit -Am'test'
+  adding test
+
+clone to b
+
+  $ mkdir ../b
+  $ cd ../b
+  $ hg clone ../a .
+  updating to branch default
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo "[extensions]" >> .hg/hgrc
+  $ echo "bookflow=" >> .hg/hgrc
+  $ hg branch X
+  abort: branching should be done using bookmarks:
+  hg bookmark X
+  [255]
+  $ hg bookmark X
+  $ hg bookmarks
+  * X 0:* (glob)
+  $ make_changes
+  $ hg push ../a > /dev/null
+
+  $ hg bookmarks
+   \* X 1:* (glob)
+
+change a
+  $ cd ../a
+  $ hg up
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo 'test' >> test; hg commit -Am'test'
+
+
+pull in b
+  $ cd ../b
+  $ hg pull -u
+  pulling from $TESTTMP/a
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+  new changesets * (glob)
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (leaving bookmark X)
+  $ assert_clean
+  $ hg bookmarks
+ X 1:* (glob)
+
+check protection of @ bookmark
+  $ hg bookmark @
+  $ hg bookmarks
+   \* @ 2:* (glob)
+ X 1:* (glob)
+  $ make_changes
+  abort: can't commit, bookmark @ is protected
+  [255]
+
+  $ assert_clean
+  $ hg bookmarks
+   \* @ 2:* (glob)
+ X 1:* (glob)
+
+  $ hg --config bookflow.protect= commit  -Am"Updated test"
+
+  $ hg bookmarks
+   \* @ 3:* (glob)
+ X 1:* (glob)
+
+check requirement for an active bookmark
+  $ hg bookmark -i
+  $ hg bookmarks
+ @ 3:* (glob)
+ X 1:* (glob)
+  $ make_changes
+  abort: can't commit without an active bookmark
+  [255]
+  $ hg revert test
+  $ rm test.orig
+  $ assert_clean
+
+
+make the bookmark move by updating it on a, and then pulling
+# add a commit to a
+  $ cd ../a
+  $ hg bookmark X
+  $ hg bookmarks
+   \* X 2:* (glob)
+  $ make_changes
+  $ hg bookmarks
+   * X 3:81af7977fdb9
+
+# go back to b, and check out X
+  $ cd ../b
+  $ hg up X
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (activating bookmark X)
+  $ hg bookmarks
+ @ 3:* (glob)
+   \* X 1:* (glob)
+
+# pull, this should move the bookmark forward, because it was changed remotely
+  $ hg pull -u | grep "updating to active bookmark X"
+  updating to active bookmark X
+
+  $ hg bookmarks
+ @ 3:* (glob)
+   * X 4:81af7977fdb9
+
+the bookmark should not move if it diverged from remote
+  $ assert_clean ../a
+  $ assert_clean ../b
+  $ make_changes ../a
+  $ make_changes ../b
+  $ assert_clean ../a
+  $ assert_clean ../b
+  $ hg --cwd ../a bookmarks
+   * X 4:238292f60a57
+  $ hg --cwd ../b bookmarks
+ @ 3:* (glob)
+   * X 5:096f7e86892d
+  $ cd ../b
+  $ # make sure we can't push after bookmarks diverged
+  $ hg push -B X | grep abort
+  abort: push creates new remote head * with bookmark 'X'! (glob)
+  (pull and merge or see 'hg help push' for details about pushing new heads)
+  [1]
+  $ hg pull -u | grep divergent
+  divergent bookmark X stored as X@default
+  1 other divergent bookmarks for "X"
+  $ hg bookmarks
+ @ 3:* (glob)
+   * X 5:096f7e86892d
+ X@default 6:238292f60a57
+  $ hg id -in
+  096f7e86892d 5
+  $ make_changes
+  $ assert_clean
+  $ hg bookmarks
+ @ 3:* (glob)
+   * X 7:227f941aeb07
+ X@default 6:238292f60a57
+
+now merge with the remote bookmark
+  $ hg merge X@default --tool :local > /dev/null
+  $ assert_clean
+  $ hg commit -m"Merged with X@default"
+  $ hg bookmarks
+ @ 3:* (glob)
+   * X 8:26fed9bb3219
+  $ hg push -B X | grep bookmark
+  pushing to $TESTTMP/a (?)
+  updating bookmark X
+  $ cd ../a
+  $ hg up > /dev/null
+  $ hg bookmarks
+   * X  

D6776: bookmarks: validate changes on push

2019-08-30 Thread idlsoft (Sandu Turcan)
idlsoft created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/bundle2.py
  mercurial/exchange.py
  mercurial/localrepo.py
  tests/test-bookmarksconflict.t

CHANGE DETAILS

diff --git a/tests/test-bookmarksconflict.t b/tests/test-bookmarksconflict.t
new file mode 100644
--- /dev/null
+++ b/tests/test-bookmarksconflict.t
@@ -0,0 +1,84 @@
+initialize
+  $ make_changes() {
+  > d=`pwd`
+  > [ ! -z $1 ] && cd $1
+  > echo "test `basename \`pwd\``" >> test
+  > hg commit -Am"${2:-test}"
+  > r=$?
+  > cd $d
+  > return $r
+  > }
+  $ ls -1a
+  .
+  ..
+  $ hg init a
+  $ cd a
+  $ echo 'test' > test; hg commit -Am'test'
+  adding test
+  $ hg book @
+
+clone to b
+
+  $ mkdir ../b
+  $ cd ../b
+  $ hg clone ../a .
+  updating to bookmark @
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ make_changes
+  $ hg book bk_b
+
+clone to c
+  $ mkdir ../c
+  $ cd ../c
+  $ hg clone ../a .
+  updating to bookmark @
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ make_changes
+  $ hg book bk_c
+
+push from b
+  $ cd ../b
+  $ hg push -B .
+  pushing to $TESTTMP/a
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+  updating bookmark @
+  exporting bookmark bk_b
+  $ hg -R ../a id -r @
+  e11a942451be tip @/bk_b
+
+push from c
+  $ cd ../c
+  $ hg push -B .
+  pushing to $TESTTMP/a
+  searching for changes
+  remote has heads on branch 'default' that are not known locally: e11a942451be
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files (+1 heads)
+  exporting bookmark bk_c
+  $ hg push -B @
+  pushing to $TESTTMP/a
+  searching for changes
+  no changes found
+  abort: push rejected: bookmark "@" has changed
+  (run 'hg pull', resolve conflicts, and push again)
+  [255]
+  $ hg -R ../a book
+   * @ 1:e11a942451be
+ bk_b  1:e11a942451be
+ bk_c  2:110743c8a16c
+  $ hg push -B @ --force
+  pushing to $TESTTMP/a
+  searching for changes
+  no changes found
+  updating bookmark @
+  [1]
+  $ hg -R ../a book
+   * @ 2:110743c8a16c
+ bk_b  1:e11a942451be
+ bk_c  2:110743c8a16c
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -307,14 +307,14 @@
 raise error.Abort(_('cannot perform stream clone against local '
 'peer'))
 
-def unbundle(self, bundle, heads, url):
+def unbundle(self, bundle, heads, url, force=None):
 """apply a bundle on a repo
 
 This function handles the repo locking itself."""
 try:
 try:
 bundle = exchange.readbundle(self.ui, bundle, None)
-ret = exchange.unbundle(self._repo, bundle, heads, 'push', url)
+ret = exchange.unbundle(self._repo, bundle, heads, 'push', 
url, force=force)
 if util.safehasattr(ret, 'getchunks'):
 # This is a bundle20 object, turn it into an unbundler.
 # This little dance should be dropped eventually when the
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1149,6 +1149,7 @@
 'bundle': stream,
 'heads': ['force'],
 'url': pushop.remote.url(),
+'force': pushop.force,
 }).result()
 except error.BundleValueError as exc:
 raise error.Abort(_('missing support for %s') % exc)
@@ -2362,7 +2363,7 @@
 raise error.PushRaced('repository changed while %s - '
   'please try again' % context)
 
-def unbundle(repo, cg, heads, source, url):
+def unbundle(repo, cg, heads, source, url, force=None):
 """Apply a bundle to a repo.
 
 this function makes sure the repo is locked during the application and have
@@ -2410,7 +2411,8 @@
 
 op = bundle2.bundleoperation(repo, gettransaction,
  captureoutput=captureoutput,
- source='push')
+ source='push',
+ force=force)
 try:
 op = bundle2.processbundle(repo, cg, op=op)
 finally:
diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -299,7 +299,7 @@
 * a way to construct a bundle response when applicable.
 """
 
-def __init__(self, repo, transactiong

D6776: bookmarks: validate changes on push

2019-08-30 Thread idlsoft (Sandu Turcan)
idlsoft added a comment.


  This is a potential fix for https://bz.mercurial-scm.org/show_bug.cgi?id=6193
  The actual validation is in `bundle2.handlebookmark`.
  The rest of the changes are there to pass the `force` parameter.
  I've also made `force` available to hooks. That way one can validate who can 
and cannot use `--force` on a shared repo.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6776/new/

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

To: idlsoft, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6776: bookmarks: validate changes on push

2019-09-03 Thread idlsoft (Sandu Turcan)
idlsoft added a comment.


  I see `--force` as a general "I know what I'm doing, forget your checks"  
instruction.
  If it's not, then all the variations would need their own `--force-heads`, 
`--force-bookmarks`, `--force-*`.
  May be a bit much.
  
  As for this being configurable?
  I, personally, don't see a lot of value in the current behavior.
  There may be a use case, but the default behavior, useful for most users, 
would be to check it, I think.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6776/new/

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

To: idlsoft, #hg-reviewers
Cc: valentin.gatienbaron, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6776: bookmarks: validate changes on push

2019-09-09 Thread idlsoft (Sandu Turcan)
idlsoft added a comment.


  Yes, server changed since your last pull, and you override the bookmark 
without so much as a warning.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6776/new/

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

To: idlsoft, #hg-reviewers
Cc: durin42, valentin.gatienbaron, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6776: bookmarks: validate changes on push (issue6193) (BC)

2019-09-11 Thread idlsoft (Sandu Turcan)
idlsoft updated this revision to Diff 16518.

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6776?vs=16515&id=16518

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6776/new/

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

AFFECTED FILES
  mercurial/bundle2.py
  mercurial/exchange.py
  mercurial/localrepo.py
  mercurial/repository.py
  mercurial/wireprotov1peer.py
  tests/test-bookmarks-conflict.t

CHANGE DETAILS

diff --git a/tests/test-bookmarks-conflict.t b/tests/test-bookmarks-conflict.t
new file mode 100644
--- /dev/null
+++ b/tests/test-bookmarks-conflict.t
@@ -0,0 +1,91 @@
+initialize
+  $ make_changes() {
+  > d=`pwd`
+  > [ ! -z $1 ] && cd $1
+  > echo "test `basename \`pwd\``" >> test
+  > hg commit -Am"${2:-test}"
+  > r=$?
+  > cd $d
+  > return $r
+  > }
+  $ ls -1a
+  .
+  ..
+  $ hg init a
+  $ cd a
+  $ echo 'test' > test; hg commit -Am'test'
+  adding test
+  $ hg book @
+
+clone to b
+
+  $ mkdir ../b
+  $ cd ../b
+  $ hg clone ../a .
+  updating to bookmark @
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ make_changes
+  $ hg book bk_b
+
+clone to c
+  $ mkdir ../c
+  $ cd ../c
+  $ hg clone ../a .
+  updating to bookmark @
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ make_changes
+  $ hg book bk_c
+
+push from b
+  $ cd ../b
+  $ hg push -B .
+  pushing to $TESTTMP/a
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+  updating bookmark @
+  exporting bookmark bk_b
+  $ hg -R ../a id -r @
+  e11a942451be tip @/bk_b
+
+push from c
+  $ cd ../c
+  $ hg push -B .
+  pushing to $TESTTMP/a
+  searching for changes
+  remote has heads on branch 'default' that are not known locally: e11a942451be
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files (+1 heads)
+  exporting bookmark bk_c
+  $ hg push -B @
+  pushing to $TESTTMP/a
+  searching for changes
+  no changes found
+  abort: push rejected: bookmark "@" has changed
+  (run 'hg pull', resolve conflicts, and push again)
+  [255]
+  $ hg -R ../a log -G -T '{rev} {bookmarks}'
+  o  2 bk_c
+  |
+  | o  1 @ bk_b
+  |/
+  @  0
+  
+
+  $ hg push -B @ --force
+  pushing to $TESTTMP/a
+  searching for changes
+  no changes found
+  updating bookmark @
+  [1]
+  $ hg -R ../a log -G -T '{rev} {bookmarks}'
+  o  2 @ bk_c
+  |
+  | o  1 bk_b
+  |/
+  @  0
+  
diff --git a/mercurial/wireprotov1peer.py b/mercurial/wireprotov1peer.py
--- a/mercurial/wireprotov1peer.py
+++ b/mercurial/wireprotov1peer.py
@@ -445,7 +445,7 @@
 else:
 return changegroupmod.cg1unpacker(f, 'UN')
 
-def unbundle(self, bundle, heads, url):
+def unbundle(self, bundle, heads, url, force=None):
 '''Send cg (a readable file-like object representing the
 changegroup to push, typically a chunkbuffer object) to the
 remote server as a bundle.
diff --git a/mercurial/repository.py b/mercurial/repository.py
--- a/mercurial/repository.py
+++ b/mercurial/repository.py
@@ -191,7 +191,7 @@
 Successful result should be a generator of data chunks.
 """
 
-def unbundle(bundle, heads, url):
+def unbundle(bundle, heads, url, force=None):
 """Transfer repository data to the peer.
 
 This is how the bulk of data during a push is transferred.
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -306,14 +306,14 @@
 raise error.Abort(_('cannot perform stream clone against local '
 'peer'))
 
-def unbundle(self, bundle, heads, url):
+def unbundle(self, bundle, heads, url, force=None):
 """apply a bundle on a repo
 
 This function handles the repo locking itself."""
 try:
 try:
 bundle = exchange.readbundle(self.ui, bundle, None)
-ret = exchange.unbundle(self._repo, bundle, heads, 'push', url)
+ret = exchange.unbundle(self._repo, bundle, heads, 'push', 
url, force=force)
 if util.safehasattr(ret, 'getchunks'):
 # This is a bundle20 object, turn it into an unbundler.
 # This little dance should be dropped eventually when the
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1159,6 +1159,7 @@
 'bundle': stream,
 'heads': ['force'],
 'url': pushop.remote.url(),
+'force': pushop.force,
 }).result()
 except error.BundleValueError as exc:
 raise error.Abort(_('missing support for %s') % exc)
@@ -2375,7 +2376,7 @@
 raise error.PushRaced('repository changed while %s - '
   'please try again' %

D6845: pushkeys: introduce a server.bookmarks-pushkey-reject option to complement D6776

2019-09-12 Thread idlsoft (Sandu Turcan)
idlsoft created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/bookmarks.py
  mercurial/configitems.py
  tests/test-bookmarks-pushpull.t

CHANGE DETAILS

diff --git a/tests/test-bookmarks-pushpull.t b/tests/test-bookmarks-pushpull.t
--- a/tests/test-bookmarks-pushpull.t
+++ b/tests/test-bookmarks-pushpull.t
@@ -1350,3 +1350,28 @@
   no changes found (ignored 1 secret changesets)
   abort: cannot push bookmark foo as it points to a secret changeset
   [255]
+
+Should fail to push a bookmark if server.bookmarks-pushkey-reject=true
+  $ hg init pb_server
+  $ cat << EOF >> pb_server/.hg/hgrc
+  > [server]
+  > bookmarks-pushkey-reject = true
+  > [web]
+  > push_ssl = false
+  > allow_push = *
+  > EOF
+  $ echo a > pb_server/a
+  $ hg --cwd pb_server add a
+  $ hg -R pb_server commit -m "Initial commit"
+  $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS
+  $ hg serve -R pb_server -p $HGPORT --pid-file=pb_server.pid -d
+  $ cat pb_server.pid >> $DAEMON_PIDS
+  $ hg clone -q http://localhost:$HGPORT/ pb_copy
+  $ hg -R pb_copy book book1
+  $ hg -R pb_copy push -B book1 --config devel.legacy.exchange=bookmarks
+  pushing to http://localhost:$HGPORT/
+  searching for changes
+  no changes found
+  abort: exporting bookmark book1 failed!
+  [255]
+  $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -1027,6 +1027,9 @@
 coreconfigitem('server', 'bookmarks-pushkey-compat',
 default=True,
 )
+coreconfigitem('server', 'bookmarks-pushkey-reject',
+default=False,
+)
 coreconfigitem('server', 'bundle1',
 default=True,
 )
diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -445,6 +445,8 @@
 return d
 
 def pushbookmark(repo, key, old, new):
+if repo.ui.configbool('server', 'bookmarks-pushkey-reject'):
+return False
 if bookmarksinstore(repo):
 wlock = util.nullcontextmanager()
 else:



To: idlsoft, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6776: bookmarks: validate changes on push (issue6193) (BC)

2019-09-12 Thread idlsoft (Sandu Turcan)
idlsoft updated this revision to Diff 16524.

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6776?vs=16519&id=16524

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6776/new/

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

AFFECTED FILES
  mercurial/bundle2.py
  mercurial/exchange.py
  mercurial/localrepo.py
  mercurial/repository.py
  mercurial/wireprotov1peer.py
  tests/test-bookmarks-conflict.t
  tests/test-bookmarks-pushpull.t
  tests/test-hook.t

CHANGE DETAILS

diff --git a/tests/test-hook.t b/tests/test-hook.t
--- a/tests/test-hook.t
+++ b/tests/test-hook.t
@@ -545,6 +545,7 @@
   HG_URL=file:$TESTTMP/a
   
   pushkey hook: HG_BUNDLE2=1
+  HG_FORCE=0
   HG_HOOKNAME=pushkey
   HG_HOOKTYPE=pushkey
   HG_KEY=foo
@@ -632,6 +633,7 @@
   HG_TXNNAME=push
   
   prepushkey.forbid hook: HG_BUNDLE2=1
+  HG_FORCE=0
   HG_HOOKNAME=prepushkey
   HG_HOOKTYPE=prepushkey
   HG_KEY=baz
diff --git a/tests/test-bookmarks-pushpull.t b/tests/test-bookmarks-pushpull.t
--- a/tests/test-bookmarks-pushpull.t
+++ b/tests/test-bookmarks-pushpull.t
@@ -813,7 +813,7 @@
  Z 0d2164f0ce0d
  foo   
  foobar
-  $ hg push -B Z http://localhost:$HGPORT/
+  $ hg push -B Z http://localhost:$HGPORT/ --config 
devel.legacy.exchange=bookmarks
   pushing to http://localhost:$HGPORT/
   searching for changes
   no changes found
diff --git a/tests/test-bookmarks-conflict.t b/tests/test-bookmarks-conflict.t
new file mode 100644
--- /dev/null
+++ b/tests/test-bookmarks-conflict.t
@@ -0,0 +1,91 @@
+initialize
+  $ make_changes() {
+  > d=`pwd`
+  > [ ! -z $1 ] && cd $1
+  > echo "test `basename \`pwd\``" >> test
+  > hg commit -Am"${2:-test}"
+  > r=$?
+  > cd $d
+  > return $r
+  > }
+  $ ls -1a
+  .
+  ..
+  $ hg init a
+  $ cd a
+  $ echo 'test' > test; hg commit -Am'test'
+  adding test
+  $ hg book @
+
+clone to b
+
+  $ mkdir ../b
+  $ cd ../b
+  $ hg clone ../a .
+  updating to bookmark @
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ make_changes
+  $ hg book bk_b
+
+clone to c
+  $ mkdir ../c
+  $ cd ../c
+  $ hg clone ../a .
+  updating to bookmark @
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ make_changes
+  $ hg book bk_c
+
+push from b
+  $ cd ../b
+  $ hg push -B .
+  pushing to $TESTTMP/a
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+  updating bookmark @
+  exporting bookmark bk_b
+  $ hg -R ../a id -r @
+  e11a942451be tip @/bk_b
+
+push from c
+  $ cd ../c
+  $ hg push -B .
+  pushing to $TESTTMP/a
+  searching for changes
+  remote has heads on branch 'default' that are not known locally: e11a942451be
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files (+1 heads)
+  exporting bookmark bk_c
+  $ hg push -B @
+  pushing to $TESTTMP/a
+  searching for changes
+  no changes found
+  abort: push rejected: bookmark "@" has changed
+  (run 'hg pull', resolve conflicts, and push again)
+  [255]
+  $ hg -R ../a log -G -T '{rev} {bookmarks}'
+  o  2 bk_c
+  |
+  | o  1 @ bk_b
+  |/
+  @  0
+  
+
+  $ hg push -B @ --force
+  pushing to $TESTTMP/a
+  searching for changes
+  no changes found
+  updating bookmark @
+  [1]
+  $ hg -R ../a log -G -T '{rev} {bookmarks}'
+  o  2 @ bk_c
+  |
+  | o  1 bk_b
+  |/
+  @  0
+  
diff --git a/mercurial/wireprotov1peer.py b/mercurial/wireprotov1peer.py
--- a/mercurial/wireprotov1peer.py
+++ b/mercurial/wireprotov1peer.py
@@ -445,7 +445,7 @@
 else:
 return changegroupmod.cg1unpacker(f, 'UN')
 
-def unbundle(self, bundle, heads, url):
+def unbundle(self, bundle, heads, url, force=None):
 '''Send cg (a readable file-like object representing the
 changegroup to push, typically a chunkbuffer object) to the
 remote server as a bundle.
diff --git a/mercurial/repository.py b/mercurial/repository.py
--- a/mercurial/repository.py
+++ b/mercurial/repository.py
@@ -191,7 +191,7 @@
 Successful result should be a generator of data chunks.
 """
 
-def unbundle(bundle, heads, url):
+def unbundle(bundle, heads, url, force=None):
 """Transfer repository data to the peer.
 
 This is how the bulk of data during a push is transferred.
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -306,14 +306,14 @@
 raise error.Abort(_('cannot perform stream clone against local '
 'peer'))
 
-def unbundle(self, bundle, heads, url):
+def unbundle(self, bundle, heads, url, force=None):
 """apply a bundle on a repo
 
 This function handles the repo locking itself."""
 try:
 try:
 bundle = exchange.readbundle(self.

D6776: bookmarks: validate changes on push (issue6193) (BC)

2019-09-13 Thread idlsoft (Sandu Turcan)
idlsoft added a comment.


  > Isn't that a client-side change only though, so we still need functionality 
on the server to reject bad pushes? (I could be missing something.)
  
  I'm actually not sure how to make this work for http, it doesn't seem to 
propagate `--force` to `unbundle`.
  Which is why the line in **test-bookmarks-pushpull.t** is `--config 
devel.legacy.exchange=bookmarks` instead of `--force`

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6776/new/

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

To: idlsoft, #hg-reviewers, durin42
Cc: pulkit, durin42, valentin.gatienbaron, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6776: bookmarks: validate changes on push (issue6193) (BC)

2019-09-13 Thread idlsoft (Sandu Turcan)
idlsoft updated this revision to Diff 16531.

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6776?vs=16524&id=16531

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6776/new/

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

AFFECTED FILES
  mercurial/bundle2.py
  mercurial/exchange.py
  mercurial/localrepo.py
  mercurial/repository.py
  mercurial/wireprotov1peer.py
  mercurial/wireprotov1server.py
  tests/test-bookmarks-conflict.t
  tests/test-bookmarks-pushpull.t
  tests/test-hook.t

CHANGE DETAILS

diff --git a/tests/test-hook.t b/tests/test-hook.t
--- a/tests/test-hook.t
+++ b/tests/test-hook.t
@@ -545,6 +545,7 @@
   HG_URL=file:$TESTTMP/a
   
   pushkey hook: HG_BUNDLE2=1
+  HG_FORCE=0
   HG_HOOKNAME=pushkey
   HG_HOOKTYPE=pushkey
   HG_KEY=foo
@@ -632,6 +633,7 @@
   HG_TXNNAME=push
   
   prepushkey.forbid hook: HG_BUNDLE2=1
+  HG_FORCE=0
   HG_HOOKNAME=prepushkey
   HG_HOOKTYPE=prepushkey
   HG_KEY=baz
diff --git a/tests/test-bookmarks-pushpull.t b/tests/test-bookmarks-pushpull.t
--- a/tests/test-bookmarks-pushpull.t
+++ b/tests/test-bookmarks-pushpull.t
@@ -813,7 +813,7 @@
  Z 0d2164f0ce0d
  foo   
  foobar
-  $ hg push -B Z http://localhost:$HGPORT/
+  $ hg push -B Z http://localhost:$HGPORT/ --force
   pushing to http://localhost:$HGPORT/
   searching for changes
   no changes found
diff --git a/tests/test-bookmarks-conflict.t b/tests/test-bookmarks-conflict.t
new file mode 100644
--- /dev/null
+++ b/tests/test-bookmarks-conflict.t
@@ -0,0 +1,91 @@
+initialize
+  $ make_changes() {
+  > d=`pwd`
+  > [ ! -z $1 ] && cd $1
+  > echo "test `basename \`pwd\``" >> test
+  > hg commit -Am"${2:-test}"
+  > r=$?
+  > cd $d
+  > return $r
+  > }
+  $ ls -1a
+  .
+  ..
+  $ hg init a
+  $ cd a
+  $ echo 'test' > test; hg commit -Am'test'
+  adding test
+  $ hg book @
+
+clone to b
+
+  $ mkdir ../b
+  $ cd ../b
+  $ hg clone ../a .
+  updating to bookmark @
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ make_changes
+  $ hg book bk_b
+
+clone to c
+  $ mkdir ../c
+  $ cd ../c
+  $ hg clone ../a .
+  updating to bookmark @
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ make_changes
+  $ hg book bk_c
+
+push from b
+  $ cd ../b
+  $ hg push -B .
+  pushing to $TESTTMP/a
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+  updating bookmark @
+  exporting bookmark bk_b
+  $ hg -R ../a id -r @
+  e11a942451be tip @/bk_b
+
+push from c
+  $ cd ../c
+  $ hg push -B .
+  pushing to $TESTTMP/a
+  searching for changes
+  remote has heads on branch 'default' that are not known locally: e11a942451be
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files (+1 heads)
+  exporting bookmark bk_c
+  $ hg push -B @
+  pushing to $TESTTMP/a
+  searching for changes
+  no changes found
+  abort: push rejected: bookmark "@" has changed
+  (run 'hg pull', resolve conflicts, and push again)
+  [255]
+  $ hg -R ../a log -G -T '{rev} {bookmarks}'
+  o  2 bk_c
+  |
+  | o  1 @ bk_b
+  |/
+  @  0
+  
+
+  $ hg push -B @ --force
+  pushing to $TESTTMP/a
+  searching for changes
+  no changes found
+  updating bookmark @
+  [1]
+  $ hg -R ../a log -G -T '{rev} {bookmarks}'
+  o  2 @ bk_c
+  |
+  | o  1 bk_b
+  |/
+  @  0
+  
diff --git a/mercurial/wireprotov1server.py b/mercurial/wireprotov1server.py
--- a/mercurial/wireprotov1server.py
+++ b/mercurial/wireprotov1server.py
@@ -548,8 +548,8 @@
 return wireprototypes.streamreslegacy(
 streamclone.generatev1wireproto(repo))
 
-@wireprotocommand('unbundle', 'heads', permission='push')
-def unbundle(repo, proto, heads):
+@wireprotocommand('unbundle', 'heads *', permission='push')
+def unbundle(repo, proto, heads, others):
 their_heads = wireprototypes.decodelist(heads)
 
 with proto.mayberedirectstdio() as output:
@@ -594,7 +594,7 @@
   hint=bundle2requiredhint)
 
 r = exchange.unbundle(repo, gen, their_heads, 'serve',
-  proto.client())
+  proto.client(), others.get('force') == 
'1')
 if util.safehasattr(r, 'addpart'):
 # The return looks streamable, we are in the bundle2 case
 # and should return a stream.
diff --git a/mercurial/wireprotov1peer.py b/mercurial/wireprotov1peer.py
--- a/mercurial/wireprotov1peer.py
+++ b/mercurial/wireprotov1peer.py
@@ -445,7 +445,7 @@
 else:
 return changegroupmod.cg1unpacker(f, 'UN')
 
-def unbundle(self, bundle, heads, url):
+def unbundle(self, bundle, heads, url, force=None):
 '''Send cg (a readable file-like object representing the
 changegroup to push, ty

D6776: bookmarks: validate changes on push (issue6193) (BC)

2019-09-13 Thread idlsoft (Sandu Turcan)
idlsoft updated this revision to Diff 16533.

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6776?vs=16531&id=16533

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6776/new/

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

AFFECTED FILES
  mercurial/bundle2.py
  mercurial/exchange.py
  mercurial/localrepo.py
  mercurial/repository.py
  mercurial/wireprotov1peer.py
  mercurial/wireprotov1server.py
  tests/test-bookmarks-conflict.t
  tests/test-bookmarks-pushpull.t
  tests/test-hook.t

CHANGE DETAILS

diff --git a/tests/test-hook.t b/tests/test-hook.t
--- a/tests/test-hook.t
+++ b/tests/test-hook.t
@@ -545,6 +545,7 @@
   HG_URL=file:$TESTTMP/a

   pushkey hook: HG_BUNDLE2=1
+  HG_FORCE=0
   HG_HOOKNAME=pushkey
   HG_HOOKTYPE=pushkey
   HG_KEY=foo
@@ -632,6 +633,7 @@
   HG_TXNNAME=push

   prepushkey.forbid hook: HG_BUNDLE2=1
+  HG_FORCE=0
   HG_HOOKNAME=prepushkey
   HG_HOOKTYPE=prepushkey
   HG_KEY=baz
diff --git a/tests/test-bookmarks-pushpull.t b/tests/test-bookmarks-pushpull.t
--- a/tests/test-bookmarks-pushpull.t
+++ b/tests/test-bookmarks-pushpull.t
@@ -813,7 +813,7 @@
  Z 0d2164f0ce0d
  foo
  foobar
-  $ hg push -B Z http://localhost:$HGPORT/
+  $ hg push -B Z http://localhost:$HGPORT/ --force
   pushing to http://localhost:$HGPORT/
   searching for changes
   no changes found
diff --git a/tests/test-bookmarks-conflict.t b/tests/test-bookmarks-conflict.t
--- /dev/null
+++ b/tests/test-bookmarks-conflict.t
@@ -0,0 +1,91 @@
+initialize
+  $ make_changes() {
+  > d=`pwd`
+  > [ ! -z $1 ] && cd $1
+  > echo "test `basename \`pwd\``" >> test
+  > hg commit -Am"${2:-test}"
+  > r=$?
+  > cd $d
+  > return $r
+  > }
+  $ ls -1a
+  .
+  ..
+  $ hg init a
+  $ cd a
+  $ echo 'test' > test; hg commit -Am'test'
+  adding test
+  $ hg book @
+
+clone to b
+
+  $ mkdir ../b
+  $ cd ../b
+  $ hg clone ../a .
+  updating to bookmark @
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ make_changes
+  $ hg book bk_b
+
+clone to c
+  $ mkdir ../c
+  $ cd ../c
+  $ hg clone ../a .
+  updating to bookmark @
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ make_changes
+  $ hg book bk_c
+
+push from b
+  $ cd ../b
+  $ hg push -B .
+  pushing to $TESTTMP/a
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+  updating bookmark @
+  exporting bookmark bk_b
+  $ hg -R ../a id -r @
+  e11a942451be tip @/bk_b
+
+push from c
+  $ cd ../c
+  $ hg push -B .
+  pushing to $TESTTMP/a
+  searching for changes
+  remote has heads on branch 'default' that are not known locally: e11a942451be
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files (+1 heads)
+  exporting bookmark bk_c
+  $ hg push -B @
+  pushing to $TESTTMP/a
+  searching for changes
+  no changes found
+  abort: push rejected: bookmark "@" has changed
+  (run 'hg pull', resolve conflicts, and push again)
+  [255]
+  $ hg -R ../a log -G -T '{rev} {bookmarks}'
+  o  2 bk_c
+  |
+  | o  1 @ bk_b
+  |/
+  @  0
+
+
+  $ hg push -B @ --force
+  pushing to $TESTTMP/a
+  searching for changes
+  no changes found
+  updating bookmark @
+  [1]
+  $ hg -R ../a log -G -T '{rev} {bookmarks}'
+  o  2 @ bk_c
+  |
+  | o  1 bk_b
+  |/
+  @  0
+
diff --git a/mercurial/wireprotov1server.py b/mercurial/wireprotov1server.py
--- a/mercurial/wireprotov1server.py
+++ b/mercurial/wireprotov1server.py
@@ -548,8 +548,8 @@
 return wireprototypes.streamreslegacy(
 streamclone.generatev1wireproto(repo))

-@wireprotocommand('unbundle', 'heads', permission='push')
-def unbundle(repo, proto, heads):
+@wireprotocommand('unbundle', 'heads *', permission='push')
+def unbundle(repo, proto, heads, others):
 their_heads = wireprototypes.decodelist(heads)

 with proto.mayberedirectstdio() as output:
@@ -594,7 +594,7 @@
   hint=bundle2requiredhint)

 r = exchange.unbundle(repo, gen, their_heads, 'serve',
-  proto.client())
+  proto.client(), others.get('force') == 
'1')
 if util.safehasattr(r, 'addpart'):
 # The return looks streamable, we are in the bundle2 case
 # and should return a stream.
diff --git a/mercurial/wireprotov1peer.py b/mercurial/wireprotov1peer.py
--- a/mercurial/wireprotov1peer.py
+++ b/mercurial/wireprotov1peer.py
@@ -445,7 +445,7 @@
 else:
 return changegroupmod.cg1unpacker(f, 'UN')

-def unbundle(self, bundle, heads, url):
+def unbundle(self, bundle, heads, url, force=None):
 '''Send cg (a readable file-like object representing the
 changegroup to push, typically a chunkbuffer object) to the
 remote server as a bundle.
@@ -464,10 +464,12 @@
   

D6776: bookmarks: validate changes on push (issue6193) (BC)

2019-09-13 Thread idlsoft (Sandu Turcan)
idlsoft updated this revision to Diff 16534.

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6776?vs=16533&id=16534

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6776/new/

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

AFFECTED FILES
  mercurial/bundle2.py
  mercurial/exchange.py
  mercurial/localrepo.py
  mercurial/repository.py
  mercurial/wireprotov1peer.py
  mercurial/wireprotov1server.py
  tests/test-bookmarks-conflict.t
  tests/test-bookmarks-pushpull.t
  tests/test-hook.t

CHANGE DETAILS

diff --git a/tests/test-hook.t b/tests/test-hook.t
--- a/tests/test-hook.t
+++ b/tests/test-hook.t
@@ -545,6 +545,7 @@
   HG_URL=file:$TESTTMP/a
   
   pushkey hook: HG_BUNDLE2=1
+  HG_FORCE=0
   HG_HOOKNAME=pushkey
   HG_HOOKTYPE=pushkey
   HG_KEY=foo
@@ -632,6 +633,7 @@
   HG_TXNNAME=push
   
   prepushkey.forbid hook: HG_BUNDLE2=1
+  HG_FORCE=0
   HG_HOOKNAME=prepushkey
   HG_HOOKTYPE=prepushkey
   HG_KEY=baz
diff --git a/tests/test-bookmarks-pushpull.t b/tests/test-bookmarks-pushpull.t
--- a/tests/test-bookmarks-pushpull.t
+++ b/tests/test-bookmarks-pushpull.t
@@ -813,7 +813,7 @@
  Z 0d2164f0ce0d
  foo   
  foobar
-  $ hg push -B Z http://localhost:$HGPORT/
+  $ hg push -B Z http://localhost:$HGPORT/ --force
   pushing to http://localhost:$HGPORT/
   searching for changes
   no changes found
diff --git a/tests/test-bookmarks-conflict.t b/tests/test-bookmarks-conflict.t
new file mode 100644
--- /dev/null
+++ b/tests/test-bookmarks-conflict.t
@@ -0,0 +1,142 @@
+initialize
+  $ make_changes() {
+  > d=`pwd`
+  > [ ! -z $1 ] && cd $1
+  > echo "test `basename \`pwd\``" >> test
+  > hg commit -Am"${2:-test}"
+  > r=$?
+  > cd $d
+  > return $r
+  > }
+  $ ls -1a
+  .
+  ..
+  $ hg init a
+  $ cd a
+  $ echo 'test' > test; hg commit -Am'test'
+  adding test
+  $ hg book @
+
+clone to b
+
+  $ mkdir ../b
+  $ cd ../b
+  $ hg clone ../a .
+  updating to bookmark @
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ make_changes
+  $ hg book bk_b
+
+clone to c
+  $ mkdir ../c
+  $ cd ../c
+  $ hg clone ../a .
+  updating to bookmark @
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ make_changes
+  $ hg book bk_c
+
+push from b
+  $ cd ../b
+  $ hg push -B .
+  pushing to $TESTTMP/a
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+  updating bookmark @
+  exporting bookmark bk_b
+  $ hg -R ../a id -r @
+  e11a942451be tip @/bk_b
+
+push from c
+  $ cd ../c
+  $ hg push -B .
+  pushing to $TESTTMP/a
+  searching for changes
+  remote has heads on branch 'default' that are not known locally: e11a942451be
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files (+1 heads)
+  exporting bookmark bk_c
+  $ hg push -B @
+  pushing to $TESTTMP/a
+  searching for changes
+  no changes found
+  abort: push rejected: bookmark "@" has changed
+  (run 'hg pull', resolve conflicts, and push again)
+  [255]
+  $ hg -R ../a log -G -T '{rev} {bookmarks}'
+  o  2 bk_c
+  |
+  | o  1 @ bk_b
+  |/
+  @  0
+  
+
+  $ hg push -B @ --force
+  pushing to $TESTTMP/a
+  searching for changes
+  no changes found
+  updating bookmark @
+  [1]
+  $ hg -R ../a log -G -T '{rev} {bookmarks}'
+  o  2 @ bk_c
+  |
+  | o  1 bk_b
+  |/
+  @  0
+  
+
+## push using ssh  
+  $ hg -R ../b push -B @ --force
+  pushing to $TESTTMP/a
+  searching for changes
+  no changes found
+  updating bookmark @
+  [1]
+  $ hg push -B @ ssh://user@dummy/a -e"$PYTHON $TESTDIR/dummyssh"
+  pushing to ssh://user@dummy/a
+  searching for changes
+  no changes found
+  remote: push rejected: bookmark "@" has changed
+  remote: (run 'hg pull', resolve conflicts, and push again)
+  abort: push failed on remote
+  [255]
+  $ hg push --force -B @ ssh://user@dummy/a -e"$PYTHON $TESTDIR/dummyssh"
+  pushing to ssh://user@dummy/a
+  searching for changes
+  no changes found
+  updating bookmark @
+  [1]
+
+# push using http
+  $ cat < ../a/.hg/hgrc
+  > [web]
+  > push_ssl = false
+  > allow_push = *
+  > EOF
+  $ hg serve -R ../a -p $HGPORT -d --pid-file=../hg.pid
+  $ cat ../hg.pid >> $DAEMON_PIDS
+  $ hg -R ../b push -B @ --force
+  pushing to $TESTTMP/a
+  searching for changes
+  no changes found
+  updating bookmark @
+  [1]
+  $ hg push -B @ http://localhost:$HGPORT
+  pushing to http://localhost:$HGPORT/
+  searching for changes
+  no changes found
+  remote: push rejected: bookmark "@" has changed
+  remote: (run 'hg pull', resolve conflicts, and push again)
+  abort: push failed on remote
+  [255]
+  $ hg push --force -B @ http://localhost:$HGPORT
+  pushing to http://localhost:$HGPORT/
+  searching for changes
+  no changes found
+  updating bookmark @
+  [1]
diff --git a/mercurial/wireprotov1server.py b/mercurial/wir

D6776: bookmarks: validate changes on push (issue6193) (BC)

2019-09-13 Thread idlsoft (Sandu Turcan)
idlsoft added a comment.


  > If you mean "reject bad pushes as long as people don't push -f", both 
versions implement this (the client-side check is not racy thanks to these 
check:bookmark bundle parts).
  
  That was the idea. This implementation is a bit more flexible I think.
  Since it’s server side, you don’t have to upgrade your clients.
  It’s true old clients won’t be able to use —force, but new ones can.
  And you can add a trigger if you want to limit who can use —force.

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6776/new/

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

To: idlsoft, #hg-reviewers, durin42
Cc: pulkit, durin42, valentin.gatienbaron, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6851: narrow: don't hexify paths and double-hexify known nodes on wire (BC)

2019-09-16 Thread idlsoft (Sandu Turcan)
idlsoft added a comment.


  > @idlsoft and their company does use narrow extension. @idlsoft can you 
upgrade server and client at the same time?
  
  I did that a little while ago to move to 5.0. It was not fun. It's server, 
teamcity, clients, docker images.
  What operations does this affect? Regular `push/pull/clone` or only `tracked 
--add-include`?

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6851/new/

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

To: martinvonz, durin42, #hg-reviewers
Cc: pulkit, idlsoft, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6851: narrow: don't hexify paths and double-hexify known nodes on wire (BC)

2019-09-16 Thread idlsoft (Sandu Turcan)
idlsoft added a comment.


  >> Just `tracked --add-include`. A workaround to simplify the upgrade would 
be to change `wireprototypes.SUPPORTED_ELLIPSESCAP` to be `(ELLIPSESCAP1, )` on 
the server from now until all clients have upgraded. But that may still be 
annoying and error-prone for you to deal with. @pulkit, I suppose we should 
just add a `exp-narrow-2` capability to deal with this? It doesn't seem fair to 
make @idlsoft deal with it.
  >
  > Sounds like a good idea!
  
  If it's just `tracked --add-include` then it's not a big deal, it won't 
disrupt regular flow.
  If backward compatibility doesn't complicate the code - great, if not - don't 
worry about it.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6851/new/

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

To: martinvonz, durin42, #hg-reviewers
Cc: pulkit, idlsoft, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D4312: New bookflow extension for bookmark-based branching

2018-09-01 Thread idlsoft (Sandu Turcan)
idlsoft added a comment.


  I added some inline comments.
  A test for `hg book EXISTING` is indeed missing, there is, however, one for 
not moving the bookmark on update, it's line 52:  ` (leaving bookmark X)`.
  Hopefully, I'll be able to make some changes later in the week.
  Was not aware about the wiki page, this indeed seems to be addressing the 
same problem. At least that's how it started., and later evolved into something 
that helps you follow the workflow.

INLINE COMMENTS

> pulkit wrote in bookflow.py:14
> Can we switch the way help is described here. From 'cmdname: help' to
> 
> `To create a new bookmark: hg book mark`.

I uppercased it to distinguish the parameter from the command. 
I thought hg uses this convention:

  hg bookmarks [OPTIONS]... [NAME]...

> pulkit wrote in bookflow.py:72
> We can better say that "the active bookmark is updated to . use hg 
> update to update to it."

For me personally "out of sync" is more obvious, it underlines the fact that 
you won't be able to do commits.

> pulkit wrote in bookflow.py:82
> This can be improved to "creating named branches is disabled and you should 
> use bookmarks. see `hg help bookmarks`."
> 
> Also maybe since we are defining a workflow using this extension, documenting 
> that workflow will be great!

Did you mean `hg help bookflow`?

> pulkit wrote in bookflow.py:89
> If I understand correctly, the above couple of lines can be deleted?

They can, but I left them to make sure people aren't tempted to add a hook.

> pulkit wrote in test-bookflow.t:2
> I am not good at bash I am certain you make it simpler by removing the logic 
> related to pwd, I am not sure why do we need that.

oh, that was done to see where the change was made, you'd have lines like:

  test a
  test a
  test b
  ...

> pulkit wrote in test-bookflow.t:3
> sorry, but is it like `hg status`?

You're probably right :)

> pulkit wrote in test-bookflow.t:29
> output of push to /dev/null, that seems a bit weird, let's not do that.

Yes, I do this in a few other places, when I don't care about the output, only 
the exit code.
It helps shorten the testcase to just the relevant pieces.

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

To: idlsoft, #hg-reviewers
Cc: pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D4312: New bookflow extension for bookmark-based branching

2018-09-04 Thread idlsoft (Sandu Turcan)
idlsoft added inline comments.

INLINE COMMENTS

> pulkit wrote in bookflow.py:14
> Can we switch the way help is described here. From 'cmdname: help' to
> 
> `To create a new bookmark: hg book mark`.

Also, this way it looks more like a cheatsheet

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

To: idlsoft, #hg-reviewers
Cc: jwatt, pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D4312: New bookflow extension for bookmark-based branching

2018-09-04 Thread idlsoft (Sandu Turcan)
idlsoft updated this revision to Diff 10754.

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4312?vs=10508&id=10754

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

AFFECTED FILES
  hgext/bookflow.py
  tests/test-bookflow.t

CHANGE DETAILS

diff --git a/tests/test-bookflow.t b/tests/test-bookflow.t
new file mode 100644
--- /dev/null
+++ b/tests/test-bookflow.t
@@ -0,0 +1,283 @@
+initialize
+  $ make_changes() { d=`pwd`; [ ! -z $1 ] && cd $1; echo "test $(basename 
`pwd`)" >> test; hg commit -Am"${2:-test}"; r=$?; cd $d; return $r; }
+  $ ls -1a
+  .
+  ..
+  $ hg init a
+  $ cd a
+  $ echo 'test' > test; hg commit -Am'test'
+  adding test
+
+clone to b
+
+  $ mkdir ../b
+  $ cd ../b
+  $ hg clone ../a .
+  updating to branch default
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo "[extensions]" >> .hg/hgrc
+  $ echo "bookflow=" >> .hg/hgrc
+  $ hg branch X
+  abort: creating named branches is disabled and you should use bookmarks
+  (see 'hg help bookflow')
+  [255]
+  $ hg bookmark X
+  $ hg bookmarks
+  * X 0:* (glob)
+  $ hg bookmark X
+  abort: bookmark X already exists, to move use the --rev option
+  [255]
+  $ make_changes
+  $ hg push ../a > /dev/null
+
+  $ hg bookmarks
+   \* X 1:* (glob)
+
+change a
+  $ cd ../a
+  $ hg up
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo 'test' >> test; hg commit -Am'test'
+
+
+pull in b
+  $ cd ../b
+  $ hg pull -u
+  pulling from $TESTTMP/a
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+  new changesets * (glob)
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (leaving bookmark X)
+  $ hg status
+  $ hg bookmarks
+ X 1:* (glob)
+
+check protection of @ bookmark
+  $ hg bookmark @
+  $ hg bookmarks
+   \* @ 2:* (glob)
+ X 1:* (glob)
+  $ make_changes
+  abort: cannot commit, bookmark @ is protected
+  [255]
+
+  $ hg status
+  M test
+  $ hg bookmarks
+   \* @ 2:* (glob)
+ X 1:* (glob)
+
+  $ hg --config bookflow.protect= commit  -Am"Updated test"
+
+  $ hg bookmarks
+   \* @ 3:* (glob)
+ X 1:* (glob)
+
+check requirement for an active bookmark
+  $ hg bookmark -i
+  $ hg bookmarks
+ @ 3:* (glob)
+ X 1:* (glob)
+  $ make_changes
+  abort: cannot commit without an active bookmark
+  [255]
+  $ hg revert test
+  $ rm test.orig
+  $ hg status
+
+
+make the bookmark move by updating it on a, and then pulling
+# add a commit to a
+  $ cd ../a
+  $ hg bookmark X
+  $ hg bookmarks
+   \* X 2:* (glob)
+  $ make_changes
+  $ hg bookmarks
+   * X 3:81af7977fdb9
+
+# go back to b, and check out X
+  $ cd ../b
+  $ hg up X
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (activating bookmark X)
+  $ hg bookmarks
+ @ 3:* (glob)
+   \* X 1:* (glob)
+
+# pull, this should move the bookmark forward, because it was changed remotely
+  $ hg pull -u | grep "updating to active bookmark X"
+  updating to active bookmark X
+
+  $ hg bookmarks
+ @ 3:* (glob)
+   * X 4:81af7977fdb9
+
+the bookmark should not move if it diverged from remote
+  $ hg -R ../a status
+  $ hg -R ../b status
+  $ make_changes ../a
+  $ make_changes ../b
+  $ hg -R ../a status
+  $ hg -R ../b status
+  $ hg -R ../a bookmarks
+   * X 4:238292f60a57
+  $ hg -R ../b bookmarks
+ @ 3:* (glob)
+   * X 5:096f7e86892d
+  $ cd ../b
+  $ # make sure we cannot push after bookmarks diverged
+  $ hg push -B X | grep abort
+  abort: push creates new remote head * with bookmark 'X'! (glob)
+  (pull and merge or see 'hg help push' for details about pushing new heads)
+  [1]
+  $ hg pull -u | grep divergent
+  divergent bookmark X stored as X@default
+  1 other divergent bookmarks for "X"
+  $ hg bookmarks
+ @ 3:* (glob)
+   * X 5:096f7e86892d
+ X@default 6:238292f60a57
+  $ hg id -in
+  096f7e86892d 5
+  $ make_changes
+  $ hg status
+  $ hg bookmarks
+ @ 3:* (glob)
+   * X 7:227f941aeb07
+ X@default 6:238292f60a57
+
+now merge with the remote bookmark
+  $ hg merge X@default --tool :local > /dev/null
+  $ hg status
+  M test
+  $ hg commit -m"Merged with X@default"
+  $ hg bookmarks
+ @ 3:* (glob)
+   * X 8:26fed9bb3219
+  $ hg push -B X | grep bookmark
+  pushing to $TESTTMP/a (?)
+  updating bookm

D4312: New bookflow extension for bookmark-based branching

2018-09-05 Thread idlsoft (Sandu Turcan)
idlsoft updated this revision to Diff 10789.

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4312?vs=10754&id=10789

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

AFFECTED FILES
  hgext/bookflow.py
  tests/test-bookflow.t

CHANGE DETAILS

diff --git a/tests/test-bookflow.t b/tests/test-bookflow.t
new file mode 100644
--- /dev/null
+++ b/tests/test-bookflow.t
@@ -0,0 +1,284 @@
+initialize
+  $ make_changes() { d=`pwd`; [ ! -z $1 ] && cd $1; echo "test $(basename 
`pwd`)" >> test; hg commit -Am"${2:-test}"; r=$?; cd $d; return $r; }
+  $ ls -1a
+  .
+  ..
+  $ hg init a
+  $ cd a
+  $ echo 'test' > test; hg commit -Am'test'
+  adding test
+
+clone to b
+
+  $ mkdir ../b
+  $ cd ../b
+  $ hg clone ../a .
+  updating to branch default
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo "[extensions]" >> .hg/hgrc
+  $ echo "bookflow=" >> .hg/hgrc
+  $ hg branch X
+  abort: creating named branches is disabled and you should use bookmarks
+  (see 'hg help bookflow')
+  [255]
+  $ hg bookmark X
+  $ hg bookmarks
+  * X 0:* (glob)
+  $ hg bookmark X
+  abort: bookmark X already exists, to move use the --rev option
+  [255]
+  $ make_changes
+  $ hg push ../a -q
+
+  $ hg bookmarks
+   \* X 1:* (glob)
+
+change a
+  $ cd ../a
+  $ hg up
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo 'test' >> test; hg commit -Am'test'
+
+
+pull in b
+  $ cd ../b
+  $ hg pull -u
+  pulling from $TESTTMP/a
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+  new changesets * (glob)
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (leaving bookmark X)
+  $ hg status
+  $ hg bookmarks
+ X 1:* (glob)
+
+check protection of @ bookmark
+  $ hg bookmark @
+  $ hg bookmarks
+   \* @ 2:* (glob)
+ X 1:* (glob)
+  $ make_changes
+  abort: cannot commit, bookmark @ is protected
+  [255]
+
+  $ hg status
+  M test
+  $ hg bookmarks
+   \* @ 2:* (glob)
+ X 1:* (glob)
+
+  $ hg --config bookflow.protect= commit  -Am"Updated test"
+
+  $ hg bookmarks
+   \* @ 3:* (glob)
+ X 1:* (glob)
+
+check requirement for an active bookmark
+  $ hg bookmark -i
+  $ hg bookmarks
+ @ 3:* (glob)
+ X 1:* (glob)
+  $ make_changes
+  abort: cannot commit without an active bookmark
+  [255]
+  $ hg revert test
+  $ rm test.orig
+  $ hg status
+
+
+make the bookmark move by updating it on a, and then pulling
+# add a commit to a
+  $ cd ../a
+  $ hg bookmark X
+  $ hg bookmarks
+   \* X 2:* (glob)
+  $ make_changes
+  $ hg bookmarks
+   * X 3:81af7977fdb9
+
+# go back to b, and check out X
+  $ cd ../b
+  $ hg up X
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (activating bookmark X)
+  $ hg bookmarks
+ @ 3:* (glob)
+   \* X 1:* (glob)
+
+# pull, this should move the bookmark forward, because it was changed remotely
+  $ hg pull -u | grep "updating to active bookmark X"
+  updating to active bookmark X
+
+  $ hg bookmarks
+ @ 3:* (glob)
+   * X 4:81af7977fdb9
+
+the bookmark should not move if it diverged from remote
+  $ hg -R ../a status
+  $ hg -R ../b status
+  $ make_changes ../a
+  $ make_changes ../b
+  $ hg -R ../a status
+  $ hg -R ../b status
+  $ hg -R ../a bookmarks
+   * X 4:238292f60a57
+  $ hg -R ../b bookmarks
+ @ 3:* (glob)
+   * X 5:096f7e86892d
+  $ cd ../b
+  $ # make sure we cannot push after bookmarks diverged
+  $ hg push -B X | grep abort
+  abort: push creates new remote head * with bookmark 'X'! (glob)
+  (pull and merge or see 'hg help push' for details about pushing new heads)
+  [1]
+  $ hg pull -u | grep divergent
+  divergent bookmark X stored as X@default
+  1 other divergent bookmarks for "X"
+  $ hg bookmarks
+ @ 3:* (glob)
+   * X 5:096f7e86892d
+ X@default 6:238292f60a57
+  $ hg id -in
+  096f7e86892d 5
+  $ make_changes
+  $ hg status
+  $ hg bookmarks
+ @ 3:* (glob)
+   * X 7:227f941aeb07
+ X@default 6:238292f60a57
+
+now merge with the remote bookmark
+  $ hg merge X@default --tool :local -q
+  $ hg status
+  M test
+  $ hg commit -m"Merged with X@default"
+  $ hg bookmarks
+ @ 3:* (glob)
+   * X 8:26fed9bb3219
+  $ hg push -B X | grep bookmark
+  pushing to $TESTTMP/a (?)
+  updating bookmark X
+  $ cd ../a

D4312: New bookflow extension for bookmark-based branching

2018-10-15 Thread idlsoft (Sandu Turcan)
idlsoft added a comment.


  At some point RhodeCode was checking if the destination bookmark was a 
descendant of the source, and not allowing such pull requests to be created.
  That would have to be handled as a fast-forward, in other words just moving 
the destination bookmark.

REPOSITORY
  rHG Mercurial

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

To: idlsoft, #hg-reviewers, pulkit, marcink
Cc: marcink, durin42, jwatt, pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D4312: New bookflow extension for bookmark-based branching

2018-10-15 Thread idlsoft (Sandu Turcan)
idlsoft added a comment.


  If this is accepted we might want to look into changing the behavior of `hg 
pull -u`.
  It should update the working directory only if the active bookmark was moved 
remotely.
  I didn't find an easy way to do this without changes to core.

REPOSITORY
  rHG Mercurial

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

To: idlsoft, #hg-reviewers, pulkit, marcink
Cc: marcink, durin42, jwatt, pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D4312: New bookflow extension for bookmark-based branching

2018-10-15 Thread idlsoft (Sandu Turcan)
idlsoft updated this revision to Diff 12149.

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4312?vs=10789&id=12149

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

AFFECTED FILES
  hgext/bookflow.py
  tests/test-bookflow.t

CHANGE DETAILS

diff --git a/tests/test-bookflow.t b/tests/test-bookflow.t
new file mode 100644
--- /dev/null
+++ b/tests/test-bookflow.t
@@ -0,0 +1,284 @@
+initialize
+  $ make_changes() { d=`pwd`; [ ! -z $1 ] && cd $1; echo "test $(basename 
`pwd`)" >> test; hg commit -Am"${2:-test}"; r=$?; cd $d; return $r; }
+  $ ls -1a
+  .
+  ..
+  $ hg init a
+  $ cd a
+  $ echo 'test' > test; hg commit -Am'test'
+  adding test
+
+clone to b
+
+  $ mkdir ../b
+  $ cd ../b
+  $ hg clone ../a .
+  updating to branch default
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo "[extensions]" >> .hg/hgrc
+  $ echo "bookflow=" >> .hg/hgrc
+  $ hg branch X
+  abort: creating named branches is disabled and you should use bookmarks
+  (see 'hg help bookflow')
+  [255]
+  $ hg bookmark X
+  $ hg bookmarks
+  * X 0:* (glob)
+  $ hg bookmark X
+  abort: bookmark X already exists, to move use the --rev option
+  [255]
+  $ make_changes
+  $ hg push ../a -q
+
+  $ hg bookmarks
+   \* X 1:* (glob)
+
+change a
+  $ cd ../a
+  $ hg up
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo 'test' >> test; hg commit -Am'test'
+
+
+pull in b
+  $ cd ../b
+  $ hg pull -u
+  pulling from $TESTTMP/a
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+  new changesets * (glob)
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (leaving bookmark X)
+  $ hg status
+  $ hg bookmarks
+ X 1:* (glob)
+
+check protection of @ bookmark
+  $ hg bookmark @
+  $ hg bookmarks
+   \* @ 2:* (glob)
+ X 1:* (glob)
+  $ make_changes
+  abort: cannot commit, bookmark @ is protected
+  [255]
+
+  $ hg status
+  M test
+  $ hg bookmarks
+   \* @ 2:* (glob)
+ X 1:* (glob)
+
+  $ hg --config bookflow.protect= commit  -Am"Updated test"
+
+  $ hg bookmarks
+   \* @ 3:* (glob)
+ X 1:* (glob)
+
+check requirement for an active bookmark
+  $ hg bookmark -i
+  $ hg bookmarks
+ @ 3:* (glob)
+ X 1:* (glob)
+  $ make_changes
+  abort: cannot commit without an active bookmark
+  [255]
+  $ hg revert test
+  $ rm test.orig
+  $ hg status
+
+
+make the bookmark move by updating it on a, and then pulling
+# add a commit to a
+  $ cd ../a
+  $ hg bookmark X
+  $ hg bookmarks
+   \* X 2:* (glob)
+  $ make_changes
+  $ hg bookmarks
+   * X 3:81af7977fdb9
+
+# go back to b, and check out X
+  $ cd ../b
+  $ hg up X
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (activating bookmark X)
+  $ hg bookmarks
+ @ 3:* (glob)
+   \* X 1:* (glob)
+
+# pull, this should move the bookmark forward, because it was changed remotely
+  $ hg pull -u | grep "updating to active bookmark X"
+  updating to active bookmark X
+
+  $ hg bookmarks
+ @ 3:* (glob)
+   * X 4:81af7977fdb9
+
+the bookmark should not move if it diverged from remote
+  $ hg -R ../a status
+  $ hg -R ../b status
+  $ make_changes ../a
+  $ make_changes ../b
+  $ hg -R ../a status
+  $ hg -R ../b status
+  $ hg -R ../a bookmarks
+   * X 4:238292f60a57
+  $ hg -R ../b bookmarks
+ @ 3:* (glob)
+   * X 5:096f7e86892d
+  $ cd ../b
+  $ # make sure we cannot push after bookmarks diverged
+  $ hg push -B X | grep abort
+  abort: push creates new remote head * with bookmark 'X'! (glob)
+  (pull and merge or see 'hg help push' for details about pushing new heads)
+  [1]
+  $ hg pull -u | grep divergent
+  divergent bookmark X stored as X@default
+  1 other divergent bookmarks for "X"
+  $ hg bookmarks
+ @ 3:* (glob)
+   * X 5:096f7e86892d
+ X@default 6:238292f60a57
+  $ hg id -in
+  096f7e86892d 5
+  $ make_changes
+  $ hg status
+  $ hg bookmarks
+ @ 3:* (glob)
+   * X 7:227f941aeb07
+ X@default 6:238292f60a57
+
+now merge with the remote bookmark
+  $ hg merge X@default --tool :local -q
+  $ hg status
+  M test
+  $ hg commit -m"Merged with X@default"
+  $ hg bookmarks
+ @ 3:* (glob)
+   * X 8:26fed9bb3219
+  $ hg push -B X | grep bookmark
+  pushing to $TESTTMP/a (?)
+  updating bookmark X
+  $ cd ../a

D4312: New bookflow extension for bookmark-based branching

2018-10-18 Thread idlsoft (Sandu Turcan)
idlsoft added a comment.


  First of all, thank you for reviewing the patch.
  
  We switched to mercurial a few months ago, mainly because of the narrow 
extension. Feature branches workflow was something everyone in the company 
understood and adhered to, so trying to adopt something else wouldn't be 
practical.
  Besides it was unclear what that something would be. Short lived branches 
were not recommended, evolve and topics aren't in core and take a while to wrap 
your mind around. Besides whatever we picked, it would need to be fully 
supported by Teamcity and IntelliJ. And Rhodecode.
  Writing a proprietary extension wasn't our first choice, not by a long shot. 
But at some point it was just the lesser evil.
  
  I see a lot of people focus on the DAG aspect of the repo, which for a core 
DVCS developer makes a lot of sense. You also mentioned anonymous heads, but 
this is not what we were trying to solve at all.
  In fact, as we realized at some point, tip and heads weren't very 
consequential for our workflow, but maintaining DAG references reliably was.
  A common problem we encountered was somebody starting their work, and before 
committing anything doing an `hg pull -u`. This would then move their bookmark 
to someone else's changes.
  To this day I can't quite see why it would make sense to move bookmarks on 
update. What was the original workflow that lead to that design?
  
  Basing a solution on bookmarks seemed like the least intrusive option. It 
would be client-side only, the only thing the server needs to do is protect 
certain bookmarks via the acl extension.
  Tools already support bookmarks, they just need to be more predictable.
  
  That's what the extension does. Really, if there was a config setting to not 
move bookmarks on update, I'm not sure we would have written anything at all 
(well, the fact that `hg bookmark NAME` can either create or move a bookmark is 
also not great).
  All the other functionality is trivial, to help guide the workflow and avoid 
confusion. We don't autocreate bookmarks, we just make sure you have one when 
you commit.
  
  While I understand the concern of endorsing too many branching models, I 
don't see this extension as introducing anything drastically new.
  It just addresses issues in the default bookmark behavior, which made them 
unsuitable for a pretty established workflow.
  Whether or not this is approved, I hope that can be revisited in core, 
perhaps made configurable.

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

To: idlsoft, #hg-reviewers, pulkit, marcink
Cc: smf, markand, marcink, durin42, jwatt, pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D4312: New bookflow extension for bookmark-based branching

2018-10-18 Thread idlsoft (Sandu Turcan)
idlsoft added a comment.


  In https://phab.mercurial-scm.org/D4312#77084, @pulkit wrote:
  
  > Unrelated, do you use narrow with ellipses or without ellipses? Also I am 
sorry to say but in this cycle, narrow extension has under gone a lot of perf 
and correctness improvements and it won't be backward compatible in upcoming 
release. I will be writing some text about this in the releasenotes too, and 
you can contact me personally and I will be glad to help you with the BC 
changes.
  
  
  Hmm, I thought we did, but no, just this:
  
[experimental]
changegroup3=true
  
  I'm actually kinda looking forward to see if `lfs` works better with all the 
new changes.
  
  ... Even more unrelated, IntelliJ 2018.3 will have a branch/bookmark compare 
dialog similar to the one for git.

REPOSITORY
  rHG Mercurial

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

To: idlsoft, #hg-reviewers, pulkit, marcink
Cc: smf, markand, marcink, durin42, jwatt, pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D4312: New bookflow extension for bookmark-based branching

2018-10-20 Thread idlsoft (Sandu Turcan)
idlsoft added a comment.


  > Were there particular pain points before?  The list of things to polish 
isn't short, but I don't mind reprioritizing things if it helps.
  
  I submitted a bug report https://bz.mercurial-scm.org/show_bug.cgi?id=5794
  It has a zip file with the repo, although to be honest I'm testing with 
another repo locally. As of 4.7.2 I'm still seeing that stack trace

REPOSITORY
  rHG Mercurial

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

To: idlsoft, #hg-reviewers, pulkit, marcink
Cc: mharbison72, smf, markand, marcink, durin42, jwatt, pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D4312: New bookflow extension for bookmark-based branching

2018-10-25 Thread idlsoft (Sandu Turcan)
idlsoft added a comment.


  @smf I just noticed your name on 
https://www.mercurial-scm.org/wiki/BookmarkUpdatePlan, which puts your comments 
into a larger context.
  This would definitely be an improvement, and reduce the scope of what this 
extension does.
  Would you consider also addressing the `hg bookmark NAME` doing two very 
different things depending on the bookmark already existing?

REPOSITORY
  rHG Mercurial

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

To: idlsoft, #hg-reviewers, pulkit, marcink
Cc: mharbison72, smf, markand, marcink, durin42, jwatt, pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D4312: New bookflow extension for bookmark-based branching

2018-12-03 Thread idlsoft (Sandu Turcan)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGe44e6b37b6af: bookflow: new extension for bookmark-based 
branching (authored by idlsoft, committed by ).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D4312?vs=12149&id=12678#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4312?vs=12149&id=12678

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

AFFECTED FILES
  hgext/bookflow.py
  tests/test-bookflow.t

CHANGE DETAILS

diff --git a/tests/test-bookflow.t b/tests/test-bookflow.t
new file mode 100644
--- /dev/null
+++ b/tests/test-bookflow.t
@@ -0,0 +1,292 @@
+initialize
+  $ make_changes() {
+  > d=`pwd`
+  > [ ! -z $1 ] && cd $1
+  > echo "test `basename \`pwd\``" >> test
+  > hg commit -Am"${2:-test}"
+  > r=$?
+  > cd $d
+  > return $r
+  > }
+  $ ls -1a
+  .
+  ..
+  $ hg init a
+  $ cd a
+  $ echo 'test' > test; hg commit -Am'test'
+  adding test
+
+clone to b
+
+  $ mkdir ../b
+  $ cd ../b
+  $ hg clone ../a .
+  updating to branch default
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo "[extensions]" >> .hg/hgrc
+  $ echo "bookflow=" >> .hg/hgrc
+  $ hg branch X
+  abort: creating named branches is disabled and you should use bookmarks
+  (see 'hg help bookflow')
+  [255]
+  $ hg bookmark X
+  $ hg bookmarks
+  * X 0:* (glob)
+  $ hg bookmark X
+  abort: bookmark X already exists, to move use the --rev option
+  [255]
+  $ make_changes
+  $ hg push ../a -q
+
+  $ hg bookmarks
+   \* X 1:* (glob)
+
+change a
+  $ cd ../a
+  $ hg up
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo 'test' >> test; hg commit -Am'test'
+
+
+pull in b
+  $ cd ../b
+  $ hg pull -u
+  pulling from $TESTTMP/a
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+  new changesets * (glob)
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (leaving bookmark X)
+  $ hg status
+  $ hg bookmarks
+ X 1:* (glob)
+
+check protection of @ bookmark
+  $ hg bookmark @
+  $ hg bookmarks
+   \* @ 2:* (glob)
+ X 1:* (glob)
+  $ make_changes
+  abort: cannot commit, bookmark @ is protected
+  [255]
+
+  $ hg status
+  M test
+  $ hg bookmarks
+   \* @ 2:* (glob)
+ X 1:* (glob)
+
+  $ hg --config bookflow.protect= commit  -Am"Updated test"
+
+  $ hg bookmarks
+   \* @ 3:* (glob)
+ X 1:* (glob)
+
+check requirement for an active bookmark
+  $ hg bookmark -i
+  $ hg bookmarks
+ @ 3:* (glob)
+ X 1:* (glob)
+  $ make_changes
+  abort: cannot commit without an active bookmark
+  [255]
+  $ hg revert test
+  $ rm test.orig
+  $ hg status
+
+
+make the bookmark move by updating it on a, and then pulling
+# add a commit to a
+  $ cd ../a
+  $ hg bookmark X
+  $ hg bookmarks
+   \* X 2:* (glob)
+  $ make_changes
+  $ hg bookmarks
+   * X 3:81af7977fdb9
+
+# go back to b, and check out X
+  $ cd ../b
+  $ hg up X
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (activating bookmark X)
+  $ hg bookmarks
+ @ 3:* (glob)
+   \* X 1:* (glob)
+
+# pull, this should move the bookmark forward, because it was changed remotely
+  $ hg pull -u | grep "updating to active bookmark X"
+  updating to active bookmark X
+
+  $ hg bookmarks
+ @ 3:* (glob)
+   * X 4:81af7977fdb9
+
+the bookmark should not move if it diverged from remote
+  $ hg -R ../a status
+  $ hg -R ../b status
+  $ make_changes ../a
+  $ make_changes ../b
+  $ hg -R ../a status
+  $ hg -R ../b status
+  $ hg -R ../a bookmarks
+   * X 4:238292f60a57
+  $ hg -R ../b bookmarks
+ @ 3:* (glob)
+   * X 5:096f7e86892d
+  $ cd ../b
+  $ # make sure we cannot push after bookmarks diverged
+  $ hg push -B X | grep abort
+  abort: push creates new remote head * with bookmark 'X'! (glob)
+  (pull and merge or see 'hg help push' for details about pushing new heads)
+  [1]
+  $ hg pull -u | grep divergent
+  divergent bookmark X stored as X@default
+  1 other divergent bookmarks for "X"
+  $ hg bookmarks
+ @ 3:* (glob)
+   * X 5:096f7e86892d
+ X@default 6:238292f60a57
+  $ hg id -in
+  096f7e86892d 5
+  $ make_changes
+  $ hg status
+  $ hg bookmarks
+ @ 3:* (glob)
+   * X 7:227f941aeb07
+ X@default 6:238292f60a57
+
+now merge with the

D4312: New bookflow extension for bookmark-based branching

2018-12-03 Thread idlsoft (Sandu Turcan)
idlsoft added a comment.


  >> Obviously, I can't say I'm too happy with this. Allowing users to shoot 
themselves in the foot even more is pretty bad.
  
  I don't think that's fair.
  Everyone's experience is different, but it did precisely the opposite for us.
  
  When we switched from git we couldn't find an official recommendation on how 
to do feature branches. Not in core 
.
  Using short-lived branches is discouraged 
, and bookmarks don't do a good job 
for all the reasons I mentioned before.
  
  For better or worse this is //**a**// solution, and after using it for a few 
months, I can at least say it works very well for us.
  It was easy for everyone on the team to understand, and all our JetBrains 
tools work seamlessly.
  Can it be done better? Sure, just like everything else. In fact, let's.
  
  But whatever the implementation, I believe a recipe for feature branches does 
belong in core, only then you can hope to get some support from hosting tools.
  
  On a completely unrelated note: having to explain the concept of multiple 
heads on a branch to a mortal sucks.

REPOSITORY
  rHG Mercurial

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

To: idlsoft, #hg-reviewers, pulkit, marcink
Cc: evzijst, krbullock, mharbison72, smf, markand, marcink, durin42, jwatt, 
pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D4312: New bookflow extension for bookmark-based branching

2018-12-06 Thread idlsoft (Sandu Turcan)
idlsoft added a comment.


  In https://phab.mercurial-scm.org/D4312#79938, @smf wrote:
  
  > This will not help the *average* user and sends a mixed (and dangerous) 
message that bookmarks should be used.
  
  
  Bookmarks have been in core for some time now, and there is not one mention 
anywhere that they are not to be used.
  They may not be trivial to use but it's certainly not officially discouraged 
anywhere.
  Bookmarks is the first thing that comes up when you search for "mercurial 
light branching", although it's from a blog post, not the official wiki.
  Meanwhile the official wiki plainly states 
 that light branching is 
a different abstraction, and branches should not be used for for that.
  
  So what IS the recommended way then?
  Is there one?
  
  I may have a horse in this race but I'd be more than happy to see it lose to 
a better one.

REPOSITORY
  rHG Mercurial

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

To: idlsoft, #hg-reviewers, pulkit, marcink
Cc: evzijst, krbullock, mharbison72, smf, markand, marcink, durin42, jwatt, 
pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6218: narrow: send specs as bundle2 data instead of param (issue5952) (issue6019)

2019-04-17 Thread idlsoft (Sandu Turcan)
idlsoft added a comment.


  Because the current client ignores the data completely, the only way to force 
it to fail I think is to change the name of the part.
  This would make things cleaner probably, but I'll deal with whatever solution 
you guys settle on.

REPOSITORY
  rHG Mercurial

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

To: pulkit, durin42, martinvonz, #hg-reviewers
Cc: indygreg, idlsoft, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6218: narrow: send specs as bundle2 data instead of param (issue5952) (issue6019)

2019-04-17 Thread idlsoft (Sandu Turcan)
idlsoft added a comment.


  If ACL is enabled, processing this part is mandatory, yes.
  On clone, or pull the user doesn't specify includes, so reading this part is 
the only way the client can get them.

REPOSITORY
  rHG Mercurial

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

To: pulkit, durin42, martinvonz, #hg-reviewers
Cc: indygreg, idlsoft, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6218: narrow: send specs as bundle2 data instead of param (issue5952) (issue6019)

2019-04-18 Thread idlsoft (Sandu Turcan)
idlsoft added a comment.


  This is nitpicking, but there is a duplicate `_NARROWACL_SECTION` definition 
in narrowbundle2.py,
  I think only the one in exchange.py should remain.
  Btw it's still 'narrowhgacl' from the old days.

REPOSITORY
  rHG Mercurial

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

To: pulkit, durin42, martinvonz, #hg-reviewers
Cc: indygreg, idlsoft, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6310: narrow: send specs as bundle2 data instead of param (issue5952) (issue6019)

2019-04-24 Thread idlsoft (Sandu Turcan)
idlsoft added inline comments.

INLINE COMMENTS

> narrowbundle2.py:167
> +excludepats = set(exc.splitlines())
> +narrowspec.validatepatterns(includepats)
> +narrowspec.validatepatterns(excludepats)

shouldn't this be inside the if?
`includepats` and `excludepats` are not defined otherwise.

REPOSITORY
  rHG Mercurial

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

To: pulkit, durin42, martinvonz, #hg-reviewers
Cc: idlsoft, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6310: narrow: send specs as bundle2 data instead of param (issue5952) (issue6019)

2019-04-25 Thread idlsoft (Sandu Turcan)
idlsoft added inline comments.

INLINE COMMENTS

> narrowbundle2.py:36
>  _CHANGESPECPART = 'narrow:changespec'
> +_RESSPECS = 'narrow:responsespec'
>  _SPECPART = 'narrow:spec'

I thought this would have an uppercase letter to make it mandatory?

REPOSITORY
  rHG Mercurial

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

To: pulkit, durin42, martinvonz, #hg-reviewers
Cc: indygreg, idlsoft, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6310: narrow: send specs as bundle2 data instead of param (issue5952) (issue6019)

2019-04-25 Thread idlsoft (Sandu Turcan)
idlsoft added inline comments.

INLINE COMMENTS

> narrowbundle2.py:34
>  
>  _NARROWACL_SECTION = 'narrowhgacl'
>  _CHANGESPECPART = 'narrow:changespec'

If we plan to change this to `narrowacl` at some point, perhaps now is the 
time, since it's a major version change.

REPOSITORY
  rHG Mercurial

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

To: pulkit, durin42, martinvonz, #hg-reviewers
Cc: indygreg, idlsoft, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6776: bookmarks: validate changes on push (issue6193) (BC)

2020-08-06 Thread idlsoft (Sandu Turcan)
idlsoft added a comment.


  As I
  
  In D6776#133068 , @marmoute 
wrote:
  
  > As @valentin.gatienbaron pointed out, the now avoid adding more semantic to 
bare `--force` with an associated `--force-bookmark` especially because we want 
to be able to select the bookmarks that get force pushed here.
  
  I've expressed my concerns about that earlier, but ultimately it's a debate 
for core maintainers, we'll use whatever they decide.
  Without a clear decision it didn't make much sense to modify the PR.
  I'm not sure if I'll have the bandwith to resume working on this, but glad to 
see it getting renewed attention.

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6776/new/

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

To: idlsoft, #hg-reviewers, durin42, baymax
Cc: marmoute, pulkit, durin42, valentin.gatienbaron, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D12600: Enforce narrowacl in narrow_widen

2022-05-03 Thread idlsoft (Sandu Turcan)
idlsoft created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: martinvonz.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/narrow/narrowwirepeer.py
  tests/test-narrow-acl.t

CHANGE DETAILS

diff --git a/tests/test-narrow-acl.t b/tests/test-narrow-acl.t
--- a/tests/test-narrow-acl.t
+++ b/tests/test-narrow-acl.t
@@ -41,3 +41,39 @@
   $ hg -R narrowclone1 tracked
   I path:f1
   I path:f2
+
+Narrow should not be able to widen to include f3
+  $ hg -R narrowclone1 tracked --addinclude f3
+  comparing with http://localhost:$HGPORT1/
+  searching for changes
+  abort: The following includes are not accessible for test: ['path:f3']
+  [255]
+  $ ls -A -1 narrowclone1 | sort
+  .hg
+  f1
+  f2
+  $ hg -R narrowclone1 tracked
+  I path:f1
+  I path:f2
+
+Narrow should allow widen to include f2
+  $ hg -R narrowclone1 tracked --removeinclude f2 > /dev/null
+  $ hg -R narrowclone1 tracked
+  I path:f1
+  $ ls -A -1 narrowclone1 | sort
+  .hg
+  f1
+  $ hg -R narrowclone1 tracked --addinclude f2
+  comparing with http://localhost:$HGPORT1/
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 0 changesets with 1 changes to 1 files
+  $ hg -R narrowclone1 tracked
+  I path:f1
+  I path:f2
+  $ ls -A -1 narrowclone1 | sort
+  .hg
+  f1
+  f2
diff --git a/hgext/narrow/narrowwirepeer.py b/hgext/narrow/narrowwirepeer.py
--- a/hgext/narrow/narrowwirepeer.py
+++ b/hgext/narrow/narrowwirepeer.py
@@ -9,6 +9,7 @@
 from mercurial import (
 bundle2,
 error,
+exchange,
 extensions,
 hg,
 narrowspec,
@@ -85,6 +86,11 @@
 newincludes = splitpaths(newincludes)
 oldexcludes = splitpaths(oldexcludes)
 newexcludes = splitpaths(newexcludes)
+
+# enforce narrow acl if set
+if repo.ui.has_section(exchange._NARROWACL_SECTION):
+exchange.applynarrowacl(repo, dict(includepats=newincludes))
+
 # validate the patterns
 narrowspec.validatepatterns(set(oldincludes))
 narrowspec.validatepatterns(set(newincludes))



To: idlsoft, durin42, martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel