D10531: tests: synchronize the git and Mercurial username

2021-04-28 Thread mharbison72 (Matt Harbison)
mharbison72 created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The problem with the default name of "test" set by the test runner is the
  stringutil methods are unable to split out separate user and email addresses
  that git wants.  This means the username is recorded in git as "test ".
  Amending a commit with that user ends up trying to use "" as the person
  field for the new commit, and the git library complains about the angle
  brackets.  We should probably abort with a clearer message any time this bad
  form is used with the git extension.
  
  One of the commit dates is tweaked to recreate the ambiguous hash prefix from
  before.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  tests/test-git-interop.t

CHANGE DETAILS

diff --git a/tests/test-git-interop.t b/tests/test-git-interop.t
--- a/tests/test-git-interop.t
+++ b/tests/test-git-interop.t
@@ -7,6 +7,7 @@
   > GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
   > GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
   > GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
+  > HGUSER="test "; export HGUSER
   > count=10
   > gitcommit() {
   >GIT_AUTHOR_DATE="2007-01-01 00:00:$count +";
@@ -196,7 +197,7 @@
 hg log FILE
 
   $ echo a >> alpha
-  $ hg ci -m 'more alpha' --traceback --date '1583522787 18000'
+  $ hg ci -m 'more alpha' --traceback --date '1583558723 18000'
   $ echo b >> beta
   $ hg ci -m 'more beta'
   heads mismatch, rebuilding dagcache
@@ -205,16 +206,16 @@
   heads mismatch, rebuilding dagcache
   $ hg log -G alpha
   heads mismatch, rebuilding dagcache
-  @  changeset:   4:6626247b7dc8
+  @  changeset:   4:cf6ddf5d9b8a
   :  bookmark:master
   :  tag: tip
-  :  user:test 
+  :  user:test 
   :  date:Thu Jan 01 00:00:00 1970 +
   :  summary: even more alpha
   :
-  o  changeset:   2:a1983dd7fb19
-  :  user:test 
-  :  date:Fri Mar 06 14:26:27 2020 -0500
+  o  changeset:   2:5b2c80b027ce
+  :  user:test 
+  :  date:Sat Mar 07 00:25:23 2020 -0500
   :  summary: more alpha
   :
   o  changeset:   0:c5864c9d16fb
@@ -223,8 +224,8 @@
  summary: Add alpha
   
   $ hg log -G beta
-  o  changeset:   3:d8ee22687733
-  :  user:test 
+  o  changeset:   3:980d4f79a9c6
+  :  user:test 
   :  date:Thu Jan 01 00:00:00 1970 +
   :  summary: more beta
   :
@@ -235,7 +236,7 @@
   
 
   $ hg log -r "children(3d9be8deba43)" -T"{node|short} {children}\n"
-  a1983dd7fb19 3:d8ee22687733
+  5b2c80b027ce 3:980d4f79a9c6
 
 hg annotate
 
@@ -279,23 +280,25 @@
 node|shortest works correctly
   $ hg log -T '{node}\n' | sort
   3d9be8deba43482be2c81a4cb4be1f10d85fa8bc
-  6626247b7dc8f231b183b8a4761c89139baca2ad
-  a1983dd7fb19cbd83ad5a1c2fc8bf3d775dea12f
-  ae1ab744f95bfd5b07cf573baef98a778058537b
+  5b2c80b027ce4250f88957326c199a2dc48dad60
+  980d4f79a9c617d60d0fe1fb383753c4a61bea8e
+  c1a41c49866ecc9c5411be932653e5b430961dd5
   c5864c9d16fb3431fe2c175ff84dc6accdbb2c18
-  d8ee22687733a1991813560b15128cd9734f4b48
-  $ hg log -r ae1ab744f95bfd5b07cf573baef98a778058537b --template 
"{shortest(node,1)}\n"
-  ae
+  cf6ddf5d9b8a120bf90020342bcf7a96d0167279
+  $ hg log -r c1a41c49866ecc9c5411be932653e5b430961dd5 --template 
"{shortest(node,1)}\n"
+  c1
 
 This covers gitlog._partialmatch()
-  $ hg log -r a
-  abort: ambiguous revision identifier: a
+  $ hg log -r c
+  abort: ambiguous revision identifier: c
   [10]
-  $ hg log -r a1
-  changeset:   2:a1983dd7fb19
-  user:test 
-  date:Fri Mar 06 14:26:27 2020 -0500
-  summary: more alpha
+  $ hg log -r c1
+  changeset:   5:c1a41c49866e
+  bookmark:master
+  tag: tip
+  user:test 
+  date:Thu Jan 01 00:00:00 1970 +
+  summary: Introduce file a/mu
   
   $ hg log -r dead
   abort: unknown revision 'dead'
@@ -355,14 +358,14 @@
 
   $ hg ex -r .
   # HG changeset patch
-  # User test 
+  # User test 
   # Date 0 0
   #  Thu Jan 01 00:00:00 1970 +
-  # Node ID 80adc61cf57e99f6a412d83fee6239d1556cefcf
-  # Parent  ae1ab744f95bfd5b07cf573baef98a778058537b
+  # Node ID 6024eda7986da123aa6797dd4603bd399d49bf5c
+  # Parent  c1a41c49866ecc9c5411be932653e5b430961dd5
   test interactive commit
   
-  diff -r ae1ab744f95b -r 80adc61cf57e alpha
+  diff -r c1a41c49866e -r 6024eda7986d alpha
   --- a/alpha  Thu Jan 01 00:00:00 1970 +
   +++ b/alpha  Thu Jan 01 00:00:00 1970 +
   @@ -1,3 +1,4 @@
@@ -371,8 +374,8 @@
a
   +bar
   $ git show
-  commit 80adc61cf57e99f6a412d83fee6239d1556cefcf
-  Author: test 
+  commit 6024eda7986da123aa6797dd4603bd399d49bf5c
+  Author: test 
   Date:   Thu Jan 1 00:00:00 1970 +
   
   test interactive commit
@@ -396,28 +399,26 @@
 This covers changelog.tiprev() 

D10532: git: ensure all dirstate state values are bytes

2021-04-28 Thread mharbison72 (Matt Harbison)
mharbison72 created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  I'm not sure how this particular git status occurs, but after the fallout of
  issue 6510 and getting into the issue 6511 state where `git status` shows the
  files as modified in both the "to be committed" and "not staged" lists,
  `hg diff` was crashing in `workingctx.__contains__()`.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  hgext/git/dirstate.py

CHANGE DETAILS

diff --git a/hgext/git/dirstate.py b/hgext/git/dirstate.py
--- a/hgext/git/dirstate.py
+++ b/hgext/git/dirstate.py
@@ -63,7 +63,7 @@
 pygit2.GIT_STATUS_WT_RENAMED: b'a',
 pygit2.GIT_STATUS_WT_TYPECHANGE: b'n',
 pygit2.GIT_STATUS_WT_UNREADABLE: b'?',
-pygit2.GIT_STATUS_INDEX_MODIFIED | pygit2.GIT_STATUS_WT_MODIFIED: 'm',
+pygit2.GIT_STATUS_INDEX_MODIFIED | pygit2.GIT_STATUS_WT_MODIFIED: b'm',
 }
 
 



To: mharbison72, durin42, #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


D10530: rewriteutil: adapt "cannot %s while merging" to work with "change branch of"

2021-04-28 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  `rewriteutil.precheck()` creates error messages by inserting a given
  verb into a sentence. The `hg branch -r` command passes in "change
  branch of" as the verb. That doesn't work well with "cannot %s while
  merging" (making it "cannot change branch of while merging"). Let's
  insert a "changeset" there to make it work better.
  
  Building sentences like this seems obviously bad for i18n, but fixing
  that is out of scope for this series, IMO.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/rewriteutil.py
  tests/test-commit-amend.t
  tests/test-uncommit.t

CHANGE DETAILS

diff --git a/tests/test-uncommit.t b/tests/test-uncommit.t
--- a/tests/test-uncommit.t
+++ b/tests/test-uncommit.t
@@ -410,7 +410,7 @@
   [20]
 
   $ hg uncommit --config experimental.uncommitondirtywdir=True
-  abort: cannot uncommit while merging
+  abort: cannot uncommit changesets while merging
   [20]
 
   $ hg status
diff --git a/tests/test-commit-amend.t b/tests/test-commit-amend.t
--- a/tests/test-commit-amend.t
+++ b/tests/test-commit-amend.t
@@ -406,7 +406,7 @@
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
   $ hg ci --amend
-  abort: cannot amend while merging
+  abort: cannot amend changesets while merging
   [20]
   $ hg ci -m 'merge'
 
diff --git a/mercurial/rewriteutil.py b/mercurial/rewriteutil.py
--- a/mercurial/rewriteutil.py
+++ b/mercurial/rewriteutil.py
@@ -44,7 +44,7 @@
 revs = (r.rev() for r in revs)
 
 if len(repo[None].parents()) > 1:
-raise error.StateError(_(b"cannot %s while merging") % action)
+raise error.StateError(_(b"cannot %s changesets while merging") % 
action)
 
 publicrevs = repo.revs(b'%ld and public()', revs)
 if publicrevs:



