D11402: rust-revset: support explicit `.` revision

Alphare (Raphaël Gomès) phabricator at mercurial-scm.org
Fri Sep 10 22:10:32 UTC 2021


Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This is basically the same thing as not specifying a revision, except this is
  done in the revset resolution function.
  
  This allows calls like `rhg cat some-file -r .` to work without falling back.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D11402

AFFECTED FILES
  rust/hg-core/src/revset.rs

CHANGE DETAILS

diff --git a/rust/hg-core/src/revset.rs b/rust/hg-core/src/revset.rs
--- a/rust/hg-core/src/revset.rs
+++ b/rust/hg-core/src/revset.rs
@@ -20,6 +20,10 @@
     let changelog = Changelog::open(repo)?;
 
     match input {
+        "." => {
+            let p1 = repo.dirstate_parents()?.p1;
+            return Ok(changelog.revlog.get_node_rev(p1.into())?)
+        }
         "null" => return Ok(NULL_REVISION),
         _ => {
             match resolve_rev_number_or_hex_prefix(input, &changelog.revlog) {



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel


More information about the Mercurial-devel mailing list