D654: blackbox: unindent a try block

2017-09-06 Thread quark (Jun Wu)
quark created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The try block is no longer necessary.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/blackbox.py

CHANGE DETAILS

diff --git a/hgext/blackbox.py b/hgext/blackbox.py
--- a/hgext/blackbox.py
+++ b/hgext/blackbox.py
@@ -146,40 +146,37 @@
 if ui._bbinlog:
 # recursion and failure guard
 return
+ui._bbinlog = True
+default = self.configdate('devel', 'default-date')
+date = util.datestr(default, '%Y/%m/%d %H:%M:%S')
+user = util.getuser()
+pid = '%d' % util.getpid()
+formattedmsg = msg[0] % msg[1:]
+rev = '(unknown)'
+changed = ''
+if ui._bbrepo:
+ctx = ui._bbrepo[None]
+parents = ctx.parents()
+rev = ('+'.join([hex(p.node()) for p in parents]))
+if (ui.configbool('blackbox', 'dirty') and
+ctx.dirty(missing=True, merge=False, branch=False)):
+changed = '+'
+if ui.configbool('blackbox', 'logsource'):
+src = ' [%s]' % event
+else:
+src = ''
 try:
-ui._bbinlog = True
-default = self.configdate('devel', 'default-date')
-date = util.datestr(default, '%Y/%m/%d %H:%M:%S')
-user = util.getuser()
-pid = '%d' % util.getpid()
-formattedmsg = msg[0] % msg[1:]
-rev = '(unknown)'
-changed = ''
-if ui._bbrepo:
-ctx = ui._bbrepo[None]
-parents = ctx.parents()
-rev = ('+'.join([hex(p.node()) for p in parents]))
-if (ui.configbool('blackbox', 'dirty') and
-ctx.dirty(missing=True, merge=False, branch=False)):
-changed = '+'
-if ui.configbool('blackbox', 'logsource'):
-src = ' [%s]' % event
-else:
-src = ''
-try:
-fmt = '%s %s @%s%s (%s)%s> %s'
-args = (date, user, rev, changed, pid, src, formattedmsg)
-with ui._openlogfile() as fp:
-fp.write(fmt % args)
-except (IOError, OSError) as err:
-self.debug('warning: cannot write to blackbox.log: %s\n' %
-   err.strerror)
-# do not restore _bbinlog intentionally to avoid failed
-# logging again
-else:
-ui._bbinlog = False
-finally:
-pass
+fmt = '%s %s @%s%s (%s)%s> %s'
+args = (date, user, rev, changed, pid, src, formattedmsg)
+with ui._openlogfile() as fp:
+fp.write(fmt % args)
+except (IOError, OSError) as err:
+self.debug('warning: cannot write to blackbox.log: %s\n' %
+   err.strerror)
+# do not restore _bbinlog intentionally to avoid failed
+# logging again
+else:
+ui._bbinlog = False
 
 def setrepo(self, repo):
 self._bbinlog = False



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


D653: blackbox: remove blackboxui.copy

2017-09-06 Thread quark (Jun Wu)
quark created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  It's equivalent to its parent class. Therefore removed.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/blackbox.py

CHANGE DETAILS

diff --git a/hgext/blackbox.py b/hgext/blackbox.py
--- a/hgext/blackbox.py
+++ b/hgext/blackbox.py
@@ -80,9 +80,6 @@
 self._bbinlog = False
 self._bbrepo = getattr(src, '_bbrepo', None)
 
-def copy(self):
-return self.__class__(self)
-
 @property
 def _bbvfs(self):
 repo = getattr(self, '_bbrepo', None)



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


D652: blackbox: remove _partialinit

2017-09-06 Thread quark (Jun Wu)
quark created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  It's no longer needed.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/blackbox.py

CHANGE DETAILS

diff --git a/hgext/blackbox.py b/hgext/blackbox.py
--- a/hgext/blackbox.py
+++ b/hgext/blackbox.py
@@ -77,20 +77,10 @@
 class blackboxui(ui.__class__):
 def __init__(self, src=None):
 super(blackboxui, self).__init__(src)
-if src is None:
-self._partialinit()
-else:
-self._bbinlog = False
-self._bbrepo = getattr(src, '_bbrepo', None)
-
-def _partialinit(self):
-if self._bbvfs:
-return
 self._bbinlog = False
-self._bbrepo = None
+self._bbrepo = getattr(src, '_bbrepo', None)
 
 def copy(self):
-self._partialinit()
 return self.__class__(self)
 
 @property
@@ -140,7 +130,6 @@
 def log(self, event, *msg, **opts):
 global lastui
 super(blackboxui, self).log(event, *msg, **opts)
-self._partialinit()
 
 if not '*' in self.track and not event in self.track:
 return



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


D648: blackbox: fix rotation with chg

2017-09-06 Thread quark (Jun Wu)
quark created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The added test will show:
  
$ $PYTHON showsize.py .hg/blackbox*
.hg/blackbox.log: < 500
.hg/blackbox.log.1: < 500
.hg/blackbox.log.2: < 500
.hg/blackbox.log.3: < 500
.hg/blackbox.log.4: < 500
.hg/blackbox.log.5: >= 500
  
  with previous code.
  
  The issue is caused by blackbox caching file objects, and the rotation size
  check runs on a wrong file object (i.e. it should check "blackbox.log", but
  filehandlers["blackbox.log"] contains a file object that has been renamed to
  "blackbox.log.5").
  
  This patch removes the "filehandlers" global cache added by 
https://phab.mercurial-scm.org/rHG45313f5a3a8c34ce02f6cb0863386eb0cea534ac to
  solve the issue.

REPOSITORY
  rHG Mercurial

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

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

CHANGE DETAILS

diff --git a/tests/test-blackbox.t b/tests/test-blackbox.t
--- a/tests/test-blackbox.t
+++ b/tests/test-blackbox.t
@@ -230,3 +230,58 @@
 
 cleanup
   $ cd ..
+
+#if chg
+
+when using chg, blackbox.log should get rotated correctly
+
+  $ cat > $TESTTMP/noop.py << EOF
+  > from __future__ import absolute_import
+  > import time
+  > from mercurial import registrar, scmutil
+  > cmdtable = {}
+  > command = registrar.command(cmdtable)
+  > @command('noop')
+  > def noop(ui, repo):
+  > pass
+  > EOF
+
+  $ hg init blackbox-chg
+  $ cd blackbox-chg
+
+  $ cat > .hg/hgrc << EOF
+  > [blackbox]
+  > maxsize = 500B
+  > [extensions]
+  > # extension change forces chg to restart
+  > noop=$TESTTMP/noop.py
+  > EOF
+
+  $ $PYTHON -c 'print("a" * 400)' > .hg/blackbox.log
+  $ chg noop
+  $ chg noop
+  $ chg noop
+  $ chg noop
+  $ chg noop
+
+  $ cat > showsize.py << 'EOF'
+  > import os, sys
+  > limit = 500
+  > for p in sys.argv[1:]:
+  > size = os.stat(p).st_size
+  > if size >= limit:
+  > desc = '>='
+  > else:
+  > desc = '<'
+  > print('%s: %s %d' % (p, desc, limit))
+  > EOF
+
+  $ $PYTHON showsize.py .hg/blackbox*
+  .hg/blackbox.log: < 500
+  .hg/blackbox.log.1: >= 500
+  .hg/blackbox.log.2: >= 500
+
+  $ cd ..
+
+#endif
+
diff --git a/hgext/blackbox.py b/hgext/blackbox.py
--- a/hgext/blackbox.py
+++ b/hgext/blackbox.py
@@ -73,21 +73,6 @@
 
 lastui = None
 
-filehandles = {}
-
-def _openlog(vfs):
-path = vfs.join('blackbox.log')
-if path in filehandles:
-return filehandles[path]
-filehandles[path] = fp = vfs('blackbox.log', 'a')
-return fp
-
-def _closelog(vfs):
-path = vfs.join('blackbox.log')
-fp = filehandles[path]
-del filehandles[path]
-fp.close()
-
 def wrapui(ui):
 class blackboxui(ui.__class__):
 def __init__(self, src=None):
@@ -132,21 +117,23 @@
 self.debug("warning: cannot rename '%s' to '%s': %s\n" 
%
(newpath, oldpath, err.strerror))
 
-fp = _openlog(self._bbvfs)
 maxsize = self.configbytes('blackbox', 'maxsize')
+name = 'blackbox.log'
 if maxsize > 0:
-st = self._bbvfs.fstat(fp)
-if st.st_size >= maxsize:
-path = fp.name
-_closelog(self._bbvfs)
-maxfiles = self.configint('blackbox', 'maxfiles', 7)
-for i in xrange(maxfiles - 1, 1, -1):
-rotate(oldpath='%s.%d' % (path, i - 1),
-   newpath='%s.%d' % (path, i))
-rotate(oldpath=path,
-   newpath=maxfiles > 0 and path + '.1')
-fp = _openlog(self._bbvfs)
-return fp
+try:
+st = self._bbvfs.stat(name)
+except OSError:
+pass
+else:
+if st.st_size >= maxsize:
+path = self._bbvfs.join(name)
+maxfiles = self.configint('blackbox', 'maxfiles', 7)
+for i in xrange(maxfiles - 1, 1, -1):
+rotate(oldpath='%s.%d' % (path, i - 1),
+   newpath='%s.%d' % (path, i))
+rotate(oldpath=path,
+   newpath=maxfiles > 0 and path + '.1')
+return self._bbvfs(name, 'a')
 
 def _bbwrite(self, fmt, *args):
 self._bbfp.write(fmt % args)



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


