Patchwork D10522: git: make changelog.tiprev() return int instead of tuple (issue6510)

login
register
mail settings
Submitter phabricator
Date April 28, 2021, 3:08 p.m.
Message ID <differential-rev-PHID-DREV-q6drad3hz7cngkqkk2th-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48842/
State Superseded
Headers show

Comments

phabricator - April 28, 2021, 3:08 p.m.
mharbison72 created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
pulkit accepted this revision.
This revision is now accepted and ready to land.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  hgext/git/gitlog.py
  tests/test-git-interop.t

CHANGE DETAILS




To: mharbison72, durin42, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/tests/test-git-interop.t b/tests/test-git-interop.t
--- a/tests/test-git-interop.t
+++ b/tests/test-git-interop.t
@@ -49,6 +49,16 @@ 
   > log-index-cache-miss = yes
   > EOF
 
+Test some edge cases around a commitless repo first
+  $ mkdir empty
+  $ cd empty
+  $ git init
+  Initialized empty Git repository in $TESTTMP/empty/.git/
+  $ hg init --git
+  $ hg heads
+  [1]
+  $ cd ..
+
 Make a new repo with git:
   $ mkdir foo
   $ cd foo
@@ -377,3 +387,24 @@ 
   $ hg rm beta
   $ hg ci -m 'remove beta'
 
+This covers changelog.tiprev() (issue6510)
+  $ hg log -r '(.^^):'
+  heads mismatch, rebuilding dagcache
+  changeset:   5:ae1ab744f95b
+  user:        test <test>
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     Introduce file a/mu
+  
+  changeset:   6:80adc61cf57e
+  user:        test <test>
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     test interactive commit
+  
+  changeset:   7:116aee5ecdff
+  bookmark:    master
+  tag:         tip
+  user:        test <test>
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     remove beta
+  
+
diff --git a/hgext/git/gitlog.py b/hgext/git/gitlog.py
--- a/hgext/git/gitlog.py
+++ b/hgext/git/gitlog.py
@@ -159,8 +159,11 @@ 
     def tiprev(self):
         t = self._db.execute(
             'SELECT rev FROM changelog ' 'ORDER BY REV DESC ' 'LIMIT 1'
-        )
-        return next(t)
+        ).fetchone()
+
+        if t is not None:
+            return t[0]
+        return -1
 
     def _partialmatch(self, id):
         if wdirhex.startswith(id):