Shelves the file if it is in a changelist

        :param changelist: Changelist to add the move to
        :type changelist: :class:`.Changelist`
969882
def shelve(self, changelist=None):
        
        if changelist is None and self.changelist.description == 'default':
            raise errors.ShelveError('Unabled to shelve files in the default changelist')

        cmd = ['shelve']
        if changelist:
            cmd += ['-c', str(changelist)]

        cmd.append(self.depotFile)

        self._connection.run(cmd)

        self.query()
141263
public static void addToListIfNotExists(List<String> list, String value) {
        boolean found = false;
        for (String item : list) {
            if (item.equalsIgnoreCase(value)) {
                found = true;
                break;
            }
        }
        if (!found) {
            list.add(value);
        }
    }
353993
def on_commit(self, changes):
        
        if _get_config(self)['enable_indexing'] is False:
            return None

        for wh in self.whoosheers:
            if not wh.auto_update:
                continue
            writer = None
            for change in changes:
                if change[0].__class__ in wh.models:
                    method_name = '{0}_{1}'.format(change[1], change[0].__class__.__name__.lower())
                    method = getattr(wh, method_name, None)
                    if method:
                        if not writer:
                            writer = type(self).get_or_create_index(_get_app(self), wh).\
                                writer(timeout=_get_config(self)['writer_timeout'])
                        method(writer, change[0])
            if writer:
                writer.commit()
445643
def add(self, resource):
        
        if isinstance(resource, collections.Iterable):
            for r in resource:
                self.add_if_changed(r)
        else:
            self.add_if_changed(resource)
590855
def seek(self, offset):
        
        if self._shifts:
            if 0 <= offset < len(self._shifts):
                current_pos = self._file.tell()
                new_pos = self._shifts[offset]
                if current_pos != new_pos:
                    if current_pos == self._shifts[-1]:  # reached the end of the file
                        self._data = self.__reader()
                        self.__file = iter(self._file.readline, '')
                    self._file.seek(new_pos)
            else:
                raise IndexError('invalid offset')
        else:
            raise self._implement_error
557470
def changes(self):
        
        try:
            return self.added, self.removed
        finally:
            self.added = list()
            self.removed = list()
42825
public static void populateFilesList(File dir, List<File> filesListInDir) {
		File[] files = dir.listFiles();
		for(File file : files){
			if(file.isFile()){
				filesListInDir.add(file);
			}else{
				populateFilesList(file, filesListInDir);
			}
		}
	}
113036
function set(changeList, property, value) {
        changeList.push({
            type:'set',
            path: property,
            val: value
        })
    }
1322463
def add_line_if_absent(filename: str, line: str) -> None:
    
    assert "\n" not in line
    if not is_line_in_file(filename, line):
        log.info("Appending line {!r} to file {!r}", line, filename)
        with open(filename, "a") as file:
            file.writelines([line])
1073212
private function didAnyFileChange(array $changedFiles) : bool
    {
        foreach ($this->filesToWatch as $file) {
            if (in_array($file, $changedFiles)) {
                return true;
            }
        }
        return false;
    }