D650: blackbox: do not cache file handler

2017-09-06 Thread quark (Jun Wu)
quark created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Having the blackbox file handler cached in `ui._bbfp` could be troublesome
  if multiple processes (ex. chg servers) have file handlers to a same file.
  
  This patch makes blackbox re-open the file every time to make the situation
  better. Ideally we also need proper locking.
  
  The caching logic traces back to the commit introducing blackbox
  (https://phab.mercurial-scm.org/rHG18242716a014eea609f09f39b190248fafde4b00). 
It does not have details about why caching is necessary.
  Consider the fact that blackbox logs are not many, it seems fine to remove
  the fp cache to be more confident.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/blackbox.py

CHANGE DETAILS

diff --git a/hgext/blackbox.py b/hgext/blackbox.py
--- a/hgext/blackbox.py
+++ b/hgext/blackbox.py
@@ -80,15 +80,13 @@
 if src is None:
 self._partialinit()
 else:
-self._bbfp = getattr(src, '_bbfp', None)
 self._bbinlog = False
 self._bbrepo = getattr(src, '_bbrepo', None)
 self._bbvfs = getattr(src, '_bbvfs', None)
 
 def _partialinit(self):
 if util.safehasattr(self, '_bbvfs'):
 return
-self._bbfp = None
 self._bbinlog = False
 self._bbrepo = None
 self._bbvfs = None
@@ -143,29 +141,20 @@
 if not '*' in self.track and not event in self.track:
 return
 
-if self._bbfp:
-ui = self
-elif self._bbvfs:
-try:
-self._bbfp = self._openlogfile()
-except (IOError, OSError) as err:
-self.debug('warning: cannot write to blackbox.log: %s\n' %
-   err.strerror)
-del self._bbvfs
-self._bbfp = None
+if self._bbvfs:
 ui = self
 else:
 # certain ui instances exist outside the context of
 # a repo, so just default to the last blackbox that
 # was seen.
 ui = lastui
 
-if not ui or not ui._bbfp:
+if not ui:
 return
 if not lastui or ui._bbrepo:
 lastui = ui
 if ui._bbinlog:
-# recursion guard
+# recursion and failure guard
 return
 try:
 ui._bbinlog = True
@@ -188,19 +177,21 @@
 else:
 src = ''
 try:
-fp = ui._bbfp
 fmt = '%s %s @%s%s (%s)%s> %s'
 args = (date, user, rev, changed, pid, src, formattedmsg)
-fp.write(fmt % args)
-fp.flush()
-except IOError as err:
+with ui._openlogfile() as fp:
+fp.write(fmt % args)
+except (IOError, OSError) as err:
 self.debug('warning: cannot write to blackbox.log: %s\n' %
err.strerror)
+# do not restore _bbinlog intentionally to avoid failed
+# logging again
+else:
+ui._bbinlog = False
 finally:
-ui._bbinlog = False
+pass
 
 def setrepo(self, repo):
-self._bbfp = None
 self._bbinlog = False
 self._bbrepo = repo
 self._bbvfs = repo.vfs



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


D649: blackbox: inline _bbwrite

2017-09-06 Thread quark (Jun Wu)
quark created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  There is no need to make it a separate method. This makes the next change
  easier to read.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/blackbox.py

CHANGE DETAILS

diff --git a/hgext/blackbox.py b/hgext/blackbox.py
--- a/hgext/blackbox.py
+++ b/hgext/blackbox.py
@@ -135,10 +135,6 @@
newpath=maxfiles > 0 and path + '.1')
 return self._bbvfs(name, 'a')
 
-def _bbwrite(self, fmt, *args):
-self._bbfp.write(fmt % args)
-self._bbfp.flush()
-
 def log(self, event, *msg, **opts):
 global lastui
 super(blackboxui, self).log(event, *msg, **opts)
@@ -192,8 +188,11 @@
 else:
 src = ''
 try:
-ui._bbwrite('%s %s @%s%s (%s)%s> %s',
-date, user, rev, changed, pid, src, formattedmsg)
+fp = ui._bbfp
+fmt = '%s %s @%s%s (%s)%s> %s'
+args = (date, user, rev, changed, pid, src, formattedmsg)
+fp.write(fmt % args)
+fp.flush()
 except IOError as err:
 self.debug('warning: cannot write to blackbox.log: %s\n' %
err.strerror)



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


D651: blackbox: remove _bbvfs state

2017-09-06 Thread quark (Jun Wu)
quark created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  `_bbvfs` is redundant because it could be calcualted from `_bbrepo`.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/blackbox.py

CHANGE DETAILS

diff --git a/hgext/blackbox.py b/hgext/blackbox.py
--- a/hgext/blackbox.py
+++ b/hgext/blackbox.py
@@ -82,19 +82,23 @@
 else:
 self._bbinlog = False
 self._bbrepo = getattr(src, '_bbrepo', None)
-self._bbvfs = getattr(src, '_bbvfs', None)
 
 def _partialinit(self):
-if util.safehasattr(self, '_bbvfs'):
+if self._bbvfs:
 return
 self._bbinlog = False
 self._bbrepo = None
-self._bbvfs = None
 
 def copy(self):
 self._partialinit()
 return self.__class__(self)
 
+@property
+def _bbvfs(self):
+repo = getattr(self, '_bbrepo', None)
+if repo:
+return repo.vfs
+
 @util.propertycache
 def track(self):
 return self.configlist('blackbox', 'track', ['*'])
@@ -194,7 +198,6 @@
 def setrepo(self, repo):
 self._bbinlog = False
 self._bbrepo = repo
-self._bbvfs = repo.vfs
 
 ui.__class__ = blackboxui
 uimod.ui = blackboxui



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


[Bug 5676] New: debuginstall fails when trying to json-format exception

2017-09-06 Thread mercurial-bugs
https://bz.mercurial-scm.org/show_bug.cgi?id=5676

Bug ID: 5676
   Summary: debuginstall fails when trying to json-format
exception
   Product: Mercurial
   Version: default branch
  Hardware: PC
OS: Linux
Status: UNCONFIRMED
  Severity: bug
  Priority: wish
 Component: Mercurial
  Assignee: bugzi...@mercurial-scm.org
  Reporter: martinv...@google.com
CC: mercurial-devel@mercurial-scm.org

Repro:

$ hg --config 'ui.username=' debuginstall -Tjson

  File "/usr/lib/python2.7/dist-packages/mercurial/debugcommands.py", line
1133, in debuginstall
fm.end()
  File "/usr/lib/python2.7/dist-packages/mercurial/formatter.py", line 331, in
end
baseformatter.end(self)
  File "/usr/lib/python2.7/dist-packages/mercurial/formatter.py", line 216, in
end
self._showitem()
  File "/usr/lib/python2.7/dist-packages/mercurial/formatter.py", line 327, in
_showitem
u = templatefilters.json(v, paranoid=False)
  File "/usr/lib/python2.7/dist-packages/mercurial/templatefilters.py", line
245, in json
raise TypeError('cannot encode type %s' % obj.__class__.__name__)
TypeError: cannot encode type Abort

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D612: directaccess: add a hiddenlevel argument to registrar.command

2017-09-06 Thread durham (Durham Goode)
durham added inline comments.

INLINE COMMENTS

> registrar.py:142
> +(recoverable write command)
> +2: Can access the hidden commits without any warnings (read command)
>  """

I think an enum would be better here (UNRECOVERABLE_WRITE, RECOVERABLE_WRITE, 
READ_ONLY).  Especially because I think people generally copy and paste the 
registrar decorators from other functions, and if we're just specifying numbers 
they are more likely to just reuse whatever value they copied.

REPOSITORY
  rHG Mercurial

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

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


D646: changegroup: fix to allow empty manifest parts

2017-09-06 Thread durham (Durham Goode)
durham created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The current chunk reading algorithm relied on counting the number of empty
  chunks and comparing it to the number of chunk lists it expected (1 list of
  files for cg1 and cg2, and 1 list of files + 1 list of trees for cg3). This
  implicitly assumed that both the changelog part and the manifestlog part were
  never empty (since them being empty would cause it to count it as one list 
being
  done, and screw up the count). In our treemanifest code, the manifest section
  could be empty, so we need to handle that case.
  
  This patches refactors that code to be more explicit about how it counts the
  expected parts.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/changegroup.py

CHANGE DETAILS

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -199,23 +199,36 @@
 network API. To do so, it parse the changegroup data, otherwise it will
 block in case of sshrepo because it don't know the end of the stream.
 """
