rust/rhg/src/commands/files.rs
changeset 48409 005ae1a343f8
parent 48342 10c32e1b892a
child 48453 9b0e1f64656f
equal deleted inserted replaced
48408:f77e4daaf612 48409:005ae1a343f8
    38     }
    38     }
    39 
    39 
    40     let rev = invocation.subcommand_args.value_of("rev");
    40     let rev = invocation.subcommand_args.value_of("rev");
    41 
    41 
    42     let repo = invocation.repo?;
    42     let repo = invocation.repo?;
       
    43 
       
    44     // It seems better if this check is removed: this would correspond to
       
    45     // automatically enabling the extension if the repo requires it.
       
    46     // However we need this check to be in sync with vanilla hg so hg tests
       
    47     // pass.
       
    48     if repo.has_sparse()
       
    49         && invocation.config.get(b"extensions", b"sparse").is_none()
       
    50     {
       
    51         return Err(CommandError::unsupported(
       
    52             "repo is using sparse, but sparse extension is not enabled",
       
    53         ));
       
    54     }
       
    55 
    43     if let Some(rev) = rev {
    56     if let Some(rev) = rev {
       
    57         if repo.has_narrow() {
       
    58             return Err(CommandError::unsupported(
       
    59                 "rhg files -r <rev> is not supported in narrow clones",
       
    60             ));
       
    61         }
    44         let files = list_rev_tracked_files(repo, rev).map_err(|e| (e, rev))?;
    62         let files = list_rev_tracked_files(repo, rev).map_err(|e| (e, rev))?;
    45         display_files(invocation.ui, repo, files.iter())
    63         display_files(invocation.ui, repo, files.iter())
    46     } else {
    64     } else {
       
    65         // The dirstate always reflects the sparse narrowspec, so if
       
    66         // we only have sparse without narrow all is fine.
       
    67         // If we have narrow, then [hg files] needs to check if
       
    68         // the store narrowspec is in sync with the one of the dirstate,
       
    69         // so we can't support that without explicit code.
       
    70         if repo.has_narrow() {
       
    71             return Err(CommandError::unsupported(
       
    72                 "rhg files is not supported in narrow clones",
       
    73             ));
       
    74         }
    47         let distate = Dirstate::new(repo)?;
    75         let distate = Dirstate::new(repo)?;
    48         let files = distate.tracked_files()?;
    76         let files = distate.tracked_files()?;
    49         display_files(invocation.ui, repo, files.into_iter().map(Ok))
    77         display_files(invocation.ui, repo, files.into_iter().map(Ok))
    50     }
    78     }
    51 }
    79 }