Patchwork [1,of,8] fetch: use cmdutil.bailifchanged()

login
register
mail settings
Submitter Martin von Zweigbergk
Date Oct. 2, 2014, 12:01 a.m.
Message ID <0b3772a1555ed003b2bc.1412208113@handduk2.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/6071/
State Accepted
Headers show

Comments

Martin von Zweigbergk - Oct. 2, 2014, 12:01 a.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@gmail.com>
# Date 1412200122 25200
#      Wed Oct 01 14:48:42 2014 -0700
# Node ID 0b3772a1555ed003b2bc787b012485b065f276d1
# Parent  4a00110fd8708373ed8e69f96367383b2dd10661
fetch: use cmdutil.bailifchanged()

Use the existing method cmdutil.bailifchanged() instead of
implementing it again in fetch.py. An effect of this is that the error
messages in case of uncommited changes will be different.
Matt Mackall - Oct. 2, 2014, 11:15 p.m.
On Wed, 2014-10-01 at 17:01 -0700, Martin von Zweigbergk wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@gmail.com>
> # Date 1412200122 25200
> #      Wed Oct 01 14:48:42 2014 -0700
> # Node ID 0b3772a1555ed003b2bc787b012485b065f276d1
> # Parent  4a00110fd8708373ed8e69f96367383b2dd10661
> fetch: use cmdutil.bailifchanged()

Queued for default, thanks. Congratulations on becoming the fetch
extension maintainer.

Patch

diff --git a/hgext/fetch.py b/hgext/fetch.py
--- a/hgext/fetch.py
+++ b/hgext/fetch.py
@@ -48,7 +48,7 @@ 
     if date:
         opts['date'] = util.parsedate(date)
 
-    parent, p2 = repo.dirstate.parents()
+    parent, _p2 = repo.dirstate.parents()
     branch = repo.dirstate.branch()
     try:
         branchnode = repo.branchtip(branch)
@@ -58,19 +58,13 @@ 
         raise util.Abort(_('working dir not at branch tip '
                            '(use "hg update" to check out branch tip)'))
 
-    if p2 != nullid:
-        raise util.Abort(_('outstanding uncommitted merge'))
-
     wlock = lock = None
     try:
         wlock = repo.wlock()
         lock = repo.lock()
-        mod, add, rem, del_ = repo.status()[:4]
 
-        if mod or add or rem:
-            raise util.Abort(_('outstanding uncommitted changes'))
-        if del_:
-            raise util.Abort(_('working directory is missing some files'))
+        cmdutil.bailifchanged(repo)
+
         bheads = repo.branchheads(branch)
         bheads = [head for head in bheads if len(repo[head].children()) == 0]
         if len(bheads) > 1:
diff --git a/tests/test-fetch.t b/tests/test-fetch.t
--- a/tests/test-fetch.t
+++ b/tests/test-fetch.t
@@ -150,7 +150,7 @@ 
 should abort, because i is modified
 
   $ hg --cwd i fetch ../h
-  abort: working directory is missing some files
+  abort: uncommitted changes
   [255]
 
 test fetch with named branches