-# an empty chunkgroup is the end of the changegroup
-# a changegroup has at least 2 chunkgroups (changelog and manifest).
-# after that, changegroup versions 1 and 2 have a series of groups
-# with one group per file. changegroup 3 has a series of directory
-# manifests before the files.
-count = 0
-emptycount = 0
-while emptycount < self._grouplistcount:
-empty = True
-count += 1
+# For changegroup 1 and 2, we expect 3 parts: changelog, manifestlog,
+# and a list of filelogs. For changegroup 3, we expect 4 parts:
+# changelog, manifestlog, a list of tree manifestlogs, and a list of
+# filelogs.
+#
+# Changelog and manifestlog parts are terminated with empty chunks. The
+# tree and file parts are a list of entry sections. Each entry section
+# is a series of chunks terminating in an empty chunk. The list of 
these
+# entry sections is terminated in yet another empty chunk, so we know
+# we've reached the end of the tree/file list when we reach an empty
+# chunk that was proceeded by no non-empty chunks.
+
+parts = 0
+while parts < 2 + self._grouplistcount:
+noentries = True
 while True:
 chunk = getchunk(self)
 if not chunk:
-if empty and count > 2:
-emptycount += 1
+# The first two empty chunks represent the end of the
+# changelog and the manifestlog portions. The remaining
+# empty chunks represent either A) the end of individual
+# tree or file entries in the file list, or B) the end of
+# the entire list. It's the end of the entire list if there
+# were no entries (i.e. empty is True).
+if parts < 2:
+parts += 1
+elif noentries:
+parts += 1
 break
-empty = False
+noentries = False
 yield chunkheader(len(chunk))
 pos = 0
 while pos < len(chunk):



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


D644: rebase: remove complex unhiding code

2017-09-06 Thread quark (Jun Wu)
quark updated this revision to Diff 1644.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D644?vs=1642=1644

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

AFFECTED FILES
  hgext/rebase.py

CHANGE DETAILS

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -44,7 +44,6 @@
 phases,
 registrar,
 repair,
-repoview,
 revset,
 revsetlang,
 scmutil,
@@ -137,7 +136,17 @@
 if opts is None:
 opts = {}
 
-self.repo = repo
+# prepared: whether we have rebasestate prepared or not. Currently it
+# decides whether "self.repo" is unfiltered or not.
+# The rebasestate has explicit hash to hash instructions not depending
+# on visibility. If rebasestate exists (in-memory or on-disk), use
+# unfiltered repo to avoid visibility issues.
+# Before knowing rebasestate (i.e. when starting a new rebase (not
+# --continue or --abort)), the original repo should be used so
+# visibility-dependent revsets are correct.
+self.prepared = False
+self._repo = repo
+
 self.ui = ui
 self.opts = opts
 self.originalwd = None
@@ -166,6 +175,13 @@
 self.keepopen = opts.get('keepopen', False)
 self.obsoletenotrebased = {}
 
+@property
+def repo(self):
+if self.prepared:
+return self._repo.unfiltered()
+else:
+return self._repo
+
 def storestatus(self, tr=None):
 """Store the current status to allow recovery"""
 if tr:
@@ -198,6 +214,7 @@
 
 def restorestatus(self):
 """Restore a previously stored status"""
+self.prepared = True
 repo = self.repo.unfiltered()
 keepbranches = None
 legacydest = None
@@ -266,7 +283,6 @@
 repo.ui.debug('computed skipped revs: %s\n' %
 (' '.join(str(r) for r in sorted(skipped)) or None))
 repo.ui.debug('rebase status resumed\n')
-_setrebasesetvisibility(repo, set(state.keys()) | {originalwd})
 
 self.originalwd = originalwd
 self.destmap = destmap
@@ -356,6 +372,8 @@
 if dest.closesbranch() and not self.keepbranchesf:
 self.ui.status(_('reopening closed branch head %s\n') % dest)
 
+self.prepared = True
+
 def _performrebase(self, tr):
 repo, ui = self.repo, self.ui
 if self.keepbranchesf:
@@ -1323,7 +1341,6 @@
 
 def clearstatus(repo):
 'Remove the status files'
-_clearrebasesetvisibiliy(repo)
 # Make sure the active transaction won't write the state file
 tr = repo.currenttransaction()
 if tr:
@@ -1438,7 +1455,6 @@
 '''
 rebaseset = destmap.keys()
 originalwd = repo['.'].rev()
-_setrebasesetvisibility(repo, set(rebaseset) | {originalwd})
 
 # This check isn't strictly necessary, since mq detects commits over an
 # applied patch. But it prevents messing up the working directory when
@@ -1580,30 +1596,6 @@
 
 return ret
 
-def _setrebasesetvisibility(repo, revs):
-"""store the currently rebased set on the repo object
-
-This is used by another function to prevent rebased revision to because
-hidden (see issue4504)"""
-repo = repo.unfiltered()
-repo._rebaseset = revs
-# invalidate cache if visibility changes
-hiddens = repo.filteredrevcache.get('visible', set())
-if revs & hiddens:
-repo.invalidatevolatilesets()
-
-def _clearrebasesetvisibiliy(repo):
-"""remove rebaseset data from the repo"""
-repo = repo.unfiltered()
-if '_rebaseset' in vars(repo):
-del repo._rebaseset
-
-def _rebasedvisible(orig, repo):
-"""ensure rebased revs stay visible (see issue4504)"""
-blockers = orig(repo)
-blockers.update(getattr(repo, '_rebaseset', ()))
-return blockers
-
 def _filterobsoleterevs(repo, revs):
 """returns a set of the obsolete revisions in revs"""
 return set(r for r in revs if repo[r].obsolete())
@@ -1668,5 +1660,3 @@
  _("use 'hg rebase --continue' or 'hg rebase --abort'")])
 cmdutil.afterresolvedstates.append(
 ['rebasestate', _('hg rebase --continue')])
-# ensure rebased rev are not hidden
-extensions.wrapfunction(repoview, 'pinnedrevs', _rebasedvisible)



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


D645: rebase: remove unnecessary '.unfiltered()' calls

2017-09-06 Thread quark (Jun Wu)
quark updated this revision to Diff 1645.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D645?vs=1643=1645

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

AFFECTED FILES
  hgext/rebase.py

CHANGE DETAILS

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -192,7 +192,8 @@
 self._writestatus(f)
 
 def _writestatus(self, f):
-repo = self.repo.unfiltered()
+repo = self.repo
+assert repo.filtername is None
 f.write(repo[self.originalwd].hex() + '\n')
 # was "dest". we now write dest per src root below.
 f.write('\n')
@@ -215,7 +216,8 @@
 def restorestatus(self):
 """Restore a previously stored status"""
 self.prepared = True
-repo = self.repo.unfiltered()
+repo = self.repo
+assert repo.filtername is None
 keepbranches = None
 legacydest = None
 collapse = False
@@ -1067,9 +1069,9 @@
   "experimental.allowdivergence=True")
 raise error.Abort(msg % (",".join(divhashes),), hint=h)
 
-def successorrevs(repo, rev):
+def successorrevs(unfi, rev):
 """yield revision numbers for successors of rev"""
-unfi = repo.unfiltered()
+assert unfi.filtername is None
 nodemap = unfi.changelog.nodemap
 for s in obsutil.allsuccessors(unfi.obsstore, [unfi[rev].node()]):
 if s in nodemap:
@@ -1091,7 +1093,8 @@
 block below.
 """
 # use unfiltered changelog since successorrevs may return filtered nodes
-cl = repo.unfiltered().changelog
+assert repo.filtername is None
+cl = repo.changelog
 def isancestor(a, b):
 # take revision numbers instead of nodes
 if a == b:
@@ -1607,7 +1610,8 @@
 obsolete => None entries in the mapping indicate nodes with no successor"""
 obsoletenotrebased = {}
 
-cl = repo.unfiltered().changelog
+assert repo.filtername is None
+cl = repo.changelog
 nodemap = cl.nodemap
 for srcrev in rebaseobsrevs:
 srcnode = cl.node(srcrev)



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


D643: rebase: use unfiltered repo when loading state

2017-09-06 Thread quark (Jun Wu)
quark updated this revision to Diff 1641.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D643?vs=1640=1641

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

AFFECTED FILES
  hgext/rebase.py
  tests/test-rebase-obsolete.t

CHANGE DETAILS

diff --git a/tests/test-rebase-obsolete.t b/tests/test-rebase-obsolete.t
--- a/tests/test-rebase-obsolete.t
+++ b/tests/test-rebase-obsolete.t
@@ -1301,3 +1301,73 @@
/
   o  0:426bada5c675 A
   
+For some reasons (--hidden, rebaseskipobsolete=0, directaccess, etc.),
+rebasestate may contain hidden hashes. "rebase --abort" should work regardless.
+
+  $ hg init $TESTTMP/hidden-state1
+  $ cd $TESTTMP/hidden-state1
+  $ cat >> .hg/hgrc < [experimental]
+  > rebaseskipobsolete=0
+  > EOF
+
+  $ hg debugdrawdag <<'EOS'
+  >C
+  >|
+  >  D B # prune: B, C
+  >  |/  # B/D=B
+  >  A
+  > EOS
+
+  $ eval `hg tags -T '{tag}={node}\n'`
+  $ rm .hg/localtags
+
+  $ hg update -q $C --hidden
+  $ hg rebase -s $B -d $D
+  rebasing 1:2ec65233581b "B"
+  merging D
+  warning: conflicts while merging D! (edit, then use 'hg resolve --mark')
+  unresolved conflicts (see hg resolve, then hg rebase --continue)
+  [1]
+
+  $ cp -R . $TESTTMP/hidden-state2
+
+  $ hg log -G
+  @  2:b18e25de2cf5 D
+  |
+  | @  1:2ec65233581b B
+  |/
+  o  0:426bada5c675 A
+  
+  $ hg summary
+  parent: 2:b18e25de2cf5 tip
+   D
+  parent: 1:2ec65233581b  (obsolete)
+   B
+  branch: default
+  commit: 2 modified, 1 unknown, 1 unresolved (merge)
+  update: (current)
+  phases: 3 draft
+  rebase: 0 rebased, 2 remaining (rebase --continue)
+
+  $ hg rebase --abort
+  rebase aborted
+
+Also test --continue for the above case
+
+  $ cd $TESTTMP/hidden-state2
+  $ hg resolve -m
+  (no more unresolved files)
+  continue: hg rebase --continue
+  $ hg rebase --continue 
+  rebasing 1:2ec65233581b "B"
+  rebasing 3:7829726be4dc "C" (tip)
+  $ hg log -G
+  @  5:1964d5d5b547 C
+  |
+  o  4:68deb90c12a2 B
+  |
+  o  2:b18e25de2cf5 D
+  |
+  o  0:426bada5c675 A
+  
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -198,7 +198,7 @@
 
 def restorestatus(self):
 """Restore a previously stored status"""
-repo = self.repo
+repo = self.repo.unfiltered()
 keepbranches = None
 legacydest = None
 collapse = False



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


D644: rebase: remove complex unhiding code

2017-09-06 Thread quark (Jun Wu)
quark created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This is similar to Martin von Zweigbergk's previous patch [1].
  
  Previous patches are adding more `.unfiltered()` to the rebase code. So I
  wonder: are we playing whack-a-mole regarding on `unfiltered()` in rebase?
  
  Thinking about it, I believe most of the rebase code *should* just use an
  unfiltered repo. The only exception is before we figuring out a
  `rebasestate`. This patch makes it so. See added comment in code for why
  that's more reasonable.
  
  This would make the code base cleaner (not mangling the `repo` object),
  faster (no need to invalidate caches), simpler (less LOC), less error-prone
  (no need to think about what to unhide, ex. should we unhide wdir p2?), and
  future proof (other code may change visibility in an unexpected way, and
  they won't affect us, ex. directaccess may make the destination only visible
  when it's in "--dest" revset tree).
  
  [1]: 
https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-March/094277.html

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/rebase.py

CHANGE DETAILS

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -44,7 +44,6 @@
 phases,
 registrar,
 repair,
-repoview,
 revset,
 revsetlang,
 scmutil,
@@ -137,7 +136,17 @@
 if opts is None:
 opts = {}
 
-self.repo = repo
+# prepared: whether we have rebasestate prepared or not. Currently it
+# decides whether "self.repo" is unfiltered or not.
+# The rebasestate has explicit hash to hash instructions not depending
+# on visibility. If rebasestate exists (in-memory or on-disk), we can
+# should use unfiltered repo to avoid visibility issues.
+# Before knowing rebasestate (i.e. when starting a new rebase (not
+# --continue or --abort)), the original repo should be used so
+# visibility-dependent revsets are correct.
+self.prepared = False
+self._repo = repo
+
 self.ui = ui
 self.opts = opts
 self.originalwd = None
@@ -166,6 +175,13 @@
 self.keepopen = opts.get('keepopen', False)
 self.obsoletenotrebased = {}
 
+@property
+def repo(self):
+if self.prepared:
+return self._repo.unfiltered()
+else:
+return self._repo
+
 def storestatus(self, tr=None):
 """Store the current status to allow recovery"""
 if tr:
@@ -198,6 +214,7 @@
 
 def restorestatus(self):
 """Restore a previously stored status"""
+self.prepared = True
 repo = self.repo.unfiltered()
 keepbranches = None
 legacydest = None
@@ -266,7 +283,6 @@
 repo.ui.debug('computed skipped revs: %s\n' %
 (' '.join(str(r) for r in sorted(skipped)) or None))
 repo.ui.debug('rebase status resumed\n')
-_setrebasesetvisibility(repo, set(state.keys()) | {originalwd})
 
 self.originalwd = originalwd
 self.destmap = destmap
@@ -356,6 +372,8 @@
 if dest.closesbranch() and not self.keepbranchesf:
 self.ui.status(_('reopening closed branch head %s\n') % dest)
 
+self.prepared = True
+
 def _performrebase(self, tr):
 repo, ui = self.repo, self.ui
 if self.keepbranchesf:
@@ -1323,7 +1341,6 @@
 
 def clearstatus(repo):
 'Remove the status files'
-_clearrebasesetvisibiliy(repo)
 # Make sure the active transaction won't write the state file
 tr = repo.currenttransaction()
 if tr:
@@ -1438,7 +1455,6 @@
 '''
 rebaseset = destmap.keys()
 originalwd = repo['.'].rev()
