[PATCH 1 of 2] rust-dirstate: add helper to iterate ancestor paths

Yuya Nishihara yuya at tcha.org
Wed Jul 10 20:18:41 EDT 2019


On Wed, 10 Jul 2019 07:36:26 -0700, Martin von Zweigbergk wrote:
> On Sun, Jun 30, 2019, 04:17 Yuya Nishihara <yuya at tcha.org> wrote:
> 
> > # HG changeset patch
> > # User Yuya Nishihara <yuya at tcha.org>
> > # Date 1561887163 -32400
> > #      Sun Jun 30 18:32:43 2019 +0900
> > # Node ID 72ab74c704053b2212b874a902574fedadad4252
> > # Parent  904e0da2e195d2a29977ceccdd25480233c34d7a
> > rust-dirstate: add helper to iterate ancestor paths
> >
> > This is modeled after std::path::Path::ancestors().
> >
> > find_dirs(b"") yields b"" because Mercurial's util.finddirs() works in that
> > way, and the test case for DirsMultiset expects such behavior.
> >
> 
> That's also how std::path::Path::ancestors() works, it seems.

finddirs(path) is basically equivalent to

  Ancestors { next: path.parent() }
  // not including the path itself.
  // note that Path::new("/").parent() returns None.

so I feel it's weird that both finddirs("foo") and finddirs("") return [''].


More information about the Mercurial-devel mailing list