D3772: highlight: adjust to attribute being private
This revision was automatically updated to reflect the committed changes. Closed by commit rHG876352ea831e: highlight: adjust to attribute being private (authored by durin42, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3772?vs=9141=9143 REVISION DETAIL https://phab.mercurial-scm.org/D3772 AFFECTED FILES hgext/highlight/highlight.py CHANGE DETAILS diff --git a/hgext/highlight/highlight.py b/hgext/highlight/highlight.py --- a/hgext/highlight/highlight.py +++ b/hgext/highlight/highlight.py @@ -89,7 +89,7 @@ coloriter = (s.encode(encoding.encoding, 'replace') for s in colorized.splitlines()) -tmpl.filters['colorize'] = lambda x: next(coloriter) +tmpl._filters['colorize'] = lambda x: next(coloriter) oldl = tmpl.cache[field] newl = oldl.replace('line|escape', 'line|colorize') To: durin42, #hg-reviewers, martinvonz Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3773: streamclone: update progress later to avoid passing None to util.bytecount
This revision was automatically updated to reflect the committed changes. Closed by commit rHGc1fca51c26f3: streamclone: update progress later to avoid passing None to util.bytecount (authored by durin42, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3773?vs=9142=9144 REVISION DETAIL https://phab.mercurial-scm.org/D3773 AFFECTED FILES mercurial/streamclone.py CHANGE DETAILS diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py --- a/mercurial/streamclone.py +++ b/mercurial/streamclone.py @@ -621,10 +621,10 @@ elapsed = util.timer() - start if elapsed <= 0: elapsed = 0.001 -progress.update(None) repo.ui.status(_('transferred %s in %.1f seconds (%s/sec)\n') % (util.bytecount(progress.pos), elapsed, util.bytecount(progress.pos / elapsed))) +progress.update(None) def applybundlev2(repo, fp, filecount, filesize, requirements): missingreqs = [r for r in requirements if r not in repo.supported] To: durin42, #hg-reviewers, martinvonz Cc: martinvonz, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3773: streamclone: update progress later to avoid passing None to util.bytecount
martinvonz accepted this revision. martinvonz added a comment. This revision is now accepted and ready to land. Thanks! REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3773 To: durin42, #hg-reviewers, martinvonz Cc: martinvonz, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: D3756: rebase: no need to backup rebased csets while aborting
okay, I think following the key rule of VCS would be better. Shall I update the comment instead? On Mon, Jun 18, 2018 at 8:50 AM, durin42 (Augie Fackler) < phabrica...@mercurial-scm.org> wrote: > durin42 added a comment. > > > In https://phab.mercurial-scm.org/D3756#58937, @indygreg wrote: > > > I'm unsure about this change. On one hand, the comment (which appears > to have been added to mpm several years ago) implies that we never should > have generated backups in this case. On the other, one of the key rules of > a VCS is "don't eat my data." Even though we are aborting the operation, I > could see some scenarios where someone would want a backup of the > aborted/partially-completed rebase. > > > > @durin42: what do you think? > > > I think the paranoia is probably better overall? Maybe update the > comment? > > (I don't feel strongly.) > > REPOSITORY > rHG Mercurial > > REVISION DETAIL > https://phab.mercurial-scm.org/D3756 > > To: khanchi97, #hg-reviewers > Cc: indygreg, durin42, mercurial-devel > ___ > Mercurial-devel mailing list > Mercurial-devel@mercurial-scm.org > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel > ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3756: rebase: no need to backup rebased csets while aborting
durin42 added a comment. In https://phab.mercurial-scm.org/D3756#58937, @indygreg wrote: > I'm unsure about this change. On one hand, the comment (which appears to have been added to mpm several years ago) implies that we never should have generated backups in this case. On the other, one of the key rules of a VCS is "don't eat my data." Even though we are aborting the operation, I could see some scenarios where someone would want a backup of the aborted/partially-completed rebase. > > @durin42: what do you think? I think the paranoia is probably better overall? Maybe update the comment? (I don't feel strongly.) REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3756 To: khanchi97, #hg-reviewers Cc: indygreg, durin42, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3773: streamclone: update progress later to avoid passing None to util.bytecount
durin42 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/D3773 AFFECTED FILES mercurial/streamclone.py CHANGE DETAILS diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py --- a/mercurial/streamclone.py +++ b/mercurial/streamclone.py @@ -621,10 +621,10 @@ elapsed = util.timer() - start if elapsed <= 0: elapsed = 0.001 -progress.update(None) repo.ui.status(_('transferred %s in %.1f seconds (%s/sec)\n') % (util.bytecount(progress.pos), elapsed, util.bytecount(progress.pos / elapsed))) +progress.update(None) def applybundlev2(repo, fp, filecount, filesize, requirements): missingreqs = [r for r in requirements if r not in repo.supported] To: durin42, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3772: highlight: adjust to attribute being private
durin42 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/D3772 AFFECTED FILES hgext/highlight/highlight.py CHANGE DETAILS diff --git a/hgext/highlight/highlight.py b/hgext/highlight/highlight.py --- a/hgext/highlight/highlight.py +++ b/hgext/highlight/highlight.py @@ -89,7 +89,7 @@ coloriter = (s.encode(encoding.encoding, 'replace') for s in colorized.splitlines()) -tmpl.filters['colorize'] = lambda x: next(coloriter) +tmpl._filters['colorize'] = lambda x: next(coloriter) oldl = tmpl.cache[field] newl = oldl.replace('line|escape', 'line|colorize') To: durin42, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH 1 of 8] templater: mark most attributes as private
On Sat, Jun 16, 2018 at 11:02 AM Gregory Szorc wrote: > On Thu, Jun 14, 2018 at 8:40 AM, Yuya Nishihara wrote: > >> # HG changeset patch >> # User Yuya Nishihara >> # Date 1525312409 -32400 >> # Thu May 03 10:53:29 2018 +0900 >> # Node ID 8541f1e6178053f6cafd2ff22c8b632499ffa298 >> # Parent 6196cc6cd37bc7260fdcb1f5c020d4adb7f8c176 >> templater: mark most attributes as private >> > > Queued this series. > This patch broke test-highlight.t. templater.filters is used on highlight.py:92. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3771: py3: make contrib/perf.py compatible to Python 3
pulkit created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY This patch makes contrib/perf.py compatible on Python 3 by using pycompat.byteskwargs(), pycompat.sysstr(), replacing sys.maxint with sys.maxsize because sys.maxint is not present on Python 3, adding conditional for xrange/range and adding a lot of b'' prefixes. This makes test-contrib-perf.t passes on Python 3. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3771 AFFECTED FILES contrib/perf.py contrib/python3-whitelist CHANGE DETAILS diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist --- a/contrib/python3-whitelist +++ b/contrib/python3-whitelist @@ -66,6 +66,7 @@ test-context.py test-contrib-check-code.t test-contrib-check-commit.t +test-contrib-perf.t test-convert-authormap.t test-convert-clonebranches.t test-convert-cvs-branch.t diff --git a/contrib/perf.py b/contrib/perf.py --- a/contrib/perf.py +++ b/contrib/perf.py @@ -90,12 +90,17 @@ except (AttributeError, ImportError): makelogtemplater = None +try: +xrange +except NameError: +xrange = range + # for "historical portability": # define util.safehasattr forcibly, because util.safehasattr has been # available since 1.9.3 (or 94b200a11cf7) _undefined = object() def safehasattr(thing, attr): -return getattr(thing, attr, _undefined) is not _undefined +return getattr(thing, pycompat.sysstr(attr), _undefined) is not _undefined setattr(util, 'safehasattr', safehasattr) # for "historical portability": @@ -123,18 +128,18 @@ # since 1.9 (or a79fea6b3e77). revlogopts = getattr(cmdutil, "debugrevlogopts", getattr(commands, "debugrevlogopts", [ -('c', 'changelog', False, ('open changelog')), -('m', 'manifest', False, ('open manifest')), -('', 'dir', False, ('open directory manifest')), +(b'c', b'changelog', False, (b'open changelog')), +(b'm', b'manifest', False, (b'open manifest')), +(b'', b'dir', False, (b'open directory manifest')), ])) cmdtable = {} # for "historical portability": # define parsealiases locally, because cmdutil.parsealiases has been # available since 1.5 (or 6252852b4332) def parsealiases(cmd): -return cmd.lstrip("^").split("|") +return cmd.lstrip(b"^").split(b"|") if safehasattr(registrar, 'command'): command = registrar.command(cmdtable) @@ -147,7 +152,7 @@ _command = command def command(name, options=(), synopsis=None, norepo=False): if norepo: -commands.norepo += ' %s' % ' '.join(parsealiases(name)) +commands.norepo += b' %s' % b' '.join(parsealiases(name)) return _command(name, list(options), synopsis) else: # for "historical portability": @@ -160,29 +165,29 @@ else: cmdtable[name] = func, list(options) if norepo: -commands.norepo += ' %s' % ' '.join(parsealiases(name)) +commands.norepo += b' %s' % b' '.join(parsealiases(name)) return func return decorator try: import mercurial.registrar import mercurial.configitems configtable = {} configitem = mercurial.registrar.configitem(configtable) -configitem('perf', 'presleep', +configitem(b'perf', b'presleep', default=mercurial.configitems.dynamicdefault, ) -configitem('perf', 'stub', +configitem(b'perf', b'stub', default=mercurial.configitems.dynamicdefault, ) -configitem('perf', 'parentscount', +configitem(b'perf', b'parentscount', default=mercurial.configitems.dynamicdefault, ) except (ImportError, AttributeError): pass def getlen(ui): -if ui.configbool("perf", "stub", False): +if ui.configbool(b"perf", b"stub", False): return lambda x: 1 return len @@ -194,7 +199,7 @@ # enforce an idle period before execution to counteract power management # experimental config: perf.presleep -time.sleep(getint(ui, "perf", "presleep", 1)) +time.sleep(getint(ui, b"perf", b"presleep", 1)) if opts is None: opts = {} @@ -210,7 +215,7 @@ # get a formatter uiformatter = getattr(ui, 'formatter', None) if uiformatter: -fm = uiformatter('perf', opts) +fm = uiformatter(b'perf', opts) else: # for "historical portability": # define formatter locally, because ui.formatter has been @@ -241,11 +246,11 @@ self._ui.write(text, **opts) def end(self): pass -fm = defaultformatter(ui, 'perf', opts) +fm = defaultformatter(ui, b'perf', opts) # stub function, runs code only once instead of in a loop # experimental config: perf.stub -if ui.configbool("perf", "stub", False): +if ui.configbool(b"perf", b"stub", False):
D3765: progress: create helper class for incrementing progress
martinvonz added a comment. In https://phab.mercurial-scm.org/D3765#59079, @indygreg wrote: > Also, it's worth keeping in mind Python function call overhead when working on this code. I'm optimistic that things that need progress bars won't be concerned about this. But it might be worth measuring and keeping in the back of your head. Good point. I also think it's unlikely to be noticeable. Also, we can probably inline the ui.progress() logic if it turns out to be an issue. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3765 To: martinvonz, #hg-reviewers, indygreg Cc: indygreg, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3770: setdiscovery: use progress helper
martinvonz added inline comments. INLINE COMMENTS > setdiscovery.py:230 > roundtrips += 1 > -ui.progress(_('searching'), roundtrips, unit=_('queries')) > +progress.increment() > ui.debug("query %i; still undecided: %i, sample size is: %i\n" Sorry, this should be progress.update(roundtrips) since progress starts at 1 (not 0). Feel free to fix in place, or let me know and I'll send a fixup REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3770 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
D3765: progress: create helper class for incrementing progress
indygreg added a comment. Also, it's worth keeping in mind Python function call overhead when working on this code. I'm optimistic that things that need progress bars won't be concerned about this. But it might be worth measuring and keeping in the back of your head. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3765 To: martinvonz, #hg-reviewers, indygreg Cc: indygreg, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3767: remove: use progress helper
This revision was automatically updated to reflect the committed changes. Closed by commit rHG89db59e5cf3e: remove: use progress helper (authored by martinvonz, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3767?vs=9130=9137 REVISION DETAIL https://phab.mercurial-scm.org/D3767 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 @@ -2181,37 +2181,35 @@ warn = False subs = sorted(wctx.substate) -total = len(subs) -count = 0 +progress = ui.makeprogress(_('searching'), total=len(subs), + unit=_('subrepos')) for subpath in subs: -count += 1 submatch = matchmod.subdirmatcher(subpath, m) if subrepos or m.exact(subpath) or any(submatch.files()): -ui.progress(_('searching'), count, total=total, unit=_('subrepos')) +progress.increment() sub = wctx.sub(subpath) try: if sub.removefiles(submatch, prefix, after, force, subrepos, dryrun, warnings): ret = 1 except error.LookupError: warnings.append(_("skipping missing subrepository: %s\n") % join(subpath)) -ui.progress(_('searching'), None) +progress.update(None) # warn about failure to delete explicit files/dirs deleteddirs = util.dirs(deleted) files = m.files() -total = len(files) -count = 0 +progress = ui.makeprogress(_('deleting'), total=len(files), + unit=_('files')) for f in files: def insubrepo(): for subpath in wctx.substate: if f.startswith(subpath + '/'): return True return False -count += 1 -ui.progress(_('deleting'), count, total=total, unit=_('files')) +progress.increment() isdir = f in deleteddirs or wctx.hasdir(f) if (f in repo.dirstate or isdir or f == '.' or insubrepo() or f in subs): @@ -2226,50 +2224,47 @@ % m.rel(f)) # missing files will generate a warning elsewhere ret = 1 -ui.progress(_('deleting'), None) +progress.update(None) if force: list = modified + deleted + clean + added elif after: list = deleted remaining = modified + added + clean -total = len(remaining) -count = 0 +progress = ui.makeprogress(_('skipping'), total=len(remaining), + unit=_('files')) for f in remaining: -count += 1 -ui.progress(_('skipping'), count, total=total, unit=_('files')) +progress.increment() if ui.verbose or (f in files): warnings.append(_('not removing %s: file still exists\n') % m.rel(f)) ret = 1 -ui.progress(_('skipping'), None) +progress.update(None) else: list = deleted + clean -total = len(modified) + len(added) -count = 0 +progress = ui.makeprogress(_('skipping'), + total=(len(modified) + len(added)), + unit=_('files')) for f in modified: -count += 1 -ui.progress(_('skipping'), count, total=total, unit=_('files')) +progress.increment() warnings.append(_('not removing %s: file is modified (use -f' ' to force removal)\n') % m.rel(f)) ret = 1 for f in added: -count += 1 -ui.progress(_('skipping'), count, total=total, unit=_('files')) +progress.increment() warnings.append(_("not removing %s: file has been marked for add" " (use 'hg forget' to undo add)\n") % m.rel(f)) ret = 1 -ui.progress(_('skipping'), None) +progress.update(None) list = sorted(list) -total = len(list) -count = 0 +progress = ui.makeprogress(_('deleting'), total=len(list), + unit=_('files')) for f in list: -count += 1 if ui.verbose or not m.exact(f): -ui.progress(_('deleting'), count, total=total, unit=_('files')) +progress.increment() ui.status(_('removing %s\n') % m.rel(f)) -ui.progress(_('deleting'), None) +progress.update(None) if not dryrun: with repo.wlock(): 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
D3765: progress: create helper class for incrementing progress
This revision was automatically updated to reflect the committed changes. Closed by commit rHGbec1212eceaa: progress: create helper class for incrementing progress (authored by martinvonz, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3765?vs=9128=9134 REVISION DETAIL https://phab.mercurial-scm.org/D3765 AFFECTED FILES mercurial/merge.py mercurial/scmutil.py mercurial/ui.py CHANGE DETAILS diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -1596,6 +1596,10 @@ else: self.debug('%s:%s %d%s\n' % (topic, item, pos, unit)) +def makeprogress(self, topic, unit="", total=None): +'''exists only so low-level modules won't need to import scmutil''' +return scmutil.progress(self, topic, unit, total) + def log(self, service, *msg, **opts): '''hook for logging facility extensions diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -1285,6 +1285,27 @@ return _locksub(repo, repo.currentwlock(), 'HG_WLOCK_LOCKER', cmd, *args, **kwargs) +class progress(object): +def __init__(self, ui, topic, unit="", total=None): +self.ui = ui +self.pos = 0 +self.topic = topic +self.unit = unit +self.total = total + +def update(self, pos, item="", total=None): +if total: +self.total = total +self.pos = pos +self._print(item) + +def increment(self, step=1, item="", total=None): +self.update(self.pos + step, item, total) + +def _print(self, item): +self.ui.progress(self.topic, self.pos, item, self.unit, + self.total) + def gdinitconfig(ui): """helper function to know if a repo should be created as general delta """ diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -1584,10 +1584,6 @@ if f1 != f and move: moves.append(f1) -_updating = _('updating') -_files = _('files') -progress = repo.ui.progress - # remove renamed files after safely stored for f in moves: if wctx[f].lexists(): @@ -1597,7 +1593,8 @@ numupdates = sum(len(l) for m, l in actions.items() if m != ACTION_KEEP) -z = 0 +progress = repo.ui.makeprogress(_('updating'), unit=_('files'), +total=numupdates) if [a for a in actions[ACTION_REMOVE] if a[0] == '.hgsubstate']: subrepoutil.submerge(repo, wctx, mctx, wctx, overwrite, labels) @@ -1614,8 +1611,7 @@ s(_("the remote file has been renamed to %s\n") % f1) s(_("resolve manually then use 'hg resolve --mark %s'\n") % f) ms.addpath(f, f1, fo) -z += 1 -progress(_updating, z, item=f, total=numupdates, unit=_files) +progress.increment(item=f) # When merging in-memory, we can't support worker processes, so set the # per-item cost at 0 in that case. @@ -1625,8 +1621,7 @@ prog = worker.worker(repo.ui, cost, batchremove, (repo, wctx), actions[ACTION_REMOVE]) for i, item in prog: -z += i -progress(_updating, z, item=item, total=numupdates, unit=_files) +progress.increment(step=i, item=item) removed = len(actions[ACTION_REMOVE]) # resolve path conflicts (must come before getting) @@ -1638,37 +1633,32 @@ wctx[f].audit() wctx[f].write(wctx.filectx(f0).data(), wctx.filectx(f0).flags()) wctx[f0].remove() -z += 1 -progress(_updating, z, item=f, total=numupdates, unit=_files) +progress.increment(item=f) # get in parallel prog = worker.worker(repo.ui, cost, batchget, (repo, mctx, wctx), actions[ACTION_GET]) for i, item in prog: -z += i -progress(_updating, z, item=item, total=numupdates, unit=_files) +progress.increment(step=i, item=item) updated = len(actions[ACTION_GET]) if [a for a in actions[ACTION_GET] if a[0] == '.hgsubstate']: subrepoutil.submerge(repo, wctx, mctx, wctx, overwrite, labels) # forget (manifest only, just log it) (must come first) for f, args, msg in actions[ACTION_FORGET]: repo.ui.debug(" %s: %s -> f\n" % (f, msg)) -z += 1 -progress(_updating, z, item=f, total=numupdates, unit=_files) +progress.increment(item=f) # re-add (manifest only, just log it) for f, args, msg in actions[ACTION_ADD]: repo.ui.debug(" %s: %s -> a\n" % (f, msg)) -z += 1 -progress(_updating, z, item=f, total=numupdates, unit=_files) +progress.increment(item=f) # re-add/mark as modified (manifest only, just log it) for f, args, msg in actions[ACTION_ADD_MODIFIED]:
D3770: setdiscovery: use progress helper
This revision was automatically updated to reflect the committed changes. Closed by commit rHGdb8f6eaf4ee0: setdiscovery: use progress helper (authored by martinvonz, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3770?vs=9133=9139 REVISION DETAIL https://phab.mercurial-scm.org/D3770 AFFECTED FILES mercurial/setdiscovery.py CHANGE DETAILS diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py --- a/mercurial/setdiscovery.py +++ b/mercurial/setdiscovery.py @@ -197,6 +197,7 @@ missing = set() full = False +progress = ui.makeprogress(_('searching'), unit=_('queries')) while undecided: if sample: @@ -226,7 +227,7 @@ sample = samplefunc(dag, undecided, targetsize) roundtrips += 1 -ui.progress(_('searching'), roundtrips, unit=_('queries')) +progress.increment() ui.debug("query %i; still undecided: %i, sample size is: %i\n" % (roundtrips, len(undecided), len(sample))) # indices between sample and externalized version must match @@ -251,7 +252,7 @@ # return any heads in that case, so discard that result.discard(nullrev) elapsed = util.timer() - start -ui.progress(_('searching'), None) +progress.update(None) ui.debug("%d total queries in %.4fs\n" % (roundtrips, elapsed)) msg = ('found %d common and %d unknown server heads,' ' %d roundtrips in %.4fs\n') 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
D3769: streamclone: use progress helper
This revision was automatically updated to reflect the committed changes. Closed by commit rHGe59eaf51cc0d: streamclone: use progress helper (authored by martinvonz, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3769?vs=9132=9138 REVISION DETAIL https://phab.mercurial-scm.org/D3769 AFFECTED FILES mercurial/streamclone.py CHANGE DETAILS diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py --- a/mercurial/streamclone.py +++ b/mercurial/streamclone.py @@ -313,16 +313,15 @@ # This is where we'll add compression in the future. assert compression == 'UN' -seen = 0 -repo.ui.progress(_('bundle'), 0, total=bytecount, unit=_('bytes')) +progress = repo.ui.makeprogress(_('bundle'), total=bytecount, +unit=_('bytes')) +progress.update(0) for chunk in it: -seen += len(chunk) -repo.ui.progress(_('bundle'), seen, total=bytecount, - unit=_('bytes')) +progress.increment(step=len(chunk)) yield chunk -repo.ui.progress(_('bundle'), None) +progress.update(None) return requirements, gen() @@ -338,8 +337,9 @@ with repo.lock(): repo.ui.status(_('%d files to transfer, %s of data\n') % (filecount, util.bytecount(bytecount))) -handled_bytes = 0 -repo.ui.progress(_('clone'), 0, total=bytecount, unit=_('bytes')) +progress = repo.ui.makeprogress(_('clone'), total=bytecount, +unit=_('bytes')) +progress.update(0) start = util.timer() # TODO: get rid of (potential) inconsistency @@ -374,9 +374,7 @@ path = store.decodedir(name) with repo.svfs(path, 'w', backgroundclose=True) as ofp: for chunk in util.filechunkiter(fp, limit=size): -handled_bytes += len(chunk) -repo.ui.progress(_('clone'), handled_bytes, - total=bytecount, unit=_('bytes')) +progress.increment(step=len(chunk)) ofp.write(chunk) # force @filecache properties to be reloaded from @@ -386,7 +384,7 @@ elapsed = util.timer() - start if elapsed <= 0: elapsed = 0.001 -repo.ui.progress(_('clone'), None) +progress.update(None) repo.ui.status(_('transferred %s in %.1f seconds (%s/sec)\n') % (util.bytecount(bytecount), elapsed, util.bytecount(bytecount / elapsed))) @@ -494,8 +492,9 @@ def _emit2(repo, entries, totalfilesize): """actually emit the stream bundle""" vfsmap = _makemap(repo) -progress = repo.ui.progress -progress(_('bundle'), 0, total=totalfilesize, unit=_('bytes')) +progress = repo.ui.makeprogress(_('bundle'), total=totalfilesize, +unit=_('bytes')) +progress.update(0) with maketempcopies() as copy: try: # copy is delayed until we are in the try @@ -522,13 +521,12 @@ chunks = util.filechunkiter(fp, limit=size) for chunk in chunks: seen += len(chunk) -progress(_('bundle'), seen, total=totalfilesize, - unit=_('bytes')) +progress.update(seen) yield chunk finally: fp.close() finally: -progress(_('bundle'), None) +progress.update(None) def generatev2(repo): """Emit content for version 2 of a streaming clone. @@ -589,10 +587,9 @@ (filecount, util.bytecount(filesize))) start = util.timer() -handledbytes = 0 -progress = repo.ui.progress - -progress(_('clone'), handledbytes, total=filesize, unit=_('bytes')) +progress = repo.ui.makeprogress(_('clone'), total=filesize, +unit=_('bytes')) +progress.update(0) vfsmap = _makemap(repo) @@ -614,9 +611,7 @@ with vfs(name, 'w') as ofp: for chunk in util.filechunkiter(fp, limit=datalen): -handledbytes += len(chunk) -progress(_('clone'), handledbytes, total=filesize, - unit=_('bytes')) +progress.increment(step=len(chunk)) ofp.write(chunk) # force @filecache properties to be reloaded from @@ -626,10 +621,10 @@ elapsed = util.timer() - start if elapsed <= 0: elapsed = 0.001 -
D3766: changegroup: use progress helper in apply() (API)
This revision was automatically updated to reflect the committed changes. Closed by commit rHG83534c4ec58b: changegroup: use progress helper in apply() (API) (authored by martinvonz, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3766?vs=9129=9135 REVISION DETAIL https://phab.mercurial-scm.org/D3766 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 @@ -237,18 +237,16 @@ pos = next yield closechunk() -def _unpackmanifests(self, repo, revmap, trp, prog, numchanges): -# We know that we'll never have more manifests than we had -# changesets. -self.callback = prog(_('manifests'), numchanges) +def _unpackmanifests(self, repo, revmap, trp, prog): +self.callback = prog.increment # no need to check for empty manifest group here: # if the result of the merge of 1 and 2 is the same in 3 and 4, # no new manifest will be created and the manifest group will # be empty during the pull self.manifestheader() deltas = self.deltaiter() repo.manifestlog._revlog.addgroup(deltas, revmap, trp) -repo.ui.progress(_('manifests'), None) +prog.update(None) self.callback = None def apply(self, repo, tr, srctype, url, targetphase=phases.draft, @@ -293,16 +291,9 @@ # pull off the changeset group repo.ui.status(_("adding changesets\n")) clstart = len(cl) -class prog(object): -def __init__(self, step, total): -self._step = step -self._total = total -self._count = 1 -def __call__(self): -repo.ui.progress(self._step, self._count, unit=_('chunks'), - total=self._total) -self._count += 1 -self.callback = prog(_('changesets'), expectedtotal) +progress = repo.ui.makeprogress(_('changesets'), unit=_('chunks'), +total=expectedtotal) +self.callback = progress.increment efiles = set() def onchangelog(cl, node): @@ -318,12 +309,16 @@ config='warn-empty-changegroup') clend = len(cl) changesets = clend - clstart -repo.ui.progress(_('changesets'), None) +progress.update(None) self.callback = None # pull off the manifest group repo.ui.status(_("adding manifests\n")) -self._unpackmanifests(repo, revmap, trp, prog, changesets) +# We know that we'll never have more manifests than we had +# changesets. +progress = repo.ui.makeprogress(_('manifests'), unit=_('chunks'), +total=changesets) +self._unpackmanifests(repo, revmap, trp, progress) needfiles = {} if repo.ui.configbool('server', 'validate'): @@ -475,9 +470,8 @@ node, p1, p2, deltabase, cs, flags = headertuple return node, p1, p2, deltabase, cs, flags -def _unpackmanifests(self, repo, revmap, trp, prog, numchanges): -super(cg3unpacker, self)._unpackmanifests(repo, revmap, trp, prog, - numchanges) +def _unpackmanifests(self, repo, revmap, trp, prog): +super(cg3unpacker, self)._unpackmanifests(repo, revmap, trp, prog) for chunkdata in iter(self.filelogheader, {}): # If we get here, there are directory manifests in the changegroup d = chunkdata["filename"] 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
D3768: similar: use progress helper
This revision was automatically updated to reflect the committed changes. Closed by commit rHGcd196be26cb7: similar: use progress helper (authored by martinvonz, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3768?vs=9131=9136 REVISION DETAIL https://phab.mercurial-scm.org/D3768 AFFECTED FILES mercurial/similar.py tests/test-subrepo-deep-nested-change.t CHANGE DETAILS diff --git a/tests/test-subrepo-deep-nested-change.t b/tests/test-subrepo-deep-nested-change.t --- a/tests/test-subrepo-deep-nested-change.t +++ b/tests/test-subrepo-deep-nested-change.t @@ -379,7 +379,7 @@ $ touch bar/abc $ hg addremove -S .. \r (no-eol) (esc) - searching for exact renames [ ] 0/1\r (no-eol) (esc) + searching for exact renames [>] 1/1\r (no-eol) (esc) \r (no-eol) (esc) adding ../sub1/sub2/folder/test.txt removing ../sub1/sub2/test.txt diff --git a/mercurial/similar.py b/mercurial/similar.py --- a/mercurial/similar.py +++ b/mercurial/similar.py @@ -18,24 +18,23 @@ Takes a list of new filectxs and a list of removed filectxs, and yields (before, after) tuples of exact matches. ''' -numfiles = len(added) + len(removed) - # Build table of removed files: {hash(fctx.data()): [fctx, ...]}. # We use hash() to discard fctx.data() from memory. hashes = {} -for i, fctx in enumerate(removed): -repo.ui.progress(_('searching for exact renames'), i, total=numfiles, - unit=_('files')) +progress = repo.ui.makeprogress(_('searching for exact renames'), +total=(len(added) + len(removed)), +unit=_('files')) +for fctx in removed: +progress.increment() h = hash(fctx.data()) if h not in hashes: hashes[h] = [fctx] else: hashes[h].append(fctx) # For each added file, see if it corresponds to a removed file. -for i, fctx in enumerate(added): -repo.ui.progress(_('searching for exact renames'), i + len(removed), -total=numfiles, unit=_('files')) +for fctx in added: +progress.increment() adata = fctx.data() h = hash(adata) for rfctx in hashes.get(h, []): @@ -45,7 +44,7 @@ break # Done -repo.ui.progress(_('searching for exact renames'), None) +progress.update(None) def _ctxdata(fctx): # lazily load text 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
D3765: progress: create helper class for incrementing progress
indygreg accepted this revision. indygreg added a comment. This revision is now accepted and ready to land. The low-level progress API has always bothered me as well. Please do follow up and add a context manager to the API! REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3765 To: martinvonz, #hg-reviewers, indygreg Cc: indygreg, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3765: progress: create helper class for incrementing progress
martinvonz created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY When using ui.progress(), there's a clear pattern that is followed: - Pass the same topic and unit - Usually pass the same total - Call with pos=None to close the progress bar - Often keep track of the current position and increment it This patch creates a simple helper class for this. I'll probably make it implement the context manager protocol later (calling update(None) on __exit__). Progress is used in low-level modules like changegroup, so I also exposed it via a method on the ui object. Perhaps the class itself should also live in ui.py? This patch also makes merge.oy use it to show that it works. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3765 AFFECTED FILES mercurial/merge.py mercurial/scmutil.py mercurial/ui.py CHANGE DETAILS diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -1596,6 +1596,10 @@ else: self.debug('%s:%s %d%s\n' % (topic, item, pos, unit)) +def makeprogress(self, topic, unit="", total=None): +'''exists only so low-level modules won't need to import scmutil''' +return scmutil.progress(self, topic, unit, total) + def log(self, service, *msg, **opts): '''hook for logging facility extensions diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -1285,6 +1285,27 @@ return _locksub(repo, repo.currentwlock(), 'HG_WLOCK_LOCKER', cmd, *args, **kwargs) +class progress(object): +def __init__(self, ui, topic, unit="", total=None): +self.ui = ui +self.pos = 0 +self.topic = topic +self.unit = unit +self.total = total + +def update(self, pos, item="", total=None): +if total: +self.total = total +self.pos = pos +self._print(item) + +def increment(self, step=1, item="", total=None): +self.update(self.pos + step, item, total) + +def _print(self, item): +self.ui.progress(self.topic, self.pos, item, self.unit, + self.total) + def gdinitconfig(ui): """helper function to know if a repo should be created as general delta """ diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -1584,10 +1584,6 @@ if f1 != f and move: moves.append(f1) -_updating = _('updating') -_files = _('files') -progress = repo.ui.progress - # remove renamed files after safely stored for f in moves: if wctx[f].lexists(): @@ -1597,7 +1593,8 @@ numupdates = sum(len(l) for m, l in actions.items() if m != ACTION_KEEP) -z = 0 +progress = repo.ui.makeprogress(_('updating'), unit=_('files'), +total=numupdates) if [a for a in actions[ACTION_REMOVE] if a[0] == '.hgsubstate']: subrepoutil.submerge(repo, wctx, mctx, wctx, overwrite, labels) @@ -1614,8 +1611,7 @@ s(_("the remote file has been renamed to %s\n") % f1) s(_("resolve manually then use 'hg resolve --mark %s'\n") % f) ms.addpath(f, f1, fo) -z += 1 -progress(_updating, z, item=f, total=numupdates, unit=_files) +progress.increment(item=f) # When merging in-memory, we can't support worker processes, so set the # per-item cost at 0 in that case. @@ -1625,8 +1621,7 @@ prog = worker.worker(repo.ui, cost, batchremove, (repo, wctx), actions[ACTION_REMOVE]) for i, item in prog: -z += i -progress(_updating, z, item=item, total=numupdates, unit=_files) +progress.increment(step=i, item=item) removed = len(actions[ACTION_REMOVE]) # resolve path conflicts (must come before getting) @@ -1638,37 +1633,32 @@ wctx[f].audit() wctx[f].write(wctx.filectx(f0).data(), wctx.filectx(f0).flags()) wctx[f0].remove() -z += 1 -progress(_updating, z, item=f, total=numupdates, unit=_files) +progress.increment(item=f) # get in parallel prog = worker.worker(repo.ui, cost, batchget, (repo, mctx, wctx), actions[ACTION_GET]) for i, item in prog: -z += i -progress(_updating, z, item=item, total=numupdates, unit=_files) +progress.increment(step=i, item=item) updated = len(actions[ACTION_GET]) if [a for a in actions[ACTION_GET] if a[0] == '.hgsubstate']: subrepoutil.submerge(repo, wctx, mctx, wctx, overwrite, labels) # forget (manifest only, just log it) (must come first) for f, args, msg in actions[ACTION_FORGET]: repo.ui.debug(" %s: %s -> f\n" % (f, msg)) -z += 1 -
D3767: remove: use progress helper
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/D3767 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 @@ -2181,37 +2181,35 @@ warn = False subs = sorted(wctx.substate) -total = len(subs) -count = 0 +progress = ui.makeprogress(_('searching'), total=len(subs), + unit=_('subrepos')) for subpath in subs: -count += 1 submatch = matchmod.subdirmatcher(subpath, m) if subrepos or m.exact(subpath) or any(submatch.files()): -ui.progress(_('searching'), count, total=total, unit=_('subrepos')) +progress.increment() sub = wctx.sub(subpath) try: if sub.removefiles(submatch, prefix, after, force, subrepos, dryrun, warnings): ret = 1 except error.LookupError: warnings.append(_("skipping missing subrepository: %s\n") % join(subpath)) -ui.progress(_('searching'), None) +progress.update(None) # warn about failure to delete explicit files/dirs deleteddirs = util.dirs(deleted) files = m.files() -total = len(files) -count = 0 +progress = ui.makeprogress(_('deleting'), total=len(files), + unit=_('files')) for f in files: def insubrepo(): for subpath in wctx.substate: if f.startswith(subpath + '/'): return True return False -count += 1 -ui.progress(_('deleting'), count, total=total, unit=_('files')) +progress.increment() isdir = f in deleteddirs or wctx.hasdir(f) if (f in repo.dirstate or isdir or f == '.' or insubrepo() or f in subs): @@ -2226,50 +2224,47 @@ % m.rel(f)) # missing files will generate a warning elsewhere ret = 1 -ui.progress(_('deleting'), None) +progress.update(None) if force: list = modified + deleted + clean + added elif after: list = deleted remaining = modified + added + clean -total = len(remaining) -count = 0 +progress = ui.makeprogress(_('skipping'), total=len(remaining), + unit=_('files')) for f in remaining: -count += 1 -ui.progress(_('skipping'), count, total=total, unit=_('files')) +progress.increment() if ui.verbose or (f in files): warnings.append(_('not removing %s: file still exists\n') % m.rel(f)) ret = 1 -ui.progress(_('skipping'), None) +progress.update(None) else: list = deleted + clean -total = len(modified) + len(added) -count = 0 +progress = ui.makeprogress(_('skipping'), + total=(len(modified) + len(added)), + unit=_('files')) for f in modified: -count += 1 -ui.progress(_('skipping'), count, total=total, unit=_('files')) +progress.increment() warnings.append(_('not removing %s: file is modified (use -f' ' to force removal)\n') % m.rel(f)) ret = 1 for f in added: -count += 1 -ui.progress(_('skipping'), count, total=total, unit=_('files')) +progress.increment() warnings.append(_("not removing %s: file has been marked for add" " (use 'hg forget' to undo add)\n") % m.rel(f)) ret = 1 -ui.progress(_('skipping'), None) +progress.update(None) list = sorted(list) -total = len(list) -count = 0 +progress = ui.makeprogress(_('deleting'), total=len(list), + unit=_('files')) for f in list: -count += 1 if ui.verbose or not m.exact(f): -ui.progress(_('deleting'), count, total=total, unit=_('files')) +progress.increment() ui.status(_('removing %s\n') % m.rel(f)) -ui.progress(_('deleting'), None) +progress.update(None) if not dryrun: with repo.wlock(): 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
D3768: similar: use progress helper
martinvonz created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY Note that a functional change here is that we now show the progress position *before* we start working on the item. This is consistent with how we do it elsewhere. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3768 AFFECTED FILES mercurial/similar.py tests/test-subrepo-deep-nested-change.t CHANGE DETAILS diff --git a/tests/test-subrepo-deep-nested-change.t b/tests/test-subrepo-deep-nested-change.t --- a/tests/test-subrepo-deep-nested-change.t +++ b/tests/test-subrepo-deep-nested-change.t @@ -379,7 +379,7 @@ $ touch bar/abc $ hg addremove -S .. \r (no-eol) (esc) - searching for exact renames [ ] 0/1\r (no-eol) (esc) + searching for exact renames [>] 1/1\r (no-eol) (esc) \r (no-eol) (esc) adding ../sub1/sub2/folder/test.txt removing ../sub1/sub2/test.txt diff --git a/mercurial/similar.py b/mercurial/similar.py --- a/mercurial/similar.py +++ b/mercurial/similar.py @@ -18,24 +18,23 @@ Takes a list of new filectxs and a list of removed filectxs, and yields (before, after) tuples of exact matches. ''' -numfiles = len(added) + len(removed) - # Build table of removed files: {hash(fctx.data()): [fctx, ...]}. # We use hash() to discard fctx.data() from memory. hashes = {} -for i, fctx in enumerate(removed): -repo.ui.progress(_('searching for exact renames'), i, total=numfiles, - unit=_('files')) +progress = repo.ui.makeprogress(_('searching for exact renames'), +total=(len(added) + len(removed)), +unit=_('files')) +for fctx in removed: +progress.increment() h = hash(fctx.data()) if h not in hashes: hashes[h] = [fctx] else: hashes[h].append(fctx) # For each added file, see if it corresponds to a removed file. -for i, fctx in enumerate(added): -repo.ui.progress(_('searching for exact renames'), i + len(removed), -total=numfiles, unit=_('files')) +for fctx in added: +progress.increment() adata = fctx.data() h = hash(adata) for rfctx in hashes.get(h, []): @@ -45,7 +44,7 @@ break # Done -repo.ui.progress(_('searching for exact renames'), None) +progress.update(None) def _ctxdata(fctx): # lazily load text 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
D3770: setdiscovery: use progress helper
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/D3770 AFFECTED FILES mercurial/setdiscovery.py CHANGE DETAILS diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py --- a/mercurial/setdiscovery.py +++ b/mercurial/setdiscovery.py @@ -197,6 +197,7 @@ missing = set() full = False +progress = ui.makeprogress(_('searching'), unit=_('queries')) while undecided: if sample: @@ -226,7 +227,7 @@ sample = samplefunc(dag, undecided, targetsize) roundtrips += 1 -ui.progress(_('searching'), roundtrips, unit=_('queries')) +progress.increment() ui.debug("query %i; still undecided: %i, sample size is: %i\n" % (roundtrips, len(undecided), len(sample))) # indices between sample and externalized version must match @@ -251,7 +252,7 @@ # return any heads in that case, so discard that result.discard(nullrev) elapsed = util.timer() - start -ui.progress(_('searching'), None) +progress.update(None) ui.debug("%d total queries in %.4fs\n" % (roundtrips, elapsed)) msg = ('found %d common and %d unknown server heads,' ' %d roundtrips in %.4fs\n') 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
D3766: changegroup: use progress helper in apply() (API)
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/D3766 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 @@ -237,18 +237,16 @@ pos = next yield closechunk() -def _unpackmanifests(self, repo, revmap, trp, prog, numchanges): -# We know that we'll never have more manifests than we had -# changesets. -self.callback = prog(_('manifests'), numchanges) +def _unpackmanifests(self, repo, revmap, trp, prog): +self.callback = prog.increment # no need to check for empty manifest group here: # if the result of the merge of 1 and 2 is the same in 3 and 4, # no new manifest will be created and the manifest group will # be empty during the pull self.manifestheader() deltas = self.deltaiter() repo.manifestlog._revlog.addgroup(deltas, revmap, trp) -repo.ui.progress(_('manifests'), None) +prog.update(None) self.callback = None def apply(self, repo, tr, srctype, url, targetphase=phases.draft, @@ -293,16 +291,9 @@ # pull off the changeset group repo.ui.status(_("adding changesets\n")) clstart = len(cl) -class prog(object): -def __init__(self, step, total): -self._step = step -self._total = total -self._count = 1 -def __call__(self): -repo.ui.progress(self._step, self._count, unit=_('chunks'), - total=self._total) -self._count += 1 -self.callback = prog(_('changesets'), expectedtotal) +progress = repo.ui.makeprogress(_('changesets'), unit=_('chunks'), +total=expectedtotal) +self.callback = progress.increment efiles = set() def onchangelog(cl, node): @@ -318,12 +309,16 @@ config='warn-empty-changegroup') clend = len(cl) changesets = clend - clstart -repo.ui.progress(_('changesets'), None) +progress.update(None) self.callback = None # pull off the manifest group repo.ui.status(_("adding manifests\n")) -self._unpackmanifests(repo, revmap, trp, prog, changesets) +# We know that we'll never have more manifests than we had +# changesets. +progress = repo.ui.makeprogress(_('manifests'), unit=_('chunks'), +total=changesets) +self._unpackmanifests(repo, revmap, trp, progress) needfiles = {} if repo.ui.configbool('server', 'validate'): @@ -475,9 +470,8 @@ node, p1, p2, deltabase, cs, flags = headertuple return node, p1, p2, deltabase, cs, flags -def _unpackmanifests(self, repo, revmap, trp, prog, numchanges): -super(cg3unpacker, self)._unpackmanifests(repo, revmap, trp, prog, - numchanges) +def _unpackmanifests(self, repo, revmap, trp, prog): +super(cg3unpacker, self)._unpackmanifests(repo, revmap, trp, prog) for chunkdata in iter(self.filelogheader, {}): # If we get here, there are directory manifests in the changegroup d = chunkdata["filename"] 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
D3769: streamclone: use progress helper
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/D3769 AFFECTED FILES mercurial/streamclone.py CHANGE DETAILS diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py --- a/mercurial/streamclone.py +++ b/mercurial/streamclone.py @@ -313,16 +313,15 @@ # This is where we'll add compression in the future. assert compression == 'UN' -seen = 0 -repo.ui.progress(_('bundle'), 0, total=bytecount, unit=_('bytes')) +progress = repo.ui.makeprogress(_('bundle'), total=bytecount, +unit=_('bytes')) +progress.update(0) for chunk in it: -seen += len(chunk) -repo.ui.progress(_('bundle'), seen, total=bytecount, - unit=_('bytes')) +progress.increment(step=len(chunk)) yield chunk -repo.ui.progress(_('bundle'), None) +progress.update(None) return requirements, gen() @@ -338,8 +337,9 @@ with repo.lock(): repo.ui.status(_('%d files to transfer, %s of data\n') % (filecount, util.bytecount(bytecount))) -handled_bytes = 0 -repo.ui.progress(_('clone'), 0, total=bytecount, unit=_('bytes')) +progress = repo.ui.makeprogress(_('clone'), total=bytecount, +unit=_('bytes')) +progress.update(0) start = util.timer() # TODO: get rid of (potential) inconsistency @@ -374,9 +374,7 @@ path = store.decodedir(name) with repo.svfs(path, 'w', backgroundclose=True) as ofp: for chunk in util.filechunkiter(fp, limit=size): -handled_bytes += len(chunk) -repo.ui.progress(_('clone'), handled_bytes, - total=bytecount, unit=_('bytes')) +progress.increment(step=len(chunk)) ofp.write(chunk) # force @filecache properties to be reloaded from @@ -386,7 +384,7 @@ elapsed = util.timer() - start if elapsed <= 0: elapsed = 0.001 -repo.ui.progress(_('clone'), None) +progress.update(None) repo.ui.status(_('transferred %s in %.1f seconds (%s/sec)\n') % (util.bytecount(bytecount), elapsed, util.bytecount(bytecount / elapsed))) @@ -494,8 +492,9 @@ def _emit2(repo, entries, totalfilesize): """actually emit the stream bundle""" vfsmap = _makemap(repo) -progress = repo.ui.progress -progress(_('bundle'), 0, total=totalfilesize, unit=_('bytes')) +progress = repo.ui.makeprogress(_('bundle'), total=totalfilesize, +unit=_('bytes')) +progress.update(0) with maketempcopies() as copy: try: # copy is delayed until we are in the try @@ -522,13 +521,12 @@ chunks = util.filechunkiter(fp, limit=size) for chunk in chunks: seen += len(chunk) -progress(_('bundle'), seen, total=totalfilesize, - unit=_('bytes')) +progress.update(seen) yield chunk finally: fp.close() finally: -progress(_('bundle'), None) +progress.update(None) def generatev2(repo): """Emit content for version 2 of a streaming clone. @@ -589,10 +587,9 @@ (filecount, util.bytecount(filesize))) start = util.timer() -handledbytes = 0 -progress = repo.ui.progress - -progress(_('clone'), handledbytes, total=filesize, unit=_('bytes')) +progress = repo.ui.makeprogress(_('clone'), total=filesize, +unit=_('bytes')) +progress.update(0) vfsmap = _makemap(repo) @@ -614,9 +611,7 @@ with vfs(name, 'w') as ofp: for chunk in util.filechunkiter(fp, limit=datalen): -handledbytes += len(chunk) -progress(_('clone'), handledbytes, total=filesize, - unit=_('bytes')) +progress.increment(step=len(chunk)) ofp.write(chunk) # force @filecache properties to be reloaded from @@ -626,10 +621,10 @@ elapsed = util.timer() - start if elapsed <= 0: elapsed = 0.001 -progress(_('clone'), None) +progress.update(None) repo.ui.status(_('transferred %s in %.1f seconds (%s/sec)\n') % -
Re: [PATCH 3 of 4] diff: accept "dict" as diff option
On 15/06/2018 13:44, Yuya Nishihara wrote: On Fri, 15 Jun 2018 10:48:34 +0200, Boris FELD wrote: I'd rather force callers of ctx.diff() to build a diffopts object. Do you see a way to solves the import cycle? Which one? + Import cycle: mercurial.obsutil -> mercurial.patch -> mercurial.scmutil -> mercurial.obsutil + Import cycle: mercurial.copies -> mercurial.scmutil -> mercurial.obsutil -> mercurial.patch -> mercurial.copies + Import cycle: mercurial.obsolete -> mercurial.obsutil -> mercurial.patch -> mercurial.scmutil -> mercurial.obsolete Maybe we can move patch.diff*opts() functions to either mdiff or new module if that's the case. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3748: import: use context manager for lock, dirstateguard, transaction
martinvonz updated this revision to Diff 9127. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3748?vs=9095=9127 REVISION DETAIL https://phab.mercurial-scm.org/D3748 AFFECTED FILES mercurial/commands.py CHANGE DETAILS diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -40,7 +40,6 @@ hbisect, help, hg, -lock as lockmod, logcmdutil, merge as mergemod, obsolete, @@ -67,8 +66,6 @@ stringutil, ) -release = lockmod.release - table = {} table.update(debugcommandsmod.command._table) @@ -3110,22 +3107,24 @@ raise error.Abort(_('cannot use --exact with --prefix')) base = opts["base"] -dsguard = lock = tr = None msgs = [] ret = 0 with repo.wlock(): -try: -if update: -cmdutil.checkunfinished(repo) -if (exact or not opts.get('force')): -cmdutil.bailifchanged(repo) - -if not opts.get('no_commit'): -lock = repo.lock() -tr = repo.transaction('import') -else: -dsguard = dirstateguard.dirstateguard(repo, 'import') +if update: +cmdutil.checkunfinished(repo) +if (exact or not opts.get('force')): +cmdutil.bailifchanged(repo) + +if not opts.get('no_commit'): +lock = repo.lock +tr = lambda: repo.transaction('import') +dsguard = util.nullcontextmanager +else: +lock = util.nullcontextmanager +tr = util.nullcontextmanager +dsguard = lambda: dirstateguard.dirstateguard(repo, 'import') +with lock(), tr(), dsguard(): parents = repo[None].parents() for patchurl in patches: if patchurl == '-': @@ -3161,17 +3160,9 @@ if not haspatch: raise error.Abort(_('%s: no diffs found') % patchurl) -if tr: -tr.close() if msgs: repo.savecommitmessage('\n* * *\n'.join(msgs)) -if dsguard: -dsguard.close() -return ret -finally: -if tr: -tr.release() -release(lock, dsguard) +return ret @command('incoming|in', [('f', 'force', None, To: martinvonz, #hg-reviewers Cc: yuja, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3748: import: use context manager for lock, dirstateguard, transaction
martinvonz added a comment. In https://phab.mercurial-scm.org/D3748#58833, @yuja wrote: > > +if not opts.get('no_commit'): > > +lock = repo.lock() > > +try: > > > > tr = repo.transaction('import') > > > > - else: > > - dsguard = dirstateguard.dirstateguard(repo, 'import') + except: +lock.release() > > Needs to re-raise. > > > +dsguard = util.nullcontextmanager() > > +else: > > +lock = util.nullcontextmanager() > > +tr = util.nullcontextmanager() > > +dsguard = dirstateguard.dirstateguard(repo, 'import') > > +with lock, tr, dsguard: > > Another option is to wrap transaction and dirstateguard by lambda or partial, > and call them with "with". > > with lock(), tr(), dsguard(): > Good idea. Done. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3748 To: martinvonz, #hg-reviewers Cc: yuja, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3764: rebase: improve output of --dry-run
khanchi97 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/D3764 AFFECTED FILES hgext/rebase.py tests/test-rebase-inmemory.t CHANGE DETAILS diff --git a/tests/test-rebase-inmemory.t b/tests/test-rebase-inmemory.t --- a/tests/test-rebase-inmemory.t +++ b/tests/test-rebase-inmemory.t @@ -208,11 +208,11 @@ Check dryrun gives correct results when there is no conflict in rebasing $ hg rebase -s 2 -d 6 -n + starting dry-run rebase; repository will not be changed rebasing 2:177f92b77385 "c" rebasing 3:055a42cdd887 "d" rebasing 4:e860deea161a "e" - there will be no conflict, you can rebase - rebase aborted + dry-run rebase completed successfully; run without -n/--dry-run to perform this rebase $ hg diff $ hg status @@ -241,11 +241,11 @@ Check dryrun working with --collapse when there is no conflict $ hg rebase -s 2 -d 6 -n --collapse + starting dry-run rebase; repository will not be changed rebasing 2:177f92b77385 "c" rebasing 3:055a42cdd887 "d" rebasing 4:e860deea161a "e" - there will be no conflict, you can rebase - rebase aborted + dry-run rebase completed successfully; run without -n/--dry-run to perform this rebase Check dryrun gives correct results when there is conflict in rebasing Make a conflict: @@ -278,14 +278,14 @@ a $ hg rebase -s 2 -d 7 -n + starting dry-run rebase; repository will not be changed rebasing 2:177f92b77385 "c" rebasing 3:055a42cdd887 "d" rebasing 4:e860deea161a "e" merging e transaction abort! rollback completed hit a merge conflict - rebase aborted $ hg diff $ hg status $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n" @@ -315,9 +315,9 @@ Check dryrun working with --collapse when there is conflicts $ hg rebase -s 2 -d 7 -n --collapse + starting dry-run rebase; repository will not be changed rebasing 2:177f92b77385 "c" rebasing 3:055a42cdd887 "d" rebasing 4:e860deea161a "e" merging e hit a merge conflict - rebase aborted diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -325,7 +325,7 @@ skippedset.update(obsoleteextinctsuccessors) _checkobsrebase(self.repo, self.ui, obsoleteset, skippedset) -def _prepareabortorcontinue(self, isabort): +def _prepareabortorcontinue(self, isabort, **opts): try: self.restorestatus() self.collapsemsg = restorecollapsemsg(self.repo, isabort) @@ -341,8 +341,10 @@ hint = _('use "hg rebase --abort" to clear broken state') raise error.Abort(msg, hint=hint) if isabort: -return abort(self.repo, self.originalwd, self.destmap, - self.state, activebookmark=self.activebookmark) +suppwarning = opts.get(r'dry_run') +return abort(self.repo, self.originalwd, self.destmap, self.state, + activebookmark=self.activebookmark, + suppwarning=suppwarning) def _preparenewrebase(self, destmap): if not destmap: @@ -821,16 +823,19 @@ opts[r'dest'] = '_destautoorphanrebase(SRC)' if dryrun: +ui.status(_('starting dry-run rebase; repository will not be changed\n')) try: overrides = {('rebase', 'singletransaction'): True} with ui.configoverride(overrides, 'rebase'): _origrebase(ui, repo, inmemory=True, leaveunfinished=True, **opts) except error.InMemoryMergeConflictsError: ui.status(_('hit a merge conflict\n')) else: -ui.status(_('there will be no conflict, you can rebase\n')) +ui.status(_('dry-run rebase completed successfully; run without ' +'-n/--dry-run to perform this rebase\n')) finally: -_origrebase(ui, repo, abort=True) +opts = {'abort':True, 'dry_run':True} +_origrebase(ui, repo, **opts) elif inmemory: try: # in-memory merge doesn't support conflicts, so if we hit any, abort @@ -891,7 +896,7 @@ ms = mergemod.mergestate.read(repo) mergeutil.checkunresolved(ms) -retcode = rbsrt._prepareabortorcontinue(abortf) +retcode = rbsrt._prepareabortorcontinue(abortf, **opts) if retcode is not None: return retcode else: @@ -1545,7 +1550,8 @@ return False -def abort(repo, originalwd, destmap, state, activebookmark=None): +def abort(repo, originalwd, destmap, state, activebookmark=None, + suppwarning=None): '''Restore the repository to its original state. Additional args: activebookmark: the name of the bookmark that should be active after the @@ -1599,7 +1605,8 @@
Re: [PATCH 1 of 2] py3: open extension source in binary mode to read docstring as bytes
On Sun, Jun 17, 2018 at 2:41 PM Yuya Nishihara wrote: > # HG changeset patch > # User Yuya Nishihara > # Date 1529225952 -32400 > # Sun Jun 17 17:59:12 2018 +0900 > # Node ID 2c1d983872f6049c73be18d5d9da938b1d61f8fd > # Parent b8f45fc27370dc7df283c47f71927c10462197fb > py3: open extension source in binary mode to read docstring as bytes > Queued the series, many thanks! ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3757: rebase: add dry-run functionality
khanchi97 updated this revision to Diff 9124. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3757?vs=9122=9124 REVISION DETAIL https://phab.mercurial-scm.org/D3757 AFFECTED FILES hgext/rebase.py tests/test-rebase-inmemory.t CHANGE DETAILS diff --git a/tests/test-rebase-inmemory.t b/tests/test-rebase-inmemory.t --- a/tests/test-rebase-inmemory.t +++ b/tests/test-rebase-inmemory.t @@ -155,4 +155,169 @@ |/ o 0: b173517d0057 'a' +Test dry-run rebasing + $ hg init skrepo + $ cd skrepo + $ echo a>a + $ hg ci -Aqma + $ echo b>b + $ hg ci -Aqmb + $ echo c>c + $ hg ci -Aqmc + $ echo d>d + $ hg ci -Aqmd + $ echo e>e + $ hg ci -Aqme + $ hg up 1 -q + $ echo f>f + $ hg ci -Amf + adding f + created new head + $ echo g>g + $ hg ci -Aqmg + $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n" + @ 6:baf10c5166d4 test + | g + | + o 5:6343ca3eff20 test + | f + | + | o 4:e860deea161a test + | | e + | | + | o 3:055a42cdd887 test + | | d + | | + | o 2:177f92b77385 test + |/ c + | + o 1:d2ae7f538514 test + | b + | + o 0:cb9a9f314b8b test + a + +Make sure it throws error while passing --continue or --abort with --dry-run + $ hg rebase -s 2 -d 6 -n --continue + abort: cannot specify both --dry-run and --continue + [255] + $ hg rebase -s 2 -d 6 -n --abort + abort: cannot specify both --dry-run and --abort + [255] + +Check dryrun gives correct results when there is no conflict in rebasing + $ hg rebase -s 2 -d 6 -n + rebasing 2:177f92b77385 "c" + rebasing 3:055a42cdd887 "d" + rebasing 4:e860deea161a "e" + there will be no conflict, you can rebase + rebase aborted + + $ hg diff + $ hg status + + $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n" + @ 6:baf10c5166d4 test + | g + | + o 5:6343ca3eff20 test + | f + | + | o 4:e860deea161a test + | | e + | | + | o 3:055a42cdd887 test + | | d + | | + | o 2:177f92b77385 test + |/ c + | + o 1:d2ae7f538514 test + | b + | + o 0:cb9a9f314b8b test + a + +Check dryrun working with --collapse when there is no conflict + $ hg rebase -s 2 -d 6 -n --collapse + rebasing 2:177f92b77385 "c" + rebasing 3:055a42cdd887 "d" + rebasing 4:e860deea161a "e" + there will be no conflict, you can rebase + rebase aborted + +Check dryrun gives correct results when there is conflict in rebasing +Make a conflict: + $ hg up 6 -q + $ echo conflict>e + $ hg ci -Aqm "conflict with e" + $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n" + @ 7:d2c195b28050 test + | conflict with e + | + o 6:baf10c5166d4 test + | g + | + o 5:6343ca3eff20 test + | f + | + | o 4:e860deea161a test + | | e + | | + | o 3:055a42cdd887 test + | | d + | | + | o 2:177f92b77385 test + |/ c + | + o 1:d2ae7f538514 test + | b + | + o 0:cb9a9f314b8b test + a + + $ hg rebase -s 2 -d 7 -n + rebasing 2:177f92b77385 "c" + rebasing 3:055a42cdd887 "d" + rebasing 4:e860deea161a "e" + merging e + transaction abort! + rollback completed + hit a merge conflict + rebase aborted + $ hg diff + $ hg status + $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n" + @ 7:d2c195b28050 test + | conflict with e + | + o 6:baf10c5166d4 test + | g + | + o 5:6343ca3eff20 test + | f + | + | o 4:e860deea161a test + | | e + | | + | o 3:055a42cdd887 test + | | d + | | + | o 2:177f92b77385 test + |/ c + | + o 1:d2ae7f538514 test + | b + | + o 0:cb9a9f314b8b test + a + +Check dryrun working with --collapse when there is conflicts + $ hg rebase -s 2 -d 7 -n --collapse + rebasing 2:177f92b77385 "c" + rebasing 3:055a42cdd887 "d" + rebasing 4:e860deea161a "e" + merging e + hit a merge conflict + rebase aborted diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -673,8 +673,7 @@ ('a', 'abort', False, _('abort an interrupted rebase')), ('', 'auto-orphans', '', _('automatically rebase orphan revisions ' 'in the specified revset (EXPERIMENTAL)')), - ] + -cmdutil.formatteropts, + ] + cmdutil.dryrunopts + cmdutil.formatteropts, _('[-s REV | -b REV] [-d REV] [OPTION]')) def rebase(ui, repo, **opts): """move changeset (and descendants) to a different branch @@ -798,6 +797,13 @@ """ inmemory = ui.configbool('rebase', 'experimental.inmemory') +dryrun = opts.get(r'dry_run') +if dryrun: +if opts.get(r'abort'): +raise error.Abort(_('cannot specify both --dry-run and --abort')) +if opts.get(r'continue'): +raise error.Abort(_('cannot specify both --dry-run and --continue')) + if (opts.get(r'continue') or opts.get(r'abort') or repo.currenttransaction() is not None):
[PATCH 2 of 2] extensions: use context manger for open()
# HG changeset patch # User Yuya Nishihara # Date 1529226109 -32400 # Sun Jun 17 18:01:49 2018 +0900 # Node ID c6f82a18a63de52c95f0e6ee362ffd0fd4154ccd # Parent 2c1d983872f6049c73be18d5d9da938b1d61f8fd extensions: use context manger for open() diff --git a/mercurial/extensions.py b/mercurial/extensions.py --- a/mercurial/extensions.py +++ b/mercurial/extensions.py @@ -605,12 +605,10 @@ def _moduledoc(file): def _disabledhelp(path): '''retrieve help synopsis of a disabled extension (without importing)''' try: -file = open(path, 'rb') +with open(path, 'rb') as src: +doc = _moduledoc(src) except IOError: return -else: -doc = _moduledoc(file) -file.close() if doc: # extracting localized synopsis return gettext(doc) ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 1 of 2] py3: open extension source in binary mode to read docstring as bytes
# HG changeset patch # User Yuya Nishihara # Date 1529225952 -32400 # Sun Jun 17 17:59:12 2018 +0900 # Node ID 2c1d983872f6049c73be18d5d9da938b1d61f8fd # Parent b8f45fc27370dc7df283c47f71927c10462197fb py3: open extension source in binary mode to read docstring as bytes diff --git a/mercurial/extensions.py b/mercurial/extensions.py --- a/mercurial/extensions.py +++ b/mercurial/extensions.py @@ -605,7 +605,7 @@ def _moduledoc(file): def _disabledhelp(path): '''retrieve help synopsis of a disabled extension (without importing)''' try: -file = open(path) +file = open(path, 'rb') except IOError: return else: ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3757: rebase: add dry-run functionality
khanchi97 added a comment. In https://phab.mercurial-scm.org/D3757#58993, @yuja wrote: > > +dryrun = opts.get(r'dry_run') > > +if dryrun: > > +if opts.get(r'abort'): > > +raise error.Abort(_('cannot specify both --dry-run and --abort')) > > +if opts.get(r'continue'): > > +raise error.Abort(_('cannot specify both --dry-run and --continue')) > > Please remove the excessive 4 spaces before the "raise". Oh, sorry. > > >> +if dryrun: >> +try: >> +overrides = {('rebase', 'singletransaction'): True} >> +with ui.configoverride(overrides, 'rebase'): >> +_origrebase(ui, repo, inmemory=True, dryrun=dryrun, **opts) > > I meant the argument name `dryrun=` is misleading because it actually does > rebase so `inmemory=True` and `_origrebase(ui, repo, abort=True)` are required. > I think it's something like `leaveunfinished=`. Ah, right. I got it. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3757 To: khanchi97, #hg-reviewers, indygreg Cc: yuja, indygreg, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3728: grep: adds allfiles mode
This revision was automatically updated to reflect the committed changes. Closed by commit rHGb8f45fc27370: grep: adds allfiles mode (authored by sangeet259, committed by ). CHANGED PRIOR TO COMMIT https://phab.mercurial-scm.org/D3728?vs=9121=9123#toc REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3728?vs=9121=9123 REVISION DETAIL https://phab.mercurial-scm.org/D3728 AFFECTED FILES mercurial/cmdutil.py mercurial/commands.py tests/test-completion.t tests/test-grep.t CHANGE DETAILS diff --git a/tests/test-grep.t b/tests/test-grep.t --- a/tests/test-grep.t +++ b/tests/test-grep.t @@ -372,6 +372,23 @@ $ cd .. +Test for showing working of allfiles flag + + $ hg init sng + $ cd sng + $ echo "unmod" >> um + $ hg ci -A -m "adds unmod to um" + adding um + $ echo "something else" >> new + $ hg ci -A -m "second commit" + adding new + $ hg grep -r "." "unmod" + [1] + $ hg grep -r "." "unmod" --allfiles + um:1:unmod + + $ cd .. + Fix_Wdir(): test that passing wdir() t -r flag does greps on the files modified in the working directory diff --git a/tests/test-completion.t b/tests/test-completion.t --- a/tests/test-completion.t +++ b/tests/test-completion.t @@ -313,7 +313,7 @@ debugwireproto: localssh, peer, noreadstderr, nologhandshake, ssh, remotecmd, insecure files: rev, print0, include, exclude, template, subrepos graft: rev, continue, stop, edit, log, force, currentdate, currentuser, date, user, tool, dry-run - grep: print0, all, text, follow, ignore-case, files-with-matches, line-number, rev, user, date, template, include, exclude + grep: print0, all, text, follow, ignore-case, files-with-matches, line-number, rev, allfiles, user, date, template, include, exclude heads: rev, topo, active, closed, style, template help: extension, command, keyword, system identify: rev, num, id, branch, tags, bookmarks, ssh, remotecmd, insecure, template diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2403,6 +2403,8 @@ ('n', 'line-number', None, _('print matching line numbers')), ('r', 'rev', [], _('only search files changed within revision range'), _('REV')), +('', 'allfiles', False, + _('include all files in the changeset while grepping (EXPERIMENTAL)')), ('u', 'user', None, _('list the author (long with -v)')), ('d', 'date', None, _('list the date (short with -q)')), ] + formatteropts + walkopts, diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -1881,10 +1881,13 @@ yielding each context, the iterator will first call the prepare function on each context in the window in forward order.''' +allfiles = opts.get('allfiles') follow = opts.get('follow') or opts.get('follow_first') revs = _walkrevs(repo, opts) if not revs: return [] +if allfiles and len(revs) > 1: +raise error.Abort(_("multiple revisions not supported with --allfiles")) wanted = set() slowpath = match.anypats() or (not match.always() and opts.get('removed')) fncache = {} @@ -1990,7 +1993,11 @@ ctx = change(rev) if not fns: def fns_generator(): -for f in ctx.files(): +if allfiles: +fiter = iter(ctx) +else: +fiter = ctx.files() +for f in fiter: if match(f): yield f fns = fns_generator() To: sangeet259, #hg-reviewers Cc: pulkit, yuja, mharbison72, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3728: grep: adds allfiles mode
yuja added a comment. > +if allfiles and len(revs) > 1: > +raise error.Abort(_("multiple revisions not supported with --allfiles")) > > wanted = set() > slowpath = match.anypats() or (not match.always() and opts.get('removed')) > fncache = {} > > @@ -1990,7 +1994,11 @@ > > ctx = change(rev) > if not fns: > def fns_generator(): > > - for f in ctx.files(): +if allfiles and len(revs) == 1: Removed `len(revs) == 1` here and queued, thanks. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3728 To: sangeet259, #hg-reviewers Cc: pulkit, yuja, mharbison72, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3757: rebase: add dry-run functionality
yuja added a comment. > +dryrun = opts.get(r'dry_run') > +if dryrun: > +if opts.get(r'abort'): > +raise error.Abort(_('cannot specify both --dry-run and --abort')) > +if opts.get(r'continue'): > +raise error.Abort(_('cannot specify both --dry-run and --continue')) Please remove the excessive 4 spaces before the "raise". > +if dryrun: > +try: > +overrides = {('rebase', 'singletransaction'): True} > +with ui.configoverride(overrides, 'rebase'): > +_origrebase(ui, repo, inmemory=True, dryrun=dryrun, **opts) I meant the argument name `dryrun=` is misleading because it actually does rebase so `inmemory=True` and `_origrebase(ui, repo, abort=True)` are required. I think it's something like `leaveunfinished=`. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3757 To: khanchi97, #hg-reviewers, indygreg Cc: yuja, indygreg, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: D3757: rebase: add dry-run functionality
> +dryrun = opts.get(r'dry_run') > +if dryrun: > +if opts.get(r'abort'): > +raise error.Abort(_('cannot specify both --dry-run and > --abort')) > +if opts.get(r'continue'): > +raise error.Abort(_('cannot specify both --dry-run and > --continue')) Please remove the excessive 4 spaces before the "raise". > +if dryrun: > +try: > +overrides = {('rebase', 'singletransaction'): True} > +with ui.configoverride(overrides, 'rebase'): > +_origrebase(ui, repo, inmemory=True, dryrun=dryrun, **opts) I meant the argument name `dryrun=` is misleading because it actually does rebase so `inmemory=True` and `_origrebase(ui, repo, abort=True)` are required. I think it's something like `leaveunfinished=`. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: D3728: grep: adds allfiles mode
> +if allfiles and len(revs) > 1: > +raise error.Abort(_("multiple revisions not supported with > --allfiles")) > wanted = set() > slowpath = match.anypats() or (not match.always() and > opts.get('removed')) > fncache = {} > @@ -1990,7 +1994,11 @@ > ctx = change(rev) > if not fns: > def fns_generator(): > -for f in ctx.files(): > +if allfiles and len(revs) == 1: Removed `len(revs) == 1` here and queued, thanks. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3757: rebase: add dry-run functionality
khanchi97 added a comment. @indygreg @yuja thanks for your reviews :) I will send some patches to improve --dry-run for rebase as greg suggested. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3757 To: khanchi97, #hg-reviewers, indygreg Cc: yuja, indygreg, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3757: rebase: add dry-run functionality
khanchi97 added a comment. @yuja I have the made the requested changes. See if I have made the correct changes. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3757 To: khanchi97, #hg-reviewers, indygreg Cc: yuja, indygreg, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3757: rebase: add dry-run functionality
khanchi97 updated this revision to Diff 9122. khanchi97 edited the summary of this revision. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3757?vs=9109=9122 REVISION DETAIL https://phab.mercurial-scm.org/D3757 AFFECTED FILES hgext/rebase.py tests/test-rebase-inmemory.t CHANGE DETAILS diff --git a/tests/test-rebase-inmemory.t b/tests/test-rebase-inmemory.t --- a/tests/test-rebase-inmemory.t +++ b/tests/test-rebase-inmemory.t @@ -155,4 +155,169 @@ |/ o 0: b173517d0057 'a' +Test dry-run rebasing + $ hg init skrepo + $ cd skrepo + $ echo a>a + $ hg ci -Aqma + $ echo b>b + $ hg ci -Aqmb + $ echo c>c + $ hg ci -Aqmc + $ echo d>d + $ hg ci -Aqmd + $ echo e>e + $ hg ci -Aqme + $ hg up 1 -q + $ echo f>f + $ hg ci -Amf + adding f + created new head + $ echo g>g + $ hg ci -Aqmg + $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n" + @ 6:baf10c5166d4 test + | g + | + o 5:6343ca3eff20 test + | f + | + | o 4:e860deea161a test + | | e + | | + | o 3:055a42cdd887 test + | | d + | | + | o 2:177f92b77385 test + |/ c + | + o 1:d2ae7f538514 test + | b + | + o 0:cb9a9f314b8b test + a + +Make sure it throws error while passing --continue or --abort with --dry-run + $ hg rebase -s 2 -d 6 -n --continue + abort: cannot specify both --dry-run and --continue + [255] + $ hg rebase -s 2 -d 6 -n --abort + abort: cannot specify both --dry-run and --abort + [255] + +Check dryrun gives correct results when there is no conflict in rebasing + $ hg rebase -s 2 -d 6 -n + rebasing 2:177f92b77385 "c" + rebasing 3:055a42cdd887 "d" + rebasing 4:e860deea161a "e" + there will be no conflict, you can rebase + rebase aborted + + $ hg diff + $ hg status + + $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n" + @ 6:baf10c5166d4 test + | g + | + o 5:6343ca3eff20 test + | f + | + | o 4:e860deea161a test + | | e + | | + | o 3:055a42cdd887 test + | | d + | | + | o 2:177f92b77385 test + |/ c + | + o 1:d2ae7f538514 test + | b + | + o 0:cb9a9f314b8b test + a + +Check dryrun working with --collapse when there is no conflict + $ hg rebase -s 2 -d 6 -n --collapse + rebasing 2:177f92b77385 "c" + rebasing 3:055a42cdd887 "d" + rebasing 4:e860deea161a "e" + there will be no conflict, you can rebase + rebase aborted + +Check dryrun gives correct results when there is conflict in rebasing +Make a conflict: + $ hg up 6 -q + $ echo conflict>e + $ hg ci -Aqm "conflict with e" + $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n" + @ 7:d2c195b28050 test + | conflict with e + | + o 6:baf10c5166d4 test + | g + | + o 5:6343ca3eff20 test + | f + | + | o 4:e860deea161a test + | | e + | | + | o 3:055a42cdd887 test + | | d + | | + | o 2:177f92b77385 test + |/ c + | + o 1:d2ae7f538514 test + | b + | + o 0:cb9a9f314b8b test + a + + $ hg rebase -s 2 -d 7 -n + rebasing 2:177f92b77385 "c" + rebasing 3:055a42cdd887 "d" + rebasing 4:e860deea161a "e" + merging e + transaction abort! + rollback completed + hit a merge conflict + rebase aborted + $ hg diff + $ hg status + $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n" + @ 7:d2c195b28050 test + | conflict with e + | + o 6:baf10c5166d4 test + | g + | + o 5:6343ca3eff20 test + | f + | + | o 4:e860deea161a test + | | e + | | + | o 3:055a42cdd887 test + | | d + | | + | o 2:177f92b77385 test + |/ c + | + o 1:d2ae7f538514 test + | b + | + o 0:cb9a9f314b8b test + a + +Check dryrun working with --collapse when there is conflicts + $ hg rebase -s 2 -d 7 -n --collapse + rebasing 2:177f92b77385 "c" + rebasing 3:055a42cdd887 "d" + rebasing 4:e860deea161a "e" + merging e + hit a merge conflict + rebase aborted diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -673,8 +673,7 @@ ('a', 'abort', False, _('abort an interrupted rebase')), ('', 'auto-orphans', '', _('automatically rebase orphan revisions ' 'in the specified revset (EXPERIMENTAL)')), - ] + -cmdutil.formatteropts, + ] + cmdutil.dryrunopts + cmdutil.formatteropts, _('[-s REV | -b REV] [-d REV] [OPTION]')) def rebase(ui, repo, **opts): """move changeset (and descendants) to a different branch @@ -798,6 +797,13 @@ """ inmemory = ui.configbool('rebase', 'experimental.inmemory') +dryrun = opts.get(r'dry_run') +if dryrun: +if opts.get(r'abort'): +raise error.Abort(_('cannot specify both --dry-run and --abort')) +if opts.get(r'continue'): +raise error.Abort(_('cannot specify both --dry-run and --continue')) + if (opts.get(r'continue') or opts.get(r'abort') or