-_setrebasesetvisibility(repo, set(rebaseset) | {originalwd})
 
 # This check isn't strictly necessary, since mq detects commits over an
 # applied patch. But it prevents messing up the working directory when
@@ -1580,30 +1596,6 @@
 
 return ret
 
-def _setrebasesetvisibility(repo, revs):
-"""store the currently rebased set on the repo object
-
-This is used by another function to prevent rebased revision to because
-hidden (see issue4504)"""
-repo = repo.unfiltered()
-repo._rebaseset = revs
-# invalidate cache if visibility changes
-hiddens = repo.filteredrevcache.get('visible', set())
-if revs & hiddens:
-repo.invalidatevolatilesets()
-
-def _clearrebasesetvisibiliy(repo):
-"""remove rebaseset data from the repo"""
-repo = repo.unfiltered()
-if '_rebaseset' in vars(repo):
-del repo._rebaseset
-
-def _rebasedvisible(orig, repo):
-"""ensure rebased revs stay visible (see issue4504)"""
-blockers = orig(repo)
-blockers.update(getattr(repo, '_rebaseset', ()))
-return blockers
-
 def _filterobsoleterevs(repo, revs):
 """returns a set of the 

D645: rebase: remove unnecessary '.unfiltered()' calls

2017-09-06 Thread quark (Jun Wu)
quark created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Now we have a clear centric place to control whether `rbstr.repo` is
  unfiltered or not, we can drop `unfiltered()` in other places.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/rebase.py

CHANGE DETAILS

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -192,7 +192,8 @@
 self._writestatus(f)
 
 def _writestatus(self, f):
-repo = self.repo.unfiltered()
+repo = self.repo
+assert repo.filtername is None
 f.write(repo[self.originalwd].hex() + '\n')
 # was "dest". we now write dest per src root below.
 f.write('\n')
@@ -215,7 +216,8 @@
 def restorestatus(self):
 """Restore a previously stored status"""
 self.prepared = True
-repo = self.repo.unfiltered()
+repo = self.repo
+assert repo.filtername is None
 keepbranches = None
 legacydest = None
 collapse = False
@@ -1067,9 +1069,9 @@
   "experimental.allowdivergence=True")
 raise error.Abort(msg % (",".join(divhashes),), hint=h)
 
-def successorrevs(repo, rev):
+def successorrevs(unfi, rev):
 """yield revision numbers for successors of rev"""
-unfi = repo.unfiltered()
+assert unfi.filtername is None
 nodemap = unfi.changelog.nodemap
 for s in obsutil.allsuccessors(unfi.obsstore, [unfi[rev].node()]):
 if s in nodemap:
@@ -1091,7 +1093,8 @@
 block below.
 """
 # use unfiltered changelog since successorrevs may return filtered nodes
-cl = repo.unfiltered().changelog
+assert repo.filtername is None
+cl = repo.changelog
 def isancestor(a, b):
 # take revision numbers instead of nodes
 if a == b:
