/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/_dirstate_helpers_pyx.pyx

  • Committer: Martin
  • Date: 2017-06-10 00:39:34 UTC
  • mto: This revision was merged to the branch mainline in revision 6676.
  • Revision ID: gzlist@googlemail.com-20170610003934-ubq4y9z5s7gyy1c7
Change cmp_by_dirs to lt_by_dirs

Show diffs side-by-side

added added

removed removed

Lines of Context:
243
243
    return 0
244
244
 
245
245
 
246
 
def cmp_by_dirs(path1, path2):
 
246
def lt_by_dirs(path1, path2):
247
247
    """Compare two paths directory by directory.
248
248
 
249
249
    This is equivalent to doing::
250
250
 
251
 
       cmp(path1.split('/'), path2.split('/'))
 
251
       operator.lt(path1.split('/'), path2.split('/'))
252
252
 
253
253
    The idea is that you should compare path components separately. This
254
 
    differs from plain ``cmp(path1, path2)`` for paths like ``'a-b'`` and
255
 
    ``a/b``. "a-b" comes after "a" but would come before "a/b" lexically.
 
254
    differs from plain ``path1 < path2`` for paths like ``'a-b'`` and ``a/b``.
 
255
    "a-b" comes after "a" but would come before "a/b" lexically.
256
256
 
257
257
    :param path1: first path
258
258
    :param path2: second path
259
 
    :return: negative number if ``path1`` comes first,
260
 
        0 if paths are equal,
261
 
        and positive number if ``path2`` sorts first
 
259
    :return: True if path1 comes first, otherwise False
262
260
    """
263
261
    if not PyString_CheckExact(path1):
264
262
        raise TypeError("'path1' must be a plain string, not %s: %r"
266
264
    if not PyString_CheckExact(path2):
267
265
        raise TypeError("'path2' must be a plain string, not %s: %r"
268
266
                        % (type(path2), path2))
269
 
    return _cmp_by_dirs(PyString_AsString(path1),
270
 
                        PyString_Size(path1),
271
 
                        PyString_AsString(path2),
272
 
                        PyString_Size(path2))
 
267
    return -1 == _cmp_by_dirs(PyString_AsString(path1),
 
268
                              PyString_Size(path1),
 
269
                              PyString_AsString(path2),
 
270
                              PyString_Size(path2))
273
271
 
274
272
 
275
273
def _cmp_path_by_dirblock(path1, path2):