##// END OF EJS Templates
scm: optimized get_nodes function....
marcink -
r3461:d0ff5601 default
parent child Browse files
Show More
@@ -513,6 +513,8 b' class ScmModel(BaseModel):'
513 513 :param commit_id: commit id for which to list nodes
514 514 :param root_path: root path to list
515 515 :param flat: return as a list, if False returns a dict with description
516 :param extended_info: show additional info such as md5, binary, size etc
517 :param content: add nodes content to the return data
516 518 :param max_file_bytes: will not return file contents over this limit
517 519
518 520 """
@@ -523,15 +525,14 b' class ScmModel(BaseModel):'
523 525 commit = _repo.scm_instance().get_commit(commit_id=commit_id)
524 526 root_path = root_path.lstrip('/')
525 527 for __, dirs, files in commit.walk(root_path):
528
526 529 for f in files:
527 530 _content = None
528 _data = f.unicode_path
529 over_size_limit = (max_file_bytes is not None
530 and f.size > max_file_bytes)
531 _data = f_name = f.unicode_path
531 532
532 533 if not flat:
533 534 _data = {
534 "name": h.escape(f.unicode_path),
535 "name": h.escape(f_name),
535 536 "type": "file",
536 537 }
537 538 if extended_info:
@@ -545,6 +546,8 b' class ScmModel(BaseModel):'
545 546 })
546 547
547 548 if content:
549 over_size_limit = (max_file_bytes is not None
550 and f.size > max_file_bytes)
548 551 full_content = None
549 552 if not f.is_binary and not over_size_limit:
550 553 full_content = safe_str(f.content)
@@ -553,11 +556,12 b' class ScmModel(BaseModel):'
553 556 "content": full_content,
554 557 })
555 558 _files.append(_data)
559
556 560 for d in dirs:
557 _data = d.unicode_path
561 _data = d_name = d.unicode_path
558 562 if not flat:
559 563 _data = {
560 "name": h.escape(d.unicode_path),
564 "name": h.escape(d_name),
561 565 "type": "dir",
562 566 }
563 567 if extended_info:
General Comments 0
You need to be logged in to leave comments. Login now