Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.py @ 9038:93fe89afc611
localrepo: removed unnecessary revkey sort helper
author | Martin Geisler <mg@lazybytes.net> |
---|---|
date | Sun, 05 Jul 2009 12:43:40 +0200 |
parents | 1fa80c5428b8 |
children | bbc78cb1bf15 |
comparison
equal
deleted
inserted
replaced
9037:a232b90ffb51 | 9038:93fe89afc611 |
---|---|
1705 # A changeset always belongs to itself, so the changenode lookup | 1705 # A changeset always belongs to itself, so the changenode lookup |
1706 # function for a changenode is identity. | 1706 # function for a changenode is identity. |
1707 def identity(x): | 1707 def identity(x): |
1708 return x | 1708 return x |
1709 | 1709 |
1710 # A function generating function. Sets up an environment for the | |
1711 # inner function. | |
1712 def revkey(revlog): | |
1713 # Key to sort a node by it's revision number in the environment's | |
1714 # revision history. Since the revision number both represents the | |
1715 # most efficient order to read the nodes in, and represents a | |
1716 # topological sorting of the nodes, this function is often useful. | |
1717 def revlog_sort_key(x): | |
1718 return revlog.rev(x) | |
1719 return revlog_sort_key | |
1720 | |
1721 # If we determine that a particular file or manifest node must be a | 1710 # If we determine that a particular file or manifest node must be a |
1722 # node that the recipient of the changegroup will already have, we can | 1711 # node that the recipient of the changegroup will already have, we can |
1723 # also assume the recipient will have all the parents. This function | 1712 # also assume the recipient will have all the parents. This function |
1724 # prunes them from the set of missing nodes. | 1713 # prunes them from the set of missing nodes. |
1725 def prune_parents(revlog, hasset, msngset): | 1714 def prune_parents(revlog, hasset, msngset): |
1726 haslst = list(hasset) | 1715 haslst = list(hasset) |
1727 haslst.sort(key=revkey(revlog)) | 1716 haslst.sort(key=revlog.rev) |
1728 for node in haslst: | 1717 for node in haslst: |
1729 parentlst = [p for p in revlog.parents(node) if p != nullid] | 1718 parentlst = [p for p in revlog.parents(node) if p != nullid] |
1730 while parentlst: | 1719 while parentlst: |
1731 n = parentlst.pop() | 1720 n = parentlst.pop() |
1732 if n not in hasset: | 1721 if n not in hasset: |
1872 # calling our functions back. | 1861 # calling our functions back. |
1873 prune_manifests() | 1862 prune_manifests() |
1874 add_extra_nodes(1, msng_mnfst_set) | 1863 add_extra_nodes(1, msng_mnfst_set) |
1875 msng_mnfst_lst = msng_mnfst_set.keys() | 1864 msng_mnfst_lst = msng_mnfst_set.keys() |
1876 # Sort the manifestnodes by revision number. | 1865 # Sort the manifestnodes by revision number. |
1877 msng_mnfst_lst.sort(key=revkey(mnfst)) | 1866 msng_mnfst_lst.sort(key=mnfst.rev) |
1878 # Create a generator for the manifestnodes that calls our lookup | 1867 # Create a generator for the manifestnodes that calls our lookup |
1879 # and data collection functions back. | 1868 # and data collection functions back. |
1880 group = mnfst.group(msng_mnfst_lst, lookup_manifest_link, | 1869 group = mnfst.group(msng_mnfst_lst, lookup_manifest_link, |
1881 filenode_collector(changedfiles)) | 1870 filenode_collector(changedfiles)) |
1882 for chnk in group: | 1871 for chnk in group: |
1910 # otherwise don't bother. | 1899 # otherwise don't bother. |
1911 if len(msng_filenode_lst) > 0: | 1900 if len(msng_filenode_lst) > 0: |
1912 yield changegroup.chunkheader(len(fname)) | 1901 yield changegroup.chunkheader(len(fname)) |
1913 yield fname | 1902 yield fname |
1914 # Sort the filenodes by their revision # | 1903 # Sort the filenodes by their revision # |
1915 msng_filenode_lst.sort(key=revkey(filerevlog)) | 1904 msng_filenode_lst.sort(key=filerevlog.rev) |
1916 # Create a group generator and only pass in a changenode | 1905 # Create a group generator and only pass in a changenode |
1917 # lookup function as we need to collect no information | 1906 # lookup function as we need to collect no information |
1918 # from filenodes. | 1907 # from filenodes. |
1919 group = filerevlog.group(msng_filenode_lst, | 1908 group = filerevlog.group(msng_filenode_lst, |
1920 lookup_filenode_link_func(fname)) | 1909 lookup_filenode_link_func(fname)) |