##// END OF EJS Templates
tersestatus: make methods part of the dirnode class...
Denis Laxalde -
r34684:3d6d4b12 default
parent child Browse files
Show More
@@ -462,29 +462,33 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(path, files, tersedict):
465 def _addfilestotersed(self, tersedict):
466 """ adds files to the their respective status list in the final tersed list
466 """
467 adds files to the their respective status list in the final tersed list
467
468
468 path is the path of parent directory of the file
469 path is the path of parent directory of the file
469 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)
470 tersedict is a dictonary which contains each status abbreviation as key and
471 tersedict is a dictonary which contains each status abbreviation as key and
471 list of files and tersed dirs in that status as value
472 list of files and tersed dirs in that status as value
472 """
473 """
473 for f, st in files:
474 for f, st in self.files:
474 tersedict[st].append(os.path.join(path, f))
475 tersedict[st].append(os.path.join(self.path, f))
475
476
476 def _processtersestatus(subdir, tersedict, terseargs):
477 def _processtersestatus(self, tersedict, terseargs):
477 """a recursive function which process status for a certain directory.
478 """
478
479 a recursive function which process status for a certain directory.
479 subdir is an oject of dirnode class defined below. each object of dirnode
480
480 class has a set of statuses which files in that directory has. This ease our
481 self is an oject of dirnode class defined below. each object of dirnode
481 check whether we can terse that directory or not.
482 class has a set of statuses which files in that directory has. This ease
482
483 our check whether we can terse that directory or not.
483 tersedict is a dictonary which contains each status abbreviation as key and
484
484 list of files and tersed dirs in that status as value. In each function call
485 tersedict is a dictonary which contains each status abbreviation as key
485 we are passing the same dict and adding files and dirs to it.
486 and list of files and tersed dirs in that status as value. In each
486
487 function call we are passing the same dict and adding files and dirs
487 terseargs is the string of arguments passed by the user with `--terse` flag.
488 to it.
489
490 terseargs is the string of arguments passed by the user with `--terse`
491 flag.
488
492
489 Following are the cases which can happen:
493 Following are the cases which can happen:
490
494
@@ -497,24 +501,25 b' def _processtersestatus(subdir, tersedic'
497 a) Add all the files which are in this directory (only the ones in
501 a) Add all the files which are in this directory (only the ones in
498 this directory, not the subdirs) to their respective status list
502 this directory, not the subdirs) to their respective status list
499
503
500 b) Recurse the function on all the subdirectories of this directory
504 b) Recurse the function on all the subdirectories of this
505 directory
501 """
506 """
502
507
503 if len(subdir.statuses) == 1:
508 if len(self.statuses) == 1:
504 onlyst = subdir.statuses.pop()
509 onlyst = self.statuses.pop()
505
510
506 # Making sure we terse only when the status abbreviation is passed as
511 # Making sure we terse only when the status abbreviation is
507 # terse argument
512 # passed as terse argument
508 if onlyst in terseargs:
513 if onlyst in terseargs:
509 tersedict[onlyst].append(subdir.path + pycompat.ossep)
514 tersedict[onlyst].append(self.path + pycompat.ossep)
510 return
515 return
511
516
512 # add the files to status list
517 # add the files to status list
513 _addfilestotersed(subdir.path, subdir.files, tersedict)
518 self._addfilestotersed(tersedict)
514
519
515 #recurse on the subdirs
520 #recurse on the subdirs
516 for dirobj in subdir.subdirs.values():
521 for dirobj in self.subdirs.values():
517 _processtersestatus(dirobj, tersedict, terseargs)
522 dirobj._processtersestatus(tersedict, terseargs)
518
523
519 def tersedir(statuslist, terseargs):
524 def tersedir(statuslist, terseargs):
520 """
525 """
@@ -553,11 +558,11 b' def tersedir(statuslist, terseargs):'
553 tersedict[attrname[0]] = []
558 tersedict[attrname[0]] = []
554
559
555 # 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
556 _addfilestotersed(rootobj.path, rootobj.files, tersedict)
561 rootobj._addfilestotersed(tersedict)
557
562
558 # process each sub-directory and build tersedict
563 # process each sub-directory and build tersedict
559 for subdir in rootobj.subdirs.values():
564 for subdir in rootobj.subdirs.values():
560 _processtersestatus(subdir, tersedict, terseargs)
565 subdir._processtersestatus(tersedict, terseargs)
561
566
562 tersedlist = []
567 tersedlist = []
563 for st in allst:
568 for st in allst:
General Comments 0
You need to be logged in to leave comments. Login now