To: 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


D10518: rewriteutil: check for divergence

2021-04-28 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
martinvonz edited the summary of this revision.
pulkit added inline comments.
pulkit accepted this revision.
This revision is now accepted and ready to land.

INLINE COMMENTS

> test-branch-change.t:153
>$ hg branch -r 4 --hidden foobar
> -  abort: cannot change branch of a obsolete changeset
> +  abort: change branch of of 3938acfb5c0f creates content-divergence with 
> 7c1991464886
> +  (add --verbose for details)

`s/of of/ of`

REVISION SUMMARY
  This code is adapted from the code in the evolve extension. It seems
  to be equivalent as far as the evolve extension's test suite can tell
  (the only impact when making their `precheck()` delegate to our
  version is that error messages are less detailed).

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/rebase.py
  mercurial/obsolete.py
  mercurial/rewriteutil.py
  tests/test-amend.t
  tests/test-branch-change.t
  tests/test-obshistory.t
  tests/test-obsmarker-template.t
  tests/test-unamend.t

CHANGE DETAILS

diff --git a/tests/test-unamend.t b/tests/test-unamend.t
--- a/tests/test-unamend.t
+++ b/tests/test-unamend.t
@@ -6,6 +6,7 @@
   > glog = log -G -T '{rev}:{node|short}  {desc}'
   > [experimental]
   > evolution = createmarkers, allowunstable
+  > evolution.allowdivergence = true
   > [extensions]
   > rebase =
   > amend =
diff --git a/tests/test-obsmarker-template.t b/tests/test-obsmarker-template.t
--- a/tests/test-obsmarker-template.t
+++ b/tests/test-obsmarker-template.t
@@ -11,6 +11,7 @@
   > publish=False
   > [experimental]
   > evolution=true
+  > evolution.allowdivergence=true
   > [templates]
   > obsfatesuccessors = "{if(successors, " as ")}{join(successors, ", ")}"
   > obsfateverb = "{obsfateverb(successors, markers)}"
diff --git a/tests/test-obshistory.t b/tests/test-obshistory.t
--- a/tests/test-obshistory.t
+++ b/tests/test-obshistory.t
@@ -13,6 +13,7 @@
   > [experimental]
   > evolution.createmarkers = yes
   > evolution.effect-flags = yes
+  > evolution.allowdivergence=true
   > EOF
 
 Test output on amended commit
diff --git a/tests/test-branch-change.t b/tests/test-branch-change.t
--- a/tests/test-branch-change.t
+++ b/tests/test-branch-change.t
@@ -150,7 +150,8 @@
   [255]
 
   $ hg branch -r 4 --hidden foobar
-  abort: cannot change branch of a obsolete changeset
+  abort: change branch of of 3938acfb5c0f creates content-divergence with 
7c1991464886
+  (add --verbose for details)
   [10]
 
 Make sure bookmark movement is correct
diff --git a/tests/test-amend.t b/tests/test-amend.t
--- a/tests/test-amend.t
+++ b/tests/test-amend.t
@@ -232,6 +232,17 @@
   $ hg debugobsolete -r .
   112478962961147124edd43549aedd1a335e44bf 
be169c7e8dbe21cd10b3d79691cbe7f241e3c21c 0 (Thu Jan 01 00:00:00 1970 +) 
{'ef1': '8', 'operation': 'amend', 'user': 'test'}
   be169c7e8dbe21cd10b3d79691cbe7f241e3c21c 
16084da537dd8f84cfdb3055c633772269d62e1b 0 (Thu Jan 01 00:00:00 1970 +) 
{'ef1': '8', 'note': 'adding bar', 'operation': 'amend', 'user': 'test'}
+
+Cannot cause divergence by default
+
+  $ hg co --hidden 1
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ hg amend -m divergent
+  abort: amend of 112478962961 creates content-divergence with 16084da537dd
+  (add --verbose for details)
+  [10]
+  $ hg amend -m divergent --config experimental.evolution.allowdivergence=true
+  2 new content-divergent changesets
 #endif
 
 Cannot amend public changeset
diff --git a/mercurial/rewriteutil.py b/mercurial/rewriteutil.py
--- a/mercurial/rewriteutil.py
+++ b/mercurial/rewriteutil.py
@@ -59,6 +59,36 @@
 _(b"cannot %s changeset with children") % action, hint=hint
 )
 
