Splits a revision ID into its generation number and opaque suffix string
335059
public static int parseRevIDNumber(String rev) {
        int result = -1;
        int dashPos = rev.indexOf('-');
        if (dashPos >= 0) {
            try {
                result = Integer.parseInt(rev.substring(0, dashPos));
            } catch (NumberFormatException e) {
                // ignore, let it return -1
            }
        }
        return result;
    }
876235
def flatten_tree_to_ident_hashes(item_or_tree,
                                 lucent_id=TRANSLUCENT_BINDER_ID):
    """"""
    if 'contents' in item_or_tree:
        tree = item_or_tree
        if tree['id'] != lucent_id:
            yield tree['id']
        for i in tree['contents']:
            # yield from flatten_tree_to_ident_hashs(i, lucent_id)
            for x in flatten_tree_to_ident_hashes(i, lucent_id):
                yield x
    else:
        item = item_or_tree
        yield item['id']
531238
@InterfaceAudience.Public
    public String getDocumentRevisionId() {
        // Get the revision id from either the embedded document contents,
        // or the '_rev' or 'rev' value key:
        String rev = null;
        if (documentRevision != null)
            rev = documentRevision.getRevID();
        if (rev == null) {
            if (value instanceof Map) {
                Map<String, Object> mapValue = (Map<String, Object>) value;
                rev = (String) mapValue.get("_rev");
                if (rev == null) {
                    rev = (String) mapValue.get("rev");
                }
            }
        }
        return rev;
    }
1019741
def tokenize_version(version_string: str) -> Tuple[int, int, int]:
    
    before_dash = version_string.split('-')[0]
    major, minor, patch = before_dash.split('.')[:3]  # take only the first 3 in case there's an extension like -dev.0
    return int(major), int(minor), int(patch)
1260861
def _split_version_specifier(spec):
    """"""
    m = re.search(r'([<>=]?=?)?\s*([0-9.a-zA-Z]+)', spec)
    return m.group(2), m.group(1)
236368
def _get_next_version(self, revisions):
        
        versions = [0]
        for v in revisions:
            if v.isdigit():
                versions.append(int(v))
        return six.text_type(sorted(versions)[-1] + 1)
568809
def show_revisions(context, page, content_type, lang=None):
    """"""
    if not pages_settings.PAGE_CONTENT_REVISION:
        return {'revisions': None}
    revisions = Content.objects.filter(page=page, language=lang,
                                type=content_type).order_by('-creation_date')
    if len(revisions) < 2:
        return {'revisions': None}
    return {'revisions': revisions[0:10]}
592349
def _pull_content_revision_parent(self):
        

        if self._revision_id is None:
            query_params = {
                "prop": "extracts|revisions",
                "explaintext": "",
                "rvprop": "ids",
            }
            query_params.update(self.__title_query_param())
            request = self.mediawiki.wiki_request(query_params)
            page_info = request["query"]["pages"][self.pageid]
            self._content = page_info["extract"]
            self._revision_id = page_info["revisions"][0]["revid"]
            self._parent_id = page_info["revisions"][0]["parentid"]
        return self._content, self._revision_id, self._parent_id
913084
def resolve_revision
      revision = @repository.tag.to_s.strip
      if revision.empty?
        revision = nil
      elsif (revision =~ SVN_REVISION_REGEX).nil?
        raise RetrieverError, "Revision reference contained illegal characters: #{revision.inspect}"
      end
      # timestamps can contain spaces; surround them with double quotes.
      revision = revision.inspect if revision.index(' ')
      revision
    end
322309
def find_string_ids(self, substring, suffix_tree_id, limit=None):
        

        # Find an edge for the substring.
        edge, ln = self.find_substring_edge(substring=substring, suffix_tree_id=suffix_tree_id)

        # If there isn't an edge, return an empty set.
        if edge is None:
            return set()

        # Get all the string IDs beneath the edge's destination node.
        string_ids = get_string_ids(
            node_id=edge.dest_node_id,
            node_repo=self.node_repo,
            node_child_collection_repo=self.node_child_collection_repo,
            stringid_collection_repo=self.stringid_collection_repo,
            length_until_end=edge.length + 1 - ln,
            limit=limit
        )

        # Return a set of string IDs.
        return set(string_ids)
1055465
def get_cached_document_ids(ids, doc_type):
    """"""
    for batch in _split_list(ids):
        for id in _get_cached_document_ids(batch, doc_type):
            yield id
1368225
def from_git_rev_read(path):
    """"""
    if ":" not in path:
        raise ValueError("Path identifier must start with a revision hash.")

    cmd = "git", "show", "-t", path
    try:
        return subprocess.check_output(cmd).rstrip().decode("utf-8")
    except subprocess.CalledProcessError:
        raise ValueError
589285
def from_string(self, sid_string):
        
        if not sid_string.startswith("S-"):
            raise ValueError("A SID string must start with S-")

        sid_entries = sid_string.split("-")
        if len(sid_entries) < 3:
            raise ValueError("A SID string must start with S and contain a "
                             "revision and identifier authority, e.g. S-1-0")

        revision = int(sid_entries[1])
        id_authority = int(sid_entries[2])
        sub_authorities = [int(i) for i in sid_entries[3:]]

        self['revision'].set_value(revision)
        self['identifier_authority'].set_value(id_authority)
        self['sub_authorities'] = sub_authorities
739144
def iddversiontuple(afile):
    """"""
    def versiontuple(vers):
        """version tuple"""
        return tuple([int(num) for num in vers.split(".")])
    try:
        fhandle = open(afile, 'rb')
    except TypeError:
        fhandle = afile
    line1 = fhandle.readline()
    try:
        line1 = line1.decode('ISO-8859-2')
    except AttributeError:
        pass
    line = line1.strip()
    if line1 == '':
        return (0,)
    vers = line.split()[-1]
    return versiontuple(vers)
746853
def _split_identifier(self, identifier):
        """"""
        try:
            name, subscript = identifier.split("_", 1)
        except (TypeError, ValueError, AttributeError):
            name = identifier
            subscript = ''
        return self._render_str(name), self._render_str(subscript)
601617
def modify_filename_id(filename):
    """"""
    split_filename = os.path.splitext(filename)
    id_num_re = re.compile('(\(\d\))')
    id_num = re.findall(id_num_re, split_filename[-2])
    if id_num:
        new_id_num = int(id_num[-1].lstrip('(').rstrip(')')) + 1

        # Reconstruct filename with incremented id and its extension
        filename = ''.join((re.sub(id_num_re, '({0})'.format(new_id_num),
                                   split_filename[-2]), split_filename[-1]))
    else:
        split_filename = os.path.splitext(filename)

        # Reconstruct filename with new id and its extension
        filename = ''.join(('{0} (2)'.format(split_filename[-2]),
                            split_filename[-1]))
    return filename
1063130
function(str){
        var versionArray = str.split(",");//replace with regex
        return {
            "raw":str,
            "major":parseInt(versionArray[0].split(" ")[1], 10),
            "minor":parseInt(versionArray[1], 10),
            "revision":parseInt(versionArray[2], 10),
            "revisionStr":versionArray[2]
        };
    }