@@ -1607,7 +1610,8 @@
 obsolete => None entries in the mapping indicate nodes with no successor"""
 obsoletenotrebased = {}
 
-cl = repo.unfiltered().changelog
+assert repo.filtername is None
+cl = repo.changelog
 nodemap = cl.nodemap
 for srcrev in rebaseobsrevs:
 srcnode = cl.node(srcrev)



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


D529: uncommit: move fb-extension to core which uncommits a changeset

2017-09-06 Thread martinvonz (Martin von Zweigbergk)
martinvonz added inline comments.

INLINE COMMENTS

> uncommit.py:16
> +files to their uncommitted state. This means that files modified or
> +deleted in the changeset will be left unchanged, and so will remain modified 
> in
> +the working directory.

How about added files? Also, I think we use "removed" for tracked changes 
("deleted" for untracked removal of file).

> uncommit.py:99
> +copies = dict(ds.copies())
> +m, a, r = repo.status(oldctx.p1(), oldctx, match=match)[:3]
> +for f in m:

I prefer the form that doesn't depend on the order in the status tuple:

  s = repo.status(...)
  for f in s.added:
  ...

> uncommit.py:148
> +if not obsolete.isenabled(repo, obsolete.createmarkersopt):
> +raise error.Abort(_("must have obsolescence enabled to uncommit"))
> +

This is inconsistent with the amend extension that Jun added. We can always add 
support for that later.

> test-uncommit.t:22
> +  
> +  uncommit some or all of a local changeset
> +  

s/some/part/ (I think)

REPOSITORY
  rHG Mercurial

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

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


D643: rebase: use unfiltered repo when loading state

2017-09-06 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a comment.


  Equally important is that --continue works after this :-)

REPOSITORY
  rHG Mercurial

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

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


D643: rebase: use unfiltered repo when loading state

2017-09-06 Thread quark (Jun Wu)
quark created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Before this patch, `rebase --abort` may fail to do the cleanup:
  
$ hg rebase --abort
rebase aborted (no revision is removed, only broken state is cleared)
  
  The added test case makes sure `--abort` works in this case.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/rebase.py
  tests/test-rebase-obsolete.t

CHANGE DETAILS

diff --git a/tests/test-rebase-obsolete.t b/tests/test-rebase-obsolete.t
--- a/tests/test-rebase-obsolete.t
+++ b/tests/test-rebase-obsolete.t
@@ -1301,3 +1301,48 @@
/
   o  0:426bada5c675 A
   
+For some reasons (--hidden, rebaseskipobsolete=0, directaccess,  etc),
+rebasestate may contain hidden hashes. "rebase --abort" should work regardless.
+
+  $ hg init $TESTTMP/hidden-state
+  $ cd $TESTTMP/hidden-state
+
+  $ hg debugdrawdag <<'EOS'
+  >C
+  >|
+  >  D B # prune: B, C
+  >  |/  # B/D=B
+  >  A
+  > EOS
+
+  $ eval `hg tags -T '{tag}={node}\n'`
+  $ rm .hg/localtags
+
+  $ hg update -q $C --hidden
+  $ hg rebase -s $B -d $D --config experimental.rebaseskipobsolete=0
+  rebasing 1:2ec65233581b "B"
+  merging D
+  warning: conflicts while merging D! (edit, then use 'hg resolve --mark')
+  unresolved conflicts (see hg resolve, then hg rebase --continue)
+  [1]
+
+  $ hg log -G
+  @  2:b18e25de2cf5 D
+  |
+  | @  1:2ec65233581b B
+  |/
+  o  0:426bada5c675 A
+  
+  $ hg summary
+  parent: 2:b18e25de2cf5 tip
+   D
+  parent: 1:2ec65233581b  (obsolete)
+   B
+  branch: default
+  commit: 2 modified, 1 unknown, 1 unresolved (merge)
+  update: (current)
+  phases: 3 draft
+  rebase: 0 rebased, 2 remaining (rebase --continue)
+
+  $ hg rebase --abort
+  rebase aborted
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -198,7 +198,7 @@
 
 def restorestatus(self):
 """Restore a previously stored status"""
-repo = self.repo
+repo = self.repo.unfiltered()
 keepbranches = None
 legacydest = None
 collapse = False



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


D632: wrapfunction: use functools.partial if possible

2017-09-06 Thread phillco (Phil Cohen)
phillco accepted this revision.
phillco added a comment.


  Nice.

REPOSITORY
  rHG Mercurial

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

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


D642: checknlink: renmae file object from 'fd' to 'fp'

2017-09-06 Thread quark (Jun Wu)
quark created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Make it clear that `fp` (`file` object) is different from `fd` (low-level
  file descriptor number).

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/util.py

CHANGE DETAILS

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -1457,24 +1457,23 @@
 
 # testfile may be open, so we need a separate file for checking to
 # work around issue2543 (or testfile may get lost on Samba shares)
-f1, f2, fd = None, None, None
+f1, f2, fp = None, None, None
 try:
 fd, f1 = tempfile.mkstemp(prefix='.%s-' % os.path.basename(testfile),
   suffix='1~', dir=os.path.dirname(testfile))
 os.close(fd)
-fd = None
 f2 = '%s2~' % f1[:-2]
 
 oslink(f1, f2)
 # nlinks() may behave differently for files on Windows shares if
 # the file is open.
-fd = posixfile(f2)
+fp = posixfile(f2)
 return nlinks(f2) > 1
 except OSError:
 return False
 finally:
-if fd is not None:
-fd.close()
+if fp is not None:
+fp.close()
 for f in (f1, f2):
 try:
 if f is not None:



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


D641: cleanup: rename "matchfn" to "match" where obviously a matcher

2017-09-06 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  We usually call matchers either "match" or "m" and reserve "matchfn"
  for functions.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/largefiles/lfcommands.py
  hgext/mq.py
  mercurial/cmdutil.py
  mercurial/commands.py
  mercurial/hgweb/webcommands.py

CHANGE DETAILS

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -,13 +,13 @@
 
 ctx = webutil.changectx(web.repo, req)
 pats = []
-matchfn = scmutil.match(ctx, [])
+match = scmutil.match(ctx, [])
 file = req.form.get('file', None)
 if file:
 pats = ['path:' + file[0]]
-matchfn = scmutil.match(ctx, pats, default='path')
+match = scmutil.match(ctx, pats, default='path')
 if pats:
-files = [f for f in ctx.manifest().keys() if matchfn(f)]
+files = [f for f in ctx.manifest().keys() if match(f)]
 if not files:
 raise ErrorResponse(HTTP_NOT_FOUND,
 'file(s) not found: %s' % file[0])
@@ -1132,7 +1132,7 @@
 req.respond(HTTP_OK, mimetype)
 
 archival.archive(web.repo, req, cnode, artype, prefix=name,
- matchfn=matchfn,
+ matchfn=match,
  subrepos=web.configbool("web", "archivesubrepos"))
 return []
 
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -477,9 +477,9 @@
 prefix = os.path.basename(repo.root) + '-%h'
 
 prefix = cmdutil.makefilename(repo, prefix, node)
-matchfn = scmutil.match(ctx, [], opts)
+match = scmutil.match(ctx, [], opts)
 archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
- matchfn, prefix, subrepos=opts.get('subrepos'))
+ match, prefix, subrepos=opts.get('subrepos'))
 
 @command('backout',
 [('', 'merge', None, _('merge with old dirstate parent after backout')),
@@ -2489,7 +2489,7 @@
 
 skip = {}
 revfiles = {}
-matchfn = scmutil.match(repo[None], pats, opts)
+match = scmutil.match(repo[None], pats, opts)
 found = False
 follow = opts.get('follow')
 
@@ -2530,7 +2530,7 @@
 
 ui.pager('grep')
 fm = ui.formatter('grep', opts)
-for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
+for ctx in cmdutil.walkchangerevs(repo, match, opts, prep):
 rev = ctx.rev()
 parent = ctx.p1().rev()
 for fn in sorted(revfiles.get(rev, [])):
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2002,19 +2002,19 @@
 regular display via changeset_printer() is done.
 """
 # options
-matchfn = None
+match = None
 if opts.get('patch') or opts.get('stat'):
-matchfn = scmutil.matchall(repo)
+match = scmutil.matchall(repo)
 
 if opts.get('template') == 'json':
-return jsonchangeset(ui, repo, matchfn, opts, buffered)
+return jsonchangeset(ui, repo, match, opts, buffered)
 
 spec = _lookuplogtemplate(ui, opts.get('template'), opts.get('style'))
 
 if not spec.ref and not spec.tmpl and not spec.mapfile:
-return changeset_printer(ui, repo, matchfn, opts, buffered)
-
-return changeset_templater(ui, repo, spec, matchfn, opts, buffered)
+return changeset_printer(ui, repo, match, opts, buffered)
+
+return changeset_templater(ui, repo, spec, match, opts, buffered)
 
 def showmarker(fm, marker, index=None):
 """utility function to display obsolescence marker in a readable way
diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -1664,15 +1664,15 @@
 changes = repo.changelog.read(top)
 man = repo.manifestlog[changes[0]].read()
 aaa = aa[:]
-matchfn = scmutil.match(repo[None], pats, opts)
+match1 = scmutil.match(repo[None], pats, opts)
 # in short mode, we only diff the files included in the
 # patch already plus specified files
 if opts.get('short'):
 # if amending a patch, we start with existing
 # files plus specified files - unfiltered
-match = scmutil.matchfiles(repo, mm + aa + dd + 
matchfn.files())
+match = scmutil.matchfiles(repo, mm + aa + dd + match1.files())
 # filter with include/exclude options
-matchfn = scmutil.match(repo[None], opts=opts)
+match1 = scmutil.match(repo[None], opts=opts)
 else:
 match = scmutil.matchall(repo)
 m, a, r, d = repo.status(match=match)[:4]
@@ -1713,8 +1713,8 @@
 a = list(aa)
 

D640: rebase: do not crash rebasing merge with a parent having hidden successor

2017-09-06 Thread quark (Jun Wu)
quark created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The added test will crash with previous code.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/rebase.py
  tests/test-rebase-obsolete.t

CHANGE DETAILS

diff --git a/tests/test-rebase-obsolete.t b/tests/test-rebase-obsolete.t
--- a/tests/test-rebase-obsolete.t
+++ b/tests/test-rebase-obsolete.t
@@ -1267,3 +1267,37 @@
   |/
   o  A
   
+Rebasing a merge with one of its parent having a hidden successor
+
+  $ hg init $TESTTMP/merge-p1-hidden-successor
+  $ cd $TESTTMP/merge-p1-hidden-successor
+
+  $ hg debugdrawdag <<'EOS'
+  >  E
+  >  |
+  > B3 B2 # amend: B1 -> B2 -> B3
+  >  |/   # B2 is hidden
+  >  |  D
+  >  |  |\
+  >  | B1 C
+  >  |/
+  >  A
+  > EOS
+
+  $ eval `hg tags -T '{tag}={node}\n'`
+  $ rm .hg/localtags
+
+  $ hg rebase -r $D -d $E
+  rebasing 5:9e62094e4d94 "D"
+
+  $ hg log -G
+  o7:a699d059adcf D
+  |\
+  | o  6:ecc93090a95c E
+  | |
+  | o  4:0dc878468a23 B3
+  | |
+  o |  1:96cc3511f894 C
+   /
+  o  0:426bada5c675 A
+  
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -1072,7 +1072,8 @@
 The new parents of a merge is slightly more complicated. See the comment
 block below.
 """