110981
private void updateList(final Map<URI, URI> changeTable, final Map<URI, URI> conflictTable, final ChunkMapReader mapReader) {
        final URI xmlDitalist = job.tempDirURI.resolve("dummy.xml");

        final Set<URI> hrefTopics = new HashSet<>();
        final Set<URI> chunkTopicSet = mapReader.getChunkTopicSet();
        for (final FileInfo f : job.getFileInfo()) {
            final URI abs = job.tempDirURI.resolve(f.uri);
            if (f.isTarget && !chunkTopicSet.contains(abs)) {
                hrefTopics.add(f.uri);
            }
        }
        for (final FileInfo f : job.getFileInfo()) {
            final URI abs = job.tempDirURI.resolve(f.uri);
            if (chunkTopicSet.contains(abs)) {
                final URI s = f.uri;
                if (s.getFragment() == null) {
                    // This entry does not have an anchor, we assume that this
                    // topic will
                    // be fully chunked. Thus it should not produce any output.
                    // The entry in hrefTopics points to the same target
                    // as entry in chunkTopics, it should be removed.
                    hrefTopics.removeIf(ent -> job.tempDirURI.resolve(ent).equals(
                            job.tempDirURI.resolve(s)));
                } else {
                    hrefTopics.remove(s);
                }
            }
        }

        // relative temporary files
        final Set<URI> topicList = new LinkedHashSet<>(128);
        final Set<URI> oldTopicList = new HashSet<>();
        for (final FileInfo f : job.getFileInfo()) {
            if (ATTR_FORMAT_VALUE_DITA.equals(f.format)) {
                oldTopicList.add(f.uri);
            }
        }
        for (final URI t : hrefTopics) {
            topicList.add(t);
            oldTopicList.remove(t);
        }

        final Set<URI> chunkedTopicSet = new LinkedHashSet<>(128);
        final Set<URI> chunkedDitamapSet = new LinkedHashSet<>(128);
        final Set<URI> ditamapList = new HashSet<>();
        for (final FileInfo f : job.getFileInfo()) {
            if (ATTR_FORMAT_VALUE_DITAMAP.equals(f.format)) {
                ditamapList.add(f.uri);
            }
        }
        for (final Map.Entry<URI, URI> entry : changeTable.entrySet()) {
            final URI oldFile = entry.getKey();
            final URI newFile = entry.getValue();
            if (newFile.equals(oldFile)) {
                // newly chunked file
                final URI newChunkedFile = getRelativePath(xmlDitalist, newFile);
                final String extName = getExtension(newChunkedFile.getPath());
                if (extName != null && !extName.equalsIgnoreCase(ATTR_FORMAT_VALUE_DITAMAP)) {
                    chunkedTopicSet.add(newChunkedFile);
                    if (!topicList.contains(newChunkedFile)) {
                        topicList.add(newChunkedFile);
                        // newly chunked file shouldn't be deleted
                        oldTopicList.remove(newChunkedFile);
                    }
                } else {
                    if (!ditamapList.contains(newChunkedFile)) {
                        ditamapList.add(newChunkedFile);
                        oldTopicList.remove(newChunkedFile);
                    }
                    chunkedDitamapSet.add(newChunkedFile);
                }

            }
        }
        // removed extra topic files
        for (final URI s : oldTopicList) {
            final File f = new File(job.tempDirURI.resolve(s));
            logger.debug("Delete " + f.toURI());
            if (f.exists() && !f.delete()) {
                logger.error("Failed to delete " + f.getAbsolutePath());
            }
        }

        // TODO we have refined topic list and removed extra topic files, next
        // we need to clean up
        // conflictTable and try to resolve file name conflicts.
        for (final Map.Entry<URI, URI> entry : changeTable.entrySet()) {
            final URI oldFile = entry.getKey();
            final URI from = entry.getValue();
            if (from.equals(oldFile)) {
                // original topic file
                // FIXME
                final URI targetPath = conflictTable.get(oldFile);
                if (targetPath != null) {
                    final URI target = targetPath;
                    if (!new File(target).exists()) {
                        // newly chunked file
                        URI relativePath = getRelativePath(xmlDitalist, from);
                        final URI relativeTargetPath = getRelativePath(xmlDitalist, target);
                        if (relativeTargetPath.getPath().contains(URI_SEPARATOR)) {
                            relativePath2fix.put(relativeTargetPath,
                                    relativeTargetPath.getPath().substring(0, relativeTargetPath.getPath().lastIndexOf(URI_SEPARATOR) + 1));
                        }
                        // ensure the newly chunked file to the old one
                        try {
                            logger.debug("Delete " + target);
                            deleteQuietly(new File(target));
                            logger.debug("Move " + from + " to " + target);
                            moveFile(new File(from), new File(target));
                            final FileInfo fi = job.getFileInfo(from);
                            if (fi != null) {
                                job.remove(fi);
                            }
                        } catch (final IOException e) {
                            logger.error("Failed to replace chunk topic: " + e.getMessage(), e);

                        }
                        topicList.remove(relativePath);
                        chunkedTopicSet.remove(relativePath);
                        relativePath = getRelativePath(xmlDitalist, target);
                        topicList.add(relativePath);
                        chunkedTopicSet.add(relativePath);
                    } else {
                        conflictTable.remove(oldFile);
                    }
                }
            }
        }

        final Set<URI> all = new HashSet<>();
        all.addAll(topicList);
        all.addAll(ditamapList);
        all.addAll(chunkedDitamapSet);
        all.addAll(chunkedTopicSet);

        // remove redundant topic information
        for (final URI file : oldTopicList) {
            if (!all.contains(file)) {
                final FileInfo fi = job.getFileInfo(file);
                if (fi != null) {
                    job.remove(fi);
                }
            }
        }

        for (final URI file : topicList) {
            // FIXME
            final FileInfo ff = job.getOrCreateFileInfo(stripFragment(file));
            ff.format = ATTR_FORMAT_VALUE_DITA;
        }
        for (final URI file : ditamapList) {
            final FileInfo ff = job.getOrCreateFileInfo(file);
            ff.format = ATTR_FORMAT_VALUE_DITAMAP;
        }

        for (final URI file : chunkedDitamapSet) {
            final FileInfo f = job.getOrCreateFileInfo(file);
            f.format = ATTR_FORMAT_VALUE_DITAMAP;
            f.isResourceOnly = false;
        }
        for (final URI file : chunkedTopicSet) {
            // FIXME
            final FileInfo f = job.getOrCreateFileInfo(stripFragment(file));
            f.format = ATTR_FORMAT_VALUE_DITA;
            f.isResourceOnly = false;
        }

        try {
            job.write();
        } catch (final IOException ex) {
            logger.error(ex.getMessage(), ex);
        }
    }
