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

login
register
mail settings
Submitter phabricator
Date Sept. 10, 2021, 10:10 p.m.
Message ID <differential-rev-PHID-DREV-qkuloxt64nblauafjtlc-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49718/
State New
Headers show

Comments

phabricator - Sept. 10, 2021, 10:10 p.m.
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




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

Patch

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) {