164 if revrangesep in spec: |
165 if revrangesep in spec: |
165 start, end = spec.split(revrangesep, 1) |
166 start, end = spec.split(revrangesep, 1) |
166 start = revfix(repo, start, 0) |
167 start = revfix(repo, start, 0) |
167 end = revfix(repo, end, len(repo) - 1) |
168 end = revfix(repo, end, len(repo) - 1) |
168 step = start > end and -1 or 1 |
169 step = start > end and -1 or 1 |
169 for rev in xrange(start, end+step, step): |
170 for rev in xrange(start, end + step, step): |
170 if rev in seen: |
171 if rev in seen: |
171 continue |
172 continue |
172 seen.add(rev) |
173 seen.add(rev) |
173 l.append(rev) |
174 l.append(rev) |
174 else: |
175 else: |
567 '''Run a command as a service.''' |
568 '''Run a command as a service.''' |
568 |
569 |
569 if opts['daemon'] and not opts['daemon_pipefds']: |
570 if opts['daemon'] and not opts['daemon_pipefds']: |
570 # Signal child process startup with file removal |
571 # Signal child process startup with file removal |
571 lockfd, lockpath = tempfile.mkstemp(prefix='hg-service-') |
572 lockfd, lockpath = tempfile.mkstemp(prefix='hg-service-') |
572 os.close(lockfd) |
573 os.close(lockfd) |
573 try: |
574 try: |
574 if not runargs: |
575 if not runargs: |
575 runargs = util.hgcmd() + sys.argv[1:] |
576 runargs = util.hgcmd() + sys.argv[1:] |
576 runargs.append('--daemon-pipefds=%s' % lockpath) |
577 runargs.append('--daemon-pipefds=%s' % lockpath) |
577 # Don't pass --cwd to the child process, because we've already |
578 # Don't pass --cwd to the child process, because we've already |
578 # changed directory. |
579 # changed directory. |
579 for i in xrange(1,len(runargs)): |
580 for i in xrange(1, len(runargs)): |
580 if runargs[i].startswith('--cwd='): |
581 if runargs[i].startswith('--cwd='): |
581 del runargs[i] |
582 del runargs[i] |
582 break |
583 break |
583 elif runargs[i].startswith('--cwd'): |
584 elif runargs[i].startswith('--cwd'): |
584 del runargs[i:i+2] |
585 del runargs[i:i + 2] |
585 break |
586 break |
586 pid = util.spawndetached(runargs) |
587 pid = util.spawndetached(runargs) |
587 while os.path.exists(lockpath): |
588 while os.path.exists(lockpath): |
588 time.sleep(0.1) |
589 time.sleep(0.1) |
589 finally: |
590 finally: |
590 try: |
591 try: |
591 os.unlink(lockpath) |
592 os.unlink(lockpath) |
901 if style and not tmpl: |
902 if style and not tmpl: |
902 mapfile = style |
903 mapfile = style |
903 if not os.path.split(mapfile)[0]: |
904 if not os.path.split(mapfile)[0]: |
904 mapname = (templater.templatepath('map-cmdline.' + mapfile) |
905 mapname = (templater.templatepath('map-cmdline.' + mapfile) |
905 or templater.templatepath(mapfile)) |
906 or templater.templatepath(mapfile)) |
906 if mapname: mapfile = mapname |
907 if mapname: |
|
908 mapfile = mapname |
907 |
909 |
908 try: |
910 try: |
909 t = changeset_templater(ui, repo, patch, opts, mapfile, buffered) |
911 t = changeset_templater(ui, repo, patch, opts, mapfile, buffered) |
910 except SyntaxError, inst: |
912 except SyntaxError, inst: |
911 raise util.Abort(inst.args[0]) |
913 raise util.Abort(inst.args[0]) |
912 if tmpl: t.use_template(tmpl) |
914 if tmpl: |
|
915 t.use_template(tmpl) |
913 return t |
916 return t |
914 |
917 |
915 def finddate(ui, repo, date): |
918 def finddate(ui, repo, date): |
916 """Find the tipmost changeset that matches the given date spec""" |
919 """Find the tipmost changeset that matches the given date spec""" |
917 |
920 |
949 function on each context in the window in forward order.''' |
952 function on each context in the window in forward order.''' |
950 |
953 |
951 def increasing_windows(start, end, windowsize=8, sizelimit=512): |
954 def increasing_windows(start, end, windowsize=8, sizelimit=512): |
952 if start < end: |
955 if start < end: |
953 while start < end: |
956 while start < end: |
954 yield start, min(windowsize, end-start) |
957 yield start, min(windowsize, end - start) |
955 start += windowsize |
958 start += windowsize |
956 if windowsize < sizelimit: |
959 if windowsize < sizelimit: |
957 windowsize *= 2 |
960 windowsize *= 2 |
958 else: |
961 else: |
959 while start > end: |
962 while start > end: |
960 yield start, min(windowsize, start-end-1) |
963 yield start, min(windowsize, start - end - 1) |
961 start -= windowsize |
964 start -= windowsize |
962 if windowsize < sizelimit: |
965 if windowsize < sizelimit: |
963 windowsize *= 2 |
966 windowsize *= 2 |
964 |
967 |
965 follow = opts.get('follow') or opts.get('follow_first') |
968 follow = opts.get('follow') or opts.get('follow_first') |
1012 if not len(filelog): |
1015 if not len(filelog): |
1013 if node is None: |
1016 if node is None: |
1014 # A zero count may be a directory or deleted file, so |
1017 # A zero count may be a directory or deleted file, so |
1015 # try to find matching entries on the slow path. |
1018 # try to find matching entries on the slow path. |
1016 if follow: |
1019 if follow: |
1017 raise util.Abort(_('cannot follow nonexistent file: "%s"') % file_) |
1020 raise util.Abort( |
|
1021 _('cannot follow nonexistent file: "%s"') % file_) |
1018 slowpath = True |
1022 slowpath = True |
1019 break |
1023 break |
1020 else: |
1024 else: |
1021 continue |
1025 continue |
1022 for rev, copied in filerevgen(filelog, node): |
1026 for rev, copied in filerevgen(filelog, node): |
1086 # is descending and the prune args are all within that range |
1090 # is descending and the prune args are all within that range |
1087 for rev in opts.get('prune', ()): |
1091 for rev in opts.get('prune', ()): |
1088 rev = repo.changelog.rev(repo.lookup(rev)) |
1092 rev = repo.changelog.rev(repo.lookup(rev)) |
1089 ff = followfilter() |
1093 ff = followfilter() |
1090 stop = min(revs[0], revs[-1]) |
1094 stop = min(revs[0], revs[-1]) |
1091 for x in xrange(rev, stop-1, -1): |
1095 for x in xrange(rev, stop - 1, -1): |
1092 if ff.match(x): |
1096 if ff.match(x): |
1093 wanted.discard(x) |
1097 wanted.discard(x) |
1094 |
1098 |
1095 def iterate(): |
1099 def iterate(): |
1096 if follow and not match.files(): |
1100 if follow and not match.files(): |
1101 def want(rev): |
1105 def want(rev): |
1102 return rev in wanted |
1106 return rev in wanted |
1103 |
1107 |
1104 for i, window in increasing_windows(0, len(revs)): |
1108 for i, window in increasing_windows(0, len(revs)): |
1105 change = util.cachefunc(repo.changectx) |
1109 change = util.cachefunc(repo.changectx) |
1106 nrevs = [rev for rev in revs[i:i+window] if want(rev)] |
1110 nrevs = [rev for rev in revs[i:i + window] if want(rev)] |
1107 for rev in sorted(nrevs): |
1111 for rev in sorted(nrevs): |
1108 fns = fncache.get(rev) |
1112 fns = fncache.get(rev) |
1109 ctx = change(rev) |
1113 ctx = change(rev) |
1110 if not fns: |
1114 if not fns: |
1111 def fns_generator(): |
1115 def fns_generator(): |