-cl = repo.changelog
+# use unfiltered changelog since successorrevs may return filtered nodes
+cl = repo.unfiltered().changelog
 def isancestor(a, b):
 # take revision numbers instead of nodes
 if a == b:



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


D639: amend: use context manager for config override

2017-09-06 Thread singhsrb (Saurabh Singh)
singhsrb accepted this revision.
singhsrb added a comment.


  Thanks for helping out with cleaning this method!

REPOSITORY
  rHG Mercurial

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

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


D611: checknlink: use a random temp file name for checking

2017-09-06 Thread quark (Jun Wu)
quark added inline comments.

INLINE COMMENTS

> yuja wrote in util.py:1465
> Nit: here fd is a file descriptor, but later it's changed to a file
> object.  fd.close() would raise AttributeError if os.close(fd) failed.
> 
> Maybe we should rename the latter to fp or something. Can
> you send a follow up?

Good catch!

REPOSITORY
  rHG Mercurial

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

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


mercurial@34076: 12 new changesets

2017-09-06 Thread Mercurial Commits
12 new changesets in mercurial:

https://www.mercurial-scm.org/repo/hg/rev/c6c8a52e28c9
changeset:   34065:c6c8a52e28c9
user:Jun Wu 
date:Mon Aug 28 14:49:00 2017 -0700
summary: revset: optimize "draft() & ::x" pattern

https://www.mercurial-scm.org/repo/hg/rev/871a58b5f428
changeset:   34066:871a58b5f428
user:Yuya Nishihara 
date:Sun Sep 03 16:12:15 2017 +0900
summary: py3: fix type of regex literals in patch.py

https://www.mercurial-scm.org/repo/hg/rev/8b8b70cb4288
changeset:   34067:8b8b70cb4288
user:Yuya Nishihara 
date:Sun Sep 03 16:19:20 2017 +0900
summary: py3: replace bytes[n] with bytes[n:n + 1] in patch.py where needed

https://www.mercurial-scm.org/repo/hg/rev/6d21737c35bf
changeset:   34068:6d21737c35bf
user:Yuya Nishihara 
date:Sun Sep 03 15:01:23 2017 +0900
summary: py3: fix type of regex literals in subrepo.py

https://www.mercurial-scm.org/repo/hg/rev/e18119b1ad5d
changeset:   34069:e18119b1ad5d
user:Yuya Nishihara 
date:Sun Sep 03 17:03:23 2017 +0900
summary: py3: fix mixed bytes/unicode in revsetlang._aliassyminitletters

https://www.mercurial-scm.org/repo/hg/rev/01c9700fbf9f
changeset:   34070:01c9700fbf9f
user:Yuya Nishihara 
date:Sun Sep 03 17:14:53 2017 +0900
summary: py3: fix type of attribute name in smartset.py

https://www.mercurial-scm.org/repo/hg/rev/f55769e41803
changeset:   34071:f55769e41803
user:Yuya Nishihara 
date:Sun Sep 03 17:37:17 2017 +0900
summary: py3: use bytes[n:n + 1] to get bytes in templater._parsetemplate()

https://www.mercurial-scm.org/repo/hg/rev/30535fe47e78
changeset:   34072:30535fe47e78
user:Yuya Nishihara 
date:Sun Sep 03 17:51:23 2017 +0900
summary: py3: fix repr(util.url) to return system string

https://www.mercurial-scm.org/repo/hg/rev/7bbc4e113e5f
changeset:   34073:7bbc4e113e5f
user:Yuya Nishihara 
date:Sun Sep 03 21:17:25 2017 +0900
summary: parser: stabilize output of prettyformat() by using byte-safe 
repr()

https://www.mercurial-scm.org/repo/hg/rev/abf91c4f9608
changeset:   34074:abf91c4f9608
user:the31k 
date:Thu Aug 31 18:24:08 2017 +0300
summary: branches: correctly show inactive multiheaded branches

https://www.mercurial-scm.org/repo/hg/rev/a9d8caf95941
changeset:   34075:a9d8caf95941
user:Martin von Zweigbergk 
date:Thu Aug 31 22:39:10 2017 -0700
summary: largefiles: remove unused assignments from wrapfunction()

https://www.mercurial-scm.org/repo/hg/rev/cd38b83bfb23
changeset:   34076:cd38b83bfb23
bookmark:@
tag: tip
user:Phil Cohen 
date:Tue Sep 05 12:04:02 2017 -0700
summary: filemerge: use fctx.write() in the internal:dump tool, instead of 
copy

-- 
Repository URL: https://www.mercurial-scm.org/repo/hg
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D638: amend: delete dead assignment to "newid"

2017-09-06 Thread martinvonz (Martin von Zweigbergk)
martinvonz 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/D638

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
@@ -3163,7 +3163,6 @@
 return old.node()
 
 ph = repo.ui.config('phases', 'new-commit', phases.draft)
-newid = None
 try:
 if opts.get('secret'):
 commitphase = 'secret'



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


D639: amend: use context manager for config override

2017-09-06 Thread martinvonz (Martin von Zweigbergk)
martinvonz 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/D639

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
@@ -35,7 +35,6 @@
 obsolete,
 patch,
 pathutil,
-phases,
 pycompat,
 registrar,
 revlog,
@@ -3162,16 +3161,13 @@
 # This not what we expect from amend.
 return old.node()
 
-ph = repo.ui.config('phases', 'new-commit', phases.draft)
-try:
-if opts.get('secret'):
-commitphase = 'secret'
-else:
-commitphase = old.phase()
-repo.ui.setconfig('phases', 'new-commit', commitphase, 'amend')
+if opts.get('secret'):
+commitphase = 'secret'
+else:
+commitphase = old.phase()
+overrides = {('phases', 'new-commit'): commitphase}
+with ui.configoverride(overrides, 'amend'):
 newid = repo.commitctx(new)
-finally:
-repo.ui.setconfig('phases', 'new-commit', ph, 'amend')
 
 # Reroute the working copy parent to the new changeset
 repo.setparents(newid, nullid)



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


mercurial@34064: 37 new changesets

2017-09-06 Thread Mercurial Commits
37 new changesets in mercurial:

https://www.mercurial-scm.org/repo/hg/rev/bfb38c5cebf4
changeset:   34028:bfb38c5cebf4
parent:  34026:b2eb0aa445cb
user:Martin von Zweigbergk 
date:Wed Aug 30 09:21:31 2017 -0700
summary: revlog: move check for wdir from changelog to revlog

https://www.mercurial-scm.org/repo/hg/rev/6e6452bc441d
changeset:   34029:6e6452bc441d
user:Michael Bolin 
date:Wed Aug 30 20:25:56 2017 +
summary: editor: use an unambiguous path suffix for editor files

https://www.mercurial-scm.org/repo/hg/rev/e97be042fa1b
changeset:   34030:e97be042fa1b
user:Yuya Nishihara 
date:Thu Aug 31 21:56:40 2017 +0900
summary: encoding: check overflow while calculating size of JSON escape 
buffer

https://www.mercurial-scm.org/repo/hg/rev/52bd006b4f49
changeset:   34031:52bd006b4f49
user:Phil Cohen 
date:Thu Aug 31 11:05:19 2017 -0700
summary: filemerge: extract _maketemp and _makebackup

https://www.mercurial-scm.org/repo/hg/rev/67cfffbfb6a0
changeset:   34032:67cfffbfb6a0
user:Phil Cohen 
date:Thu Aug 31 11:28:59 2017 -0700
summary: filemerge: eliminate most uses of tempfiles

https://www.mercurial-scm.org/repo/hg/rev/d37f1bb68169
changeset:   34033:d37f1bb68169
user:Phil Cohen 
date:Thu Aug 31 11:28:59 2017 -0700
summary: filemerge: move a util copy call to filectx.write

https://www.mercurial-scm.org/repo/hg/rev/7558917f291e
changeset:   34034:7558917f291e
user:Phil Cohen 
date:Thu Aug 31 11:28:59 2017 -0700
summary: filemerge: add `_workingpath`

https://www.mercurial-scm.org/repo/hg/rev/96123bdea43e
changeset:   34035:96123bdea43e
user:Phil Cohen 
date:Thu Aug 31 11:28:59 2017 -0700
summary: filemerge: reduce creation of tempfiles until needed