354659
def add(self, filename, change=None):
        
        try:
            if not self.canAdd(filename):
                raise errors.RevisionError('File is not under client path')

            if change is None:
                self.run(['add', filename])
            else:
                self.run(['add', '-c', str(change.change), filename])

            data = self.run(['fstat', filename])[0]
        except errors.CommandError as err:
            LOGGER.debug(err)
            raise errors.RevisionError('File is not under client path')

        rev = Revision(data, self)

        if isinstance(change, Changelist):
            change.append(rev)

        return rev
67451
def _process_list(self, list_line):
        # -rw-r--r-- 1 ftp ftp 68	 May 09 19:37 testftp.txt
        
        res = list_line.split(' ', 8)
        if res[0].startswith('-'):
            self.state['file_list'].append(res[-1])
        if res[0].startswith('d'):
            self.state['dir_list'].append(res[-1])
1104419
private void addCurrentDirFiles(List<File> theFiles, List<File> theDirs, File currentDir) {
    File dirs[] = currentDir.listFiles(new FileFilter() {

      @Override
      public boolean accept(File file) {
        return file.isDirectory() && !file.getName().startsWith(".") && !file.getName().equals("META-INF");
      }
      
    });
    
    File htmlFiles[] = currentDir.listFiles(new FileFilter() {

      @Override
      public boolean accept(File file) {
        return !file.isDirectory() && file.isFile() && file.canRead() && !file.getName().startsWith(".") && (file.getName().endsWith(".html") || file.getName().endsWith(".htm"));
      }
      
    });
    
    if(dirs != null && dirs.length > 0) {
      theDirs.addAll(Arrays.asList(dirs));
    }
    if(htmlFiles != null && htmlFiles.length > 0) {
      theFiles.addAll(Arrays.asList(htmlFiles));
    }
  }
548697
def seek(self, offset):
        
        if self._shifts:
            if 0 <= offset < len(self._shifts):
                current_pos = self._file.tell()
                new_pos = self._shifts[offset]
                if current_pos != new_pos:
                    if current_pos == self._shifts[-1]:  # reached the end of the file
                        self._data = self.__reader()
                        self.__file = iter(self._file.readline, '')
                        self._file.seek(0)
                        next(self._data)
                        if offset:  # move not to the beginning of the file
                            self._file.seek(new_pos)
                    else:
                        if not self.__already_seeked:
                            if self._shifts[0] < current_pos:  # in the middle of the file
                                self._data.send(True)
                            self.__already_seeked = True
                        self._file.seek(new_pos)
            else:
                raise IndexError('invalid offset')
        else:
            raise self._implement_error
1310983
def _force_on_change(self):
        
        for layout in self.force_on_change:
            if layout in self.available_combinations:
                if self.active_layout != layout:
                    self.displayed = layout
                    self._apply(force=True)
                    self.py3.update()
                    break
                else:
                    break
389305
def commits(self, drop_collections=True):
        
        base_df = self._data
        if drop_collections is True:
            out_df = self._drop_collections(base_df)
        else:
            out_df = base_df
        return out_df