Patchwork [2,of,4,V2] copies: switch to using pathutil.dirname

login
register
mail settings
Submitter Durham Goode
Date May 22, 2015, 8:50 p.m.
Message ID <c20e031c8664a4c73d47.1432327816@dev2000.prn2.facebook.com>
Download mbox | patch
Permalink /patch/9243/
State Accepted
Delegated to: Augie Fackler
Headers show

Comments

Durham Goode - May 22, 2015, 8:50 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1432324707 25200
#      Fri May 22 12:58:27 2015 -0700
# Node ID c20e031c8664a4c73d474ea45813b1c310c63a3b
# Parent  53d97bfd60a1d5e397b808def920fe6a73a1cac6
copies: switch to using pathutil.dirname

copies had it's own dirname implementation. Now that pathutils has a common one,
let's use that instead.

Patch

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -5,15 +5,9 @@ 
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
-import util
+import util, pathutil
 import heapq
 
-def _dirname(f):
-    s = f.rfind("/")
-    if s == -1:
-        return ""
-    return f[:s]
-
 def _findlimit(repo, a, b):
     """
     Find the last revision that needs to be checked to ensure that a full
@@ -384,7 +378,7 @@  def mergecopies(repo, c1, c2, ca):
     # examine each file copy for a potential directory move, which is
     # when all the files in a directory are moved to a new directory
     for dst, src in fullcopy.iteritems():
-        dsrc, ddst = _dirname(src), _dirname(dst)
+        dsrc, ddst = pathutil.dirname(src), pathutil.dirname(dst)
         if dsrc in invalid:
             # already seen to be uninteresting
             continue