https://www.mercurial-scm.org/repo/hg/rev/fe04c018eaac
changeset:   34036:fe04c018eaac
user:Phil Cohen 
date:Thu Aug 31 11:28:59 2017 -0700
summary: filemerge: add _restorebackup

https://www.mercurial-scm.org/repo/hg/rev/65ae54582713
changeset:   34037:65ae54582713
user:Phil Cohen 
date:Thu Aug 31 11:28:59 2017 -0700
summary: merge: move some of the logic in batchget() to workingfilectx

https://www.mercurial-scm.org/repo/hg/rev/bc2535238de2
changeset:   34038:bc2535238de2
user:Jun Wu 
date:Mon Aug 28 13:43:25 2017 -0700
summary: import-checker: allow relative import a module being checked

https://www.mercurial-scm.org/repo/hg/rev/72b23c9452d6
changeset:   34039:72b23c9452d6
user:Jun Wu 
date:Wed Aug 02 21:01:38 2017 -0700
summary: run-tests: pass --with-hg to run-tests.py command used by bisect

https://www.mercurial-scm.org/repo/hg/rev/85bfd6a0bdbf
changeset:   34040:85bfd6a0bdbf
user:Jun Wu 
date:Wed Aug 02 21:01:38 2017 -0700
summary: run-tests: extract prefix of bisect commands to a variable

https://www.mercurial-scm.org/repo/hg/rev/40313c63da87
changeset:   34041:40313c63da87
user:Jun Wu 
date:Wed Aug 02 21:24:29 2017 -0700
summary: run-tests: allow bisecting a different repo

https://www.mercurial-scm.org/repo/hg/rev/c0170d88ed2b
changeset:   34042:c0170d88ed2b
user:Pulkit Goyal <7895pul...@gmail.com>
date:Wed Aug 30 18:19:14 2017 +0530
summary: patch: take messages out of the function so that extensions can 
add entries

https://www.mercurial-scm.org/repo/hg/rev/90896b61fe26
changeset:   34043:90896b61fe26
user:Yuya Nishihara 
date:Wed Feb 17 21:30:04 2016 +0900
summary: parser: add helper function that constructs parsed tree from 
template

https://www.mercurial-scm.org/repo/hg/rev/b862e6fca7ac
changeset:   34044:b862e6fca7ac
user:Yuya Nishihara 
date:Wed Feb 17 21:38:25 2016 +0900
summary: revsetlang: build optimized tree by helper function

https://www.mercurial-scm.org/repo/hg/rev/79681d8ee587
changeset:   34045:79681d8ee587
user:Yuya Nishihara 
date:Wed Feb 17 21:31:09 2016 +0900
summary: parser: add helper function to test if pattern matches parsed tree

https://www.mercurial-scm.org/repo/hg/rev/f23cbca9b277
changeset:   34046:f23cbca9b277
user:Yuya Nishihara 
date:Wed Feb 17 21:40:59 2016 +0900
summary: revsetlang: match tree by helper function on optimize

https://www.mercurial-scm.org/repo/hg/rev/b2c691d75d93
changeset:   34047:b2c691d75d93
user:Yuya Nishihara 
date:Sat Aug 19 22:04:03 2017 +0900
summary: revsetlang: remove unused functions

https://www.mercurial-scm.org/repo/hg/rev/0e0ac8f09048
changeset:   34048:0e0ac8f09048
user:Christophe 

D637: check-code: fix incorrect capitalization in camelcase regex

2017-09-06 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This was found internally at Google as part of a monorepo-wide
  cleanup.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  contrib/check-code.py

CHANGE DETAILS

diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -262,7 +262,7 @@
 (r'(\S[ \t]+|^[ \t]+)\n', "trailing whitespace"),
 #(r'^\s+[^_ \n][^_. \n]+_[^_\n]+\s*=',
 # "don't use underbars in identifiers"),
