cleanup: use p1() instead of parents() when we only need the first parent
authorMartin von Zweigbergk <martinvonz@google.com>
Fri, 25 Jan 2019 23:22:23 -0800
changeset 41399 5cb8158a61f7
parent 41398 2ff8994ac71d
child 41400 4a409c19831f
cleanup: use p1() instead of parents() when we only need the first parent Differential Revision: https://phab.mercurial-scm.org/D5708
hgext/fetch.py
hgext/histedit.py
hgext/mq.py
hgext/transplant.py
--- a/hgext/fetch.py	Fri Jan 25 23:43:11 2019 -0800
+++ b/hgext/fetch.py	Fri Jan 25 23:22:23 2019 -0800
@@ -68,7 +68,7 @@
     if date:
         opts['date'] = dateutil.parsedate(date)
 
-    parent, _p2 = repo.dirstate.parents()
+    parent = repo.dirstate.p1()
     branch = repo.dirstate.branch()
     try:
         branchnode = repo.branchtip(branch)
--- a/hgext/histedit.py	Fri Jan 25 23:43:11 2019 -0800
+++ b/hgext/histedit.py	Fri Jan 25 23:22:23 2019 -0800
@@ -1459,7 +1459,7 @@
                 'exactly one common root'))
         root = rr[0].node()
 
-        topmost, empty = repo.dirstate.parents()
+        topmost = repo.dirstate.p1()
         revs = between(repo, root, topmost, keep)
         if not revs:
             raise error.Abort(_('%s is not an ancestor of working directory') %
@@ -1873,7 +1873,7 @@
     cmdutil.checkunfinished(repo)
     cmdutil.bailifchanged(repo)
 
-    topmost, empty = repo.dirstate.parents()
+    topmost = repo.dirstate.p1()
     if outg:
         if freeargs:
             remote = freeargs[0]
--- a/hgext/mq.py	Fri Jan 25 23:43:11 2019 -0800
+++ b/hgext/mq.py	Fri Jan 25 23:22:23 2019 -0800
@@ -970,7 +970,7 @@
                         repo.dirstate.remove(f)
                     for f in merged:
                         repo.dirstate.merge(f)
-                    p1, p2 = repo.dirstate.parents()
+                    p1 = repo.dirstate.p1()
                     repo.setparents(p1, merge)
 
             if all_files and '.hgsubstate' in all_files:
--- a/hgext/transplant.py	Fri Jan 25 23:43:11 2019 -0800
+++ b/hgext/transplant.py	Fri Jan 25 23:22:23 2019 -0800
@@ -155,7 +155,7 @@
         if opts is None:
             opts = {}
         revs = sorted(revmap)
-        p1, p2 = repo.dirstate.parents()
+        p1 = repo.dirstate.p1()
         pulls = []
         diffopts = patch.difffeatureopts(self.ui, opts)
         diffopts.git = True
@@ -186,7 +186,7 @@
                             exchange.pull(repo, source.peer(), heads=pulls)
                         merge.update(repo, pulls[-1], branchmerge=False,
                                      force=False)
-                        p1, p2 = repo.dirstate.parents()
+                        p1 = repo.dirstate.p1()
                         pulls = []
 
                 domerge = False
@@ -323,7 +323,7 @@
         else:
             files = None
         if merge:
-            p1, p2 = repo.dirstate.parents()
+            p1 = repo.dirstate.p1()
             repo.setparents(p1, node)
             m = match.always(repo.root, '')
         else:
@@ -387,7 +387,7 @@
 
         extra = {'transplant_source': node}
         try:
-            p1, p2 = repo.dirstate.parents()
+            p1 = repo.dirstate.p1()
             if p1 != parent:
                 raise error.Abort(_('working directory not at transplant '
                                    'parent %s') % nodemod.hex(parent))
@@ -668,7 +668,7 @@
 
     tp = transplanter(ui, repo, opts)
 
-    p1, p2 = repo.dirstate.parents()
+    p1 = repo.dirstate.p1()
     if len(repo) > 0 and p1 == revlog.nullid:
         raise error.Abort(_('no revision checked out'))
     if opts.get('continue'):