Show More
@@ -462,19 +462,17 b' class dirnode(object):' | |||||
462 | if status not in self.statuses: |
|
462 | if status not in self.statuses: | |
463 | self.statuses.add(status) |
|
463 | self.statuses.add(status) | |
464 |
|
464 | |||
465 | def _addfilestotersed(self, tersedict): |
|
465 | def iterfilepaths(self): | |
466 | """ |
|
466 | """ | |
467 | adds files to the their respective status list in the final tersed list |
|
467 | adds files to the their respective status list in the final tersed list | |
468 |
|
468 | |||
469 | path is the path of parent directory of the file |
|
469 | path is the path of parent directory of the file | |
470 | files is a list of tuple where each tuple is (filename, status) |
|
470 | files is a list of tuple where each tuple is (filename, status) | |
471 | tersedict is a dictonary which contains each status abbreviation as key and |
|
|||
472 | list of files and tersed dirs in that status as value |
|
|||
473 | """ |
|
471 | """ | |
474 | for f, st in self.files: |
|
472 | for f, st in self.files: | |
475 |
|
|
473 | yield st, os.path.join(self.path, f) | |
476 |
|
474 | |||
477 |
def |
|
475 | def tersewalk(self, terseargs): | |
478 | """ |
|
476 | """ | |
479 | a recursive function which process status for a certain directory. |
|
477 | a recursive function which process status for a certain directory. | |
480 |
|
478 | |||
@@ -494,12 +492,12 b' class dirnode(object):' | |||||
494 |
|
492 | |||
495 | 1) All the files in the directory (including all the files in its |
|
493 | 1) All the files in the directory (including all the files in its | |
496 | subdirectories) share the same status and the user has asked us to terse |
|
494 | subdirectories) share the same status and the user has asked us to terse | |
497 | that status. -> we add the directory name to status list and return |
|
495 | that status. -> yield (status, dirpath) | |
498 |
|
496 | |||
499 | 2) If '1)' does not happen, we do following: |
|
497 | 2) If '1)' does not happen, we do following: | |
500 |
|
498 | |||
501 |
a) |
|
499 | a) Yield (status, filepath) for all the files which are in this | |
502 |
this directory, not the subdirs) |
|
500 | directory (only the ones in this directory, not the subdirs) | |
503 |
|
501 | |||
504 | b) Recurse the function on all the subdirectories of this |
|
502 | b) Recurse the function on all the subdirectories of this | |
505 | directory |
|
503 | directory | |
@@ -511,15 +509,17 b' class dirnode(object):' | |||||
511 | # Making sure we terse only when the status abbreviation is |
|
509 | # Making sure we terse only when the status abbreviation is | |
512 | # passed as terse argument |
|
510 | # passed as terse argument | |
513 | if onlyst in terseargs: |
|
511 | if onlyst in terseargs: | |
514 |
|
|
512 | yield onlyst, self.path + pycompat.ossep | |
515 | return |
|
513 | return | |
516 |
|
514 | |||
517 | # add the files to status list |
|
515 | # add the files to status list | |
518 | self._addfilestotersed(tersedict) |
|
516 | for st, fpath in self.iterfilepaths(): | |
|
517 | yield st, fpath | |||
519 |
|
518 | |||
520 | #recurse on the subdirs |
|
519 | #recurse on the subdirs | |
521 | for dirobj in self.subdirs.values(): |
|
520 | for dirobj in self.subdirs.values(): | |
522 |
dirobj. |
|
521 | for st, fpath in dirobj.tersewalk(terseargs): | |
|
522 | yield st, fpath | |||
523 |
|
523 | |||
524 | def tersedir(statuslist, terseargs): |
|
524 | def tersedir(statuslist, terseargs): | |
525 | """ |
|
525 | """ | |
@@ -536,7 +536,7 b' def tersedir(statuslist, terseargs):' | |||||
536 |
|
536 | |||
537 | tersedict (defined in the function) is a dictionary which has one word key |
|
537 | tersedict (defined in the function) is a dictionary which has one word key | |
538 | for each status and a list of files and dir in that status as the respective |
|
538 | for each status and a list of files and dir in that status as the respective | |
539 | value. The dictionary is passed to other helper functions which builds it. |
|
539 | value. | |
540 | """ |
|
540 | """ | |
541 | # the order matters here as that is used to produce final list |
|
541 | # the order matters here as that is used to produce final list | |
542 | allst = ('m', 'a', 'r', 'd', 'u', 'i', 'c') |
|
542 | allst = ('m', 'a', 'r', 'd', 'u', 'i', 'c') | |
@@ -558,11 +558,13 b' def tersedir(statuslist, terseargs):' | |||||
558 | tersedict[attrname[0]] = [] |
|
558 | tersedict[attrname[0]] = [] | |
559 |
|
559 | |||
560 | # we won't be tersing the root dir, so add files in it |
|
560 | # we won't be tersing the root dir, so add files in it | |
561 | rootobj._addfilestotersed(tersedict) |
|
561 | for st, fpath in rootobj.iterfilepaths(): | |
|
562 | tersedict[st].append(fpath) | |||
562 |
|
563 | |||
563 | # process each sub-directory and build tersedict |
|
564 | # process each sub-directory and build tersedict | |
564 | for subdir in rootobj.subdirs.values(): |
|
565 | for subdir in rootobj.subdirs.values(): | |
565 |
subdir. |
|
566 | for st, f in subdir.tersewalk(terseargs): | |
|
567 | tersedict[st].append(f) | |||
566 |
|
568 | |||
567 | tersedlist = [] |
|
569 | tersedlist = [] | |
568 | for st in allst: |
|
570 | for st in allst: |
General Comments 0
You need to be logged in to leave comments.
Login now