-(r'^\s+(self\.)?[A-za-z][a-z0-9]+[A-Z]\w* = ',
+(r'^\s+(self\.)?[A-Za-z][a-z0-9]+[A-Z]\w* = ',
  "don't use camelcase in identifiers"),
 (r'^\s*(if|while|def|class|except|try)\s[^[\n]*:\s*[^\\n]#\s]+',
  "linebreak after :"),



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


[Bug 5675] New: ShareExtension does not avoid copying subrepositories

2017-09-06 Thread mercurial-bugs
https://bz.mercurial-scm.org/show_bug.cgi?id=5675

Bug ID: 5675
   Summary: ShareExtension does not avoid copying subrepositories
   Product: Mercurial
   Version: 2.8.2
  Hardware: PC
OS: Linux
Status: UNCONFIRMED
  Severity: bug
  Priority: wish
 Component: Mercurial
  Assignee: bugzi...@mercurial-scm.org
  Reporter: koen.po...@vandewiele.com
CC: mercurial-devel@mercurial-scm.org

The ShareExtension is great for reducing disk usage when several checkouts of
the same repository are made:

>> hg share Repo WC1
>> hg share Repo WC2

The resulting WC1 and WC2 will typically be a fraction of the size of the Repo,
because the .hg/store is only kept once, in Repo.

However, for subrepositories, this is not the case and the store folder is
copied. So there is no WC1/.hg/store, but there is a WC1/SubRepo/.hg/store.

Request: can the sharing also be applied to subrepositories?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D622: copytrace: move the default copytracing algorithm in a new function

2017-09-06 Thread pulkit (Pulkit Goyal)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGb4b196092cc3: copytrace: move the default copytracing 
algorithm in a new function (authored by pulkit).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D622?vs=1602=1632

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

AFFECTED FILES
  mercurial/copies.py
  tests/test-copy-move-merge.t

CHANGE DETAILS

diff --git a/tests/test-copy-move-merge.t b/tests/test-copy-move-merge.t
--- a/tests/test-copy-move-merge.t
+++ b/tests/test-copy-move-merge.t
@@ -1,3 +1,6 @@
+Test for the full copytracing algorithm
+===
+
   $ hg init t
   $ cd t
 
diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -306,9 +306,13 @@
 
 def mergecopies(repo, c1, c2, base):
 """
-The basic algorithm for copytracing. Copytracing is used in commands like
-rebase, merge, unshelve, etc to merge files that were moved/ copied in one
-merge parent and modified in another. For example:
+The function calling different copytracing algorithms on the basis of 
config
+which find moves and copies between context c1 and c2 that are relevant for
+merging. 'base' will be used as the merge base.
+
+Copytracing is used in commands like rebase, merge, unshelve, etc to merge
+files that were moved/ copied in one merge parent and modified in another.
+For example:
 
 o  ---> 4 another commit
 |
@@ -324,13 +328,6 @@
 
 ```other changed  which local deleted```
 
-If copytrace is enabled, this function finds all the new files that were
-added from merge base up to the top commit (here 4), and for each file it
-checks if this file was copied from another file (a.txt in the above case).
-
-Find moves and copies between context c1 and c2 that are relevant
-for merging. 'base' will be used as the merge base.
-
 Returns five dicts: "copy", "movewithdir", "diverge", "renamedelete" and
 "dirmove".
 
@@ -360,12 +357,24 @@
 if c2.node() is None and c1.node() == repo.dirstate.p1():
 return repo.dirstate.copies(), {}, {}, {}, {}
 
+copytracing = repo.ui.config('experimental', 'copytrace')
+
 # Copy trace disabling is explicitly below the node == p1 logic above
 # because the logic above is required for a simple copy to be kept across a
 # rebase.
-if repo.ui.config('experimental', 'copytrace') == 'off':
+if copytracing == 'off':
 return {}, {}, {}, {}, {}
+else:
+return _fullcopytracing(repo, c1, c2, base)
 
+def _fullcopytracing(repo, c1, c2, base):
+""" The full copytracing algorithm which finds all the new files that were
+added from merge base up to the top commit and for each file it checks if
+this file was copied from another file.
+
+This is pretty slow when a lot of changesets are involved but will track 
all
+the copies.
+"""
 # In certain scenarios (e.g. graft, update or rebase), base can be
 # overridden We still need to know a real common ancestor in this case We
 # can't just compute _c1.ancestor(_c2) and compare it to ca, because there



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


D611: checknlink: use a random temp file name for checking

2017-09-06 Thread quark (Jun Wu)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG1104718fb090: checknlink: use a random temp file name for 
checking (authored by quark).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D611?vs=1616=1633

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

AFFECTED FILES
  mercurial/util.py

CHANGE DETAILS

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -1457,21 +1457,14 @@
 
 # testfile may be open, so we need a separate file for checking to
 # work around issue2543 (or testfile may get lost on Samba shares)
-f1 = testfile + ".hgtmp1"
-if os.path.lexists(f1):
-return False
+f1, f2, fd = None, None, None
 try:
-posixfile(f1, 'w').close()
-except IOError:
-try:
-os.unlink(f1)
-except OSError:
-pass
-return False
-
-f2 = testfile + ".hgtmp2"
-fd = None
-try:
+fd, f1 = tempfile.mkstemp(prefix='.%s-' % os.path.basename(testfile),
+  suffix='1~', dir=os.path.dirname(testfile))
+os.close(fd)
+fd = None
+f2 = '%s2~' % f1[:-2]
+
 oslink(f1, f2)
 # nlinks() may behave differently for files on Windows shares if
 # the file is open.
@@ -1484,7 +1477,8 @@
 fd.close()
 for f in (f1, f2):
 try:
-os.unlink(f)
+if f is not None:
+os.unlink(f)
 except OSError:
 pass
 



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


D621: copytrace: replace experimental.disablecopytrace config with copytrace (BC)

2017-09-06 Thread pulkit (Pulkit Goyal)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG26531db4647a: copytrace: replace 
experimental.disablecopytrace config with copytrace (BC) (authored by pulkit).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D621?vs=1601=1631#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D621?vs=1601=1631

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

AFFECTED FILES
  mercurial/configitems.py
  mercurial/copies.py
  tests/test-copy-move-merge.t

CHANGE DETAILS

diff --git a/tests/test-copy-move-merge.t b/tests/test-copy-move-merge.t
--- a/tests/test-copy-move-merge.t
+++ b/tests/test-copy-move-merge.t
@@ -81,7 +81,7 @@
   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
   saved backup bundle to 
$TESTTMP/t/.hg/strip-backup/550bd84c0cd3-fc575957-backup.hg (glob)
   $ hg up -qC 2
-  $ hg rebase --keep -d 1 -b 2 --config extensions.rebase= --config 
experimental.disablecopytrace=True --config ui.interactive=True << EOF
+  $ hg rebase --keep -d 1 -b 2 --config extensions.rebase= --config 
experimental.copytrace=off --config ui.interactive=True << EOF
   > c
   > EOF
   rebasing 2:add3f11052fa "other" (tip)
@@ -117,7 +117,7 @@
   |
   o  0 add a
   
-  $ hg rebase -d . -b 2 --config extensions.rebase= --config 
experimental.disablecopytrace=True
+  $ hg rebase -d . -b 2 --config extensions.rebase= --config 
experimental.copytrace=off
   rebasing 2:6adcf8c12e7d "copy b->x"
   saved backup bundle to 
$TESTTMP/copydisable/.hg/strip-backup/6adcf8c12e7d-ce4b3e75-rebase.hg (glob)
   $ hg up -q 3
@@ -150,7 +150,7 @@
   |/
   o  0 add a
   
-  $ hg rebase -d 2 -s 3 --config extensions.rebase= --config 
experimental.disablecopytrace=True
+  $ hg rebase -d 2 -s 3 --config extensions.rebase= --config 
experimental.copytrace=off
   rebasing 3:47e1a9e6273b "copy a->b (2)" (tip)
   saved backup bundle to 
$TESTTMP/copydisable3/.hg/strip-backup/47e1a9e6273b-2d099c59-rebase.hg (glob)
 
diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -203,7 +203,7 @@
 return cm
 
 def _backwardrenames(a, b):
-if a._repo.ui.configbool('experimental', 'disablecopytrace'):
+if a._repo.ui.config('experimental', 'copytrace') == 'off':
 return {}
 
 # Even though we're not taking copies into account, 1:n rename situations
@@ -363,7 +363,7 @@
 # Copy trace disabling is explicitly below the node == p1 logic above
 # because the logic above is required for a simple copy to be kept across a
 # rebase.
-if repo.ui.configbool('experimental', 'disablecopytrace'):
+if repo.ui.config('experimental', 'copytrace') == 'off':
 return {}, {}, {}, {}, {}
 
 # In certain scenarios (e.g. graft, update or rebase), base can be
@@ -728,8 +728,8 @@
 '''
 exclude = {}
 if (skiprev is not None and
-not repo.ui.configbool('experimental', 'disablecopytrace')):
-# disablecopytrace skips this line, but not the entire function because
+repo.ui.config('experimental', 'copytrace') != 'off'):
+# copytrace='off' skips this line, but not the entire function because
 # the line below is O(size of the repo) during a rebase, while the rest
 # of the function is much faster (and is required for carrying copy
 # metadata across the rebase anyway).
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -172,12 +172,12 @@
 coreconfigitem('experimental', 'clientcompressionengines',
 default=list,
 )
+coreconfigitem('experimental', 'copytrace',
+default='on',
+)
 coreconfigitem('experimental', 'crecordtest',
 default=None,
 )
-coreconfigitem('experimental', 'disablecopytrace',
-default=False,
-)
 coreconfigitem('experimental', 'editortmpinhg',
 default=False,
 )



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


D611: checknlink: use a random temp file name for checking

2017-09-06 Thread yuja (Yuya Nishihara)
yuja accepted this revision.
yuja added a comment.
This revision is now accepted and ready to land.


  Queued, thanks.

INLINE COMMENTS

> util.py:1465
> +os.close(fd)
> +fd = None
> +f2 = '%s2~' % f1[:-2]

Nit: here fd is a file descriptor, but later it's changed to a file
object.  fd.close() would raise AttributeError if os.close(fd) failed.

Maybe we should rename the latter to fp or something. Can
you send a follow up?

REPOSITORY
  rHG Mercurial

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

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


D625: copytrace: use the full copytracing method if only drafts are involved

2017-09-06 Thread yuja (Yuya Nishihara)
yuja requested changes to this revision.
yuja added a comment.
This revision now requires changes to proceed.


  > The `heuristics` option for `experimental.copytrace` performs full
  >  copytracing if drafts are involved.
  
  This sounds somewhat incorrect. One of the involved revisions should
  always be draft on rebase. Can you rephrase?

INLINE COMMENTS

> copies.py:373
>  elif copytracing == 'heuristics':
> +# Do full copytracing if only drafts are involved
> +if _isfullcopytraceable(c1, base):

Please comment "why" instead of "what this is doing."

> copies.py:388
> +
> +if cdst.phase() == phases.draft and base.phase() == phases.draft:
> +return True

What if some of them are "secret" ?

REPOSITORY
  rHG Mercurial

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

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


D624: copytrace: move the full copytracing algorithm under 'full' option

2017-09-06 Thread yuja (Yuya Nishihara)
yuja requested changes to this revision.
yuja added inline comments.
This revision now requires changes to proceed.

INLINE COMMENTS

> copies.py:376
>  else:
> -return _fullcopytracing(repo, c1, c2, base)
> +repo.ui.debug('unable to parse the copytracing mode %s' % 
> copytracing)
>  

This should either abort or fall back to the default copy tracing.
Returning None doesn't make sense.

REPOSITORY
  rHG Mercurial

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

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


D623: copytrace: move fast heuristic copytracing algorithm to core

2017-09-06 Thread yuja (Yuya Nishihara)
yuja requested changes to this revision.
yuja added a comment.
This revision now requires changes to proceed.


  Generally looks good.
  
  We might need something to handle copies between `anc` (real common
  ancestor) and `base` (pseudo merge base) as we do in the "full" copy tracing,
  but I'm not pretty sure. Since this is an experimental feature, and it may 
miss
  some copies by design, I think this is mostly good to go.

INLINE COMMENTS

> copies.py:22
>  
> +defaultdict = collections.defaultdict
> +

Nit: there are only two use sites, so let's remove the module-level
alias.

> copies.py:608
>  
> +def _heuristicscopytracing(repo, cdst, csrc, base):
> +""" Fast copytracing using filename heuristics

This cdst/csrc naming is confusing because c1 is actually the
source revision (= the original wctx) in "update" scenario. And
IIUC, we are searching for copies from c1 to c2.

Can you rename them?

> copies.py:638
> +mdst = cdst.manifest()
> +while ctx != base:
> +if len(ctx.parents()) == 2:

Perhaps this wouldn't stop if the base were in the other side.
I don't think that would happen thanks to how mergecopies()
are used currently, but it's probably better to error out early.

> copies.py:641
> +# To keep things simple let's not handle merges
> +repo.ui.debug("swicthing to full copytracing because of merges")
> +return _fullcopytracing(repo, cdst, csrc, base)

Typo: "switching", and missing "\n".

REPOSITORY
  rHG Mercurial

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

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


D622: copytrace: move the default copytracing algorithm in a new function

2017-09-06 Thread yuja (Yuya Nishihara)
yuja accepted this revision.
yuja added a comment.
This revision is now accepted and ready to land.


  Queued, thanks.

REPOSITORY
  rHG Mercurial

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

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


D621: copytrace: replace experimental.disablecopytrace config with copytrace (BC)

2017-09-06 Thread yuja (Yuya Nishihara)
yuja accepted this revision.
yuja added a comment.
This revision is now accepted and ready to land.


  > experimental.copytrace defaults to 'off'. The new value is not boolean 
value as
  
  s/off/on/ and queued, thanks.

INLINE COMMENTS

> copies.py:366
>  # rebase.
> -if repo.ui.configbool('experimental', 'disablecopytrace'):
> +if repo.ui.config('experimental', 'copytrace') == 'off':
>  return {}, {}, {}, {}, {}

This could be kept as configbool so any falsy value could be
specified, but I don't have strong preference.

> copies.py:731
>  if (skiprev is not None and
> -not repo.ui.configbool('experimental', 'disablecopytrace')):
> -# disablecopytrace skips this line, but not the entire function 
> because
> +not (repo.ui.config('experimental', 'copytrace') == 'off')):
> +# copytrace='off' skips this line, but not the entire function 
> because

Updated to use !=.

REPOSITORY
  rHG Mercurial

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

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