+if not obsolete.isenabled(repo, obsolete.allowdivergenceopt):
+new_divergence = _find_new_divergence(repo, revs)
+if new_divergence:
+local_ctx, other_ctx, base_ctx = new_divergence
+msg = _(b'%s of %s creates content-divergence with %s') % (
+action,
+local_ctx,
+other_ctx,
+)
+if local_ctx.rev() != base_ctx.rev():
+msg += _(b', from %s') % base_ctx
+if repo.ui.verbose:
+if local_ctx.rev() != base_ctx.rev():
+msg += _(
+b'\nchangeset %s is a successor of ' b'changeset 
%s'
+) % (local_ctx, base_ctx)
+msg += _(
+b'\nchangeset %s already has a successor in '
+b'changeset %s\n'
+b'rewriting changeset %s would create '
+b'"content-divergence"\n'
+b'set experimental.evolution.allowdivergence=True to '
+b'skip this check'
+) % (base_ctx, other_ctx, 

D10528: git: initialize `extra` to have at least the branch name for nullid

2021-04-28 Thread mharbison72 (Matt Harbison)
mharbison72 created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
pulkit accepted this revision.
This revision is now accepted and ready to land.

REVISION SUMMARY
  Otherwise, this crashes trying to convert to local encoding:
  
...
  File "/mnt/c/Users/Matt/hg/mercurial/logcmdutil.py", line 333, in _show
branch = ctx.branch()
  File "/mnt/c/Users/Matt/hg/mercurial/context.py", line 675, in branch
return encoding.tolocal(self._changeset.extra.get(b"branch"))
  File "/mnt/c/Users/Matt/hg/mercurial/encoding.py", line 181, in tolocal
if isasciistr(s):
TypeError: a bytes-like object is required, not 'NoneType'
  
  This was originally reported to the thg bug tracker.
  
  https://foss.heptapod.net/mercurial/tortoisehg/thg/-/issues/5629

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  hgext/git/gitlog.py
  tests/test-git-interop.t

CHANGE DETAILS

diff --git a/tests/test-git-interop.t b/tests/test-git-interop.t
--- a/tests/test-git-interop.t
+++ b/tests/test-git-interop.t
@@ -57,6 +57,12 @@
   $ hg init --git
   $ hg heads
   [1]
+  $ hg tip
+  changeset:   -1:
+  tag: tip
+  user:
+  date:Thu Jan 01 00:00:00 1970 +
+  
   $ cd ..
 
 Make a new repo with git:
diff --git a/hgext/git/gitlog.py b/hgext/git/gitlog.py
--- a/hgext/git/gitlog.py
+++ b/hgext/git/gitlog.py
@@ -221,9 +221,10 @@
 n = self.node(nodeorrev)
 else:
 n = nodeorrev
+extra = {b'branch': b'default'}
 # handle looking up nullid
 if n == nullid:
-return hgchangelog._changelogrevision(extra={}, manifest=nullid)
+return hgchangelog._changelogrevision(extra=extra, manifest=nullid)
 hn = gitutil.togitnode(n)
 # We've got a real commit!
 files = [
@@ -253,7 +254,7 @@
 filesremoved=filesremoved,
 description=c.message.encode('utf8'),
 # TODO do we want to handle extra? how?
-extra={b'branch': b'default'},
+extra=extra,
 )
 
 def ancestors(self, revs, stoprev=0, inclusive=False):



To: mharbison72, durin42, #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


D10526: git: pass the correct type to the sqlite3 query for baselog.hasnode()

2021-04-28 Thread mharbison72 (Matt Harbison)
mharbison72 created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
pulkit accepted this revision.
This revision is now accepted and ready to land.

REVISION SUMMARY
  It looks like this function is mostly used in exchange (which isn't supported
  now) and histedit (which crashes).  But I did verify in a REPL that passing
  bytes to `db.execute()` fails to find the row, whereas passing str works.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  hgext/git/gitlog.py

CHANGE DETAILS

diff --git a/hgext/git/gitlog.py b/hgext/git/gitlog.py
--- a/hgext/git/gitlog.py
+++ b/hgext/git/gitlog.py
@@ -68,7 +68,8 @@
 
 def hasnode(self, n):
 t = self._db.execute(
-'SELECT node FROM changelog WHERE node = ?', (n,)
+'SELECT node FROM changelog WHERE node = ?',
+(pycompat.sysstr(n),),
 ).fetchone()
 return t is not None
 



To: mharbison72, durin42, #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


D10525: git: use the correct type for stopping changelog.revs()

2021-04-28 Thread mharbison72 (Matt Harbison)
mharbison72 created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
pulkit accepted this revision.
This revision is now accepted and ready to land.

REVISION SUMMARY
  The `tip` function returns a binary node, but the database is expecting an 
int.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  hgext/git/gitlog.py

CHANGE DETAILS

diff --git a/hgext/git/gitlog.py b/hgext/git/gitlog.py
--- a/hgext/git/gitlog.py
+++ b/hgext/git/gitlog.py
@@ -147,7 +147,7 @@
 
 def revs(self, start=0, stop=None):
 if stop is None:
-stop = self.tip()
+stop = self.tiprev()
 t = self._db.execute(
 'SELECT rev FROM changelog '
 'WHERE rev >= ? AND rev <= ? '



To: mharbison72, durin42, #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


D10529: node: replace nullid and friends with nodeconstants class

2021-04-28 Thread joerg.sonnenberger (Joerg Sonnenberger)
joerg.sonnenberger created this revision.
Herald added a reviewer: indygreg.
Herald added a reviewer: durin42.
Herald added a reviewer: durin42.
Herald added a reviewer: martinvonz.
Herald added subscribers: mercurial-patches, Kwan.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The introduction of 256bit hashes require changes to nullid and other
  constant magic values. Start pushing them down from repository and
  revlog where sensible.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/absorb.py
  hgext/convert/git.py
  hgext/convert/hg.py
  hgext/git/dirstate.py
  hgext/git/gitlog.py
  hgext/git/gitutil.py
  hgext/git/index.py
  hgext/gpg.py
  hgext/hgk.py
  hgext/journal.py
  hgext/largefiles/basestore.py
  hgext/largefiles/lfcommands.py
  hgext/largefiles/lfutil.py
  hgext/lfs/wrapper.py
  hgext/mq.py
  hgext/narrow/narrowbundle2.py
  hgext/narrow/narrowcommands.py
  hgext/phabricator.py
  hgext/remotefilelog/contentstore.py
  hgext/remotefilelog/datapack.py
  hgext/remotefilelog/debugcommands.py
  hgext/remotefilelog/fileserverclient.py
  hgext/remotefilelog/historypack.py
  hgext/remotefilelog/metadatastore.py
  hgext/remotefilelog/remotefilectx.py
  hgext/remotefilelog/remotefilelog.py
  hgext/remotefilelog/remotefilelogserver.py
  hgext/remotefilelog/repack.py
  hgext/remotefilelog/shallowbundle.py
  hgext/remotefilelog/shallowrepo.py
  hgext/sqlitestore.py
  hgext/transplant.py
  hgext/uncommit.py
  mercurial/bookmarks.py
  mercurial/branchmap.py
  mercurial/bundle2.py
  mercurial/bundlerepo.py
  mercurial/changegroup.py
  mercurial/changelog.py
  mercurial/cmdutil.py
  mercurial/commands.py
  mercurial/commit.py
  mercurial/context.py
  mercurial/copies.py
  mercurial/debugcommands.py
  mercurial/dirstate.py
  mercurial/discovery.py
  mercurial/exchange.py
  mercurial/exchangev2.py
  mercurial/filelog.py
  mercurial/filemerge.py
  mercurial/hg.py
  mercurial/hgweb/webutil.py
  mercurial/interfaces/dirstate.py
  mercurial/localrepo.py
  mercurial/logcmdutil.py
  mercurial/manifest.py
  mercurial/merge.py
  mercurial/mergestate.py
  mercurial/metadata.py
  mercurial/obsolete.py
  mercurial/patch.py
  mercurial/phases.py
  mercurial/pure/parsers.py
  mercurial/revlog.py
  mercurial/scmutil.py
  mercurial/setdiscovery.py
  mercurial/shelve.py
  mercurial/sparse.py
  mercurial/strip.py
  mercurial/subrepo.py
  mercurial/tagmerge.py
  mercurial/tags.py
  mercurial/templatefuncs.py
  mercurial/templatekw.py
  mercurial/testing/storage.py
  mercurial/treediscovery.py
  mercurial/util.py
  mercurial/utils/storageutil.py
  mercurial/verify.py
  mercurial/wireprotov1server.py
  mercurial/wireprotov2server.py
  tests/drawdag.py
  tests/simplestorerepo.py
  tests/test-annotate.t
  tests/test-commit.t
  tests/test-fastannotate-hg.t
  tests/test-filelog.py
  tests/test-parseindex2.py
  tests/test-remotefilelog-datapack.py
  tests/test-remotefilelog-histpack.py
  tests/test-revlog-raw.py
  tests/testlib/ext-sidedata.py

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


D10527: git: consistently use str for parents when rebuilding the index database

2021-04-28 Thread mharbison72 (Matt Harbison)
mharbison72 created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
pulkit accepted this revision.
This revision is now accepted and ready to land.

REVISION SUMMARY
  The tests show no changes, but when these values are overwritten shortly after
  when a git commit object is available, that uses str.  It seems better to use
  that for consistency.
  
  It does materially affect the database though, because the old value stored 
was
  `X'3030..3030'` and is now '00..00' when the changelog table is dumped in
  sqlite3.  There is one query that specifies the parents, but it passes the non
  null hashes as str, so it worked as expected.  That likely explains the lack 
of
  test changes.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  hgext/git/index.py

CHANGE DETAILS

diff --git a/hgext/git/index.py b/hgext/git/index.py
--- a/hgext/git/index.py
+++ b/hgext/git/index.py
@@ -6,7 +6,6 @@
 
 from mercurial.i18n import _
 from mercurial.node import (
-nullhex,
 nullid,
 )
 
@@ -281,7 +280,7 @@
 for pos, commit in enumerate(walker):
 if prog is not None:
 prog.update(pos)
-p1 = p2 = nullhex
+p1 = p2 = gitutil.nullgit
 if len(commit.parents) > 2:
 raise error.ProgrammingError(
 (



To: mharbison72, durin42, #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


D10523: tests: add coverage for git.changelog.headrevs(...)

2021-04-28 Thread mharbison72 (Matt Harbison)
mharbison72 created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
pulkit accepted this revision.
This revision is now accepted and ready to land.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  tests/test-git-interop.t

CHANGE DETAILS

diff --git a/tests/test-git-interop.t b/tests/test-git-interop.t
--- a/tests/test-git-interop.t
+++ b/tests/test-git-interop.t
@@ -407,4 +407,12 @@
   date:Thu Jan 01 00:00:00 1970 +
   summary: remove beta
   
+This covers changelog.headrevs() with a non-None arg
 
+TODO: Fix the user name.  The stray > char also break `hg ci --amend`.
+  $ hg log -r 'heads(.)' -Tcompact
+  7[tip][master]   116aee5ecdff   1970-01-01 00:00 +   test>
+remove beta
+  
+
+



To: mharbison72, durin42, #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


D10522: git: make changelog.tiprev() return int instead of tuple (issue6510)

2021-04-28 Thread mharbison72 (Matt Harbison)
mharbison72 created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
pulkit accepted this revision.
This revision is now accepted and ready to land.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  hgext/git/gitlog.py
  tests/test-git-interop.t

CHANGE DETAILS

diff --git a/tests/test-git-interop.t b/tests/test-git-interop.t
--- a/tests/test-git-interop.t
+++ b/tests/test-git-interop.t
@@ -49,6 +49,16 @@
   > log-index-cache-miss = yes
   > EOF
 
+Test some edge cases around a commitless repo first
+  $ mkdir empty
+  $ cd empty
+  $ git init
+  Initialized empty Git repository in $TESTTMP/empty/.git/
+  $ hg init --git
+  $ hg heads
+  [1]
+  $ cd ..
+
 Make a new repo with git:
   $ mkdir foo
   $ cd foo
@@ -377,3 +387,24 @@
   $ hg rm beta
   $ hg ci -m 'remove beta'
 
+This covers changelog.tiprev() (issue6510)
+  $ hg log -r '(.^^):'
+  heads mismatch, rebuilding dagcache
+  changeset:   5:ae1ab744f95b
+  user:test 
+  date:Thu Jan 01 00:00:00 1970 +
+  summary: Introduce file a/mu
+  
+  changeset:   6:80adc61cf57e
+  user:test 
+  date:Thu Jan 01 00:00:00 1970 +
+  summary: test interactive commit
+  
+  changeset:   7:116aee5ecdff
+  bookmark:master
+  tag: tip
+  user:test 
+  date:Thu Jan 01 00:00:00 1970 +
+  summary: remove beta
+  
+
diff --git a/hgext/git/gitlog.py b/hgext/git/gitlog.py
--- a/hgext/git/gitlog.py
+++ b/hgext/git/gitlog.py
@@ -159,8 +159,11 @@
 def tiprev(self):
 t = self._db.execute(
 'SELECT rev FROM changelog ' 'ORDER BY REV DESC ' 'LIMIT 1'
-)
-return next(t)
+).fetchone()
+
+if t is not None:
+return t[0]
+return -1
 
 def _partialmatch(self, id):
 if wdirhex.startswith(id):



To: mharbison72, durin42, #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


D10524: git: use the proper filenode for deleted files in changelog.changelogrevision

2021-04-28 Thread mharbison72 (Matt Harbison)
mharbison72 created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
pulkit accepted this revision.
This revision is now accepted and ready to land.

REVISION SUMMARY
  Inline printing shows it still doesn't find the removed file in the test, but 
it
  is at least a str instead of bytes like the immediate query before it that 
does
  find files.  Looking at the database, it doesn't look like the remove was
  recorded.  Additionally, `hg log -r 'removes("re:.*")'` stacktraces.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  hgext/git/gitlog.py

CHANGE DETAILS

diff --git a/hgext/git/gitlog.py b/hgext/git/gitlog.py
--- a/hgext/git/gitlog.py
+++ b/hgext/git/gitlog.py
@@ -238,7 +238,7 @@
 for r in self._db.execute(
 'SELECT filename FROM changedfiles '
 'WHERE node = ? and filenode = ?',
-(hn, nullhex),
+(hn, gitutil.nullgit),
 )
 ]
 c = self.gitrepo[hn]



To: mharbison72, durin42, #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


D10521: git: fix partial node matching

2021-04-28 Thread mharbison72 (Matt Harbison)
mharbison72 created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
pulkit accepted this revision.
This revision is now accepted and ready to land.

REVISION SUMMARY
  Looks like everything is meant to be a str here.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  hgext/git/gitlog.py
  tests/test-git-interop.t

CHANGE DETAILS

diff --git a/tests/test-git-interop.t b/tests/test-git-interop.t
--- a/tests/test-git-interop.t
+++ b/tests/test-git-interop.t
@@ -271,6 +271,20 @@
   $ hg log -r ae1ab744f95bfd5b07cf573baef98a778058537b --template 
"{shortest(node,1)}\n"
   ae
 
+This covers gitlog._partialmatch()
+  $ hg log -r a
+  abort: ambiguous revision identifier: a
+  [10]
+  $ hg log -r a1
+  changeset:   2:a1983dd7fb19
+  user:test 
+  date:Fri Mar 06 14:26:27 2020 -0500
+  summary: more alpha
+  
+  $ hg log -r dead
+  abort: unknown revision 'dead'
+  [255]
+
 This coveres changelog.findmissing()
   $ hg merge --preview 3d9be8deba43
 
diff --git a/hgext/git/gitlog.py b/hgext/git/gitlog.py
--- a/hgext/git/gitlog.py
+++ b/hgext/git/gitlog.py
@@ -168,7 +168,8 @@
 candidates = [
 bin(x[0])
 for x in self._db.execute(
-'SELECT node FROM changelog WHERE node LIKE ?', (id + b'%',)
+'SELECT node FROM changelog WHERE node LIKE ?',
+(pycompat.sysstr(id + b'%'),),
 )
 ]
 if nullhex.startswith(id):



To: mharbison72, durin42, #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


D10519: branch: delete obsolete message about changing branch of obsolete commit

2021-04-28 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
pulkit accepted this revision.
This revision is now accepted and ready to land.

REVISION SUMMARY
  We now rely on `rewriteutil.precheck()` to check for divergence, so we
  don't need the extra check in `cmdutil.changebranch()`. The former
  check is a little less strict in that it allows you to rewrite a
  commit without non-obsolete successors.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/cmdutil.py

CHANGE DETAILS

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -998,11 +998,6 @@
 _(b"a branch of the same name already exists")
 )
 
-if repo.revs(b'obsolete() and %ld', revs):
-raise error.InputError(
-_(b"cannot change branch of a obsolete changeset")
-)
-
 # make sure only topological heads
 if repo.revs(b'heads(%ld) - head()', revs):
 raise error.InputError(



To: 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


D10520: tests: stabilize test-git-interop.t for some versions of git

2021-04-28 Thread mharbison72 (Matt Harbison)
mharbison72 created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
pulkit accepted this revision.
This revision is now accepted and ready to land.

REVISION SUMMARY
  Not sure why this differs on my system, but it's likely due to running 2.17.1 
on
  Ubuntu 18.04.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  tests/test-git-interop.t

CHANGE DETAILS

diff --git a/tests/test-git-interop.t b/tests/test-git-interop.t
--- a/tests/test-git-interop.t
+++ b/tests/test-git-interop.t
@@ -67,6 +67,7 @@
   On branch master
   Untracked files:
 (use "git add ..." to include in what will be committed)
+   (?)
gamma
   
   nothing added to commit but untracked files present (use "git add" to track)
@@ -134,6 +135,7 @@
   On branch master
   Untracked files:
 (use "git add ..." to include in what will be committed)
+   (?)
gamma
   
   nothing added to commit but untracked files present (use "git add" to track)
@@ -153,7 +155,9 @@
   $ git status
   On branch master
   Changes to be committed:
-(use "git restore --staged ..." to unstage)
+(use "git restore --staged ..." to unstage) (?)
+(use "git reset HEAD ..." to unstage) (?)
+   (?)
new file:   gamma
   
 
@@ -165,6 +169,7 @@
   On branch master
   Untracked files:
 (use "git add ..." to include in what will be committed)
+   (?)
gamma
   
   nothing added to commit but untracked files present (use "git add" to track)



To: mharbison72, durin42, #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


D10517: rewriteutil: point to help about instability when rewriting creates orphan

2021-04-28 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
pulkit accepted this revision.
This revision is now accepted and ready to land.

REVISION SUMMARY
  This replicates the message from the evolve extension.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/rewriteutil.py
  tests/test-amend.t
  tests/test-branch-change.t
  tests/test-fix.t
  tests/test-rebase-collapse.t
  tests/test-rebase-scenario-global.t
  tests/test-split.t
  tests/test-unamend.t

CHANGE DETAILS

diff --git a/tests/test-unamend.t b/tests/test-unamend.t
--- a/tests/test-unamend.t
+++ b/tests/test-unamend.t
@@ -284,6 +284,7 @@
 
   $ hg --config experimental.evolution=createmarkers unamend
   abort: cannot unamend changeset with children
+  (see 'hg help evolution.instability')
   [10]
 
   $ hg unamend
diff --git a/tests/test-split.t b/tests/test-split.t
--- a/tests/test-split.t
+++ b/tests/test-split.t
@@ -467,6 +467,7 @@
 #if obsstore-off
   $ runsplit -r 1 --no-rebase
   abort: cannot split changeset with children
+  (see 'hg help evolution.instability')
   [10]
 #else
   $ runsplit -r 1 --no-rebase >/dev/null
@@ -518,6 +519,7 @@
   $ rm .hg/localtags
   $ hg split $B --config experimental.evolution=createmarkers
   abort: cannot split changeset with children
+  (see 'hg help evolution.instability')
   [10]
   $ cat > $TESTTMP/messages < Split B
diff --git a/tests/test-rebase-scenario-global.t 
b/tests/test-rebase-scenario-global.t
--- a/tests/test-rebase-scenario-global.t
+++ b/tests/test-rebase-scenario-global.t
@@ -453,7 +453,7 @@
   $ cd ah1
   $ hg rebase -r '2::8' -d 1
   abort: cannot rebase changeset with children
-  (use --keep to keep original changesets)
+  (see 'hg help evolution.instability')
   [10]
   $ hg rebase -r '2::8' -d 1 -k
   rebasing 2:c9e50f6cdc55 "C"
@@ -499,7 +499,7 @@
   $ cd ah2
   $ hg rebase -r '3::8' -d 1
   abort: cannot rebase changeset with children
-  (use --keep to keep original changesets)
+  (see 'hg help evolution.instability')
   [10]
   $ hg rebase -r '3::8' -d 1 --keep
   rebasing 3:ffd453c31098 "D"
@@ -542,7 +542,7 @@
   $ cd ah3
   $ hg rebase -r '3::7' -d 1
   abort: cannot rebase changeset with children
-  (use --keep to keep original changesets)
+  (see 'hg help evolution.instability')
   [10]
   $ hg rebase -r '3::7' -d 1 --keep
   rebasing 3:ffd453c31098 "D"
@@ -582,7 +582,7 @@
   $ cd ah4
   $ hg rebase -r '3::(7+5)' -d 1
   abort: cannot rebase changeset with children
-  (use --keep to keep original changesets)
+  (see 'hg help evolution.instability')
   [10]
   $ hg rebase -r '3::(7+5)' -d 1 --keep
   rebasing 3:ffd453c31098 "D"
diff --git a/tests/test-rebase-collapse.t b/tests/test-rebase-collapse.t
--- a/tests/test-rebase-collapse.t
+++ b/tests/test-rebase-collapse.t
@@ -550,7 +550,7 @@
   
   $ hg rebase --collapse -r 1 -d 0
   abort: cannot rebase changeset with children
-  (use --keep to keep original changesets)
+  (see 'hg help evolution.instability')
   [10]
 
 Test collapsing in place
diff --git a/tests/test-fix.t b/tests/test-fix.t
--- a/tests/test-fix.t
+++ b/tests/test-fix.t
@@ -1173,6 +1173,7 @@
   $ hg commit -m "second"
   $ hg --config experimental.evolution.allowunstable=False fix -r '.^'
   abort: cannot fix changeset with children
+  (see 'hg help evolution.instability')
   [10]
   $ hg fix -r '.^'
   1 new orphan changesets
diff --git a/tests/test-branch-change.t b/tests/test-branch-change.t
--- a/tests/test-branch-change.t
+++ b/tests/test-branch-change.t
@@ -58,6 +58,7 @@
 
   $ hg branch -r 1::3 foo
   abort: cannot change branch of changeset with children
+  (see 'hg help evolution.instability')
   [10]
 
 Change with dirty working directory
@@ -129,6 +130,7 @@
 
   $ hg branch -r 2 stable
   abort: cannot change branch of changeset with children
+  (see 'hg help evolution.instability')
   [10]
 
 Enabling the allowunstable config and trying to change branch on a branch head
diff --git a/tests/test-amend.t b/tests/test-amend.t
--- a/tests/test-amend.t
+++ b/tests/test-amend.t
@@ -197,6 +197,7 @@
   $ echo 2 >> B
   $ hg amend
   abort: cannot amend changeset with children
+  (see 'hg help evolution.instability')
   [10]
 
 #if obsstore-on
diff --git a/mercurial/rewriteutil.py b/mercurial/rewriteutil.py
--- a/mercurial/rewriteutil.py
+++ b/mercurial/rewriteutil.py
@@ -54,7 +54,10 @@
 
 newunstable = disallowednewunstable(repo, revs)
 if newunstable:
-raise error.InputError(_(b"cannot %s changeset with children") % 
action)
+hint = _(b"see 'hg help evolution.instability'")
+raise error.InputError(
+_(b"cannot %s changeset with children") % action, hint=hint
+)
 
 
 def disallowednewunstable(repo, revs):



To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list

D10516: help: add topic about evolution, based on text from evolve extension

2021-04-28 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
pulkit accepted this revision.
This revision is now accepted and ready to land.

REVISION SUMMARY
  I've taken the text produced by `hg help evolution` when the evolve
  extension is enabled and made that available by the same command with
  just hg core. Changes I've made:
  
  - Added "(EXPERIMENTAL)" to the title. (That doesn't hide the topic from `hg 
help`, though.)
  - Replaced old-style `experimental.evolution=` config by new-style 
`experimental.evolution.=true`.
  - Replaces a "obsolete markers" by "obsolescence markers".
  - Removed most content from "Current feature status".
  
  When the evolve extension is enabled, its help text takes precedence.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/help.py
  mercurial/helptext/evolution.txt
  tests/test-globalopts.t
  tests/test-help-hide.t
  tests/test-help.t
  tests/test-hgweb-json.t

CHANGE DETAILS

diff --git a/tests/test-hgweb-json.t b/tests/test-hgweb-json.t
--- a/tests/test-hgweb-json.t
+++ b/tests/test-hgweb-json.t
@@ -2272,6 +2272,10 @@
 "topic": "environment"
   },
   {
+"summary": "Safely rewriting history (EXPERIMENTAL)",
+"topic": "evolution"
+  },
+  {
 "summary": "Using Additional Features",
 "topic": "extensions"
   },
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -169,6 +169,7 @@
   Concepts:
   
bundlespecBundle File Formats
+   evolution Safely rewriting history (EXPERIMENTAL)
glossary  Glossary
phasesWorking with Phases
subrepos  Subrepositories
@@ -298,6 +299,7 @@
   Concepts:
   
bundlespecBundle File Formats
+   evolution Safely rewriting history (EXPERIMENTAL)
glossary  Glossary
phasesWorking with Phases
subrepos  Subrepositories
@@ -2274,6 +2276,13 @@
   Environment Variables
   
   
+  
+  evolution
+  
+  
+  Safely rewriting history (EXPERIMENTAL)
+  
+  
   
   extensions
   
diff --git a/tests/test-help-hide.t b/tests/test-help-hide.t
--- a/tests/test-help-hide.t
+++ b/tests/test-help-hide.t
@@ -117,6 +117,7 @@
   Concepts:
   
bundlespecBundle File Formats
+   evolution Safely rewriting history (EXPERIMENTAL)
glossary  Glossary
phasesWorking with Phases
subrepos  Subrepositories
@@ -254,6 +255,7 @@
   Concepts:
   
bundlespecBundle File Formats
+   evolution Safely rewriting history (EXPERIMENTAL)
glossary  Glossary
phasesWorking with Phases
subrepos  Subrepositories
diff --git a/tests/test-globalopts.t b/tests/test-globalopts.t
--- a/tests/test-globalopts.t
+++ b/tests/test-globalopts.t
@@ -419,6 +419,7 @@
   Concepts:
   
bundlespecBundle File Formats
+   evolution Safely rewriting history (EXPERIMENTAL)
glossary  Glossary
phasesWorking with Phases
subrepos  Subrepositories
@@ -552,6 +553,7 @@
   Concepts:
   
bundlespecBundle File Formats
+   evolution Safely rewriting history (EXPERIMENTAL)
glossary  Glossary
phasesWorking with Phases
subrepos  Subrepositories
diff --git a/mercurial/helptext/evolution.txt b/mercurial/helptext/evolution.txt
new file mode 100644
--- /dev/null
+++ b/mercurial/helptext/evolution.txt
@@ -0,0 +1,56 @@
+Obsolescence markers make it possible to mark changesets that have been
+deleted or superseded in a new version of the changeset.
+
+Unlike the previous way of handling such changes, by stripping the old
+changesets from the repository, obsolescence markers can be propagated
+between repositories. This allows for a safe and simple way of exchanging
+mutable history and altering it after the fact. Changeset phases are
+respected, such that only draft and secret changesets can be altered (see
+:hg:`help phases` for details).
+
+Obsolescence is tracked using "obsolescence markers", a piece of metadata
+tracking which changesets have been made obsolete, potential successors for
+a given changeset, the moment the changeset was marked as obsolete, and the
+user who performed the rewriting operation. The markers are stored
+separately from standard changeset data can be exchanged without any of the
+precursor changesets, preventing unnecessary exchange of obsolescence data.
+
+The complete set of obsolescence markers describes a history of changeset
+modifications that is orthogonal to the repository history of file
+modifications. This changeset history allows for detection and automatic
+resolution of edge cases arising from multiple users rewriting the same part
+of history concurrently.
+
+Current feature status
+==
+
+This feature is still in development.
+
+Instability
+===
+
+Rewriting changesets might introduce 

D10513: convert-bazaar: use breezy package instead of old bzr one

2021-04-28 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
Alphare planned changes to this revision.
Alphare added a comment.
baymax updated this revision to Diff 27164.


  I broke something, sorry for the noise.

baymax added a comment.


  :white_check_mark: refresh by Heptapod after a successful CI run (:octopus: 
:green_heart:)
  ⚠ This patch is intended for stable ⚠
  {image https://media.giphy.com/media/nYI8SmmChYXK0/source.gif}

REVISION SUMMARY
  Breezy is the most recent of the two, and works on Python 3 while being
  compatible with the (old) Bazaar file format.
  
  This patch contains a variety of unicode <-> bytes changes, API breakage 
fixing,
  restoring failing imports and changing the executable from `bzr` to `brz`.
  
  I recommend using the debian packages for `brz` and `python3-breezy` (3.1+),
  because the pip package seems to be haunted by radioactive dragons.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  contrib/import-checker.py
  hgext/convert/bzr.py
  tests/hghave.py
  tests/test-convert-bzr-114.t
  tests/test-convert-bzr-directories.t
  tests/test-convert-bzr-ghosts.t
  tests/test-convert-bzr-merges.t
  tests/test-convert-bzr-treeroot.t
  tests/test-convert-bzr.t

CHANGE DETAILS

diff --git a/tests/test-convert-bzr.t b/tests/test-convert-bzr.t
--- a/tests/test-convert-bzr.t
+++ b/tests/test-convert-bzr.t
@@ -6,7 +6,7 @@
 
   $ mkdir test-createandrename
   $ cd test-createandrename
-  $ bzr init -q source
+  $ brz init -q source
 
 test empty repo conversion (issue3233)
 
@@ -22,18 +22,18 @@
   $ echo a > a
   $ echo c > c
   $ echo e > e
-  $ bzr add -q a c e
-  $ bzr commit -q -m 'Initial add: a, c, e'
-  $ bzr mv a b
+  $ brz add -q a c e
+  $ brz commit -q -m 'Initial add: a, c, e'
+  $ brz mv a b
   a => b
-  $ bzr mv c d
+  $ brz mv c d
   c => d
-  $ bzr mv e f
+  $ brz mv e f
   e => f
   $ echo a2 >> a
   $ mkdir e
-  $ bzr add -q a e
-  $ bzr commit -q -m 'rename a into b, create a, rename c into d'
+  $ brz add -q a e
+  $ brz commit -q -m 'rename a into b, create a, rename c into d'
   $ cd ..
   $ hg convert source source-hg
   scanning source...
@@ -86,7 +86,7 @@
 
 convert from lightweight checkout
 
-  $ bzr checkout --lightweight source source-light
+  $ brz checkout --lightweight source source-light
   $ hg convert -s bzr source-light source-light-hg
   initializing destination source-light-hg repository
   warning: lightweight checkouts may cause conversion failures, try with a 
regular branch instead.
@@ -99,7 +99,7 @@
 compare timestamps
 
   $ cd source
-  $ bzr log | \
+  $ brz log | \
   >   sed '/timestamp/!d;s/.\{15\}\([0-9: -]\{16\}\):.. \(.[0-9]\{4\}\)/\1 
\2/' \
   >   > ../bzr-timestamps
   $ cd ..
@@ -113,20 +113,21 @@
   $ cd test-merge
   $ cat > helper.py < import sys
-  > from bzrlib import workingtree
+  > from breezy import workingtree
+  > import breezy.bzr.bzrdir
   > wt = workingtree.WorkingTree.open('.')
   > 
   > message, stamp = sys.argv[1:]
   > wt.commit(message, timestamp=int(stamp))
   > EOF
-  $ bzr init -q source
+  $ brz init -q source
   $ cd source
   $ echo content > a
   $ echo content2 > b
-  $ bzr add -q a b
-  $ bzr commit -q -m 'Initial add'
+  $ brz add -q a b
+  $ brz commit -q -m 'Initial add'
   $ cd ..
-  $ bzr branch -q source source-improve
+  $ brz branch -q source source-improve
   $ cd source
   $ echo more >> a
   $ "$PYTHON" ../helper.py 'Editing a' 100
@@ -134,8 +135,8 @@
   $ echo content3 >> b
   $ "$PYTHON" ../helper.py 'Editing b' 200
   $ cd ../source
-  $ bzr merge -q ../source-improve
-  $ bzr commit -q -m 'Merged improve branch'
+  $ brz merge -q ../source-improve
+  $ brz commit -q -m 'Merged improve branch'
   $ cd ..
   $ hg convert --datesort source source-hg
   initializing destination source-hg repository
@@ -163,7 +164,7 @@
 
   $ mkdir test-symlinks
   $ cd test-symlinks
-  $ bzr init -q source
+  $ brz init -q source
   $ cd source
   $ touch program
   $ chmod +x program
@@ -171,15 +172,15 @@
   $ mkdir d
   $ echo a > d/a
   $ ln -s a syma
-  $ bzr add -q altname program syma d/a
-  $ bzr commit -q -m 'Initial setup'
+  $ brz add -q altname program syma d/a
+  $ brz commit -q -m 'Initial setup'
   $ touch newprog
   $ chmod +x newprog
   $ rm altname
   $ ln -s newprog altname
   $ chmod -x program
-  $ bzr add -q newprog
-  $ bzr commit -q -m 'Symlink changed, x bits changed'
+  $ brz add -q newprog
+  $ brz commit -q -m 'Symlink changed, x bits changed'
   $ cd ..
   $ hg convert source source-hg
   initializing destination source-hg repository
@@ -215,30 +216,28 @@
 
 Multiple branches
 
-  $ bzr init-repo -q --no-trees repo
-  $ bzr init -q repo/trunk
-  $ bzr co repo/trunk repo-trunk
+  $ brz init-repo -q --no-trees repo
+  $ brz init -q repo/trunk
+  $ brz co repo/trunk repo-trunk
   $ cd repo-trunk
   $ echo a > a
-  $ bzr add -q a
-  $ bzr ci -qm adda

D10509: revlog: remove the revlogio class

2021-04-28 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: indygreg.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The class only contains a single `parseindex` method. Lets just make it a 
function and remove the `revlogio` class. It served us well but became thinner 
and thinner overtime

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  contrib/perf.py
  mercurial/cext/revlog.c
  mercurial/revlog.py

CHANGE DETAILS

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -37,8 +37,6 @@
 FLAG_GENERALDELTA,
 FLAG_INLINE_DATA,
 INDEX_ENTRY_V0,
-INDEX_ENTRY_V1,
-INDEX_ENTRY_V2,
 INDEX_HEADER,
 REVLOGV0,
 REVLOGV1,
@@ -287,34 +285,61 @@
 return INDEX_ENTRY_V0.pack(*e2)
 
 
-class revlogoldio(object):
-def parseindex(self, data, inline):
-s = INDEX_ENTRY_V0.size
-index = []
-nodemap = nodemaputil.NodeMap({sha1nodeconstants.nullid: nullrev})
-n = off = 0
-l = len(data)
-while off + s <= l:
-cur = data[off : off + s]
-off += s
-e = INDEX_ENTRY_V0.unpack(cur)
-# transform to revlogv1 format
-e2 = (
-offset_type(e[0], 0),
-e[1],
--1,
-e[2],
-e[3],
-nodemap.get(e[4], nullrev),
-nodemap.get(e[5], nullrev),
-e[6],
-)
-index.append(e2)
-nodemap[e[6]] = n
-n += 1
-
-index = revlogoldindex(index)
-return index, None
+def parse_index_v0(data, inline):
+s = INDEX_ENTRY_V0.size
+index = []
+nodemap = nodemaputil.NodeMap({sha1nodeconstants.nullid: nullrev})
+n = off = 0
+l = len(data)
+while off + s <= l:
+cur = data[off : off + s]
+off += s
+e = INDEX_ENTRY_V0.unpack(cur)
+# transform to revlogv1 format
+e2 = (
+offset_type(e[0], 0),
+e[1],
+-1,
+e[2],
+e[3],
+nodemap.get(e[4], nullrev),
+nodemap.get(e[5], nullrev),
+e[6],
+)
+index.append(e2)
+nodemap[e[6]] = n
+n += 1
+
+index = revlogoldindex(index)
+return index, None
+
+
+def parse_index_v1(data, inline):
+# call the C implementation to parse the index data
+index, cache = parsers.parse_index2(data, inline)
+return index, cache
+
+
+def parse_index_v2(data, inline):
+# call the C implementation to parse the index data
+index, cache = parsers.parse_index2(data, inline, revlogv2=True)
+return index, cache
+
+
+if util.safehasattr(parsers, 'parse_index_devel_nodemap'):
+
+def parse_index_v1_nodemap(data, inline):
+index, cache = parsers.parse_index_devel_nodemap(data, inline)
+return index, cache
+
+
+else:
+parse_index_v1_nodemap = None
+
+
+def parse_index_v1_mixed(data, inline):
+index, cache = parse_index_v1(data, inline)
+return rustrevlog.MixedIndex(index), cache
 
 
 # corresponds to uncompressed length of indexformatng (2 gigs, 4-byte
@@ -322,40 +347,6 @@
 _maxentrysize = 0x7FFF
 
 
-class revlogio(object):
-def parseindex(self, data, inline):
-# call the C implementation to parse the index data
-index, cache = parsers.parse_index2(data, inline)
-return index, cache
-
-
-class revlogv2io(object):
-def parseindex(self, data, inline):
-index, cache = parsers.parse_index2(data, inline, revlogv2=True)
-return index, cache
-
-
-NodemapRevlogIO = None
-
-if util.safehasattr(parsers, 'parse_index_devel_nodemap'):
-
-class NodemapRevlogIO(revlogio):
-"""A debug oriented IO class that return a PersistentNodeMapIndexObject
-
-The PersistentNodeMapIndexObject object is meant to test the 
persistent nodemap feature.
-"""
-
-def parseindex(self, data, inline):
-index, cache = parsers.parse_index_devel_nodemap(data, inline)
-return index, cache
-
-
-class rustrevlogio(revlogio):
-def parseindex(self, data, inline):
-index, cache = super(rustrevlogio, self).parseindex(data, inline)
-return rustrevlog.MixedIndex(index), cache
-
-
 class revlog(object):
 """
 the underlying revision storage object
@@ -614,7 +605,7 @@
 devel_nodemap = (
 self.nodemap_file
 and opts.get(b'devel-force-nodemap', False)
-and NodemapRevlogIO is not None
+and parse_index_v1_nodemap is not None
 )
 
 use_rust_index = False
@@ -624,17 +615,17 @@
 else:
 use_rust_index = self.opener.options.get(b'rust.index')
 
-self._io = revlogio()
+self._parse_index = parse_index_v1
 if 

D10515: rewriteutil: add devel warning if precheck is called with contexts

2021-04-28 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
pulkit accepted this revision.
This revision is now accepted and ready to land.

REVISION SUMMARY
  I'm trying to upstream parts from the evolve extension. This check
  exists there.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/rewriteutil.py

CHANGE DETAILS

diff --git a/mercurial/rewriteutil.py b/mercurial/rewriteutil.py
--- a/mercurial/rewriteutil.py
+++ b/mercurial/rewriteutil.py
@@ -21,6 +21,7 @@
 obsutil,
 revset,
 scmutil,
+util,
 )
 
 
@@ -38,6 +39,10 @@
 hint = _(b"no changeset checked out")
 raise error.InputError(msg, hint=hint)
 
+if any(util.safehasattr(r, 'rev') for r in revs):
+repo.ui.develwarn(b"rewriteutil.precheck called with ctx not revs")
+revs = (r.rev() for r in revs)
+
 if len(repo[None].parents()) > 1:
 raise error.StateError(_(b"cannot %s while merging") % action)
 



To: 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


D10514: rewriteutil: replace "null changeset" by "the null revision" in error message

2021-04-28 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
pulkit accepted this revision.
This revision is now accepted and ready to land.

REVISION SUMMARY
  The evolve extension uses "the null revision" and we seem to use that
  term much more frequently in core too.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/rewriteutil.py
  tests/test-uncommit.t

CHANGE DETAILS

diff --git a/tests/test-uncommit.t b/tests/test-uncommit.t
--- a/tests/test-uncommit.t
+++ b/tests/test-uncommit.t
@@ -51,7 +51,7 @@
 Uncommit with no commits should fail
 
   $ hg uncommit
-  abort: cannot uncommit null changeset
+  abort: cannot uncommit the null revision
   (no changeset checked out)
   [10]
 
diff --git a/mercurial/rewriteutil.py b/mercurial/rewriteutil.py
--- a/mercurial/rewriteutil.py
+++ b/mercurial/rewriteutil.py
@@ -34,7 +34,7 @@
 Make sure this function is called after taking the lock.
 """
 if nullrev in revs:
-msg = _(b"cannot %s null changeset") % action
+msg = _(b"cannot %s the null revision") % action
 hint = _(b"no changeset checked out")
 raise error.InputError(msg, hint=hint)
 



To: 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


D10511: revlog: code for `revlogv0` in its own module

2021-04-28 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: indygreg.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This code is mostly unused compatiblity code. Yet it take a prohiminent place 
in the `revlog.py` module. That module is already quite big, so we move all 
that code in a dedicated module.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/revlog.py
  mercurial/revlogutils/revlogv0.py

CHANGE DETAILS

diff --git a/mercurial/revlogutils/revlogv0.py 
b/mercurial/revlogutils/revlogv0.py
new file mode 100644
--- /dev/null
+++ b/mercurial/revlogutils/revlogv0.py
@@ -0,0 +1,144 @@
+# revlogv0 - code related to revlog format "V0"
+#
+# Copyright 2005-2007 Olivia Mackall 
+#
+# This software may be used and distributed according to the terms of the
+# GNU General Public License version 2 or any later version.
+from __future__ import absolute_import
+
+
+from ..node import sha1nodeconstants
+from .constants import (
+INDEX_ENTRY_V0,
+)
+from ..i18n import _
+
+from .. import (
+error,
+node,
+pycompat,
+util,
+)
+
+from . import (
+flagutil,
+nodemap as nodemaputil,
+)
+
+
+def getoffset(q):
+return int(q >> 16)
+
+
+def gettype(q):
+return int(q & 0x)
+
+
+def offset_type(offset, type):
+if (type & ~flagutil.REVIDX_KNOWN_FLAGS) != 0:
+raise ValueError(b'unknown revlog index flags')
+return int(int(offset) << 16 | type)
+
+
+class revlogoldindex(list):
+entry_size = INDEX_ENTRY_V0.size
+
+@property
+def nodemap(self):
+msg = b"index.nodemap is deprecated, use index.[has_node|rev|get_rev]"
+util.nouideprecwarn(msg, b'5.3', stacklevel=2)
+return self._nodemap
+
+@util.propertycache
+def _nodemap(self):
+nodemap = nodemaputil.NodeMap({sha1nodeconstants.nullid: node.nullrev})
+for r in range(0, len(self)):
+n = self[r][7]
+nodemap[n] = r
+return nodemap
+
+def has_node(self, node):
+"""return True if the node exist in the index"""
+return node in self._nodemap
+
+def rev(self, node):
+"""return a revision for a node
+
+If the node is unknown, raise a RevlogError"""
+return self._nodemap[node]
+
+def get_rev(self, node):
+"""return a revision for a node
+
+If the node is unknown, return None"""
+return self._nodemap.get(node)
+
+def append(self, tup):
+self._nodemap[tup[7]] = len(self)
+super(revlogoldindex, self).append(tup)
+
+def __delitem__(self, i):
+if not isinstance(i, slice) or not i.stop == -1 or i.step is not None:
+raise ValueError(b"deleting slices only supports a:-1 with step 1")
+for r in pycompat.xrange(i.start, len(self)):
+del self._nodemap[self[r][7]]
+super(revlogoldindex, self).__delitem__(i)
+
+def clearcaches(self):
+self.__dict__.pop('_nodemap', None)
+
+def __getitem__(self, i):
+if i == -1:
+return (0, 0, 0, -1, -1, -1, -1, node.nullid)
+return list.__getitem__(self, i)
+
+def pack_header(self, header):
+"""pack header information in binary"""
+return b''
+
+def entry_binary(self, rev):
+"""return the raw binary string representing a revision"""
+entry = self[rev]
+if gettype(entry[0]):
+raise error.RevlogError(
+_(b'index entry flags need revlog version 1')
+)
+e2 = (
+getoffset(entry[0]),
+entry[1],
+entry[3],
+entry[4],
+self[entry[5]][7],
+self[entry[6]][7],
+entry[7],
+)
+return INDEX_ENTRY_V0.pack(*e2)
+
+
+def parse_index_v0(data, inline):
+s = INDEX_ENTRY_V0.size
+index = []
+nodemap = nodemaputil.NodeMap({node.nullid: node.nullrev})
+n = off = 0
+l = len(data)
+while off + s <= l:
+cur = data[off : off + s]
+off += s
+e = INDEX_ENTRY_V0.unpack(cur)
+# transform to revlogv1 format
+e2 = (
+offset_type(e[0], 0),
+e[1],
+-1,
+e[2],
+e[3],
+nodemap.get(e[4], node.nullrev),
+nodemap.get(e[5], node.nullrev),
+e[6],
+)
+index.append(e2)
+nodemap[e[6]] = n
+n += 1
+
+index = revlogoldindex(index)
+return index, None
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -36,7 +36,6 @@
 from .revlogutils.constants import (
 FLAG_GENERALDELTA,
 FLAG_INLINE_DATA,
-INDEX_ENTRY_V0,
 INDEX_HEADER,
 REVLOGV0,
 REVLOGV1,
@@ -76,6 +75,7 @@
 deltas as deltautil,
 flagutil,
 nodemap as nodemaputil,
+revlogv0,
 sidedata as sidedatautil,
 )

D10508: revlog: add a `entry_binary` method on index

2021-04-28 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: indygreg.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The revlog index is already responsible for unpacking the binary entry, it 
would be
  simpler to make it responsible for packing them. In practice the C version of
  the index is already doing this internally.
  
  We introduce a "entry_binary" method that return the binary version of an
  existing revision. The method currently need to also take the revlog header to
  deal with the "first revision" special case. We will introduce further 
refactor
  in a later changeset to split that logic out.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/cext/revlog.c
  mercurial/pure/parsers.py
  mercurial/revlog.py
  rust/hg-cpython/src/revlog.rs

CHANGE DETAILS

diff --git a/rust/hg-cpython/src/revlog.rs b/rust/hg-cpython/src/revlog.rs
--- a/rust/hg-cpython/src/revlog.rs
+++ b/rust/hg-cpython/src/revlog.rs
@@ -172,6 +172,11 @@
 self.call_cindex(py, "clearcaches", args, kw)
 }
 
+/// return the raw binary string representing a revision
+def entry_binary(, *args, **kw) -> PyResult {
+self.call_cindex(py, "entry_binary", args, kw)
+}
+
 /// get an index entry
 def get(, *args, **kw) -> PyResult {
 self.call_cindex(py, "get", args, kw)
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -268,6 +268,24 @@
 return (0, 0, 0, -1, -1, -1, -1, sha1nodeconstants.nullid)
 return list.__getitem__(self, i)
 
+def entry_binary(self, rev, header):
+"""return the raw binary string representing a revision"""
+entry = self[rev]
+if gettype(entry[0]):
+raise error.RevlogError(
+_(b'index entry flags need revlog version 1')
+)
+e2 = (
+getoffset(entry[0]),
+entry[1],
+entry[3],
+entry[4],
+self[entry[5]][7],
+self[entry[6]][7],
+entry[7],
+)
+return INDEX_ENTRY_V0.pack(*e2)
+
 
 class revlogoldio(object):
 def parseindex(self, data, inline):
@@ -298,29 +316,6 @@
 index = revlogoldindex(index)
 return index, None
 
-def packentry(self, entry, node, version, rev):
-"""return the binary representation of an entry
-
-entry:   a tuple containing all the values (see index.__getitem__)
-node:a callback to convert a revision to nodeid
-version: the changelog version
-rev: the revision number
-"""
-if gettype(entry[0]):
-raise error.RevlogError(
-_(b'index entry flags need revlog version 1')
-)
-e2 = (
-getoffset(entry[0]),
-entry[1],
-entry[3],
-entry[4],
-node(entry[5]),
-node(entry[6]),
-entry[7],
-)
-return INDEX_ENTRY_V0.pack(*e2)
-
 
 # corresponds to uncompressed length of indexformatng (2 gigs, 4-byte
 # signed integer)
@@ -333,24 +328,12 @@
 index, cache = parsers.parse_index2(data, inline)
 return index, cache
 
-def packentry(self, entry, node, version, rev):
-p = INDEX_ENTRY_V1.pack(*entry)
-if rev == 0:
-p = INDEX_HEADER.pack(version) + p[4:]
-return p
-
 
 class revlogv2io(object):
 def parseindex(self, data, inline):
 index, cache = parsers.parse_index2(data, inline, revlogv2=True)
 return index, cache
 
-def packentry(self, entry, node, version, rev):
-p = INDEX_ENTRY_V2.pack(*entry)
-if rev == 0:
-p = INDEX_HEADER.pack(version) + p[4:]
-return p
-
 
 NodemapRevlogIO = None
 
@@ -2068,7 +2051,7 @@
 self._inline = False
 io = self._io
 for i in self:
-e = io.packentry(self.index[i], self.node, self.version, i)
+e = self.index.entry_binary(i, self.version)
 fp.write(e)
 
 # the temp file replace the real index when we exit the context
@@ -2390,7 +2373,7 @@
 e = e[:8]
 
 self.index.append(e)
-entry = self._io.packentry(e, self.node, self.version, curr)
+entry = self.index.entry_binary(curr, self.version)
 self._writeentry(
 transaction,
 ifh,
@@ -3243,5 +3226,5 @@
 for i, entry in enumerate(new_entries):
 rev = startrev + i
 self.index.replace_sidedata_info(rev, entry[8], entry[9])
-packed = self._io.packentry(entry, self.node, self.version, 
rev)
+packed = self.index.entry_binary(rev, self.version)
 fp.write(packed)
diff --git a/mercurial/pure/parsers.py b/mercurial/pure/parsers.py
--- 

D10512: bzr: only support bzr conversion on Python3

2021-04-28 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Python 2 support will be dropped from Mercurial before anyone needs to do a
  bzr -> hg conversion on Python 2 again. Bazaar tests were broken with the new
  lib anyway, which we'll get into in the next patches.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  tests/hghave.py

CHANGE DETAILS

diff --git a/tests/hghave.py b/tests/hghave.py
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -29,7 +29,8 @@
 stdout = getattr(sys.stdout, 'buffer', sys.stdout)
 stderr = getattr(sys.stderr, 'buffer', sys.stderr)
 
-if sys.version_info[0] >= 3:
+is_not_python2 = sys.version_info[0] >= 3
+if is_not_python2:
 
 def _sys2bytes(p):
 if p is None:
@@ -169,6 +170,8 @@
 
 @check("bzr", "Canonical's Bazaar client")
 def has_bzr():
+if not is_not_python2:
+return False
 try:
 import bzrlib
 import bzrlib.bzrdir



To: Alphare, #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


D10510: revlog: have an explicit "pack_header" method

2021-04-28 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: indygreg.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Having to pass the version header when retrieving the binary version of every 
single entry is a bit silly. So we extract that special logic in its own 
method. This also prepare the move to newer revlog format, not storing the 
header within an actual entry…

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/cext/revlog.c
  mercurial/pure/parsers.py
  mercurial/revlog.py
  rust/hg-cpython/src/revlog.rs

CHANGE DETAILS

diff --git a/rust/hg-cpython/src/revlog.rs b/rust/hg-cpython/src/revlog.rs
--- a/rust/hg-cpython/src/revlog.rs
+++ b/rust/hg-cpython/src/revlog.rs
@@ -177,6 +177,11 @@
 self.call_cindex(py, "entry_binary", args, kw)
 }
 
+/// return a binary packed version of the header
+def pack_header(, *args, **kw) -> PyResult {
+self.call_cindex(py, "pack_header", args, kw)
+}
+
 /// get an index entry
 def get(, *args, **kw) -> PyResult {
 self.call_cindex(py, "get", args, kw)
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -266,7 +266,7 @@
 return (0, 0, 0, -1, -1, -1, -1, sha1nodeconstants.nullid)
 return list.__getitem__(self, i)
 
-def entry_binary(self, rev, header):
+def entry_binary(self, rev):
 """return the raw binary string representing a revision"""
 entry = self[rev]
 if gettype(entry[0]):
@@ -284,6 +284,10 @@
 )
 return INDEX_ENTRY_V0.pack(*e2)
 
+def pack_header(self, header):
+"""Pack header information in binary"""
+return b''
+
 
 def parse_index_v0(data, inline):
 s = INDEX_ENTRY_V0.size
@@ -2041,7 +2045,10 @@
 self.version &= ~FLAG_INLINE_DATA
 self._inline = False
 for i in self:
-e = self.index.entry_binary(i, self.version)
+e = self.index.entry_binary(i)
+if i == 0:
+header = self.index.pack_header(self.version)
+e = header + e
 fp.write(e)
 
 # the temp file replace the real index when we exit the context
@@ -2363,7 +2370,10 @@
 e = e[:8]
 
 self.index.append(e)
-entry = self.index.entry_binary(curr, self.version)
+entry = self.index.entry_binary(curr)
+if curr == 0:
+header = self.index.pack_header(self.version)
+entry = header + entry
 self._writeentry(
 transaction,
 ifh,
@@ -3216,5 +3226,8 @@
 for i, entry in enumerate(new_entries):
 rev = startrev + i
 self.index.replace_sidedata_info(rev, entry[8], entry[9])
-packed = self.index.entry_binary(rev, self.version)
+packed = self.index.entry_binary(rev)
+if rev == 0:
+header = self.index.pack_header(self.version)
+packed = header + packed
 fp.write(packed)
diff --git a/mercurial/pure/parsers.py b/mercurial/pure/parsers.py
--- a/mercurial/pure/parsers.py
+++ b/mercurial/pure/parsers.py
@@ -127,14 +127,17 @@
 r = (offset_type(0, gettype(r[0])),) + r[1:]
 return r
 
-def entry_binary(self, rev, header):
+def pack_header(self, header):
+"""pack header information as binary"""
+v_fmt = revlog_constants.INDEX_HEADER
+return v_fmt.pack(header)
+
+def entry_binary(self, rev):
 """return the raw binary string representing a revision"""
 entry = self[rev]
 p = revlog_constants.INDEX_ENTRY_V1.pack(*entry)
 if rev == 0:
-v_fmt = revlog_constants.INDEX_HEADER
-v_bin = v_fmt.pack(header)
-p = v_bin + p[v_fmt.size :]
+p = p[revlog_constants.INDEX_HEADER.size :]
 return p
 
 
@@ -286,14 +289,12 @@
 msg = b"cannot rewrite entries outside of this transaction"
 raise KeyError(msg)
 
-def entry_binary(self, rev, header):
+def entry_binary(self, rev):
 """return the raw binary string representing a revision"""
 entry = self[rev]
 p = revlog_constants.INDEX_ENTRY_V2.pack(*entry)
 if rev == 0:
-v_fmt = revlog_constants.INDEX_HEADER
-v_bin = v_fmt.pack(header)
-p = v_bin + p[v_fmt.size :]
+p = p[revlog_constants.INDEX_HEADER.size :]
 return p
 
 
diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c
+++ b/mercurial/cext/revlog.c
@@ -343,18 +343,28 @@
}
 }
 /*
+ * Pack header information in binary
+ */
+static PyObject *index_pack_header(indexObject *self, PyObject *args)
+{
+   int header;
+   char 

D10506: lint: fix failing code check

2021-04-28 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
Alphare added a comment.
pulkit accepted this revision.
This revision is now accepted and ready to land.


  /!\ Meant for stable /!\

REVISION SUMMARY
  8d2b62d716b0 
 
introduced code that `test-check-code.t` wasn't happy about, this
  fixes it.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  setup.py

CHANGE DETAILS

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -438,7 +438,9 @@
 else:
 version = '0+hg' + kw.get('node', '')[:12]
 elif os.path.exists('mercurial/__version__.py'):
-data = open('mercurial/__version__.py').read()
+f = open('mercurial/__version__.py')
+data = f.read()
+f.close()
 version = re.search('version = b"(.*)"', data).group(1)
 
 if version:



To: Alphare, #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


D10507: tests: don't hard-code /bin/bash

2021-04-28 Thread joerg.sonnenberger (Joerg Sonnenberger)
joerg.sonnenberger created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
Alphare accepted this revision.
This revision is now accepted and ready to land.
joerg.sonnenberger closed this revision.
joerg.sonnenberger added a comment.


  Merged as 77e73827a02d 


REVISION SUMMARY
  From Thomas Klausner in pkgsrc.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  tests/test-transaction-rollback-on-sigpipe.t

CHANGE DETAILS

diff --git a/tests/test-transaction-rollback-on-sigpipe.t 
b/tests/test-transaction-rollback-on-sigpipe.t
--- a/tests/test-transaction-rollback-on-sigpipe.t
+++ b/tests/test-transaction-rollback-on-sigpipe.t
@@ -22,14 +22,14 @@
 
   $ killable_pipe=`pwd`/killable_pipe.sh
   $ script $killable_pipe < #!/bin/bash
+  > #!/usr/bin/env bash
   > echo \$\$ >> $pidfile
   > exec cat
   > EOF
 
   $ remotecmd=`pwd`/remotecmd.sh
   $ script $remotecmd < #!/bin/bash
+  > #!/usr/bin/env bash
   > hg "\$@" 1> >($killable_pipe) 2> >($killable_pipe >&2)
   > EOF
 
@@ -38,7 +38,7 @@
 
   $ hook_script=`pwd`/pretxnchangegroup.sh
   $ script $hook_script < #!/bin/bash
+  > #!/usr/bin/env bash
   > for pid in \$(cat $pidfile) ; do
   >   kill \$pid
   >   while kill -0 \$pid 2>/dev/null ; do



To: joerg.sonnenberger, #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