Mercurial > hg
view tests/check-perf-code.py @ 37032:98663bed146e
rebase: store rebase state after each commit
Before this patch, we stored the rebase state early in the processing
of a node, before we updated the rebase state to indicate that the
node was processed. This meant that we could redo the working copy
merge and run into conflicts. However, this only happened in the
--collapse case if the rebase was interrupted while editing the final
commit message; in the case earlier interruptions, we would instead
detect the in-process revision by finding two dirstate parents.
This patch moves the writing of the rebase state to after we have
completed the revision completely, and, importantly, after we have
updated the rebase state to mark it done. This means we'll realize
that all nodes have been rebased in the case mentioned above of
editing the final commit message of a --collapse. See change to test
case.
I also moved the writing outside of the large if/elif block in
_rebasenode(). This shouldn't matter much, but seems cleaner. One
observable effect is if rebase was interrupted just after ignoring an
obsolete node ("not rebasing ####, already in destination"), we used
to come up with the same decision after --continue too, but after this
patch we'll instead say "already rebased ###". This seems more
consistent, since that's what we would do with obsolete nodes that had
been marked done earlier in the process (not only just before the
interruption).
Differential Revision: https://phab.mercurial-scm.org/D2913
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Wed, 21 Mar 2018 11:01:19 -0700 |
parents | bd872f64a8ba |
children | eb8a8af4cbd0 |
line wrap: on
line source
#!/usr/bin/env python # # check-perf-code - (historical) portability checker for contrib/perf.py from __future__ import absolute_import import os import sys # write static check patterns here perfpypats = [ [ (r'(branchmap|repoview)\.subsettable', "use getbranchmapsubsettable() for early Mercurial"), (r'\.(vfs|svfs|opener|sopener)', "use getvfs()/getsvfs() for early Mercurial"), (r'ui\.configint', "use getint() instead of ui.configint() for early Mercurial"), ], # warnings [ ] ] def modulewhitelist(names): replacement = [('.py', ''), ('.c', ''), # trim suffix ('mercurial%s' % (os.sep), ''), # trim "mercurial/" path ] ignored = {'__init__'} modules = {} # convert from file name to module name, and count # of appearances for name in names: name = name.strip() for old, new in replacement: name = name.replace(old, new) if name not in ignored: modules[name] = modules.get(name, 0) + 1 # list up module names, which appear multiple times whitelist = [] for name, count in modules.items(): if count > 1: whitelist.append(name) return whitelist if __name__ == "__main__": # in this case, it is assumed that result of "hg files" at # multiple revisions is given via stdin whitelist = modulewhitelist(sys.stdin) assert whitelist, "module whitelist is empty" # build up module whitelist check from file names given at runtime perfpypats[0].append( # this matching pattern assumes importing modules from # "mercurial" package in the current style below, for simplicity # # from mercurial import ( # foo, # bar, # baz # ) ((r'from mercurial import [(][a-z0-9, \n#]*\n(?! *%s,|^[ #]*\n|[)])' % ',| *'.join(whitelist)), "import newer module separately in try clause for early Mercurial" )) # import contrib/check-code.py as checkcode assert 'RUNTESTDIR' in os.environ, "use check-perf-code.py in *.t script" contribpath = os.path.join(os.environ['RUNTESTDIR'], '..', 'contrib') sys.path.insert(0, contribpath) checkcode = __import__('check-code') # register perf.py specific entry with "checks" in check-code.py checkcode.checks.append(('perf.py', r'contrib/perf.py$', '', checkcode.pyfilters, perfpypats)) sys.exit(checkcode.main())